Beispiel #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;
            }
        }
Beispiel #2
0
 public FormSurgicalDetail(Surgical sDetail, String userAction)
 {
     InitializeComponent();
     this.surgicalDetail = sDetail;
     this.UserAction     = userAction;
     SetSDForUpdate(sDetail);
 }
Beispiel #3
0
 private void buttonSurgeryDelete_Click(object sender, EventArgs e)
 {
     if (dataViewSurgical.SelectedRows.Count > 0)
     {
         int      surgicalID     = Convert.ToInt32(dataViewSurgical.SelectedRows[0].Cells[0].Value);
         Surgical deleteSurgical = Surgical.GetSurgical(surgicalID);
         if (deleteSurgical.State != 1)
         {
             DialogResult dialogResult = MessageBox.Show("Xác nhận xóa ca phẩu thuật", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (dialogResult == DialogResult.Yes)
             {
                 try
                 {
                     if (SurgicalDetail.DeleteSurgicalDetail(surgicalID) > 0 && Surgical.DeleteSurgical(surgicalID) > 0)
                     {
                         MessageBox.Show("Xóa 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);
                 }
             }
         }
         else
         {
             MessageBox.Show("Không thể xóa ca phẩu thuật đã được thực hiện", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         refreshDataViewSurgical();
         refreshDataViewSurgicalDetail();
     }
 }
Beispiel #4
0
        //Refresh datagridview in surgical tab
        private void refreshDataViewSurgical()
        {
            try
            {
                // Get surgical's datatable
                DataTable surgicalTable = Surgical.GetListSurgical();

                // Add Vietnamese column's name
                surgicalTable.Columns.Add("Mã ca phẩu thuật", typeof(string), "[SURGICALID]");
                surgicalTable.Columns.Add("Mã bệnh nhân", typeof(string), "[PATIENTID]");
                surgicalTable.Columns.Add("Ngày thực hiện", typeof(DateTime), "[DATE]");
                surgicalTable.Columns.Add("Mô tả", typeof(string), "[DESCRIPTION]");
                surgicalTable.Columns.Add("Trạng thái", typeof(string), "IIF([STATE] = 0, 'Chưa thực hiện', 'Đã thực hiện')");
                // Set data source to dataview for searching
                dataViewSurgical.DataSource = surgicalTable.DefaultView;

                // Hide English columns'name
                for (int i = 0; i < 5; i++)
                {
                    dataViewSurgical.Columns[i].Visible = false;
                }
            }
            catch
            {
                MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        private void dataViewSurgical_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataViewSurgical.SelectedRows.Count > 0)
            {
                int                surgicalID     = Convert.ToInt32(dataViewSurgical.SelectedRows[0].Cells[0].Value);
                Surgical           updateSurgical = Surgical.GetSurgical(surgicalID);
                FormSurgicalDetail formSD         = new FormSurgicalDetail(updateSurgical, "edit");
                formSD.ShowDialog();

                refreshDataViewSurgical();
                refreshDataViewSurgicalDetail();
            }
        }
Beispiel #6
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);
     }
 }