void cmdDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Utility.isValidGrid(grdList))
         {
             Utility.ShowMsg("Bạn cần chọn ít nhất một Bệnh nhân để thực hiện xóa đơn thuốc");
             return;
         }
         if (!isValidPres(Utility.Int32Dbnull(grdList.GetValue(KcbDonthuoc.Columns.IdDonthuoc), -1))) return;
         if (Utility.AcceptQuestion("Bạn có chắc chắn muốn xóa đơn thuốc ra khỏi hệ thống\n.Lưu ý: Toàn bộ đơn thuốc cũng bị xóa theo", "Cảnh báo", true))
         {
             ActionResult _result = new KCB_KEDONTHUOC().XoaDonthuoctaiquay(Utility.Int64Dbnull(grdList.GetValue(KcbDonthuoc.Columns.IdBenhnhan), -1), Utility.Int64Dbnull(grdList.GetValue(KcbDonthuoc.Columns.IdDonthuoc), -1));
             if (_result == ActionResult.Success)
             {
                 DataRow[] arrDr = m_dtSearchdata.Select(KcbDonthuoc.Columns.IdBenhnhan + "=" + Utility.sDbnull(grdList.GetValue(KcbDonthuoc.Columns.IdBenhnhan), "-1"));
                 if (arrDr.Length > 0)
                 {
                     m_dtSearchdata.Rows.Remove(arrDr[0]);
                     m_dtSearchdata.AcceptChanges();
                     m_dtChitietthanhtoan.Rows.Clear();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Utility.CatchException("Lỗi khi xóa đơn thuốc tại quầy", ex);
     }
     finally
     {
         ClearControl();
         ModifyPresCommand();
         ModifyCommand();
     }
 }
        private void PrintPres(int PresID)
        {
            DataTable v_dtData =new  KCB_KEDONTHUOC().LaythongtinDonthuoc_In(PresID);
            Utility.AddColumToDataTable(ref v_dtData, "BarCode", typeof(byte[]));
            //barcode.Data = Utility.sDbnull(Pres_ID);
            byte[] Barcode = Utility.GenerateBarCode(barcode);
            string ICD_Name = "";
            string ICD_Code = "";

            foreach (DataRow drv in v_dtData.Rows)
            {
                drv["BarCode"] = Barcode;
                drv["chan_doan"] ="";
                drv["ma_icd"] = "";
            }
            THU_VIEN_CHUNG.CreateXML(v_dtData, "thamkham_InDonthuocA4.xml");
            v_dtData.AcceptChanges();
            // log.Info("Thuc hien in don thuoc");
            Utility.UpdateLogotoDatatable(ref v_dtData);
            string KhoGiay = "A5";
            if (PropertyLib._MayInProperties.CoGiayInDonthuoc == Papersize.A4) KhoGiay = "A4";
            ReportDocument reportDocument = new ReportDocument();
            string tieude = "", reportname = "",reportCode="";
            switch (KhoGiay)
            {
                case "A5":
                    reportCode = "quaythuoc_InDonthuocA5";
                    reportDocument = Utility.GetReport("quaythuoc_InDonthuocA5", ref tieude, ref reportname);
                    break;
                case "A4":
                    reportCode = "quaythuoc_InDonthuocA4";
                    reportDocument = Utility.GetReport("quaythuoc_InDonthuocA4", ref tieude, ref reportname);
                    break;
                default:
                    reportCode = "quaythuoc_InDonthuocA4";
                    reportDocument = Utility.GetReport("quaythuoc_InDonthuocA4", ref tieude, ref reportname);
                    break;
            }
            if (reportDocument == null) return;
            //v_dtData.AcceptChanges();
            Utility.WaitNow(this);
            ReportDocument crpt = reportDocument;
            var objForm = new frmPrintPreview("IN ĐƠN THUỐC BỆNH NHÂN", crpt, true, true);
            try
            {
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode = reportCode;
                crpt.SetDataSource(v_dtData);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
                Utility.SetParameterValue(crpt, "ReportTitle", tieude);
                Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTime(globalVariables.SysDate));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                if (Utility.isPrintPreview(PropertyLib._MayInProperties.TenMayInBienlai, PropertyLib._MayInProperties.PreviewInDonthuoc))
                {
                    objForm.SetDefaultPrinter(PropertyLib._MayInProperties.TenMayInBienlai, 0);
                    objForm.ShowDialog();
                    cbomayinphoiBHYT.Text = PropertyLib._MayInProperties.TenMayInBienlai;
                }
                else
                {
                    objForm.addTrinhKy_OnFormLoad();
                    crpt.PrintOptions.PrinterName = PropertyLib._MayInProperties.TenMayInBienlai;
                    crpt.PrintToPrinter(1, false, 0, 0);
                }
                Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                Utility.DefaultNow(this);
            }
        }