예제 #1
0
        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;
        }
예제 #2
0
 public FormSurgicalDetail(Surgical sDetail, String userAction)
 {
     InitializeComponent();
     this.surgicalDetail = sDetail;
     this.UserAction = userAction;
     SetSDForUpdate(sDetail);
 }
예제 #3
0
 public static int InsertSurgical(Surgical newSurgical)
 {
     String sqlInsert = @"INSERT INTO SURGICAL(PATIENTID, DATE, DESCRIPTION, STATE)
                         VALUES        (@PATIENTID,@DATE,@DESCRIPTION,@STATE)";
     SqlParameter[] sqlParameters = { new SqlParameter("@PATIENTID", newSurgical.PatientID),
                                     new SqlParameter("@DATE", newSurgical.Date),
                                     new SqlParameter("@DESCRIPTION", newSurgical.Description ),
                                    new SqlParameter("@STATE",newSurgical.State)};
     return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters);
 }
예제 #4
0
 public static int UpdateSurgical(Surgical updateSurgical)
 {
     string sqlUpdate = @"UPDATE       SURGICAL
                         SET                DATE =@DATE, DESCRIPTION =@DESCRIPTION, STATE =@STATE
                         WHERE         SURGICALID=@SURGICALID ";
     SqlParameter[] sqlParameters = { new SqlParameter("@SURGICALID", updateSurgical.SurgicalID),
                                     new SqlParameter("@DATE", updateSurgical.Date),
                                    new SqlParameter("@DESCRIPTION", updateSurgical.Description),
                                    new SqlParameter("@STATE", updateSurgical.State)};
     return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters);
 }
예제 #5
0
        public static int InsertSurgical(Surgical newSurgical)
        {
            String sqlInsert = @"INSERT INTO SURGICAL(PATIENTID, DATE, DESCRIPTION, STATE)
                                VALUES        (@PATIENTID,@DATE,@DESCRIPTION,@STATE)";

            SqlParameter[] sqlParameters = { new SqlParameter("@PATIENTID",   newSurgical.PatientID),
                                             new SqlParameter("@DATE",        newSurgical.Date),
                                             new SqlParameter("@DESCRIPTION", newSurgical.Description),
                                             new SqlParameter("@STATE",       newSurgical.State) };
            return(SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters));
        }
예제 #6
0
        public static int UpdateSurgical(Surgical updateSurgical)
        {
            string sqlUpdate = @"UPDATE       SURGICAL
                                SET                DATE =@DATE, DESCRIPTION =@DESCRIPTION, STATE =@STATE
                                WHERE         SURGICALID=@SURGICALID ";

            SqlParameter[] sqlParameters = { new SqlParameter("@SURGICALID",  updateSurgical.SurgicalID),
                                             new SqlParameter("@DATE",        updateSurgical.Date),
                                             new SqlParameter("@DESCRIPTION", updateSurgical.Description),
                                             new SqlParameter("@STATE",       updateSurgical.State) };
            return(SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters));
        }
예제 #7
0
 public static Surgical GetSurgical(int surgicalID)
 {
     Surgical newSurgical = new Surgical();
     int tempInterger;
     string sqlSelect = @"SELECT        SURGICALID, PATIENTID, DATE, DESCRIPTION, STATE
                         FROM            SURGICAL
                         WHERE        SURGICALID=@SURGICALID";
     SqlParameter[] sqlParameters = { new SqlParameter("@SURGICALID", surgicalID) };
     DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect, sqlParameters);
     if (dataTable.Rows.Count > 0)
     {
         int.TryParse(dataTable.Rows[0][0].ToString(), out tempInterger);
         newSurgical.SurgicalID = tempInterger;
         newSurgical.PatientID = int.Parse(dataTable.Rows[0][1].ToString());
         newSurgical.Date = DateTime.Parse((dataTable.Rows[0][2].ToString()));
         newSurgical.Description = dataTable.Rows[0][3].ToString();
         newSurgical.State = int.Parse(dataTable.Rows[0][4].ToString());
     }
     return newSurgical;
 }
예제 #8
0
        public static Surgical GetSurgical(int surgicalID)
        {
            Surgical newSurgical = new Surgical();
            int      tempInterger;
            string   sqlSelect = @"SELECT        SURGICALID, PATIENTID, DATE, DESCRIPTION, STATE
                                FROM            SURGICAL
                                WHERE        SURGICALID=@SURGICALID";

            SqlParameter[] sqlParameters = { new SqlParameter("@SURGICALID", surgicalID) };
            DataTable      dataTable     = SqlResult.ExecuteQuery(sqlSelect, sqlParameters);

            if (dataTable.Rows.Count > 0)
            {
                int.TryParse(dataTable.Rows[0][0].ToString(), out tempInterger);
                newSurgical.SurgicalID  = tempInterger;
                newSurgical.PatientID   = int.Parse(dataTable.Rows[0][1].ToString());
                newSurgical.Date        = DateTime.Parse((dataTable.Rows[0][2].ToString()));
                newSurgical.Description = dataTable.Rows[0][3].ToString();
                newSurgical.State       = int.Parse(dataTable.Rows[0][4].ToString());
            }
            return(newSurgical);
        }
예제 #9
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     if (!superValidator1.Validate())
         return;
     if (listBoxCurrentStaff.Items.Count > 0)
     {
         try
         {
             Surgical newSurgical = new Surgical();
             newSurgical.PatientID = Convert.ToInt32(textBoxPatientID.Text);
             newSurgical.Date = dateCreate.Value;
             newSurgical.State = comboBoxState.SelectedIndex;
             newSurgical.Description = textBoxDescription.Text;
             if (this.UserAction == "edit")
             {
                 newSurgical.SurgicalID = Convert.ToInt32(textBoxSurgicalID.Text);
                 DialogResult dialogResult = MessageBox.Show("Xác nhận cập nhập thông tin ca phẩu thuật này không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 if (dialogResult == DialogResult.OK)
                 {
                     if (Surgical.UpdateSurgical(newSurgical) > 0)
                     {
                         SurgicalDetail.DeleteSurgicalDetail(newSurgical.SurgicalID);
                         for (int i = 0; i < listSD.Count; i++)
                         {
                             SurgicalDetail newSD = listSD[i];
                             newSD.SurgicalID = newSurgical.SurgicalID;
                             SurgicalDetail.InsertSurgicalDetail(newSD);
                         }
                         listSD.Clear();
                         MessageBox.Show("Cập nhập thông tin ca phẩu thuật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                 }
             }
             else
             {
                 if (Surgical.InsertSurgical(newSurgical) > 0)
                 {
                     int curSurgicalID = Surgical.GetCurrentIdentity();
                     for (int i = 0; i < listSD.Count; i++)
                     {
                         listSD[i].SurgicalID = curSurgicalID;
                         SurgicalDetail.InsertSurgicalDetail(listSD[i]);
                     }
                     MessageBox.Show("Thêm ca phẩu thuật 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);
         }
         listSD.Clear();
         this.Close();
     }
     else
     {
         MessageBox.Show("Chưa có nhân viên nào tham gia ca phẩu thuật", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     
     
 }