public static void InphieuDieuTri(DataTable dtPrint, DateTime ngayin)
        {
            string tieude = "", reportname = "";
            var    crpt = Utility.GetReport("noitru_phieudieutri", ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }
            //var crpt = new crpt_PhieuDieuTri();
            var objForm = new frmPrintPreview("IN PHIẾU ĐIỀU TRỊ", crpt, true, true);

            crpt.SetDataSource(dtPrint);
            objForm.mv_sReportFileName = Path.GetFileName(reportname);
            objForm.mv_sReportCode     = "noitru_phieudieutri";
            Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
            Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
            Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTime(ngayin));
            Utility.SetParameterValue(crpt, "sTitleReport", tieude);
            Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());

            objForm.crptViewer.ReportSource = crpt;
            objForm.ShowDialog();
            objForm.Dispose();
        }
        /// <summary>
        /// hàm thực hiện việc in phiếu dịch vụ
        /// </summary>
        /// <param name="m_dtReportPhieuThu"></param>
        /// <param name="NgayInPhieu"></param>
        /// <param name="sTitleReport"></param>
        public void LAOKHOA_INPHIEU_DICHVU(DataTable m_dtReportPhieuThu, DateTime NgayInPhieu, string sTitleReport)
        {
            Utility.UpdateLogotoDatatable(ref m_dtReportPhieuThu);
            string tieude = "", reportname = "";
            var    crpt = Utility.GetReport("thanhtoan_crpt_PhieuDV_A5", ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }
            var objForm = new frmPrintPreview("", crpt, true, true);

            //try
            //{
            crpt.SetDataSource(m_dtReportPhieuThu);
            //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "                                                                      ".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
            Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
            Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
            Utility.SetParameterValue(crpt, "Telephone", globalVariables.Branch_Phone);
            Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
            //  Utility.SetParameterValue(crpt,"DateTime", Utility.FormatDateTime(dtCreateDate.Value));
            Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTime(NgayInPhieu));
            Utility.SetParameterValue(crpt, "sTitleReport", sTitleReport);
            Utility.SetParameterValue(crpt, "sMoneyCharacter",
                                      new MoneyByLetter().sMoneyToLetter(SumOfTotal(m_dtReportPhieuThu).ToString()));
            Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
            objForm.crptViewer.ReportSource = crpt;
            objForm.ShowDialog();
        }
        /// <summary>
        /// hàm thực hiện việc in phiếu báo cáo tổng hợp
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuXN_Click(object sender, EventArgs e)
        {
            _dtData = BAOCAO_NGOAITRU.BaocaoTamungHoanung(Utility.Int16Dbnull(txtNhanvien.MyID, -1), chkByDate.Checked?dtFromDate.Value.ToString("dd/MM/yyyy"):"01/01/1900",
                                                          chkByDate.Checked ? dtToDate.Value.ToString("dd/MM/yyyy") : "01/01/1900",
                                                          Utility.Int16Dbnull(cbokhoa.SelectedValue, -1),
                                                          Utility.Int16Dbnull(cboDoituongKCB.SelectedValue, -1),
                                                          Utility.Bool2byte(optHoanung.Checked)
                                                          );

            Utility.SetDataSourceForDataGridEx(grdList, _dtData, false, true, "1=1", "");


            Utility.UpdateLogotoDatatable(ref _dtData);
            THU_VIEN_CHUNG.CreateXML(_dtData, "baocao_tamung.xml");
            if (_dtData.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy dữ liệu báo cáo theo điều kiện bạn chọn", "Thông báo", MessageBoxIcon.Information);
                return;
            }
            string Condition = string.Format("Từ ngày {0} đến {1} - Thu ngân viên :{2} ", dtFromDate.Text, dtToDate.Text, txtNhanvien.Text);
            var    crpt      = Utility.GetReport(optTamung.Checked?"baocao_tamung":"baocao_hoanung", ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }

            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                frmPrintPreview objForm = new frmPrintPreview(tieude, crpt, true, _dtData.Rows.Count <= 0 ? false : true);
                //try
                //{
                crpt.SetDataSource(_dtData);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = optTamung.Checked?"baocao_tamung":"baocao_hoanung";
                Utility.SetParameterValue(crpt, "StaffName", StaffName);
                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, "FromDateToDate", Condition);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "Tongtien_chu", new MoneyByLetter().sMoneyToLetter(_dtData.Compute("SUM(so_tien)", "1=1").ToString()));
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
        }
        private void cmdInPhieu_Click(object sender, EventArgs e)
        {
            int trangthai = -1;

            DataTable dtDanhsach =
                SPs.BhytBaocaoDongchitra(dtFromDate.Value, dtToDate.Value,
                                         Utility.sDbnull(cboKhoa.SelectedValue, "KKB"), globalVariables.gv_intIDNhanvien, trangthai)
                .GetDataSet().Tables[0];

            Utility.SetDataSourceForDataGridEx(grdResult, dtDanhsach, false, false, "", "");

            THU_VIEN_CHUNG.CreateXML(dtDanhsach, "BHYT_baocao_dongchitra.XML");
            Utility.UpdateLogotoDatatable(ref dtDanhsach);
            string reportCode = "BHYT_baocao_dongchitra";

            string Condition =
                string.Format("Từ ngày {0} đến {1} - Khoa KCB :{2}",
                              dtFromDate.Text, dtToDate.Text, globalVariables.MA_KHOA_THIEN);
            ReportDocument crpt = Utility.GetReport(reportCode, ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }

            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                var objForm = new frmPrintPreview(tieude, crpt, true, dtDanhsach.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(dtDanhsach);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportCode;
                crpt.SetParameterValue("StaffName", StaffName);
                crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
                crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                crpt.SetParameterValue("Address", globalVariables.Branch_Address);
                crpt.SetParameterValue("Phone", globalVariables.Branch_Phone);
                crpt.SetParameterValue("FromDateToDate", Condition);
                crpt.SetParameterValue("sTitleReport", tieude);
                crpt.SetParameterValue("sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                crpt.SetParameterValue("BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
            finally
            {
                Utility.FreeMemory(crpt);
            }
        }
Example #5
0
        void cmdPrint_Click(object sender, EventArgs e)
        {
            Utility.WaitNow(this);
            DataTable dtData =
                SPs.KcbThamkhamPhieuchuyenvien(Utility.DoTrim(txtMaluotkham.Text)).GetDataSet().Tables[0];

            if (dtData.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            THU_VIEN_CHUNG.CreateXML(dtData, "thamkham_phieuchuyenvien.XML");
            Utility.UpdateLogotoDatatable(ref dtData);
            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }

            string         tieude = "", reportname = "";
            ReportDocument crpt = Utility.GetReport("thamkham_phieuchuyenvien", ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }
            try
            {
                frmPrintPreview objForm = new frmPrintPreview("PHIẾU CHUYỂN TUYẾN", crpt, true, dtData.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(dtData);

                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "thamkham_phieuchuyenvien";
                Utility.SetParameterValue(crpt, "StaffName", StaffName);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTimeWithThanhPho(dtpNgayin.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
            finally
            {
                Utility.DefaultNow(this);
                GC.Collect();
                Utility.FreeMemory(crpt);
            }
        }
Example #6
0
        public static void INMAU_CHUYENKHAM_CHUYENKHOA(DataTable mDtReport, string sTitleReport, string report,
                                                       string lydochuyen)
        {
            Utility.UpdateLogotoDatatable(ref mDtReport);
            string         tieude = "", reportname = "";
            ReportDocument reportDocument = report == "PHIEUKHAM_CHUYENKHOA"
                ? Utility.GetReport("thamkham_phieukham_chuyenkhoa", ref tieude, ref reportname)
                : Utility.GetReport("thamkham_phieuxn_benhpham", ref tieude, ref reportname);

            if (reportDocument == null)
            {
                return;
            }
            ReportDocument crpt = reportDocument;

            var objForm = new frmPrintPreview(sTitleReport, crpt, true, mDtReport.Rows.Count > 0);

            try
            {
                mDtReport.AcceptChanges();
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "thamkham_phieukham_chuyenkhoa";
                crpt.SetDataSource(mDtReport);
                Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone + globalVariables.SOMAYLE);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTime(globalVariables.SysDate));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "lydochuyen", lydochuyen);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky",
                                          Utility.getTrinhky(objForm.mv_sReportFileName,
                                                             globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
                //if (Utility.isPrintPreview(PropertyLib._MayInProperties.TenMayInPhieuKCB, PropertyLib._MayInProperties.PreviewPhieuKCB))
                //{
                //    objForm.SetDefaultPrinter(PropertyLib._MayInProperties.TenMayInPhieuKCB, 0);
                //    objForm.ShowDialog();
                //}
                //else
                //{
                //    objForm.addTrinhKy_OnFormLoad();
                //    crpt.PrintOptions.PrinterName = PropertyLib._MayInProperties.TenMayInBienlai;
                //    crpt.PrintToPrinter(1, false, 0, 0);
                //}
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.ToString());
            }
            finally
            {
                GC.Collect();
            }
        }
        /// <summary>
        /// HÀM THỰC HIỆN VIỆC IN PHIẾU BIÊN LAI CHO BẢO HIỂM Y TẾ
        /// </summary>
        /// <param name="m_dtReportPhieuThu"></param>
        /// <param name="sTitleReport"></param>
        /// <param name="ngayIn"></param>
        public void LAOKHOA_INPHIEU_BIENLAI_BHYT(DataTable m_dtReportPhieuThu, string sTitleReport, DateTime ngayIn)
        {
            if (m_dtReportPhieuThu.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy bản ghi nào", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            Utility.UpdateLogotoDatatable(ref m_dtReportPhieuThu);
            THU_VIEN_CHUNG.Sapxepthutuin(ref m_dtReportPhieuThu, true);
            m_dtReportPhieuThu.DefaultView.Sort = "THU_TU ASC";
            m_dtReportPhieuThu.AcceptChanges();
            decimal        phuthu = SumOfTotal(m_dtReportPhieuThu, "PHU_THU");
            decimal        bnct = SumOfTotal(m_dtReportPhieuThu, "BNCT");
            decimal        Total = bnct + phuthu;
            string         tieude = "", reportname = "";
            ReportDocument crpt = Utility.GetReport("thanhtoan_Bienlai_BHYT_A4", ref tieude, ref reportname);

            if (PropertyLib._MayInProperties.CoGiayInBienlai == Papersize.A4)
            {
                crpt = Utility.GetReport("thanhtoan_Bienlai_BHYT_A4", ref tieude, ref reportname);
            }
            else
            {
                crpt = Utility.GetReport("thanhtoan_Bienlai_BHYT_A5", ref tieude, ref reportname);
            }
            if (crpt == null)
            {
                return;
            }
            var objForm = new frmPrintPreview(sTitleReport, crpt, true, true);

            //try
            //{

            crpt.SetDataSource(m_dtReportPhieuThu.DefaultView);
            //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "    Nhân viên                                                                   ".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
            Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
            Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
            //Utility.SetParameterValue(crpt,"ParentBranchName", globalVariables.ParentBranch_Name);
            Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
            Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTime(ngayIn));
            Utility.SetParameterValue(crpt, "sTitleReport", sTitleReport);
            Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
            Utility.SetParameterValue(crpt, "sMoneyLetter", _moneyByLetter.sMoneyToLetter(Total.ToString()));
            objForm.crptViewer.ReportSource = crpt;
            objForm.ShowDialog();

            //}
            //catch (Exception ex)
            //{
            //    Utility.DefaultNow(this);
            //}
        }
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            try
            {
                //Truyền dữ liệu vào datatable
                DataTable m_dtReport = BAOCAO_THUOC.ThuocLaythongtinInphieuDutruthuoc(Utility.Int16Dbnull(cboKhoxuat.SelectedValue, -1), KIEU_THUOC_VT);
                THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_PhieuDutru.xml");

                if (m_dtReport.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }

                //Add logo vào datatable
                Utility.UpdateLogotoDatatable(ref m_dtReport);
                string tieude = "", reportname = "";
                string mabaocao = "thuoc_PhieuDutru";
                var    crpt     = Utility.GetReport(mabaocao, ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }

                //baocaO_TIEUDE1.TIEUDE
                frmPrintPreview objForm = new frmPrintPreview(tieude, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(m_dtReport);

                objForm.mv_sReportFileName = System.IO.Path.GetFileName(reportname);
                objForm.mv_sReportCode     = mabaocao;
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(globalVariables.SysDate));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", "");
                Utility.SetParameterValue(crpt, "tenkho", cboKhoxuat.Text);


                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
        }
Example #9
0
        public static void InphieuNhapkho(int IDPhieuNhap, string sTitleReport, DateTime NgayIn)
        {
            DataTable m_dtReport = new THUOC_NHAPKHO().Laythongtininphieunhapkhothuoc(IDPhieuNhap);

            if (m_dtReport.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy thông tin ", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_phieu_nhapkho.xml");
            MoneyByLetter _moneyByLetter = new MoneyByLetter();
            string        tinhtong = TinhTong(m_dtReport, TPhieuNhapxuatthuocChitiet.ThanhTienColumn.ColumnName);
            string        tieude = "", reportname = "";
            var           crpt = Utility.GetReport("thuoc_phieunhapkho", ref tieude, ref reportname);

            // VNS.HIS.UI.BaoCao.PhieuNhapKho.CRPT_PHIEU_NHAPKHO crpt =new CRPT_PHIEU_NHAPKHO();
            var objForm = new frmPrintPreview(sTitleReport, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);

            Utility.UpdateLogotoDatatable(ref m_dtReport);
            try
            {
                m_dtReport.AcceptChanges();
                crpt.SetDataSource(m_dtReport);

                ////crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "  PHÒNG TIẾP ĐÓN   ".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "thuoc_phieunhapkho";
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sMoneyLetter", _moneyByLetter.sMoneyToLetter(tinhtong));

                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
                // Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
        }
Example #10
0
        public static void InBienBanGiaoHang(int IDPhieuNhap, string sTitleReport, DateTime NgayIn)
        {
            DataTable m_dtReport = SPs.ThuocLaydulieuinphieuchuyenkho2lien(IDPhieuNhap).GetDataSet().Tables[0];

            if (m_dtReport.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy thông tin ", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_phieu_bienbangiaohang");
            string tieude = "", reportname = "";
            var    crpt = Utility.GetReport("thuoc_phieu_bienbangiaohang", ref tieude, ref reportname);

            Utility.UpdateLogotoDatatable(ref m_dtReport);
            var objForm = new frmPrintPreview(sTitleReport, crpt, true, true);

            try
            {
                m_dtReport.AcceptChanges();
                crpt.SetDataSource(m_dtReport);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "thuoc_phieu_bienbangiaohang";
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                //  Utility.SetParameterValue(crpt, "sMoneyLetter", new MoneyByLetter().sMoneyToLetter(tinhtong));
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;

                objForm.ShowDialog();
                // Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
            finally
            {
                Utility.FreeMemory(crpt);
            }
        }
Example #11
0
        public static void Inphieuxuatthuockhoa(int IDPhieuNhap, string sTitleReport, DateTime NgayIn)
        {
            DataTable m_dtReport = SPs.ThuocLaythongtininphieuXuatkhothuoc(IDPhieuNhap).GetDataSet().Tables[0];

            if (m_dtReport.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy thông tin ", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            string tieude = "", reportname = "";
            var    crpt = Utility.GetReport("CRPT_PHIEUXUAT_KHOLE_TOIKHOA", ref tieude, ref reportname);


            var objForm = new frmPrintPreview(sTitleReport, crpt, true, true);

            Utility.UpdateLogotoDatatable(ref m_dtReport);
            try
            {
                m_dtReport.AcceptChanges();
                crpt.SetDataSource(m_dtReport);
                //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) +
                //"".Replace("#$X$#",
                //           Strings.Chr(34) + "&Chr(13)&" +
                //           Strings.Chr(34)) + Strings.Chr(34);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "CRPT_PHIEUXUAT_KHOLE_TOIKHOA";

                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", sTitleReport);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
                // Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
        }
Example #12
0
        public static void InphieuThanhly(int IDPhieuNhap, string sTitleReport, DateTime NgayIn)
        {
            DataTable m_dtReport = SPs.ThuocLaythongtininphieuXuatkhothuoc(IDPhieuNhap).GetDataSet().Tables[0];

            if (m_dtReport.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy thông tin ", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            MoneyByLetter _moneyByLetter = new MoneyByLetter();
            string        tinhtong       = TinhTong(m_dtReport, TPhieuNhapxuatthuocChitiet.ThanhTienColumn.ColumnName);

            THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_bienban_thanhly");
            string tieude = "", reportname = "";
            var    crpt = Utility.GetReport("thuoc_bienban_thanhly", ref tieude, ref reportname);


            Utility.UpdateLogotoDatatable(ref m_dtReport);
            var objForm = new frmPrintPreview(sTitleReport, crpt, true, true);

            try
            {
                m_dtReport.AcceptChanges();
                crpt.SetDataSource(m_dtReport);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "thuoc_bienban_thanhly";

                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sMoneyLetter", _moneyByLetter.sMoneyToLetter(tinhtong));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
        }
        public void KYDONG_INPHIEU_DICHVU(DataTable m_dtReportPhieuThu, DateTime NgayInPhieu, string sTitleReport, string khogiay)
        {
            Utility.UpdateLogotoDatatable(ref m_dtReportPhieuThu);
            ReportDocument reportDocument = new ReportDocument();
            string         tieude = "", reportname = "";

            switch (khogiay)
            {
            case "A4":
                reportDocument = Utility.GetReport("thanhtoan_Bienlai_Dichvu_A4", ref tieude, ref reportname);
                break;

            case "A5":
                reportDocument = Utility.GetReport("thanhtoan_13", ref tieude, ref reportname);
                break;
            }

            if (reportDocument == null)
            {
                return;
            }
            var crpt = reportDocument;

            decimal tong = m_dtReportPhieuThu.AsEnumerable().Sum(c => c.Field <decimal>("TONG_BN"));
            var     objForm = new frmPrintPreview("", crpt, true, true);

            //try
            //{
            crpt.SetDataSource(m_dtReportPhieuThu);
            //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "                                                                      ".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
            Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
            Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
            Utility.SetParameterValue(crpt, "Telephone", globalVariables.Branch_Phone);
            Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
            //  Utility.SetParameterValue(crpt,"DateTime", Utility.FormatDateTime(dtCreateDate.Value));
            Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTime(NgayInPhieu));
            Utility.SetParameterValue(crpt, "sTitleReport", sTitleReport);
            Utility.SetParameterValue(crpt, "sMoneyCharacter",
                                      new MoneyByLetter().sMoneyToLetter(Utility.sDbnull(tong)));
            Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
            objForm.crptViewer.ReportSource = crpt;
            objForm.ShowDialog();
        }
Example #14
0
        public static void InphieuTraKholeVeKhochan(int IDPhieuNhap, string sTitleReport, DateTime NgayIn)
        {
            try
            {
                DataTable m_dtReport = SPs.ThuocLaythongtininphieutrakholevekhochan(IDPhieuNhap).GetDataSet().Tables[0];
                if (m_dtReport.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy thông tin ", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }
                THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_phieutrakholevekhochan.xml");
                Utility.UpdateLogotoDatatable(ref m_dtReport);
                string tieude = "", reportname = "";
                var    crpt = Utility.GetReport("thuoc_phieutrakholevekhochan", ref tieude, ref reportname);

                var objForm = new frmPrintPreview(sTitleReport, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);

                m_dtReport.AcceptChanges();
                crpt.SetDataSource(m_dtReport);

                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "thuoc_phieutrakholevekhochan";
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", sTitleReport);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "sMoneybyletter", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;

                objForm.ShowDialog();
                // Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
        }
Example #15
0
        public static void InphieuTranhacungcap(int IDPhieuNhap, string sTitleReport, DateTime NgayIn)
        {
            try
            {
                DataTable m_dtReport = SPs.ThuocLaydulieuinphieuchuyenkho2lien(IDPhieuNhap).GetDataSet().Tables[0];
                if (m_dtReport.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy thông tin ", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }
                THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_phieutranhacungcap");
                string tieude = "", reportname = "";
                var    crpt = Utility.GetReport("thuoc_phieutranhacungcap", ref tieude, ref reportname);
                Utility.UpdateLogotoDatatable(ref m_dtReport);
                var objForm = new frmPrintPreview(sTitleReport, crpt, true, true);

                m_dtReport.AcceptChanges();
                crpt.SetDataSource(m_dtReport);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "thuoc_phieutranhacungcap";


                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
        }
Example #16
0
        public static void InBanCamKetPhauThuat(DataTable mDtReport, string sTitleReport, DateTime ngayIn)
        {
            string         tieude = "", reportname = "";
            ReportDocument crpt = Utility.GetReport("noitru_giaycamketPT_A5", ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }
            THU_VIEN_CHUNG.CreateXML(mDtReport, "noitru_giaycamketPT_A5.xml");
            var moneyByLetter = new MoneyByLetter();
            var objForm       = new frmPrintPreview(sTitleReport, crpt, true, mDtReport.Rows.Count > 0);

            // string tinhtong = TinhTong(m_dtReport);
            Utility.UpdateLogotoDatatable(ref mDtReport);
            try
            {
                crpt.SetDataSource(mDtReport);


                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "noitru_giaycamketPT_A5";
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTimeWithThanhPho(ngayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
        }
Example #17
0
        void cmdIn_Click(object sender, EventArgs e)
        {
            try
            {
                if (objLuotkham == null)
                {
                    Utility.ShowMsg("Bạn cần chọn bệnh nhân in phiếu tạm ứng");
                    return;
                }
                if (grdTamung.GetDataRows().Count() <= 0)
                {
                    Utility.ShowMsg("Bạn cần chọn phiếu tạm ứng muốn in");
                    return;
                }
                if (!Utility.isValidGrid(grdTamung))
                {
                    grdTamung.MoveFirst();
                }
                DataTable m_dtReport = noitru_TamungHoanung.NoitruInphieutamung(Utility.Int64Dbnull(Utility.GetValueFromGridColumn(grdTamung, NoitruTamung.Columns.Id), -1));
                THU_VIEN_CHUNG.CreateXML(m_dtReport, "noitru_phieutamung.xml");
                if (m_dtReport.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy dữ liệu", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }
                string tieude = "", reportname = "";
                var    crpt = Utility.GetReport("noitru_phieutamung", ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }

                MoneyByLetter _moneyByLetter = new MoneyByLetter();
                var           objForm        = new frmPrintPreview(tieude, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
                Utility.UpdateLogotoDatatable(ref m_dtReport);

                crpt.SetDataSource(m_dtReport);


                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "noitru_phieutamung";
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "TelePhone", globalVariables.Branch_Phone);
                Utility.SetParameterValue(crpt, "sMoneyLetter", _moneyByLetter.sMoneyToLetter(Utility.Int32Dbnull(m_dtReport.Compute("SUM(so_tien)", "1=1"), 0).ToString()));
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(DateTime.Now));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;

                if (Utility.isPrintPreview(PropertyLib._MayInProperties.TenMayInBienlai, PropertyLib._MayInProperties.PreviewPhieuTamung))
                {
                    objForm.SetDefaultPrinter(PropertyLib._MayInProperties.TenMayInBienlai, 0);
                    objForm.ShowDialog();
                }
                else
                {
                    objForm.addTrinhKy_OnFormLoad();
                    crpt.PrintOptions.PrinterName = PropertyLib._MayInProperties.TenMayInBienlai;
                    crpt.PrintToPrinter(objForm.getPrintNumber, false, 0, 0);
                }
            }
            catch (Exception)
            {
            }
        }
Example #18
0
        private void INPHIEU_XETNGHIEM(bool IsQuick, string sTitleReport, DateTime NgayIn)
        {
            string strPatient_ID = string.Empty;
            var    DTPrint       = new DataTable();
            string vTestTypeId   = GetCheckTestType();
            string vTestID       = GetcheckTestID();

            if (vTestTypeId == "-1")
            {
                Utility.ShowMsg("Chưa chọn loại xét nghiệm để in");
                return;
            }

            if (grdList.GetCheckedRows().Length > 0)
            {
                foreach (GridEXRow gridExRow in grdList.GetCheckedRows())
                {
                    strPatient_ID += "," + Utility.Int32Dbnull(gridExRow.Cells["Patient_ID"].Value, -1);
                }
                strPatient_ID = strPatient_ID.Remove(0, 1);
            }
            else
            {
                strPatient_ID = Utility.sDbnull(grdList.GetValue("Patient_ID"));
            }
            DTPrint =
                SPs.GtvtGetTestResultForPrintV2FromDateToDate(strPatient_ID, vTestTypeId, vTestID,
                                                              dtFromDate.Date.ToShortDateString(),
                                                              dtToDate.Date.ToShortDateString()).GetDataSet().Tables[0];
            if (DTPrint.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy bản ghi nào", "Thông báo");
                return;
            }
            ProcessData(ref DTPrint);
            if (SysPara.IsNormalResult == 1)
            {
                string normalLevel = Utility.Int32Dbnull(DTPrint.Rows[0]["Sex"], 1) == 1
                                         ? "Normal_Level"
                                         : "Normal_LevelW";
                ProcessNormalResult(ref DTPrint);
                //ProcessNormalResult(ref DTPrint, "Test_result", normalLevel, -1, 1, 0,
                //                                            "binhthuong", false);
                foreach (DataRow row in DTPrint.Rows)
                {
                    if (
                        (row["Test_result"].ToString().Trim().ToUpper().StartsWith("ÂM")) ||
                        (row["Test_result"].ToString().Trim().ToUpper().Contains("AM"))
                        )
                    {
                        row["binhthuong"] = -1;
                    }
                    else if (
                        (row["Test_result"].ToString().Trim().ToUpper().StartsWith("DƯƠ")) ||
                        (row["Test_result"].ToString().Trim().ToUpper().Contains("DUO"))
                        )
                    {
                        row["binhthuong"] = 1;
                    }
                }
            }
            try
            {
                reporttype = File.ReadAllText(filereporttype);
                if (chkA5.Checked)
                {
                    StrCode = reporttype;
                }
                else if (chkA4.Checked)
                {
                    StrCode = reporttype;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Loz" + ex, "Thông báo");
            }

            //Tạo list loại xét nghiệm được tick chọn
            //CrptBusiness.testTypeList.Clear();
            //foreach (var row in grdTestType.GetCheckedRows())
            //{
            //    var a = row.Cells["TestType_ID"].Value;
            //    CrptBusiness.testTypeList.Add(Utility.Int32Dbnull(row.Cells["TestType_ID"].Value));
            //}
            string tieude = "", reportname = "";
            var    crpt    = Utility.GetReport("LAOKHOA_crpt_DetailTestReport_TESTTYPE", ref tieude, ref reportname);
            var    objForm = new frmPrintPreview(sTitleReport, crpt, true, DTPrint.Rows.Count <= 0 ? false : true);

            Utility.UpdateLogotoDatatable(ref DTPrint);
            try
            {
                DTPrint.AcceptChanges();
                crpt.SetDataSource(DTPrint);
                objForm.crptViewer.ReportSource = crpt;
                ////crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "  PHÒNG TIẾP ĐÓN   ".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                objForm.crptTrinhKyName = Path.GetFileName(reportname);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());

                objForm.ShowDialog();
                // Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
            //StrCode = reporttype.Trim();
            //// neu rpt A4 hoac A5 ma chua khai bao thi lay me no cai mac dinh(.)
            //if (StrCode == "")
            //{
            //    crptBusiness.StrCode = rdoNoheader.Checked ? "LABNOHEADER" : "LABREPORT";
            //}
            //else
            //{
            //    crptBusiness.StrCode = StrCode;
            //}
            //crptBusiness.FormPreviewTitle = "In kết quả xét nghiệm";
            //crptBusiness.Print(IsQuick, printDocument.PrinterSettings.PrinterName);
        }
        private void cmdInPhieuXN_Click(object sender, EventArgs e)
        {
            _dtData =
                SPs.BaocaoThongkeSokhambenh(dtFromDate.Value, dtToDate.Value,
                                            Utility.Int16Dbnull(cboDoituongKCB.SelectedValue, -1),
                                            Utility.Int16Dbnull(txtNhanvientiepdon.txtMyID, -1),
                                            Utility.sDbnull(cboKhoa.SelectedValue, "KKB"), thamso, Utility.Int16Dbnull(cboTinhTrang.SelectedValue, -1)).GetDataSet().
                Tables[0];

            Utility.SetDataSourceForDataGridEx(grdList, _dtData, true, true, "1=1", "");
            THU_VIEN_CHUNG.CreateXML(_dtData, "baocao_thongke_sokhambenh.XML");
            if (_dtData.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy dữ liệu báo cáo theo điều kiện bạn chọn", "Thông báo",
                                MessageBoxIcon.Information);
                return;
            }
            Utility.UpdateLogotoDatatable(ref _dtData);
            reportname = "baocao_thongke_sokhambenh";

            string Condition =
                string.Format("Từ ngày {0} đến {1} - Đối tượng : {2} - Khoa KCB :{3} - Người tiếp đón: {4}",
                              dtFromDate.Text, dtToDate.Text,
                              cboDoituongKCB.SelectedIndex >= 0
                                  ? Utility.sDbnull(cboDoituongKCB.Text)
                                  : "Tất cả",
                              cboKhoa.SelectedIndex > 0
                                  ? Utility.sDbnull(cboKhoa.Text)
                                  : "Tất cả", txtNhanvientiepdon.MyCode == "-1" ? "Tất cả" : txtNhanvientiepdon.Text);
            ReportDocument crpt = Utility.GetReport(reportname, ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }

            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                var objForm = new frmPrintPreview(tieude, crpt, true, _dtData.Rows.Count > 0);
                //try
                //{
                crpt.SetDataSource(_dtData);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportname;
                crpt.SetParameterValue("StaffName", StaffName);
                crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
                crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                crpt.SetParameterValue("Address", globalVariables.Branch_Address);
                crpt.SetParameterValue("FromDateToDate", Condition);
                crpt.SetParameterValue("sTitleReport", tieude);
                crpt.SetParameterValue("sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                crpt.SetParameterValue("BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky",
                                          Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
            finally
            {
                Utility.FreeMemory(crpt);
            }
        }
Example #20
0
        private void cmdInPhieuXN_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(cboKhoThuoc.Text))
                {
                    var query = (from chk in cboKhoThuoc.CheckedValues.AsEnumerable()
                                 let x = Utility.sDbnull(chk)
                                         select x).ToArray();
                    if (query.Count() > 0)
                    {
                        chuoiIDKhoThuoc = string.Join(",", query);
                    }
                }
                //Lấy giá trị xác nhận hết hạn hay chưa
                Int16 ishethan;
                if (radTatCa.Checked)
                {
                    ishethan = -1;
                }
                else if (radChuaHetHan.Checked)
                {
                    ishethan = 0;
                }
                else if (radDaHetHan.Checked)
                {
                    ishethan = 1;
                }
                else
                {
                    ishethan = -1;
                }
                //Truyền dữ liệu vào datatable
                DataTable m_dtReport = BAOCAO_THUOC.ThuocBaocaoSoluongtonthuoctheokho(chuoiIDKhoThuoc, Utility.Int32Dbnull(txtDrugID.Text, -1), Utility.Int32Dbnull(txtLoaithuoc.MyID, -1), ishethan, KIEU_THUOC_VT);
                THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_baocaothuocton_theokho.xml");
                //Truyền dữ liệu vào datagrid-view
                Utility.SetDataSourceForDataGridEx(grdList, m_dtReport, false, true, "1=1", "");
                if (m_dtReport.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }
                //Add stt vào datatable
                Utility.AddColumToDataTable(ref m_dtReport, "STT", typeof(Int32));
                int idx = 1;
                foreach (DataRow drv in m_dtReport.Rows)
                {
                    drv["STT"] = idx;
                    idx++;
                }
                m_dtReport.AcceptChanges();
                //Add logo vào datatable
                Utility.UpdateLogotoDatatable(ref m_dtReport);



                //Lấy chuỗi condition truyền vào biến ?FromDateToDate trên crpt
                string Condition = string.Format("Thuộc kho :{0} - Thuốc: {1}", string.IsNullOrEmpty(cboKhoThuoc.Text) ? "Tất cả" : cboKhoThuoc.Text,
                                                 string.IsNullOrEmpty(txtthuoc.Text) ? "Tất cả" : txtthuoc.Text);

                //Lấy tên người tạo báo cáo và gọi crpt
                string StaffName = globalVariables.gv_strTenNhanvien;
                string tieude = "", reportname = "";
                string tenbaocao = chkInbienbankiemke.Checked?"vt_bienban_kiemkevt":"vt_baocaovtton_theokho";
                if (KIEU_THUOC_VT == "THUOC")
                {
                    tenbaocao = chkInbienbankiemke.Checked ? "thuoc_bienban_kiemkethuoc" : "thuoc_baocaothuocton_theokho";
                }
                var crpt = Utility.GetReport(tenbaocao, ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }

                if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
                {
                    StaffName = globalVariables.UserName;
                }

                frmPrintPreview objForm = new frmPrintPreview(baocaO_TIEUDE1.TIEUDE, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(m_dtReport);

                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = tenbaocao;
                //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                Utility.SetParameterValue(crpt, "ReportCondition", Condition);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "ReportTitle", baocaO_TIEUDE1.TIEUDE);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "DayOfWarning", nmrSongay.Value);
                Utility.SetParameterValue(crpt, "ngay_in", dtNgayInPhieu.Value.ToString("dd/MM/yyyy"));
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
            }
        }
        /// <summary>
        /// hàm thực hiện việc in phiếu xét nghiêm
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            try
            {
                string nhomdichvu = "-1";
                if (!string.IsNullOrEmpty(cboNhomdichvuCLS.Text) && cboNhomdichvuCLS.CheckedValues != null)
                {
                    var query = (from chk in cboNhomdichvuCLS.CheckedValues.AsEnumerable()
                                 let x = Utility.sDbnull(chk)
                                         select x).ToArray();
                    if (query.Count() > 0)
                    {
                        nhomdichvu = string.Join(",", query);
                    }
                }
                if (chkChitiet.Checked)
                {
                    _reportTable =
                        BAOCAO_NGOAITRU.BaocaoThutientheokhoaChitiet(Utility.sDbnull(cboPhong.SelectedValue, -1),
                                                                     chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                                                                     chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate, Utility.sDbnull(cboDoituongKCB.SelectedValue, -1), nhomdichvu,
                                                                     Utility.sDbnull(cbonhanvien.SelectedValue, -1), Utility.sDbnull(cbokhoa.SelectedValue, -1));

                    Utility.SetDataSourceForDataGridEx(grdChitiet, _reportTable, false, true, "1=1", "");
                    Janus.Windows.GridEX.GridEXColumn gridExColumnTientong = grdChitiet.RootTable.Columns["Thanh_Tien"];
                    tong_tien = Utility.Int32Dbnull(grdChitiet.GetTotal(gridExColumnTientong, Janus.Windows.GridEX.AggregateFunction.Sum));
                }
                else
                {
                    _reportTable =
                        BAOCAO_NGOAITRU.BaocaoThutientheokhoaTonghop(Utility.sDbnull(cboPhong.SelectedValue, -1),
                                                                     chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                                                                     chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate, Utility.sDbnull(cboDoituongKCB.SelectedValue, -1), nhomdichvu,
                                                                     Utility.sDbnull(cbonhanvien.SelectedValue, -1), Utility.sDbnull(cbokhoa.SelectedValue, -1));

                    Utility.SetDataSourceForDataGridEx(grdList, _reportTable, false, true, "1=1", "");
                    Janus.Windows.GridEX.GridEXColumn gridExColumnTientong = grdList.RootTable.Columns["Thanh_Tien"];
                    tong_tien = Utility.Int32Dbnull(grdList.GetTotal(gridExColumnTientong, Janus.Windows.GridEX.AggregateFunction.Sum));
                }

                if (_reportTable.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }
                string StaffName = globalVariables.gv_strTenNhanvien;
                if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
                {
                    StaffName = globalVariables.UserName;
                }
                string Condition = string.Format("Từ ngày {0} đến {1} - Đối tượng : {2} - Nhân viên :{3} - Khoa chỉ định :{4} - Phòng thực hiện :{5} - Nhóm dịch vụ: {6}", dtFromDate.Text, dtToDate.Text,
                                                 cboDoituongKCB.SelectedIndex > 0
                                            ? Utility.sDbnull(cboDoituongKCB.Text)
                                            : "Tất cả",
                                                 cbonhanvien.SelectedIndex > 0
                                            ? Utility.sDbnull(cbonhanvien.Text)
                                            : "Tất cả", cbokhoa.SelectedIndex > 0 ? Utility.sDbnull(cbokhoa.Text) : "Tất cả",
                                                 cboPhong.SelectedIndex > 0 ? Utility.sDbnull(cboPhong.Text) : "Tất cả", cboNhomdichvuCLS.CheckedValues != null ? Utility.sDbnull(cboNhomdichvuCLS.Text) : "Tất cả");
                Utility.UpdateLogotoDatatable(ref _reportTable);
                string reportCode = chkChitiet.Checked ? "baocao_thutientheokhoa_chitiet" : "baocao_thutientheokhoa_tonghop";
                var    crpt       = Utility.GetReport(reportCode, ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }


                frmPrintPreview objForm = new frmPrintPreview(tieude, crpt, true, _reportTable.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(_reportTable);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportCode;
                Utility.SetParameterValue(crpt, "StaffName", StaffName);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
                Utility.SetParameterValue(crpt, "FromDateToDate", Condition);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "Tongtien_chu", new MoneyByLetter().sMoneyToLetter(tong_tien.ToString()));
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());

                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi in báo cáo", ex);
            }
        }
        /// <summary>
        /// hàm thực hiện việc in phiếu báo cáo tổng hợp
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuXN_Click(object sender, EventArgs e)
        {
            if (chkTachCDHA.Checked)
            {
                _dtData =
                    BAOCAO_NGOAITRU.BaocaoDoanhthuphongkham(
                        chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                        chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                        Utility.sDbnull(cboDoituongKCB.SelectedValue, -1), Utility.sDbnull(cboNhanvien.SelectedValue, -1), Utility.ByteDbnull(cboLoaidichvu.SelectedValue, 2), Utility.sDbnull(cboKhoa.SelectedValue, -1));

                Utility.SetDataSourceForDataGridEx(grdChitiet, _dtData, false, true, "1=1", "");
                Janus.Windows.GridEX.GridEXColumn gridExColumnTientong = grdChitiet.RootTable.Columns["TONGCONG"];
                tong_tien = Utility.Int32Dbnull(grdChitiet.GetTotal(gridExColumnTientong, Janus.Windows.GridEX.AggregateFunction.Sum));
            }
            else
            {
                _dtData =
                    BAOCAO_NGOAITRU.BaocaoDoanhthuphongkhamTonghop(
                        chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                        chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                        Utility.sDbnull(cboDoituongKCB.SelectedValue, -1), Utility.sDbnull(cboNhanvien.SelectedValue, -1), Utility.ByteDbnull(cboLoaidichvu.SelectedValue, -1), Utility.sDbnull(cboKhoa.SelectedValue, -1));

                Utility.SetDataSourceForDataGridEx(grdList, _dtData, false, true, "1=1", "");
                Janus.Windows.GridEX.GridEXColumn gridExColumnTientong = grdList.RootTable.Columns["TONGCONG"];
                tong_tien = Utility.Int32Dbnull(grdList.GetTotal(gridExColumnTientong, Janus.Windows.GridEX.AggregateFunction.Sum));
            }

            if (_dtData.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy dữ liệu báo cáo theo điều kiện bạn chọn", "Thông báo", MessageBoxIcon.Information);
                return;
            }
            Utility.UpdateLogotoDatatable(ref _dtData);


            string Condition = string.Format("Từ ngày {0} đến {1} - Đối tượng : {2} - Nhân viên :{3}", dtFromDate.Text, dtToDate.Text,
                                             cboDoituongKCB.SelectedIndex >= 0
                                              ? Utility.sDbnull(cboDoituongKCB.Text)
                                              : "Tất cả",
                                             cboNhanvien.SelectedIndex > 0
                                              ? Utility.sDbnull(cboNhanvien.Text)
                                              : "Tất cả");
            string reportcode = chkTachCDHA.Checked ? "baocao_doanhthuphongkham_chitiet" : "baocao_doanhthuphongkham_tonghop";
            var    crpt       = Utility.GetReport(reportcode, ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }

            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                frmPrintPreview objForm = new frmPrintPreview(tieude, crpt, true, _dtData.Rows.Count <= 0 ? false : true);
                //try
                //{
                crpt.SetDataSource(_dtData);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportcode;
                crpt.SetParameterValue("StaffName", StaffName);
                crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                crpt.SetParameterValue("Address", globalVariables.Branch_Address);
                crpt.SetParameterValue("Phone", globalVariables.Branch_Phone);
                crpt.SetParameterValue("FromDateToDate", Condition);
                crpt.SetParameterValue("sTitleReport", tieude);
                crpt.SetParameterValue("sMoneybyLetter", new MoneyByLetter().sMoneyToLetter(tong_tien.ToString()));
                crpt.SetParameterValue("sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                crpt.SetParameterValue("BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
            }
        }
Example #23
0
        private void cmdInPhieuXN_Click(object sender, EventArgs e)
        {
            _dtData = new DataTable();
            if (chkChitiet.Checked)
            {
                _dtData =
                    BAOCAO_NGOAITRU.BaoCaoThongkeTheoMaBenhICD10ChiTiet(
                        chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                        chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                        Utility.sDbnull(cboDoituongKCB.SelectedValue, ""), Utility.sDbnull(cboKhoa.SelectedValue, ""),
                        Utility.sDbnull(txtListICD.Text, ""));
                THU_VIEN_CHUNG.CreateXML(_dtData, "baocao_thongketheomabenh_icd10_chitiet.xml");
                Utility.SetDataSourceForDataGridEx(grdChitiet, _dtData, false, true, "1=1", "");
            }
            else
            {
                _dtData =
                    BAOCAO_NGOAITRU.BaoCaoThongkeTheoMaBenhICD10TongHop(
                        chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                        chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                        Utility.sDbnull(cboDoituongKCB.SelectedValue, ""), Utility.sDbnull(cboKhoa.SelectedValue, ""),
                        Utility.sDbnull(txtListICD.Text, ""));
                THU_VIEN_CHUNG.CreateXML(_dtData, "baocao_thongketheomabenh_icd10_tonghop.xml");
                Utility.SetDataSourceForDataGridEx(grdList, _dtData, false, true, "1=1", "");
            }

            if (_dtData.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy dữ liệu báo cáo theo điều kiện bạn chọn", "Thông báo",
                                MessageBoxIcon.Information);
                return;
            }
            Utility.UpdateLogotoDatatable(ref _dtData);


            string Condition =
                string.Format("Từ ngày {0} đến {1} - Đối tượng : {2} - Khoa KCB :{3} - Người tiếp đón: {4}",
                              dtFromDate.Text, dtToDate.Text,
                              cboDoituongKCB.SelectedIndex >= 0
                                  ? Utility.sDbnull(cboDoituongKCB.Text)
                                  : "Tất cả",
                              cboKhoa.SelectedIndex > 0
                                  ? Utility.sDbnull(cboKhoa.Text)
                                  : "Tất cả", txtMaBenhICD10.MyCode == "-1" ? "Tất cả" : txtMaBenhICD10.Text);
            ReportDocument crpt =
                Utility.GetReport(
                    chkChitiet.Checked
                        ? "baocao_thongketheomabenh_icd10_chitiet"
                        : "baocao_thongketheomabenh_icd10_tonghop", ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }

            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                var objForm = new frmPrintPreview(tieude, crpt, true, _dtData.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(_dtData);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = chkChitiet.Checked
                                             ? "baocao_thongketheomabenh_icd10_chitiet"
                                             : "baocao_thongketheomabenh_icd10_tonghop";
                crpt.SetParameterValue("StaffName", StaffName);
                crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
                crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                crpt.SetParameterValue("Address", globalVariables.Branch_Address);
                crpt.SetParameterValue("Phone", globalVariables.Branch_Phone);
                crpt.SetParameterValue("FromDateToDate", Condition);
                crpt.SetParameterValue("sTitleReport", tieude);
                crpt.SetParameterValue("sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                crpt.SetParameterValue("BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
        }
        private void cmdInPhieu_Click(object sender, EventArgs e)
        {
            int trangthai = -1;

            if (radTatca.Checked)
            {
                trangthai = -1;
            }
            if (radDathuchien.Checked)
            {
                trangthai = 1;
            }
            if (radChuathuchien.Checked)
            {
                trangthai = 0;
            }
            DataTable dtDanhsach =
                SPs.BaocaoThongkedanhsachThuchienchucnang(dtFromDate.Value, dtToDate.Value,
                                                          Utility.Int16Dbnull(cboDoituongKCB.SelectedValue, -1),
                                                          Utility.sDbnull(cboKhoa.SelectedValue, "KKB"), Args,
                                                          Utility.Int32Dbnull(txtdichvu.MyID, -1), trangthai)
                .GetDataSet().Tables[0];

            Utility.SetDataSourceForDataGridEx(grdResult, dtDanhsach, false, false, "", "");
            THU_VIEN_CHUNG.CreateXML(dtDanhsach, "baocao_thongkedanhsach_chucnang.XML");
            if (dtDanhsach.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không có dữ liệu để báo cáo!");
                return;
            }
            Utility.UpdateLogotoDatatable(ref dtDanhsach);
            string reportCode = "";

            switch (Args.Substring(0, 2))
            {
            case "SA":
                reportCode = "baocao_thongkedanhsach_sieuam";
                break;

            case "XQ":
                reportCode = "baocao_thongkedanhsach_xquang";
                break;

            case "DT":
                reportCode = "baocao_thongkedanhsach_dientim";
                break;

            case "NS":
                reportCode = "baocao_thongkedanhsach_noisoi";
                break;

            case "PT":
                reportCode = "baocao_thongkedanhsach_pttt";
                break;

            default:
                reportCode = "baocao_thongkedanhsach_noisoi";
                break;
            }
            string Condition =
                string.Format("Từ ngày {0} đến {1} - Đối tượng : {2} - Khoa KCB :{3}",
                              dtFromDate.Text, dtToDate.Text,
                              cboDoituongKCB.SelectedIndex >= 0
                                  ? Utility.sDbnull(cboDoituongKCB.Text)
                                  : "Tất cả",
                              cboKhoa.SelectedIndex > 0
                                  ? Utility.sDbnull(cboKhoa.Text)
                                  : "Tất cả");
            ReportDocument crpt = Utility.GetReport(reportCode, ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }

            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                var objForm = new frmPrintPreview(tieude, crpt, true, dtDanhsach.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(dtDanhsach);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportCode;
                crpt.SetParameterValue("StaffName", StaffName);
                crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
                crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                crpt.SetParameterValue("Address", globalVariables.Branch_Address);
                crpt.SetParameterValue("Phone", globalVariables.Branch_Phone);
                crpt.SetParameterValue("FromDateToDate", Condition);
                crpt.SetParameterValue("sTitleReport", tieude);
                crpt.SetParameterValue("sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                crpt.SetParameterValue("BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky",
                                          Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
            finally
            {
                Utility.FreeMemory(crpt);
            }
        }
        /// <summary>
        /// hàm thực hiện việc in phiếu báo cáo tổng hợp
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuXN_Click(object sender, EventArgs e)
        {
            string kieutimkiem = "-1";

            if (chktienkham.Checked == true && chktientiem.Checked == false && chktienvacxin.Checked == false)
            {
                kieutimkiem = "1";
            }
            if (chktienkham.Checked == true && chktientiem.Checked == true && chktienvacxin.Checked == false)
            {
                kieutimkiem = "1,11";
            }
            if (chktienkham.Checked == false && chktientiem.Checked == true && chktienvacxin.Checked == false)
            {
                kieutimkiem = "11";
            }
            if (chktienkham.Checked == true && chktientiem.Checked == false && chktienvacxin.Checked == true)
            {
                kieutimkiem = "1,3";
            }
            if (chktienkham.Checked == false && chktientiem.Checked == true && chktienvacxin.Checked == true)
            {
                kieutimkiem = "11,3";
            }

            if (chkChitiet.Checked)
            {
                _dtData =
                    BAOCAO_NGOAITRU.BaocaoThutientiemchungchitiet(
                        chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                        chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                        Utility.sDbnull(cboDoituongKCB.SelectedValue, -1),
                        Utility.sDbnull(cboNhanvien.SelectedValue, -1),
                        Utility.sDbnull(cboLoaidichvu.SelectedValue, ""),
                        Utility.sDbnull(thamso, ""),
                        Utility.sDbnull(cboKhoa.SelectedValue, -1), kieutimkiem);
                THU_VIEN_CHUNG.CreateXML(_dtData, "baocao_thutien_tiemchung_chitiet.xml");
                Utility.SetDataSourceForDataGridEx(grdChitiet, _dtData, false, true, "1=1", "");
                Janus.Windows.GridEX.GridEXColumn gridExColumnTientong = grdChitiet.RootTable.Columns["Thanh_Tien"];
                tong_tien = Utility.Int32Dbnull(grdChitiet.GetTotal(gridExColumnTientong, Janus.Windows.GridEX.AggregateFunction.Sum));
            }
            else
            {
                _dtData =
                    BAOCAO_NGOAITRU.BaocaoThutientiemchungtonghop(
                        chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                        chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                        Utility.sDbnull(cboDoituongKCB.SelectedValue, -1),
                        Utility.sDbnull(cboNhanvien.SelectedValue, -1),
                        Utility.Int16Dbnull(cboLoaidichvu.SelectedValue, -1), Utility.sDbnull(thamso, ""), Utility.sDbnull(cboKhoa.SelectedValue, -1));
                THU_VIEN_CHUNG.CreateXML(_dtData, "baocao_thutien_tiemchung_tonghop.xml");
                Utility.SetDataSourceForDataGridEx(grdList, _dtData, false, true, "1=1", "");
                Janus.Windows.GridEX.GridEXColumn gridExColumnTientong = grdList.RootTable.Columns["Thanh_Tien"];
                tong_tien = Utility.Int32Dbnull(grdList.GetTotal(gridExColumnTientong, Janus.Windows.GridEX.AggregateFunction.Sum));
            }

            if (_dtData.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy dữ liệu báo cáo theo điều kiện bạn chọn", "Thông báo", MessageBoxIcon.Information);
                return;
            }

            if (chktienkham.Checked == false && chktientiem.Checked == false && chktienvacxin.Checked == true)
            {
                kieutimkiem = "3";
            }

            Utility.UpdateLogotoDatatable(ref _dtData);
            string condition = string.Format("Từ ngày {0} đến {1} - Đối tượng : {2} - Nhân viên :{3} - Phương thức thanh toán: {4}", dtFromDate.Text, dtToDate.Text,
                                             cboDoituongKCB.SelectedIndex >= 0
                                              ? Utility.sDbnull(cboDoituongKCB.Text)
                                              : "Tất cả",
                                             cboNhanvien.SelectedIndex > 0
                                              ? Utility.sDbnull(cboNhanvien.Text)
                                              : "Tất cả", cboLoaidichvu.SelectedIndex > 0 ?Utility.sDbnull(cboLoaidichvu.Text):"Tất cả");
            var crpt = Utility.GetReport(chkChitiet.Checked ? "baocao_thutien_tiemchung_chitiet" : "baocao_thutien_tiemchung_tonghop", ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }

            string staffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                staffName = globalVariables.UserName;
            }
            try
            {
                frmPrintPreview objForm = new frmPrintPreview(tieude, crpt, true, _dtData.Rows.Count <= 0 ? false : true);
                //try
                //{
                crpt.SetDataSource(_dtData);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = chkChitiet.Checked ? "baocao_thutien_tiemchung_chitiet" : "baocao_thutien_tiemchung_tonghop";
                crpt.SetParameterValue("StaffName", staffName);
                crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                crpt.SetParameterValue("Address", globalVariables.Branch_Address);
                crpt.SetParameterValue("Phone", globalVariables.Branch_Phone);
                crpt.SetParameterValue("FromDateToDate", condition);
                crpt.SetParameterValue("sTitleReport", tieude);
                crpt.SetParameterValue("sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                crpt.SetParameterValue("BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
        }
        /// <summary>
        /// hàm thực hiện việc in báo cáo thống kê chuyển viện
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (radChuyenDi.Checked)
                {
                    _reportTable =
                        BAOCAO_NGOAITRU.BaoCaoThongkeChuyenVienDi(
                            chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                            chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate, Utility.sDbnull(txtTenBenh.MyCode, "-1"), Utility.Int32Dbnull(txtBacSy.MyID, -1),
                            Utility.Int32Dbnull(txtBenhVien.MyID, -1), Utility.Int32Dbnull(cboNTNT.SelectedValue, -1),
                            Utility.Int32Dbnull(cboDoituongKCB.SelectedValue, -1));
                    THU_VIEN_CHUNG
                    .CreateXML(_reportTable, "baocao_thongke_chuyendi.XML");
                    Utility.SetDataSourceForDataGridEx(grdChuyendi, _reportTable, false, true, "1=1", "");
                }
                else
                {
                    _reportTable =
                        BAOCAO_NGOAITRU.BaoCaoThongkeChuyenVienDen(
                            chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                            chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                            Utility.Int32Dbnull(txtBenhVien.MyID, -1), Utility.Int32Dbnull(cboNTNT.SelectedValue, -1),
                            Utility.Int32Dbnull(cboDoituongKCB.SelectedValue, -1));
                    THU_VIEN_CHUNG
                    .CreateXML(_reportTable, "baocao_thongke_chuyenden.XML");
                    Utility.SetDataSourceForDataGridEx(grdChuyenDen, _reportTable, false, true, "1=1", "");
                }

                if (_reportTable.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }
                string StaffName = globalVariables.gv_strTenNhanvien;
                if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
                {
                    StaffName = globalVariables.UserName;
                }
                string Condition = string.Format("Từ ngày {0} đến {1} - Đối tượng : {2} - Loại điều trị :{3} ", dtFromDate.Text, dtToDate.Text,
                                                 cboDoituongKCB.SelectedIndex > 0
                                            ? Utility.sDbnull(cboDoituongKCB.Text)
                                            : "Tất cả", cboNTNT.SelectedIndex > 0 ? Utility.sDbnull(cboNTNT.Text) : "Tất cả");
                Utility.UpdateLogotoDatatable(ref _reportTable);
                string reportCode = radChuyenDen.Checked ? "baocao_thongke_chuyenden" : "baocao_thongke_chuyendi";
                var    crpt       = Utility.GetReport(reportCode, ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }


                frmPrintPreview objForm = new frmPrintPreview(tieude, crpt, true, _reportTable.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(_reportTable);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportCode;
                Utility.SetParameterValue(crpt, "StaffName", StaffName);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
                Utility.SetParameterValue(crpt, "FromDateToDate", Condition);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi in báo cáo", ex);
            }
        }
Example #27
0
        private void InphieuCLS()
        {
            m_dtReport = null;
            //SPs.ClsLaokhoaInphieuChidinhCls(objAssignInfo.AssignCode, objAssignInfo.PatientCode,
            //                                Utility.Int32Dbnull(objAssignInfo.PatientId)).GetDataSet().Tables[0];
            if (m_dtReport.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy bản ghi nào, bạn xem lại, phải chọn một bản ghi để thực hiện việc in phiếu chỉ định", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            m_dtReport = (from lox in m_dtReport.AsEnumerable().Cast <DataRow>()
                          where Utility.Int32Dbnull(lox["CHO_PHEP_IN"], 0) == 1
                          select lox
                          ).CopyToDataTable();
            Utility.UpdateLogotoDatatable(ref m_dtReport);
            Utility.AddColumToDataTable(ref m_dtReport, "SO_PHIEU_BARCODE", typeof(byte[]));
            byte[] arrBarCode = Utility.GenerateBarCode(barcode);
            foreach (DataRow drv in m_dtReport.Rows)
            {
                drv["SO_PHIEU_BARCODE"] = arrBarCode;
            }
            m_dtReport.AcceptChanges();
            string KhoGiay = "A5";

            if (radKhoA4.Checked)
            {
                KhoGiay = "A4";
            }
            try
            {
                ReportDocument reportDocument = new ReportDocument();
                string         tieude = "", reportname = "";
                switch (KhoGiay)
                {
                case "A5":
                    reportDocument = Utility.GetReport("thamkham_PHIEU_CHIDINH_CLS_A5", ref tieude, ref reportname);
                    break;

                case "A4":
                    reportDocument = Utility.GetReport("thamkham_PHIEU_CHIDINH_CLS", ref tieude, ref reportname);
                    break;

                default:
                    reportDocument = Utility.GetReport("thamkham_PHIEU_CHIDINH_CLS", ref tieude, ref reportname);
                    break;
                }
                if (reportDocument == null)
                {
                    return;
                }
                var             crpt    = reportDocument;
                frmPrintPreview objForm = new frmPrintPreview(txtTieuDe.Text, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
                //try
                //{
                crpt.SetDataSource(m_dtReport);
                //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                // 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, "sTitleReport", txtTieuDe.Text);
                Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
            }
        }
        /// <summary>
        /// hàm thực hiên viecj in báo cáo doanh thu tiền khám chữa bệnh viện phí
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuXN_Click(object sender, EventArgs e)
        {
            _mabschidinh = "-1";
            _idThuoc     = -1;
            // Lấy Id Bác sỹ
            if (!string.IsNullOrEmpty(cboBacSyChiDinh.Text))
            {
                var query = (from chk in cboBacSyChiDinh.CheckedValues.AsEnumerable()
                             let x = Utility.sDbnull(chk)
                                     select x).ToArray();
                if (query.Count() > 0)
                {
                    _mabschidinh = string.Join(",", query);
                }
            }

            //Truyền dữ liệu vào datatable
            DataTable m_dtReport = BAOCAO_THUOC.ThuocBaocaoTinhhinhkedonthuocTheobacsy(Utility.Int32Dbnull(cboStock.SelectedValue, -1), Utility.Int32Dbnull(cboDoiTuong.SelectedValue, -1),
                                                                                       _mabschidinh, _idThuoc, chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"), chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate, Utility.Int16Dbnull(cboTrangthai.SelectedValue, -1));

            if (m_dtReport == null)
            {
                return;
            }
            THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_baocaokedon_theobacsy.xml");
            //Kiểm tra dữ liệu
            if (m_dtReport.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            //Truyền tổng tiền vào text và chuyển qua tiền bằng chữ
            Janus.Windows.GridEX.GridEXColumn gridExColumnTong = grdList.RootTable.Columns["thanh_tien"];
            decimal tong =
                Utility.DecimaltoDbnull(grdList.GetTotal(gridExColumnTong, Janus.Windows.GridEX.AggregateFunction.Sum));


            m_dtReport.AcceptChanges();
            Utility.UpdateLogotoDatatable(ref m_dtReport);
            //Truyền dữ liệu vào datagrid-view
            Utility.SetDataSourceForDataGridEx(grdList, m_dtReport, false, true, "1=1", "");
            //Lấy chuỗi condition truyền vào biến ?FromDateToDate trên crpt
            string Condition = string.Format("Từ ngày {0} đến {1}- Đối tượng {2} - Thuộc kho :{3} - Bác sỹ: {4}", dtFromDate.Text, dtToDate.Text,
                                             cboDoiTuong.SelectedIndex > 0
                                                 ? Utility.sDbnull(cboDoiTuong.SelectedValue)
                                                 : "Tất cả",
                                             cboStock.SelectedIndex > 0
                                                 ? Utility.sDbnull(cboStock.SelectedValue)
                                                 : "Tất cả",
                                             string.IsNullOrEmpty(cboBacSyChiDinh.Text) ? "Tất cả" : cboBacSyChiDinh.Text);

            //Lấy tên người tạo báo cáo và gọi crpt
            string StaffName = globalVariables.gv_strTenNhanvien;
            string tieude = "", reportname = "";
            var    crpt = Utility.GetReport("thuoc_baocaokedon_theobacsy", ref tieude, ref reportname);

            if (crpt == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                frmPrintPreview objForm = new frmPrintPreview(baocaO_TIEUDE1.TIEUDE, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(m_dtReport);

                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = "thuoc_baocaokedon_theobacsy";
                Utility.SetParameterValue(crpt, "StaffName", StaffName);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
                Utility.SetParameterValue(crpt, "FromDateToDate", Condition);
                Utility.SetParameterValue(crpt, "sTitleReport", baocaO_TIEUDE1.TIEUDE);
                Utility.SetParameterValue(crpt, "TienBangChu", _moneyByLetter.sMoneyToLetter(tong.ToString()));
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "Department_Name", globalVariables.KhoaDuoc);
                Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
            }
        }
        /// <summary>
        /// hàm thực hiên viecj in báo cáo doanh thu tiền khám chữa bệnh viện phí
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuXN_Click(object sender, EventArgs e)
        {
            DataTable m_dtReport =
                BAOCAO_THUOC.ThuocBaocaoTinhhinhPhatthuocbenhnhan(
                    chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                    chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                    Utility.Int32Dbnull(cboStock.SelectedValue, -1),
                    Utility.Int32Dbnull(cboDoiTuong.SelectedValue, "-1"), chkThongketheongaychot.Checked ? 1 : 0,
                    kieuthuoc_vt);

            Utility.SetDataSourceForDataGridEx(grdList, m_dtReport, false, true, "1=1", "");
            GridEXColumn gridExColumn = grdList.RootTable.Columns["THANH_TIEN"];

            if (m_dtReport.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            Utility.AddColumToDataTable(ref m_dtReport, "STT", typeof(Int32));
            int idx = 1;

            foreach (DataRow drv in m_dtReport.Rows)
            {
                drv["STT"] = idx;
                idx++;
            }
            m_dtReport.AcceptChanges();
            Utility.UpdateLogotoDatatable(ref m_dtReport);
            string Condition = string.Format("Từ ngày {0} đến {1}- Đối tượng {2} - Thuộc kho :{3}", dtFromDate.Text,
                                             dtToDate.Text,
                                             cboDoiTuong.SelectedIndex > 0
                                                 ? Utility.sDbnull(cboDoiTuong.Text)
                                                 : "Tất cả",
                                             cboStock.SelectedIndex > 0
                                                 ? Utility.sDbnull(cboStock.Text)
                                                 : "Tất cả");

            //  Utility.AddColumToDataTable(ref m_dtReport, "SO_PHIEU_BARCODE", typeof(byte[]));
            // byte[] arrBarCode = Utility.GenerateBarCode(barcode);
            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                string tieude = "", reportname = "";
                string reportCode = kieuthuoc_vt == "THUOC"
                                        ? "thuoc_baocao_chitiet_thuoccapphat_benhnhan"
                                        : "vt_baocao_chitiet_vtcapphat_benhnhan";
                ReportDocument crpt = Utility.GetReport(reportCode, ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }
                var objForm = new frmPrintPreview(baocaO_TIEUDE1.txtTieuDe.Text, crpt, true,
                                                  m_dtReport.Rows.Count <= 0 ? false : true);
                //try
                //{
                crpt.SetDataSource(m_dtReport);

                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportCode;
                //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                // Utility.SetParameterValue(crpt,"ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "StaffName", StaffName);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
                Utility.SetParameterValue(crpt, "FromDateToDate", Condition);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "Deparment_Name", globalVariables.KhoaDuoc);
                Utility.SetParameterValue(crpt, "txtTrinhky",
                                          Utility.getTrinhky(objForm.mv_sReportFileName,
                                                             globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
                //Utility.DecimaltoDbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_INGIAYXINNOP_TIENTHUOC", "0", false), 0m)
                if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_INGIAYXINNOP_TIENTHUOC", "0", false) == "1")
                {
                    string tieude2 = "", reportname2 = "";
                    string reportCode2 = kieuthuoc_vt == "THUOC"
                                             ? "thuoc_baocao_giayxinnop_tienthuoc"
                                             : "vt_baocao_chitiet_vtcapphat_benhnhan";
                    ReportDocument crpt2 = Utility.GetReport(reportCode2, ref tieude2, ref reportname2);
                    if (crpt2 == null)
                    {
                        return;
                    }
                    var objForm2 = new frmPrintPreview(baocaO_TIEUDE1.txtTieuDe.Text, crpt2, true,
                                                       m_dtReport.Rows.Count <= 0 ? false : true);
                    //try
                    //{
                    crpt2.SetDataSource(m_dtReport);

                    objForm2.mv_sReportFileName = Path.GetFileName(reportname2);
                    objForm2.mv_sReportCode     = reportCode2;
                    //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                    // Utility.SetParameterValue(crpt,"ParentBranchName", globalVariables.ParentBranch_Name);
                    Utility.SetParameterValue(crpt2, "StaffName", StaffName);
                    Utility.SetParameterValue(crpt2, "BranchName", globalVariables.Branch_Name);
                    Utility.SetParameterValue(crpt2, "Address", globalVariables.Branch_Address);
                    Utility.SetParameterValue(crpt2, "Phone", globalVariables.Branch_Phone);
                    Utility.SetParameterValue(crpt2, "FromDateToDate", Condition);
                    Utility.SetParameterValue(crpt2, "sTitleReport", tieude2);
                    Utility.SetParameterValue(crpt2, "sCurrentDate",
                                              Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                    Utility.SetParameterValue(crpt2, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                    Utility.SetParameterValue(crpt2, "Deparment_Name", globalVariables.KhoaDuoc);
                    Utility.SetParameterValue(crpt2, "txtTrinhky",
                                              Utility.getTrinhky(objForm2.mv_sReportFileName,
                                                                 globalVariables.SysDate));
                    objForm2.crptViewer.ReportSource = crpt2;
                    objForm2.ShowDialog();
                }
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
        }
        /// <summary>
        /// hàm thực hiện việc in phiếu xét nghiêm
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (chkChitiet.Checked)
                {
                    _reportTable =
                        BAOCAO_NGOAITRU.BaocaoThuvienphiChitiet(Utility.sDbnull(cbokhoa.SelectedValue, "-1"), chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                                                                chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate, Utility.sDbnull(cbonhanvien.SelectedValue, -1),
                                                                Utility.sDbnull(cboDoituongKCB.SelectedValue, -1),
                                                                Utility.Int32Dbnull(cboNTNT.SelectedValue, -1), Utility.Int32Dbnull(cboHoadon.SelectedValue, -1), chkLoaitimkiem.Checked ? 1 : 0);

                    Utility.SetDataSourceForDataGridEx(grdChitiet, _reportTable, false, true, "1=1", "");
                    //Janus.Windows.GridEX.GridEXColumn gridExColumnTientong = grdChitiet.RootTable.Columns["tong_Tien"];
                    //tong_tien = Utility.Int32Dbnull(grdList.GetTotal(gridExColumnTientong, Janus.Windows.GridEX.AggregateFunction.Sum));
                }
                else
                {
                    _reportTable =
                        BAOCAO_NGOAITRU.BaocaoThuvienphiTonghop(Utility.sDbnull(cbokhoa.SelectedValue, "-1"), chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                                                                chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate, Utility.sDbnull(cbonhanvien.SelectedValue, "-1"),
                                                                Utility.sDbnull(cboDoituongKCB.SelectedValue, "-1"),
                                                                Utility.Int32Dbnull(cboNTNT.SelectedValue, -1), Utility.Int32Dbnull(cboHoadon.SelectedValue, -1), chkLoaitimkiem.Checked ? 1 : 0);

                    Utility.SetDataSourceForDataGridEx(grdList, _reportTable, false, true, "1=1", "");
                    //Janus.Windows.GridEX.GridEXColumn gridExColumnTientong = grdList.RootTable.Columns["tong_Tien"];
                    //tong_tien = Utility.Int32Dbnull(grdList.GetTotal(gridExColumnTientong, Janus.Windows.GridEX.AggregateFunction.Sum));
                }
                THU_VIEN_CHUNG.CreateXML(_reportTable, chkChitiet.Checked ? "baocao_thuvienphi_chitiet" : "baocao_thuvienphi_tonghop");
                if (_reportTable.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }
                string StaffName = globalVariables.gv_strTenNhanvien;
                if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
                {
                    StaffName = globalVariables.UserName;
                }
                string Condition = string.Format("Từ ngày {0} đến {1} - Đối tượng : {2} -TNV :{3} - Loại điều trị :{4} ", dtFromDate.Text, dtToDate.Text,
                                                 cboDoituongKCB.SelectedIndex > 0
                                            ? Utility.sDbnull(cboDoituongKCB.Text)
                                            : "Tất cả",
                                                 cbonhanvien.SelectedIndex > 0
                                            ? Utility.sDbnull(cbonhanvien.Text)
                                            : "Tất cả", cboNTNT.SelectedIndex > 0 ? Utility.sDbnull(cboNTNT.Text) : "Tất cả");
                Utility.UpdateLogotoDatatable(ref _reportTable);
                string reportCode = chkChitiet.Checked ? "baocao_thuvienphi_chitiet" : "baocao_thuvienphi_tonghop";
                var    crpt       = Utility.GetReport(reportCode, ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }


                frmPrintPreview objForm = new frmPrintPreview(tieude, crpt, true, _reportTable.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(_reportTable);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportCode;
                Utility.SetParameterValue(crpt, "StaffName", StaffName);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
                Utility.SetParameterValue(crpt, "FromDateToDate", Condition);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());

                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi in báo cáo", ex);
            }
        }