Ejemplo n.º 1
0
        // TÌM XÉT NGHIỆM
        private void tbTimXN_TextChanged(object sender, EventArgs e)
        {
            String           key        = tbTimXN.Text.Trim();
            List <XetNghiem> xetNghiems = new XetNghiemBUL().TimXNCuaBN(maBN, key);

            dataGridView1.DataSource = xetNghiems;
            CheckHan();
            CheckStatus();
        }
Ejemplo n.º 2
0
        public void Reload()
        {
            key = int.Parse(f1.tbID.Text.Trim());
            List <XetNghiem> xetNghiems = new XetNghiemBUL().TimXN(key);

            dataGridView1.DataSource = xetNghiems;
            DgvDefine();
            CheckStatus();
            CheckHan();
        }
Ejemplo n.º 3
0
 private void cbChoketQua_CheckedChanged(object sender, EventArgs e)
 {
     if (cbChoketQua.Checked == true)
     {
         cbLocXNPass.Checked = false;
         cbLocXNfail.Checked = false;
         String           key1       = "Chưa có kết quả";
         List <XetNghiem> xetNghiems = new XetNghiemBUL().LocXnChoKetQua(maBN, key1);
         dataGridView1.DataSource = xetNghiems;
         CheckStatus();
         CheckHan();
     }
     else
     {
         Reload();
     }
 }
