void mnuHuyLinhthuocAll_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Utility.isValidGrid(grdPres))
         {
             return;
         }
         List <int> lstNoValidData = new List <int>();
         List <int> lstID_Donthuoc = (from p in grdPres.GetDataRows().AsEnumerable()
                                      where Utility.Int32Dbnull(((DataRowView)p.DataRow)[TPhieuCapphatChitiet.Columns.DaLinh], -1) == 1
                                      select Utility.Int32Dbnull(((DataRowView)p.DataRow)["id_donthuoc"], -1)).ToList <int>();
         if (lstID_Donthuoc.Count <= 0)
         {
             return;
         }
         if (Utility.AcceptQuestion(string.Format("Bạn có chắc chắn hủy bệnh nhân lĩnh thuốc cho {0} đơn thuốc đang chọn hay không?", lstID_Donthuoc.Count.ToString()), "Thông báo", true))
         {
             frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy();
             _NhaplydoHuy.ShowDialog();
             if (!_NhaplydoHuy.m_blnCancel)
             {
                 if (CapphatThuocKhoa.BenhNhanLinhThuoc(idPhieucapphat, lstID_Donthuoc, 0, ref lstNoValidData) == ActionResult.Success)
                 {
                     foreach (GridEXRow _row in grdPres.GetDataRows())
                     {
                         if (lstID_Donthuoc.Contains(Utility.Int32Dbnull(_row.Cells["id_donthuoc"].Value, -1)))
                         {
                             _row.BeginEdit();
                             _row.Cells["da_linh"].Value = 0;
                             if (lstNoValidData.Count > 0 && lstNoValidData.Contains(Utility.Int32Dbnull(_row.Cells["id_donthuoc"].Value, -1)))
                             {
                                 _row.Cells["not_valid"].Value = 1;
                             }
                             _row.EndEdit();
                         }
                     }
                     grdPres.Refetch();
                     Utility.SetMsg(uiStatusBar2.Panels["Msg"], "Hủy lĩnh thuốc thành công!", false);
                 }
                 else
                 {
                     Utility.SetMsg(uiStatusBar2.Panels["Msg"], "Hủy lĩnh thuóc không thành công!Liên hệ VMS để được trợ giúp", true);
                 }
                 mnuHuyLinhthuocAll.Enabled     = m_Donthuoc.Select("da_linh=1").Length > 0;
                 mnuLinhthuocAll.Enabled        = m_Donthuoc.Select("da_linh=0").Length > 0;
                 mnuHuyLinhthuocCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("da_linh"), "-1") == "1";
                 mnuLinhthuocCurrent.Enabled    = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("da_linh"), "-1") == "0";
                 if (lstNoValidData.Count > 0)
                 {
                     Utility.ShowMsg("Chú ý: Một số đơn thuốc bạn chọn chứa thuốc trả lại đã được tổng hợp trong phiếu trả thuốc thừa nên hệ thống bỏ qua không thực hiện và đánh dấu màu đỏ. Đề nghị bạn kiểm tra lại");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Utility.CatchException(ex);
     }
 }
