private void SetSDForUpdate(Surgical sDetail) { textBoxPatientID.Text = sDetail.PatientID.ToString(); textBoxSurgicalID.Text = sDetail.SurgicalID.ToString(); dateCreate.Value = sDetail.Date; textBoxDescription.Text = sDetail.Description; comboBoxState.SelectedIndex = sDetail.State; DataTable dtStaff = Staff.GetListStaff(); for (int i = 0; i < dtStaff.Rows.Count; i++) { String staffName = dtStaff.Rows[i][6].ToString() + " " + dtStaff.Rows[i][5].ToString(); Staff newStaff = Staff.GetStaff(Convert.ToInt32(dtStaff.Rows[i][0])); listStaff.Add(newStaff); listBoxSystemStaff.Items.Add(staffName); } listBoxSystemStaff.SelectedIndex = 0; DataTable dtSD = SurgicalDetail.GetListSurgicalDetail(sDetail.SurgicalID); for (int i = 0; i < dtSD.Rows.Count; i++) { String staffName = dtSD.Rows[i][2].ToString() + " " + dtSD.Rows[i][3].ToString(); SurgicalDetail newSD = new SurgicalDetail(); newSD.SurgicalID = Convert.ToInt32(dtSD.Rows[i][0]); newSD.StaffID = Convert.ToInt32(dtSD.Rows[i][1]); listSD.Add(newSD); listBoxCurrentStaff.Items.Add(staffName); } if (listBoxCurrentStaff.Items.Count > 0) { listBoxCurrentStaff.SelectedIndex = 0; } }
// Refresh datagridview when click a cell private void dataViewSurgical_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataViewSurgical.SelectedRows.Count > 0) { // Get SurgicalnDetail's datatable int surgicalID = Convert.ToInt32(dataViewSurgical.SelectedRows[0].Cells[0].Value); DataTable surgicalDetailTable = SurgicalDetail.GetListSurgicalDetail(surgicalID); // Set data source to dataview for searching dataViewSurgicalDetail.DataSource = surgicalDetailTable; } }
private void refreshDataViewSurgicalDetail() { if (dataViewSurgical.SelectedRows.Count > 0) { try { // Get SurgicalDetail's datatable int surgicalID = Convert.ToInt32(dataViewSurgical.Rows[0].Cells[0].Value); DataTable surgicalDetailTable = SurgicalDetail.GetListSurgicalDetail(surgicalID); // Set data source to dataview for searching dataViewSurgicalDetail.DataSource = surgicalDetailTable.DefaultView; } catch { MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }