-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMgonjwa List.cs
83 lines (72 loc) · 3.43 KB
/
Mgonjwa List.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace Hospital_Management_System_1
{
public partial class Mgonjwa_List : Form
{
public Mgonjwa_List()
{
InitializeComponent();
}
sick sick = new sick();
private void Mgonjwa_List_Load(object sender, EventArgs e)
{
// populate the datagridview with nurse data
MySqlCommand command = new MySqlCommand("SELECT * FROM `mgonjwa`");
dataGridView2.ReadOnly = true;
DataGridViewImageColumn piCol = new DataGridViewImageColumn();
dataGridView2.RowTemplate.Height = 80;
dataGridView2.DataSource = sick.getMgonjwa(command);
piCol.ImageLayout = DataGridViewImageCellLayout.Zoom;
dataGridView2.AllowUserToAddRows = false;
}
private void dataGridView2_DoubleClick(object sender, EventArgs e)
{
// dispalay the selected nurse in a new form to edit/remove
EditRemove_Mgonjwa edit = new EditRemove_Mgonjwa();
edit.textBoxID.Text = dataGridView2.CurrentRow.Cells[0].Value.ToString();
edit.textBoxFirstName.Text = dataGridView2.CurrentRow.Cells[1].Value.ToString();
edit.textBoxLastName.Text = dataGridView2.CurrentRow.Cells[2].Value.ToString();
//gender
if (dataGridView2.CurrentRow.Cells[3].Value.ToString() == "Female")
{
edit.radioButtonFemale.Checked = true;
}
edit.dateTimePicker1.Value = (DateTime)dataGridView2.CurrentRow.Cells[4].Value;
edit.textBoxPhoneNumber.Text = dataGridView2.CurrentRow.Cells[5].Value.ToString();
edit.textBoxAddress.Text = dataGridView2.CurrentRow.Cells[6].Value.ToString();
//the image
byte[] pic;
pic = (byte[])dataGridView2.CurrentRow.Cells[7].Value;
MemoryStream Picture = new MemoryStream(pic);
edit.pictureBox1.Image = Image.FromStream(Picture);
edit.textBoxCountry.Text = dataGridView2.CurrentRow.Cells[8].Value.ToString();
edit.textBoxCity.Text = dataGridView2.CurrentRow.Cells[9].Value.ToString();
edit.textBoxEmail.Text = dataGridView2.CurrentRow.Cells[10].Value.ToString();
edit.textBoxPassport.Text = dataGridView2.CurrentRow.Cells[11].Value.ToString();
edit.textBoxDisease.Text = dataGridView2.CurrentRow.Cells[12].Value.ToString();
edit.textBoxDoctorsName.Text = dataGridView2.CurrentRow.Cells[13].Value.ToString();
edit.Show();
}
private void buttonRefresh_Click(object sender, EventArgs e)
{
// refresh the datagridview data
MySqlCommand command = new MySqlCommand("SELECT * FROM `mgonjwa`");
dataGridView2.ReadOnly = true;
DataGridViewImageColumn piCol = new DataGridViewImageColumn();
dataGridView2.RowTemplate.Height = 70;
dataGridView2.DataSource = sick.getMgonjwa(command);
piCol.ImageLayout = DataGridViewImageCellLayout.Zoom;
dataGridView2.AllowUserToAddRows = false;
}
}
}