Esempio n. 2
0
 void mnuHuychotAll_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Utility.isValidGrid(grdPres))
         {
             return;
         }
         List <int> lstID_Donthuoc = (from p in grdPres.GetDataRows().AsEnumerable()
                                      where Utility.Int32Dbnull(((DataRowView)p.DataRow)["trangthai_chot"], -1) == 1
                                      select Utility.Int32Dbnull(((DataRowView)p.DataRow)["id_donthuoc"], -1)).ToList <int>();
         if (lstID_Donthuoc.Count <= 0)
         {
             return;
         }
         if (Utility.AcceptQuestion(string.Format("Bạn có chắc chắn hủy chốt số liệu cấp phát thuốc cho {0} đơn thuốc đã được chốt hay không?", lstID_Donthuoc.Count.ToString()), "Thông báo", true))
         {
             frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy();
             _NhaplydoHuy.ShowDialog();
             if (!_NhaplydoHuy.m_blnCancel)
             {
                 if (new ChotThuoc().HUYCHOT_CAPPHAT(lstID_Donthuoc, id_kho, _NhaplydoHuy.ngay_thuchien, _NhaplydoHuy.ten) == ActionResult.Success)
                 {
                     foreach (GridEXRow _row in grdPres.GetDataRows())
                     {
                         if (lstID_Donthuoc.Contains(Utility.Int32Dbnull(_row.Cells["id_donthuoc"].Value, -1)))
                         {
                             _row.BeginEdit();
                             _row.Cells["trangthai_chot"].Value = 0;
                             _row.Cells["ngay_chot"].Value      = DBNull.Value;
                             _row.EndEdit();
                         }
                     }
                     grdPres.Refetch();
                     Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu thành công!", false);
                 }
                 else
                 {
                     Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu không thành công!Liên hệ VMS để được trợ giúp", true);
                 }
                 mnuHuychotAll.Enabled     = m_dtDataDonThuoc.Select("trangthai_chot=1").Length > 0 && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                 mnuChotAll.Enabled        = m_dtDataDonThuoc.Select("trangthai_chot=0").Length > 0;
                 mnuHuychotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "1" && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                 mnuChotCurrent.Enabled    = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "0";
             }
         }
     }
     catch (Exception ex)
     {
         Utility.CatchException(ex);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// hàm thực hiện việc hủy thông tin đơn thuốc
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdHuyDonThuoc_Click(object sender, EventArgs e)
        {
            if (Utility.AcceptQuestion("Bạn có muốn thực hiện hủy phát thuốc cho bệnh nhân \n Dữ liệu hủy sẽ được trả lại kho phát thuốc", "Thông báo", true))
            {
                if (!InValiHuyDonthuoc())
                {
                    return;
                }

                frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy("LYDOHUYXACNHAN", "HỦY XÁC NHẬN ĐƠN THUỐC", "Chọn lý do hủy xác nhận trước khi thực hiện...", "Lý do hủy", "Ngày hủy");
                _NhaplydoHuy.ShowDialog();
                if (!_NhaplydoHuy.m_blnCancel)
                {
                    int   Pres_ID = Utility.Int32Dbnull(grdPres.GetValue(KcbDonthuoc.Columns.IdDonthuoc), -1);
                    Int16 stockID = Utility.Int16Dbnull(_mDtDataPresDetail.Rows[0][KcbDonthuocChitiet.Columns.IdKho]);
                    dtNgayPhatThuoc.Value = globalVariables.SysDate;
                    try
                    {
                        ActionResult actionResult =
                            new XuatThuoc().HuyXacNhanDonThuocBN(Pres_ID, stockID, _NhaplydoHuy.ngay_thuchien, _NhaplydoHuy.ten);
                        switch (actionResult)
                        {
                        case ActionResult.DataUsed:
                            Utility.ShowMsg("Một trong các thuốc bạn chọn đã được sử dụng nên bạn không thể thực hiện hủy xác nhận", "thông báo", MessageBoxIcon.Information);
                            break;

                        case ActionResult.Success:
                            UpdateHuyHasConfirm();
                            THU_VIEN_CHUNG.Log(this.Name, globalVariables.UserName,
                                               string.Format(
                                                   "Hủy phát thuốc của bệnh nhân có mã lần khám {0} và mã bệnh nhân là: {1}. Đơn thuốc {2} bởi {3}",
                                                   Utility.sDbnull(grdPres.CurrentRow.Cells["ma_luotkham"].Value),
                                                   Utility.sDbnull(grdPres.CurrentRow.Cells["id_benhnhan"].Value),
                                                   Utility.sDbnull(grdPres.CurrentRow.Cells["id_donthuoc"].Value),
                                                   globalVariables.UserName), action.Delete);
                            Utility.ShowMsg("Bạn thực hiện việc hủy phát thuốc thành công", "thông báo", MessageBoxIcon.Information);
                            break;

                        case ActionResult.Error:
                            Utility.ShowMsg("Lỗi trong quá trình hủy phát thuốc cho bệnh nhân", "Thông báo", MessageBoxIcon.Error);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Utility.ShowMsg("Lỗi trong quá trình hủy đơn thuốc" + ex.Message);
                    }
                }
            }
        }
Esempio n. 4
0
        void mnuHuychotCurrent_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Utility.isValidGrid(grdPres))
                {
                    return;
                }
                List <int> lstID_Donthuoc = new List <int>()
                {
                    Utility.Int32Dbnull(grdPres.GetValue("id_donthuoc"), -1)
                };
                if (Utility.AcceptQuestion("Bạn có chắc chắn hủy chốt số liệu cấp phát thuốc cho đơn thuốc đang chọn hay không?", "Thông báo", true))
                {
                    frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy();
                    _NhaplydoHuy.ShowDialog();
                    if (!_NhaplydoHuy.m_blnCancel)
                    {
                        if (new ChotThuoc().HUYCHOT_CAPPHAT(lstID_Donthuoc, id_kho, _NhaplydoHuy.ngay_thuchien, _NhaplydoHuy.ten) == ActionResult.Success)
                        {
                            grdPres.CurrentRow.BeginEdit();
                            grdPres.CurrentRow.Cells["trangthai_chot"].Value = 0;
                            grdPres.CurrentRow.Cells["ngay_chot"].Value      = DBNull.Value;
                            grdPres.CurrentRow.EndEdit();
                            grdPres.Refetch();
                            Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu thành công!", false);
                        }
                        else
                        {
                            Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu không thành công!Liên hệ VMS để được trợ giúp", true);
                        }



                        mnuHuychotAll.Enabled     = m_dtDataDonThuoc.Select("trangthai_chot=1").Length > 0 && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                        mnuChotAll.Enabled        = m_dtDataDonThuoc.Select("trangthai_chot=0").Length > 0;
                        mnuHuychotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "1" && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                        mnuChotCurrent.Enabled    = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "0";
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        void mnuHuychotCurrent_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Utility.isValidGrid(grdPres)) return;
                List<int> lstID_Donthuoc = new List<int>() { Utility.Int32Dbnull(grdPres.GetValue("id_donthuoc"), -1) };
                if (Utility.AcceptQuestion("Bạn có chắc chắn hủy chốt số liệu cấp phát thuốc cho đơn thuốc đang chọn hay không?", "Thông báo", true))
                {
                     frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy();
                     _NhaplydoHuy.ShowDialog();
                     if (!_NhaplydoHuy.m_blnCancel)
                     {
                         if (new ChotThuoc().HUYCHOT_CAPPHAT(lstID_Donthuoc, id_kho, _NhaplydoHuy.ngay_thuchien, _NhaplydoHuy.ten) == ActionResult.Success)
                         {
                             grdPres.CurrentRow.BeginEdit();
                             grdPres.CurrentRow.Cells["trangthai_chot"].Value = 0;
                             grdPres.CurrentRow.Cells["ngay_chot"].Value = DBNull.Value;
                             grdPres.CurrentRow.EndEdit();
                             grdPres.Refetch();
                             Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu thành công!", false);
                         }
                         else
                             Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu không thành công!Liên hệ VMS để được trợ giúp", true);

                         mnuHuychotAll.Enabled = m_dtDataDonThuoc.Select("trangthai_chot=1").Length > 0 && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                         mnuChotAll.Enabled = m_dtDataDonThuoc.Select("trangthai_chot=0").Length > 0;
                         mnuHuychotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "1" && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                         mnuChotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "0";
                     }
                }
            }
            catch (Exception ex)
            {

            }
        }
        void mnuHuychotAll_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Utility.isValidGrid(grdPres)) return;
                List<int> lstID_Donthuoc = (from p in grdPres.GetDataRows().AsEnumerable()
                                            where Utility.Int32Dbnull(((DataRowView)p.DataRow)["trangthai_chot"], -1) == 1
                                            select Utility.Int32Dbnull(((DataRowView)p.DataRow)["id_donthuoc"], -1)).ToList<int>();
                if (lstID_Donthuoc.Count <= 0) return;
                if (Utility.AcceptQuestion(string.Format("Bạn có chắc chắn hủy chốt số liệu cấp phát thuốc cho {0} đơn thuốc đã được chốt hay không?", lstID_Donthuoc.Count.ToString()), "Thông báo", true))
                {
                    frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy();
                    _NhaplydoHuy.ShowDialog();
                    if (!_NhaplydoHuy.m_blnCancel)
                    {
                        if (new ChotThuoc().HUYCHOT_CAPPHAT(lstID_Donthuoc, id_kho, _NhaplydoHuy.ngay_thuchien, _NhaplydoHuy.ten) == ActionResult.Success)
                        {
                            foreach (GridEXRow _row in grdPres.GetDataRows())
                            {
                                if (lstID_Donthuoc.Contains(Utility.Int32Dbnull(_row.Cells["id_donthuoc"].Value, -1)))
                                {
                                    _row.BeginEdit();
                                    _row.Cells["trangthai_chot"].Value = 0;
                                    _row.Cells["ngay_chot"].Value = DBNull.Value;
                                    _row.EndEdit();
                                }
                            }
                            grdPres.Refetch();
                            Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu thành công!", false);

                        }
                        else
                            Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu không thành công!Liên hệ VMS để được trợ giúp", true);
                        mnuHuychotAll.Enabled = m_dtDataDonThuoc.Select("trangthai_chot=1").Length > 0 && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                        mnuChotAll.Enabled = m_dtDataDonThuoc.Select("trangthai_chot=0").Length > 0;
                        mnuHuychotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "1" && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                        mnuChotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "0";
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
        }
 /// <summary>
 /// hàm thực hiện việc cập nhập thông tin theo đơn thuốc
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdPhatThuoc_Click(object sender, EventArgs e)
 {
     string thaotac = optDachot.Checked ? " hủy chốt" : " chốt thuốc";
     if (grdPres.GetCheckedRows().Length<=0)
     {
         Utility.ShowMsg("Bạn cần chọn ít nhất một đơn thuốc để thực hiện thao tác " + thaotac + "!");
         return;
     }
     List<int> lstID_Donthuoc = (from p in grdPres.GetCheckedRows().AsEnumerable()
                                 select Utility.Int32Dbnull(((DataRowView)p.DataRow)["id_donthuoc"], -1)).ToList<int>();
     try
     {
         Utility.SetMsg(uiStatusBar2.Panels["1"], "", false);
         if (Utility.AcceptQuestion("Bạn có chắc chắn " + thaotac + " số liệu cấp phát thuốc cho các đơn thuốc được chọn hay không?", "Thông báo", true))
         {
             if (cmdPhatThuoc.Tag.ToString() == "CHOT")
             {
                 if (new ChotThuoc().CHOT_CAPPHAT(lstID_Donthuoc, id_kho, dtNgayPhatThuoc.Value.Date) == ActionResult.Success)
                 {
                     foreach (GridEXRow dr in grdPres.GetCheckedRows())
                     {
                         dr.BeginEdit();
                         dr.Cells["trangthai_chot"].Value = 1;
                         dr.Cells["ngay_chot"].Value = dtNgayPhatThuoc.Value.Date;
                         dr.EndEdit();
                     }
                     grdPres.Refetch();
                     Utility.SetMsg(uiStatusBar2.Panels["1"], "Chốt số liệu thành công!", false);
                 }
                 else
                     Utility.SetMsg(uiStatusBar2.Panels["1"], "Chốt số liệu không thành công!Liên hệ VMS để được trợ giúp", true);
             }
             else
             {
                 frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy();
                 _NhaplydoHuy.ShowDialog();
                 if (!_NhaplydoHuy.m_blnCancel)
                 {
                     if (new ChotThuoc().HUYCHOT_CAPPHAT(lstID_Donthuoc, id_kho, _NhaplydoHuy.ngay_thuchien, _NhaplydoHuy.ten) == ActionResult.Success)
                     {
                         foreach (GridEXRow dr in grdPres.GetCheckedRows())
                         {
                             dr.BeginEdit();
                             dr.Cells["trangthai_chot"].Value = 0;
                             dr.Cells["ngay_chot"].Value = DBNull.Value;
                             dr.EndEdit();
                         }
                         m_dtDataDonThuoc.AcceptChanges();
                         Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu thành công!", false);
                     }
                     else
                         Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu không thành công!Liên hệ VMS để được trợ giúp", true);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Utility.SetMsg(uiStatusBar2.Panels["1"], "Lỗi khi chốt số liệu:\n" + ex.Message, true);
     }
     finally
     {
         mnuHuychotAll.Enabled = m_dtDataDonThuoc.Select("trangthai_chot=1").Length > 0 && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
         mnuChotAll.Enabled = m_dtDataDonThuoc.Select("trangthai_chot=0").Length > 0;
         mnuHuychotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "1" && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
         mnuChotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "0";
     }
 }
Esempio n. 8
0
        /// <summary>
        /// hàm thực hiện việc cập nhập thông tin theo đơn thuốc
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdPhatThuoc_Click(object sender, EventArgs e)
        {
            string thaotac = optDachot.Checked ? " hủy chốt" : " chốt thuốc";

            if (grdPres.GetCheckedRows().Length <= 0)
            {
                Utility.ShowMsg("Bạn cần chọn ít nhất một đơn thuốc để thực hiện thao tác " + thaotac + "!");
                return;
            }
            List <int> lstID_Donthuoc = (from p in grdPres.GetCheckedRows().AsEnumerable()
                                         select Utility.Int32Dbnull(((DataRowView)p.DataRow)["id_donthuoc"], -1)).ToList <int>();

            try
            {
                Utility.SetMsg(uiStatusBar2.Panels["1"], "", false);
                if (Utility.AcceptQuestion("Bạn có chắc chắn " + thaotac + " số liệu cấp phát thuốc cho các đơn thuốc được chọn hay không?", "Thông báo", true))
                {
                    if (cmdPhatThuoc.Tag.ToString() == "CHOT")
                    {
                        if (new ChotThuoc().CHOT_CAPPHAT(lstID_Donthuoc, id_kho, dtNgayPhatThuoc.Value.Date) == ActionResult.Success)
                        {
                            foreach (GridEXRow dr in grdPres.GetCheckedRows())
                            {
                                dr.BeginEdit();
                                dr.Cells["trangthai_chot"].Value = 1;
                                dr.Cells["ngay_chot"].Value      = dtNgayPhatThuoc.Value.Date;
                                dr.EndEdit();
                            }
                            grdPres.Refetch();
                            Utility.SetMsg(uiStatusBar2.Panels["1"], "Chốt số liệu thành công!", false);
                        }
                        else
                        {
                            Utility.SetMsg(uiStatusBar2.Panels["1"], "Chốt số liệu không thành công!Liên hệ VMS để được trợ giúp", true);
                        }
                    }
                    else
                    {
                        frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy();
                        _NhaplydoHuy.ShowDialog();
                        if (!_NhaplydoHuy.m_blnCancel)
                        {
                            if (new ChotThuoc().HUYCHOT_CAPPHAT(lstID_Donthuoc, id_kho, _NhaplydoHuy.ngay_thuchien, _NhaplydoHuy.ten) == ActionResult.Success)
                            {
                                foreach (GridEXRow dr in grdPres.GetCheckedRows())
                                {
                                    dr.BeginEdit();
                                    dr.Cells["trangthai_chot"].Value = 0;
                                    dr.Cells["ngay_chot"].Value      = DBNull.Value;
                                    dr.EndEdit();
                                }
                                m_dtDataDonThuoc.AcceptChanges();
                                Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu thành công!", false);
                            }
                            else
                            {
                                Utility.SetMsg(uiStatusBar2.Panels["1"], "Hủy chốt số liệu không thành công!Liên hệ VMS để được trợ giúp", true);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.SetMsg(uiStatusBar2.Panels["1"], "Lỗi khi chốt số liệu:\n" + ex.Message, true);
            }
            finally
            {
                mnuHuychotAll.Enabled     = m_dtDataDonThuoc.Select("trangthai_chot=1").Length > 0 && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                mnuChotAll.Enabled        = m_dtDataDonThuoc.Select("trangthai_chot=0").Length > 0;
                mnuHuychotCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "1" && PropertyLib._HisDuocProperties.ChoPhepHuyChotThuoc;
                mnuChotCurrent.Enabled    = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("trangthai_chot"), "-1") == "0";
            }
        }
        /// <summary>
        /// hàm thực hiện việc hủy thông tin đơn thuốc
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdHuyDonThuoc_Click(object sender, EventArgs e)
        {
            if (Utility.AcceptQuestion("Bạn có muốn thực hiện hủy phát thuốc cho bệnh nhân \n Dữ liệu hủy sẽ được trả lại kho phát thuốc", "Thông báo", true))
            {

                if (!InValiHuyDonthuoc()) return;

                frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy("LYDOHUYXACNHAN", "HỦY XÁC NHẬN ĐƠN THUỐC", "Chọn lý do hủy xác nhận trước khi thực hiện...", "Lý do hủy","Ngày hủy");
                _NhaplydoHuy.ShowDialog();
                if (!_NhaplydoHuy.m_blnCancel)
                {
                    int Pres_ID = Utility.Int32Dbnull(grdPres.GetValue(KcbDonthuoc.Columns.IdDonthuoc), -1);
                    dtNgayPhatThuoc.Value = globalVariables.SysDate;
                    ActionResult actionResult =
                        new XuatThuoc().HuyXacNhanDonThuocBN(Pres_ID, Utility.Int16Dbnull(cboKho.SelectedValue, 0), _NhaplydoHuy.ngay_thuchien, _NhaplydoHuy.ten);
                    switch (actionResult)
                    {
                        case ActionResult.Success:
                            UpdateHuyHasConfirm();
                            Utility.ShowMsg("Bạn thực hiện việc hủy phát thuốc thành công", "thông báo", MessageBoxIcon.Information);
                            break;
                        case ActionResult.Error:
                            Utility.ShowMsg("Lỗi trong quá trình hủy phát thuốc cho bệnh nhân", "Thông báo", MessageBoxIcon.Error);
                            break;
                    }
                }
            }
        }
        void mnuHuyLinhthuocAll_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Utility.isValidGrid(grdPres)) return;
                List<int> lstNoValidData = new List<int>();
                List<int> lstID_Donthuoc = (from p in grdPres.GetDataRows().AsEnumerable()
                                            where Utility.Int32Dbnull(((DataRowView)p.DataRow)[TPhieuCapphatChitiet.Columns.DaLinh], -1) == 1
                                            select Utility.Int32Dbnull(((DataRowView)p.DataRow)["id_donthuoc"], -1)).ToList<int>();
                if (lstID_Donthuoc.Count <= 0) return;
                if (Utility.AcceptQuestion(string.Format("Bạn có chắc chắn hủy bệnh nhân lĩnh thuốc cho {0} đơn thuốc đang chọn hay không?", lstID_Donthuoc.Count.ToString()), "Thông báo", true))
                {
                    frm_NhaplydoHuy _NhaplydoHuy = new frm_NhaplydoHuy();
                    _NhaplydoHuy.ShowDialog();
                    if (!_NhaplydoHuy.m_blnCancel)
                    {
                        if (CapphatThuocKhoa.BenhNhanLinhThuoc(idPhieucapphat, lstID_Donthuoc, 0, ref lstNoValidData) == ActionResult.Success)
                        {
                            foreach (GridEXRow _row in grdPres.GetDataRows())
                            {
                                if (lstID_Donthuoc.Contains(Utility.Int32Dbnull(_row.Cells["id_donthuoc"].Value, -1)))
                                {
                                    _row.BeginEdit();
                                    _row.Cells["da_linh"].Value = 0;
                                    if (lstNoValidData.Count > 0 && lstNoValidData.Contains(Utility.Int32Dbnull(_row.Cells["id_donthuoc"].Value, -1)))
                                        _row.Cells["not_valid"].Value = 1;
                                    _row.EndEdit();
                                }
                            }
                            grdPres.Refetch();
                            Utility.SetMsg(uiStatusBar2.Panels["Msg"], "Hủy lĩnh thuốc thành công!", false);

                        }
                        else
                            Utility.SetMsg(uiStatusBar2.Panels["Msg"], "Hủy lĩnh thuóc không thành công!Liên hệ VMS để được trợ giúp", true);
                        mnuHuyLinhthuocAll.Enabled = m_Donthuoc.Select("da_linh=1").Length > 0 ;
                        mnuLinhthuocAll.Enabled = m_Donthuoc.Select("da_linh=0").Length > 0;
                        mnuHuyLinhthuocCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("da_linh"), "-1") == "1";
                        mnuLinhthuocCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("da_linh"), "-1") == "0";
                        if (lstNoValidData.Count > 0)
                        {
                            Utility.ShowMsg("Chú ý: Một số đơn thuốc bạn chọn chứa thuốc trả lại đã được tổng hợp trong phiếu trả thuốc thừa nên hệ thống bỏ qua không thực hiện và đánh dấu màu đỏ. Đề nghị bạn kiểm tra lại");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
        }