//This constructor for update, confirm feature public FormDCDetail(DischargeCertificate dcDetail, String userAction) { InitializeComponent(); this.DCDetail = dcDetail; this.UserAction = userAction; SetDCForUpdate(dcDetail); }
private void SetDCForUpdate(DischargeCertificate dcDetail) { textBoxDCID.Text = dcDetail.DCID.ToString(); textBoxPatientID.Text = dcDetail.PatientID.ToString(); textBoxStaffID.Text = dcDetail.StaffID.ToString(); dateDischarge.Value = dcDetail.Date; comboBoxState.SelectedIndex = dcDetail.State; comboBoxState.Enabled = false; }
public static int InsertDC(DischargeCertificate newDC) { String sqlInsert = @"INSERT INTO DISCHARGEDCERTIFICATE(STAFFID, PATIENTID, DATE, STATE) VALUES (@STAFFID,@PATIENTID,@DATE,@STATE)"; SqlParameter[] sqlParameters = { new SqlParameter("@STAFFID", newDC.StaffID), new SqlParameter("@PATIENTID", newDC.PatientID), new SqlParameter("@DATE", newDC.Date), new SqlParameter("@STATE",newDC.State)}; return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters); }
public static int InsertDC(DischargeCertificate newDC) { String sqlInsert = @"INSERT INTO DISCHARGEDCERTIFICATE(STAFFID, PATIENTID, DATE, STATE) VALUES (@STAFFID,@PATIENTID,@DATE,@STATE)"; SqlParameter[] sqlParameters = { new SqlParameter("@STAFFID", newDC.StaffID), new SqlParameter("@PATIENTID", newDC.PatientID), new SqlParameter("@DATE", newDC.Date), new SqlParameter("@STATE", newDC.State) }; return(SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters)); }
public static int UpdateDC(DischargeCertificate updateDC) { string sqlUpdate = @"UPDATE DISCHARGEDCERTIFICATE SET PATIENTID =@PATIENTID, STAFFID =@STAFFID, DATE =@DATE, STATE =@STATE WHERE DCID=@DCID "; SqlParameter[] sqlParameters = { new SqlParameter("@DCID", updateDC.DCID ), new SqlParameter("@PATIENTID", updateDC.PatientID), new SqlParameter("@STAFFID",updateDC.StaffID), new SqlParameter("@DATE", updateDC.Date), new SqlParameter("STATE", updateDC.State)}; return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters); }
public static int UpdateDC(DischargeCertificate updateDC) { string sqlUpdate = @"UPDATE DISCHARGEDCERTIFICATE SET PATIENTID =@PATIENTID, STAFFID =@STAFFID, DATE =@DATE, STATE =@STATE WHERE DCID=@DCID "; SqlParameter[] sqlParameters = { new SqlParameter("@DCID", updateDC.DCID), new SqlParameter("@PATIENTID", updateDC.PatientID), new SqlParameter("@STAFFID", updateDC.StaffID), new SqlParameter("@DATE", updateDC.Date), new SqlParameter("STATE", updateDC.State) }; return(SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters)); }
public static DischargeCertificate GetDC(int dCID) { DischargeCertificate dC = new DischargeCertificate(); string sqlSelect = @"SELECT DCID, STAFFID, PATIENTID, DATE, STATE FROM DISCHARGEDCERTIFICATE WHERE DCID=@DCID"; SqlParameter[] sqlParameters = { new SqlParameter("@DCID", dCID) }; DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect, sqlParameters); if (dataTable.Rows.Count > 0) { dC.DCID = Convert.ToInt32(dataTable.Rows[0][0]); dC.StaffID = Convert.ToInt32(dataTable.Rows[0][1]); dC.PatientID = Convert.ToInt32(dataTable.Rows[0][2]); dC.Date = (DateTime)dataTable.Rows[0][3]; dC.State = (int)dataTable.Rows[0][4]; } return dC; }
public static DischargeCertificate GetDC(int dCID) { DischargeCertificate dC = new DischargeCertificate(); string sqlSelect = @"SELECT DCID, STAFFID, PATIENTID, DATE, STATE FROM DISCHARGEDCERTIFICATE WHERE DCID=@DCID"; SqlParameter[] sqlParameters = { new SqlParameter("@DCID", dCID) }; DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect, sqlParameters); if (dataTable.Rows.Count > 0) { dC.DCID = Convert.ToInt32(dataTable.Rows[0][0]); dC.StaffID = Convert.ToInt32(dataTable.Rows[0][1]); dC.PatientID = Convert.ToInt32(dataTable.Rows[0][2]); dC.Date = (DateTime)dataTable.Rows[0][3]; dC.State = (int)dataTable.Rows[0][4]; } return(dC); }
private void buttonOk_Click(object sender, EventArgs e) { try { DischargeCertificate newDC = new DischargeCertificate(); newDC.PatientID = Convert.ToInt32(textBoxPatientID.Text); newDC.StaffID = Convert.ToInt32(textBoxStaffID.Text); newDC.Date = dateDischarge.Value; newDC.State = comboBoxState.SelectedIndex; if (UserAction == "edit") { newDC.DCID = Convert.ToInt32(textBoxDCID.Text); DialogResult dialogResult = MessageBox.Show("Xác nhận cập nhập thông tin giấy xuất viện", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult== DialogResult.Yes) { if (DischargeCertificate.UpdateDC(newDC) > 0) MessageBox.Show("Cập nhập thông tin giấy xuất viện thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if (DischargeCertificate.IsPatientHadDC(Convert.ToInt32(textBoxPatientID.Text))) { MessageBox.Show("Bệnh nhân đã có giấy xuất viện", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { newDC.DCID = 0; if (DischargeCertificate.InsertDC(newDC) > 0) MessageBox.Show("Thêm giấy xuất viện thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); }