Ejemplo n.º 4
0
        public void UpdateXN()
        {
            MemoryStream stream = new MemoryStream();

            pictureBox1.Image.Save(stream, ImageFormat.Jpeg);
            String tenXN  = TenXN;
            String idXN   = f2.maXN;
            String ketQua = tbketQua.Text.Trim();
            String ghiChu = tbGhiChu.Text.Trim();
            String stt    = f2.stt;
            int    maBN   = f2.maBN;

            if (cbPass.Checked == true)
            {
                stt = "Thông qua";
            }
            if (cbFail.Checked == true)
            {
                stt = "Không đạt";
            }


            if (cbXnLai.Checked == true) // bệnh nhân xét nghiệm lại: gia hạn thời hạn XN + thêm số lần XN
            {
                DateTime hanXn    = DateTime.ParseExact(f2.hanXN, "dd/MM/yyyy", null);
                DateTime now      = DateTime.UtcNow;
                TimeSpan ngay     = hanXn - now;
                int      tongngay = ngay.Days;

                if (tongngay < 0) // kiểm tra hạn xét nghiệm trước khi thêm
                {
                    LayHanXN();
                    String thoiHan = DateTime.Now.AddDays(hanXN).ToString("dd/MM/yyyy");
                    String ngayXN  = DateTime.Now.ToString("dd/MM/yyyy");
                    int    solan   = f2.soLan++;
                    String maXN    = f2.maXN + solan;
                    if (ketQua == "")
                    {
                        stt = "Chưa có kết quả";
                        DialogResult dialogResult = MessageBox.Show("Chưa điền kết quả\nKết quả sẽ ở trạng thái chờ", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (dialogResult == DialogResult.Yes)
                        {
                            XetNghiem xn1 = new XetNghiem()
                            {
                                ID = maXN, TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, MaBN = maBN, Note = ghiChu, IDLoaiXN = f2.IDLoaiXN, Status = stt, Thoihan = thoiHan, SoLanXN = solan, Image = stream.ToArray()
                            };
                            bool result1 = new XetNghiemBUL().ThemXN(xn1);
                            if (result1)
                            {
                                f2.Reload();
                                Thread.Sleep(200);
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Đây là xét nghiệm cũ\nhãy cập nhật ở xét nghiệm lần gần đây nhất", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        XetNghiem xn1 = new XetNghiem()
                        {
                            ID = maXN, TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, MaBN = maBN, Note = ghiChu, IDLoaiXN = f2.IDLoaiXN, Status = stt, Thoihan = thoiHan, SoLanXN = solan, Image = stream.ToArray()
                        };
                        bool result1 = new XetNghiemBUL().ThemXN(xn1);
                        if (result1)
                        {
                            f2.Reload();
                            Thread.Sleep(200);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Đây là xét nghiệm cũ\nhãy cập nhật ở xét nghiệm lần gần đây nhất", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    DialogResult dialogResultThem = MessageBox.Show("Xét nghiệm vẫn còn hạn \nBạn có muốn xét nghiệm lại", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dialogResultThem == DialogResult.Yes)
                    {
                        LayHanXN();
                        String thoiHan = DateTime.Now.AddDays(hanXN).ToString("dd/MM/yyyy");
                        String ngayXN  = DateTime.Now.ToString("dd/MM/yyyy");
                        int    solan   = f2.soLan + 1;
                        String maXN    = f2.maXN + solan;
                        if (ketQua == "")
                        {
                            stt = "Chưa có kết quả";
                            DialogResult dialogResult1 = MessageBox.Show("Chưa điền kết quả\nKết quả sẽ ở trạng thái chờ", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            if (dialogResult1 == DialogResult.Yes)
                            {
                                XetNghiem xn1 = new XetNghiem()
                                {
                                    ID = maXN, TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, MaBN = maBN, Note = ghiChu, IDLoaiXN = f2.IDLoaiXN, Status = stt, Thoihan = thoiHan, SoLanXN = solan, Image = stream.ToArray()
                                };
                                bool result1 = new XetNghiemBUL().ThemXN(xn1);
                                if (result1)
                                {
                                    f2.Reload();
                                    Thread.Sleep(200);
                                    this.Close();
                                }
                                else
                                {
                                    MessageBox.Show("Đây là xét nghiệm cũ\nhãy cập nhật ở xét nghiệm lần gần đây nhất", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            XetNghiem xn1 = new XetNghiem()
                            {
                                ID = maXN, TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, MaBN = maBN, Note = ghiChu, IDLoaiXN = f2.IDLoaiXN, Status = stt, Thoihan = thoiHan, SoLanXN = solan, Image = stream.ToArray()
                            };
                            bool result1 = new XetNghiemBUL().ThemXN(xn1);
                            if (result1)
                            {
                                f2.Reload();
                                Thread.Sleep(200);
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Đây là xét nghiệm cũ\nhãy cập nhật ở xét nghiệm lần gần đây nhất", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }

            else // Chỉ update thông tin, bệnh nhân không XN lại
            {
                String thoiHanTruocDo = f2.hanXN;
                String ngayXN         = f2.ngayXN;
                if (ketQua == "")
                {
                    stt = "Chưa có kết quả";
                    DialogResult dialogResult = MessageBox.Show("Chưa điền kết quả\nKết quả sẽ ở trạng thái chờ", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dialogResult == DialogResult.Yes)
                    {
                        XetNghiem xn1 = new XetNghiem()
                        {
                            TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, MaBN = maBN, Note = ghiChu, Status = stt, Thoihan = thoiHanTruocDo, Image = stream.ToArray()
                        };
                        bool result1 = new XetNghiemBUL().UpdateXN(idXN, xn1);
                        if (result1)
                        {
                            f2.Reload();
                            Thread.Sleep(200);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Cập nhật không thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    XetNghiem xn1 = new XetNghiem()
                    {
                        TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, MaBN = maBN, Note = ghiChu, Status = stt, Thoihan = thoiHanTruocDo, Image = stream.ToArray()
                    };
                    bool result1 = new XetNghiemBUL().UpdateXN(idXN, xn1);
                    if (result1)
                    {
                        f2.Reload();
                        Thread.Sleep(200);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Cập nhật không thành công", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void UpdateXN()
 {
     try
     {
         MemoryStream stream = new MemoryStream();
         pictureBox1.Image.Save(stream, ImageFormat.Jpeg);
         String tenXN  = cbbLoaiXN.Text;
         String idXN   = "BN" + f2.maBN + id;
         String ngayXN = DateTime.Now.ToString("dd/MM/yyyy");
         String ketQua = tbketQua.Text.Trim();
         String ghiChu = tbGhiChu.Text.Trim();
         String hanXN  = DateTime.Now.AddDays(thoiHan).ToString("dd/MM/yyyy");
         int    solan  = 1;
         int    maBN   = f2.maBN;
         if (ketQua == "")
         {
             stt = "Chưa có kết quả";
             DialogResult dialogResult = MessageBox.Show("Chưa điền kết quả\nKết quả sẽ ở trạng thái chờ", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (dialogResult == DialogResult.Yes)
             {
                 XetNghiem xn1 = new XetNghiem()
                 {
                     ID = idXN, TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, IDLoaiXN = Convert.ToInt32(id), MaBN = maBN, Note = ghiChu, Status = stt, SoLanXN = solan, Image = stream.ToArray(), Thoihan = hanXN
                 };
                 bool result1 = new XetNghiemBUL().ThemXN(xn1);
                 if (result1)
                 {
                     f2.Reload();
                     Thread.Sleep(200);
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Chưa chọn xét nghiệm !", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
         }
         else if (cbFail.Checked == true || cbPass.Checked == true)
         {
             XetNghiem xn1 = new XetNghiem()
             {
                 ID = idXN, TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, IDLoaiXN = Convert.ToInt32(id), MaBN = maBN, Note = ghiChu, Status = stt, SoLanXN = solan, Image = stream.ToArray(), Thoihan = hanXN
             };
             bool result1 = new XetNghiemBUL().ThemXN(xn1);
             if (result1)
             {
                 f2.Reload();
                 Thread.Sleep(200);
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Chưa chọn xét nghiệm !", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             MessageBox.Show("Chưa chọn trạng thái cho kết quả", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 6
0
 public void AddXN()
 {
     try
     {
         System.IO.MemoryStream stream = new MemoryStream();
         pictureBox1.Image.Save(stream, ImageFormat.Jpeg);
         int    id     = f.idLoaiXN;
         String tenXN  = f.tenXN;
         String idXN   = "BN" + f.maBN + id;
         String ngayXN = DateTime.Now.ToString("dd/MM/yyyy");
         String ketQua = tbketQua.Text.Trim();
         String ghiChu = tbGhiChu.Text.Trim();
         String hanXN  = DateTime.Now.AddDays(f.thoiHanXN).ToString("dd/MM/yyyy");
         int    solan  = 1;
         int    maBN   = f.maBN;
         if (ketQua == "")
         {
             stt = "Chưa có kết quả";
             DialogResult dialogResult = MessageBox.Show("Chưa điền kết quả\nKết quả sẽ ở trạng thái chờ", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (dialogResult == DialogResult.Yes)
             {
                 XetNghiem xn1 = new XetNghiem()
                 {
                     ID = idXN, TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, IDLoaiXN = id, MaBN = maBN, Note = ghiChu, Status = stt, SoLanXN = solan, Image = stream.ToArray(), Thoihan = hanXN
                 };
                 bool result1 = new XetNghiemBUL().ThemXN(xn1);
                 if (result1)
                 {
                     Thread.Sleep(200);
                     bool result = new HenXetNghiemBUL().XoaHen(f.idLichHen); // Xóa thông tin lịch sau khi thêm XN
                     f.Reload();                                              // reload Dgv danh sách hẹn
                     this.Close();
                 }
                 else
                 {
                     DialogResult dialogResult2 = MessageBox.Show("Xét nghiệm đã có !\nXóa lịch hẹn ?", "Lỗi", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                     if (dialogResult == DialogResult.Yes)
                     {
                         bool result = new HenXetNghiemBUL().XoaHen(f.idLichHen);
                         f.Reload();
                         this.Close();
                     }
                 }
             }
         }
         else if (cbFail.Checked == true || cbPass.Checked == true)
         {
             XetNghiem xn1 = new XetNghiem()
             {
                 ID = idXN, TenXN = tenXN, NgayXN = ngayXN, KetQua = ketQua, IDLoaiXN = Convert.ToInt32(id), MaBN = maBN, Note = ghiChu, Status = stt, SoLanXN = solan, Image = stream.ToArray(), Thoihan = hanXN
             };
             bool result1 = new XetNghiemBUL().ThemXN(xn1);
             if (result1)
             {
                 Thread.Sleep(200);
                 bool result = new HenXetNghiemBUL().XoaHen(f.idLichHen);
                 f.Reload();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Xét nghiệm đã có !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             DialogResult dialogResult2 = MessageBox.Show("Xét nghiệm đã có !\nXóa lịch hẹn ?", "Lỗi", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
             if (dialogResult2 == DialogResult.Yes)
             {
                 bool result = new HenXetNghiemBUL().XoaHen(f.idLichHen);
                 f.Reload();
                 this.Close();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }