private void setComboBox() { roomDAO rD = new roomDAO(); DataSet ds = rD.getRooms(); foreach (DataRow row in ds.Tables[0].Rows) { string roomNo = row["roomNo"].ToString(); roomComboBox.Items.Add(roomNo); } if (roomComboBox.Items.Count > 0) { roomComboBox.SelectedIndex = 0; } }
private void staffDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { bool blank = false; if (staffDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString() == "") { blank = true; } if (staffDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString() == "") { blank = true; } if (staffDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString() == "") { blank = true; } if (staffDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString() == "") { blank = true; } if (staffDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString() == "") { } if (staffDataGridView.Rows[e.RowIndex].Cells[5].Value.ToString() == "") { blank = true; } if (staffDataGridView.Rows[e.RowIndex].Cells[6].Value.ToString() == "") { blank = true; } if (blank) { loadStaffsInfo(); return; } int staffId = Convert.ToInt32(staffDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString()); string name = staffDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString(); string gender = staffDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); string age = staffDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString(); string roomNo = staffDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString(); string phone = staffDataGridView.Rows[e.RowIndex].Cells[5].Value.ToString(); string salary = staffDataGridView.Rows[e.RowIndex].Cells[6].Value.ToString(); DataSet ds = new DataSet(); roomDAO rD = new roomDAO(); 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 && roomNo != "") { loadStaffsInfo(); return; } st = new staffDTO(staffId, name, gender, age, roomNo, phone, salary); sD.updateStaff(st); loadStaffsInfo(); }
private void getBillButton_Click(object sender, EventArgs e) { if (patientDataGridView.SelectedRows.Count == 0) { MessageBox.Show("Please select a patient"); return; } string checkoutDate = datePicker.Value.ToShortDateString(); int medicineBill = Convert.ToInt32(medicineBox.Text == "" ? "0" : medicineBox.Text); int serviceBill = Convert.ToInt32(serviceBox.Text == "" ? "0" : serviceBox.Text); int testBill = Convert.ToInt32(testBox.Text == "" ? "0" : testBox.Text); int vatInPercentage = Convert.ToInt32(vatBox.Text == "" ? "0" : vatBox.Text); int roomBill = -1; string checkinDate = patientDataGridView.SelectedRows[0].Cells[9].Value.ToString(); roomDAO rD = new roomDAO(); DataSet ds = new DataSet(); ds = rD.getRooms(); foreach (DataRow row in ds.Tables[0].Rows) { string roomNo = row["roomNo"].ToString(); if (roomNo == patientDataGridView.SelectedRows[0].Cells[6].Value.ToString()) { roomBill = Convert.ToInt32(row["price"].ToString()); break; } } string[] value = checkinDate.Split('/'); int year = Convert.ToInt32(value[2]); int month = Convert.ToInt32(value[0]); int day = Convert.ToInt32(value[1]); DateTime dT1 = new DateTime(year, month, day); value = checkoutDate.Split('/'); year = Convert.ToInt32(value[2]); month = Convert.ToInt32(value[0]); day = Convert.ToInt32(value[1]); DateTime dT2 = new DateTime(year, month, day); int days = (dT2 - dT1).Days; //MessageBox.Show("room bill = " + roomBill + " days = " + days); roomBill = roomBill * days; int subTotal = roomBill + medicineBill + serviceBill + testBill; int vat = (int)((vatInPercentage / 100.0) * subTotal); int total = vat + subTotal; string name = patientDataGridView.SelectedRows[0].Cells[1].Value.ToString(); string gender = patientDataGridView.SelectedRows[0].Cells[2].Value.ToString(); string age = patientDataGridView.SelectedRows[0].Cells[3].Value.ToString(); string address = patientDataGridView.SelectedRows[0].Cells[4].Value.ToString(); string phone = patientDataGridView.SelectedRows[0].Cells[5].Value.ToString(); checkoutData c = new checkoutData(roomBill, medicineBill, serviceBill, testBill, subTotal, vat, total, name, gender, age, address, phone); this.Hide(); BillForm frm = new BillForm(c); frm.Show(); deletePatientForCheckout(); }
public void loadRoomsInfo() { roomDataGridView.DataSource = rD.getRooms().Tables[0]; }
private void testDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { bool blank = false; if (testDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString() == "") { blank = true; } if (testDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString() == "") { blank = true; } if (testDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString() == "") { blank = true; } if (testDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString() == "") { blank = true; } if (blank) { loadTestsInfo(); //MessageBox.Show("Error in here"); return; } int testId = Convert.ToInt32(testDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString()); string name = testDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString(); string category = testDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); string roomNo = testDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString(); int price = Convert.ToInt32(testDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString()); DataSet ds = new DataSet(); roomDAO rD = new roomDAO(); 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) { loadTestsInfo(); //MessageBox.Show("went to middle"); return; } t = new testDTO(testId, name, category, roomNo, price); tD.updateTest(t); loadTestsInfo(); //MessageBox.Show("went to last"); }
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; } }
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(); }