Esempio n. 1
0
 //This constructor for update feature
 public FormTestDetail(TestCertificate tDetail, String userAction)
 {
     InitializeComponent();
     this.testDetail = tDetail;
     this.UserAction = userAction;
     SetTDForUpdate(tDetail);
 }
Esempio n. 2
0
        private void SetTDForUpdate(TestCertificate tDetail)
        {
            textBoxTCID.Text = tDetail.TCID.ToString();
            textBoxPatientID.Text = tDetail.PatientID.ToString();
            textBoxStaffID.Text = tDetail.StafID.ToString();
            dateCreate.Value = tDetail.Date;
            comboBoxState.SelectedIndex = tDetail.State;

            DataTable dtTestType = TestType.GetListTestType();
            for (int i = 0; i < dtTestType.Rows.Count; i++)
            {
                TestType newTestType = new TestType();
                newTestType.TestTypeID = Convert.ToInt16(dtTestType.Rows[i][0]);
                newTestType.TestName = dtTestType.Rows[i][1].ToString();
                listTestType.Add(newTestType);
                comboBoxTestType.Items.Add(newTestType.TestName);
            }
            comboBoxTestType.SelectedIndex = 0;

            DataTable dtTestDetail = TestDetail.GetListTestDetail(tDetail.TCID);
            for (int i = 0; i < dtTestDetail.Rows.Count; i++)
            {
                TestDetail newTD = new TestDetail();
                newTD.TCID =Convert.ToInt32(dtTestDetail.Rows[i][0]);
                newTD.TestTypeID = Convert.ToInt16(dtTestDetail.Rows[i][1]);
                newTD.Result = dtTestDetail.Rows[i][2].ToString();
                listTD.Add(newTD);
                listSelectedTestType.Items.Add(dtTestDetail.Rows[i][3].ToString());
            }
            if (listSelectedTestType.Items.Count > 0)
                listSelectedTestType.SelectedIndex = 0;
        }
Esempio n. 3
0
 public static int UpdateTC(TestCertificate updateTC)
 {
     string sqlUpdate = @"UPDATE       TESTCERTIFICATE
                         SET                DATE =@DATE, STATE =@STATE
                         WHERE         TCID=@TCID ";
     SqlParameter[] sqlParameters = { new SqlParameter("@TCID", updateTC.TCID),
                                     new SqlParameter("@DATE", updateTC.Date),
                                    new SqlParameter("@STATE", updateTC.State)};
     return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters);
 }
Esempio n. 4
0
 public static int InsertTC(TestCertificate newTC)
 {
     String sqlInsert = @"INSERT INTO TESTCERTIFICATE(PATIENTID, STAFFID, DATE, STATE)
                         VALUES        (@PATIENTID,@STAFFID,@DATE,@STATE)";
     SqlParameter[] sqlParameters = { new SqlParameter("@PATIENTID", newTC.PatientID),
                                     new SqlParameter("@STAFFID", newTC.StafID),
                                     new SqlParameter("@DATE", newTC.Date),
                                     new SqlParameter("@STATE", newTC.State)};
     return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters);
 }
Esempio n. 5
0
 public static TestCertificate GetTC(int tCID)
 {
     TestCertificate newTC = new TestCertificate();
     string sqlSelect = @"SELECT        TCID, PATIENTID, STAFFID, DATE, STATE
                         FROM            TESTCERTIFICATE
                         WHERE        TCID=@TCID";
     SqlParameter[] sqlParameters = { new SqlParameter("@TCID", tCID) };
     DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect, sqlParameters);
     if (dataTable.Rows.Count > 0)
     {
         newTC.TCID = Convert.ToInt32(dataTable.Rows[0][0]);
         newTC.PatientID = Convert.ToInt32(dataTable.Rows[0][1]);
         newTC.StafID = Convert.ToInt32(dataTable.Rows[0][2]);
         newTC.Date = DateTime.Parse((dataTable.Rows[0][3].ToString()));
         newTC.State = int.Parse(dataTable.Rows[0][4].ToString());
     }
     return newTC;
 }
Esempio n. 6
0
        public static TestCertificate GetTC(int tCID)
        {
            TestCertificate newTC     = new TestCertificate();
            string          sqlSelect = @"SELECT        TCID, PATIENTID, STAFFID, DATE, STATE
                                FROM            TESTCERTIFICATE
                                WHERE        TCID=@TCID";

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

            if (dataTable.Rows.Count > 0)
            {
                newTC.TCID      = Convert.ToInt32(dataTable.Rows[0][0]);
                newTC.PatientID = Convert.ToInt32(dataTable.Rows[0][1]);
                newTC.StafID    = Convert.ToInt32(dataTable.Rows[0][2]);
                newTC.Date      = DateTime.Parse((dataTable.Rows[0][3].ToString()));
                newTC.State     = int.Parse(dataTable.Rows[0][4].ToString());
            }
            return(newTC);
        }
Esempio n. 7
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     if (!superValidator1.Validate())
         return;
     try
     {
         if (listSelectedTestType.Items.Count > 0)
         {
             TestCertificate newTC = new TestCertificate();
             newTC.PatientID = Convert.ToInt32(textBoxPatientID.Text);
             newTC.StafID = Convert.ToInt32(textBoxStaffID.Text);
             newTC.Date = dateCreate.Value;
             newTC.State = comboBoxState.SelectedIndex;
             if (this.UserAction == "edit")
             {
                 newTC.TCID = Convert.ToInt32(textBoxTCID.Text);
                 DialogResult dialogResult = MessageBox.Show("Xác nhận cập nhập thông tin phiếu xét nghiệm", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 if (dialogResult == DialogResult.OK)
                 {
                     if (TestCertificate.UpdateTC(newTC) > 0)
                     {
                         TestDetail.DeleteTestDetail(newTC.TCID);
                         for (int i = 0; i < listTD.Count; i++)
                         {
                             listTD[i].TCID = newTC.TCID;
                             TestDetail.InsertTestDetail(listTD[i]);
                         }
                         listTD.Clear();
                         MessageBox.Show("Cập nhập thông tin phiếu xét nghiệm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                 }
             }
             else
             {
                 newTC.TCID = 0;
                 if (TestCertificate.InsertTC(newTC) > 0)
                 {
                     int tcID = TestCertificate.GetCurrentIdentity();
                     for (int i = 0; i < listTD.Count; i++)
                     {
                         listTD[i].TCID = tcID;
                         TestDetail.InsertTestDetail(listTD[i]);
                     }
                     MessageBox.Show("Thêm phiếu xét nghiệm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     listTD.Clear();
                 }
                 
             }
             this.Close();
         }
         else
         {
             MessageBox.Show("Yêu cầu nhập loại xét nghiệm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch
     {
         MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     
     
 }