private void patientDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { bool blank = false; if (patientDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[5].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[6].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[7].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[8].Value.ToString() == "") { blank = true; } if (patientDataGridView.Rows[e.RowIndex].Cells[9].Value.ToString() == "") { blank = true; } if (blank) { loadPatientsInfo(); return; } int patientId = Convert.ToInt32(patientDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString()); string name = patientDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString(); string gender = patientDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); string age = patientDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString(); string address = patientDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString(); string phone = patientDataGridView.Rows[e.RowIndex].Cells[5].Value.ToString(); string roomNo = patientDataGridView.Rows[e.RowIndex].Cells[6].Value.ToString(); int doctorId = Convert.ToInt32(patientDataGridView.Rows[e.RowIndex].Cells[7].Value.ToString()); int testId = Convert.ToInt32(patientDataGridView.Rows[e.RowIndex].Cells[8].Value.ToString()); string checkinDate = patientDataGridView.Rows[e.RowIndex].Cells[9].Value.ToString(); DataSet ds = new DataSet(); roomDAO rD = new roomDAO(); testDAO tD = new testDAO(); doctorDAO dD = new doctorDAO(); ds = rD.getRooms(); bool flag = false; foreach (DataRow row in ds.Tables[0].Rows) { string rN = row["roomNo"].ToString(); if (roomNo == rN) { flag = true; break; } } if (flag == false) { loadPatientsInfo(); return; } ds = tD.getTests(); flag = false; foreach (DataRow row in ds.Tables[0].Rows) { string tI = row["testId"].ToString(); if (testId == Convert.ToInt32(tI)) { flag = true; break; } } if (flag == false) { loadPatientsInfo(); return; } ds = dD.getDoctors(); flag = false; foreach (DataRow row in ds.Tables[0].Rows) { string dI = row["doctorId"].ToString(); if (doctorId == Convert.ToInt32(dI)) { flag = true; break; } } if (flag == false) { loadPatientsInfo(); return; } p = new patientDTO(patientId, name, gender, age, address, phone, roomNo, doctorId, testId, checkinDate); pD.updatePatient(p); loadPatientsInfo(); }
private void setComboBox() { roomComboBox.Items.Clear(); roomComboBox.Text = ""; doctorComboBox.Items.Clear(); doctorComboBox.Text = ""; testComboBox.Items.Clear(); testComboBox.Text = ""; roomDAO rD = new roomDAO(); DataSet ds = rD.getRooms(); LinkedList <string> listOfAllRooms = new LinkedList <string>(); foreach (DataRow row in ds.Tables[0].Rows) { string roomNo = row["roomNo"].ToString(); //roomComboBox.Items.Add(roomNo); listOfAllRooms.AddLast(roomNo); } patientDAO pD = new patientDAO(); ds = pD.getPatients(); LinkedList <string> listOfUsedRooms = new LinkedList <string>(); foreach (DataRow row in ds.Tables[0].Rows) { string roomNo = row["roomNo"].ToString(); //roomComboBox.Items.Add(roomNo); listOfUsedRooms.AddLast(roomNo); } LinkedList <string> listOfUnUsedRooms = new LinkedList <string>(); for (int i = 0; i < listOfAllRooms.Count; i++) { bool flag = true; for (int j = 0; j < listOfUsedRooms.Count; j++) { string allRoom = listOfAllRooms.ElementAt(i); string usedRoom = listOfUsedRooms.ElementAt(j); if (allRoom == usedRoom) { flag = false; break; } } if (flag) { listOfUnUsedRooms.AddLast(listOfAllRooms.ElementAt(i)); } } for (int i = 0; i < listOfUnUsedRooms.Count; i++) { string roomNo = listOfUnUsedRooms.ElementAt(i); roomComboBox.Items.Add(roomNo); } if (roomComboBox.Items.Count > 0) { roomComboBox.SelectedIndex = 0; } doctorDAO dD = new doctorDAO(); ds = dD.getDoctors(); foreach (DataRow row in ds.Tables[0].Rows) { int doctorId = Convert.ToInt32(row["doctorId"].ToString()); string name = row["name"].ToString(); doctorComboBox.Items.Add(doctorId + "," + name); } if (doctorComboBox.Items.Count > 0) { doctorComboBox.SelectedIndex = 0; } testDAO tD = new testDAO(); ds = tD.getTests(); foreach (DataRow row in ds.Tables[0].Rows) { int testId = Convert.ToInt32(row["testId"].ToString()); string name = row["name"].ToString(); string category = row["category"].ToString(); testComboBox.Items.Add(testId + "," + name + "," + category); } if (testComboBox.Items.Count > 0) { testComboBox.SelectedIndex = 0; } }
public void loadDoctorsInfo() { doctorDataGridView.DataSource = dD.getDoctors().Tables[0]; }