public static void Baocaohuychot(DataTable m_dtReport, string kieuthuoc_vt, string sTitleReport,  string dieukienbaocao, bool theonhom)
        {
            string tieude = "", reportname = "", reportcode = "thuoc_baocao_huychot_theonhom";
              ReportDocument crpt = null;
              if (kieuthuoc_vt .Contains("THUOC"))
              {
              if (theonhom)
              {
                  reportcode = "thuoc_baocao_huychot_theonhom";
              }
              else
              {
                  reportcode = "thuoc_baocao_huychot";
              }
              }
              else//VTTH
              {
              if (theonhom)
              {
                  reportcode = "vt_baocao_huychot_theonhom";
              }
              else
              {
                  reportcode = "vt_baocao_huychot";
              }
              }
              crpt = Utility.GetReport(reportcode, ref tieude, ref reportname);
              if (crpt == null) return;

              MoneyByLetter _moneyByLetter = new MoneyByLetter();
              var objForm = new frmPrintPreview(sTitleReport, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
              objForm.mv_sReportFileName = Path.GetFileName(reportname);
              objForm.mv_sReportCode = reportcode;
              Utility.UpdateLogotoDatatable(ref m_dtReport);
              try
              {
              if (theonhom)
                  m_dtReport.DefaultView.Sort = "stt_hthi_nhom,tenbietduoc";
              else
                  m_dtReport.DefaultView.Sort = "tenbietduoc";
              m_dtReport.AcceptChanges();
              crpt.SetDataSource(m_dtReport.DefaultView);

              Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
              Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
              Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone);
              Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
              Utility.SetParameterValue(crpt, "dieukienbaocao", dieukienbaocao);
              Utility.SetParameterValue(crpt, "sTitleReport", tieude);
              Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
              Utility.SetParameterValue(crpt, "txttrinhky","");
              objForm.crptViewer.ReportSource = crpt;
              objForm.ShowDialog();
              // Utility.DefaultNow(this);
              }
              catch (Exception ex)
              {
              Utility.CatchException(ex);
              }
        }
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
      {
           string s ="";
         if (dtpFromDate.Value.Date == dtpToDate.Value.Date)
         {
             s = string.Format("{0}Ngày {1}", s, dtpFromDate.Value.ToString("dd/MM/yyyy"));
         }
         else
         {
             s = string.Format("{0}{1}", s,
                               string.Format("Thời gian từ ngày {0} đến ngày {1}", dtpFromDate.Value.ToString("dd/MM/yyyy"),
                                             dtpToDate.Value.ToString("dd/MM/yyyy")));
         }
         var crpt = new Crp_DSBN_TestType();
         var oForm = new frmPrintPreview("In Báo cáo lưu", crpt, true, true);
         crpt.SetDataSource(dt);
         crpt.DataDefinition.FormulaFields["Formula_1"].Text = "";
         crpt.SetParameterValue("TongBenhNhan", dt.Rows.Count);
         crpt.SetParameterValue("TestType_Name",cboTestType.Text.ToUpper());
         crpt.SetParameterValue("strFromDateToDate", s);
         crpt.SetParameterValue("ParentBranchName", ManagementUnit.gv_sParentBranchName);
         crpt.SetParameterValue("BranchName", ManagementUnit.gv_sBranchName);
         crpt.SetParameterValue("sCurrentDate", dtCreatePrint.Value);
         oForm.crptViewer.ReportSource = crpt;
         oForm.ShowDialog();
         oForm.Dispose();
     }
     catch (Exception ex)
     {
         Utility.ShowMsg(ex.Message);
     }
 }
        public static void Inphieunhapvien(DataTable m_dtReport, string sTitleReport, DateTime NgayIn)
        {
            string tieude = "", reportname = "";
            var crpt = Utility.GetReport("noitru_phieunhapvien", ref tieude, ref reportname);
            if (crpt == null) return;
            THU_VIEN_CHUNG.CreateXML(m_dtReport, "noitru_phieunhapvien.xml");
            MoneyByLetter _moneyByLetter = new MoneyByLetter();
            var objForm = new frmPrintPreview(sTitleReport, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
               // string tinhtong = TinhTong(m_dtReport);
            Utility.UpdateLogotoDatatable(ref m_dtReport);
            try
            {

                crpt.SetDataSource(m_dtReport);

                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode = "noitru_phieunhapvien";
                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());
                }
            }
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                ReportDocument crpt;

                string s;
                if (cboTestType.SelectedValue.ToString() == "-1")
                {
                    s = "TẤT CẢ CÁC LOẠI XÉT NGHIỆM";
                }
                else
                {
                    s = string.Format("XÉT NGHIỆM {0}", cboTestType.SelectedText.ToUpper());
                }
                var ds =
                        SPs.SpBaoCaoXoaKetQua(dtpFromDate.Value.ToString("yyyy/MM/dd"),
                                              dtpToDate.Value.ToString("yyyy/MM/dd"),
                                              Utility.Int32Dbnull(cboTestType.SelectedValue, -1),
                                              Utility.sDbnull(cboUserName.SelectedValue, "")).GetDataSet();
                if (cboReportType.SelectedIndex == 1)
                {
                    crpt = new crpt_BAOCAO_XOA_KETQUA_TONGHOP();
                    dt = ds.Tables[0];
                }
                else
                {
                    crpt = new crpt_BAOCAO_SUAXOA_KETQUA_CHITIET();
                    dt = ds.Tables[1];
                }
                if (dt.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không có dữ liệu để báo cáo");
                }
                else
                {
                    var oForm = new frmPrintPreview("In báo cáo sửa xóa", crpt, true, true);
                    crpt.SetDataSource(dt);
                    crpt.DataDefinition.FormulaFields["Formula_1"].Text = "";
                    //crpt.SetParameterValue("TongBenhNhan", dt.Rows.Count);
                    crpt.SetParameterValue("TestType_Name", s);
                    crpt.SetParameterValue("ParentBranchName", ManagementUnit.gv_sParentBranchName);
                    crpt.SetParameterValue("BranchName", ManagementUnit.gv_sBranchName);
                    //crpt.SetParameterValue("sCurrentDate", dtpDatePrintFrom.Value);
                    oForm.crptViewer.ReportSource = crpt;
                    oForm.ShowDialog();
                    oForm.Dispose();
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
 private void cmdPrint_Click(object sender, EventArgs e)
 {
     try
     {
         LayDuLieu();
         if (dt.Rows.Count<=0 || dtRawResult == null)
         {
             Utility.ShowMsg("Không có dữ liệu để báo cáo");
         }
         else
         {
             string s = "";
             if (dtpFromDate.Value.Date == dtpToDate.Value.Date)
             {
                 s = string.Format("{0}Ngày {1}", s, dtpFromDate.Value.ToString("dd/MM/yyyy"));
             }
             else
             {
                 s = string.Format("{0}{1}", s,
                                   string.Format("Từ ngày {0} đến ngày {1}",
                                                 dtpFromDate.Value.ToString("dd/MM/yyyy"),
                                                 dtpToDate.Value.ToString("dd/MM/yyyy")));
             }
             var crpt = new VD_crpt_DailyParamTestReport();
             var oForm = new frmPrintPreview("In Báo cáo lưu", crpt, true, true);
             crpt.SetDataSource(dt);
             crpt.DataDefinition.FormulaFields["Formula_1"].Text = "";
             crpt.SetParameterValue("sFromDateToDate", s);
             crpt.SetParameterValue("TongSoBenhNhan", dt.Rows.Count);
             crpt.SetParameterValue("ParentBranchName", ManagementUnit.gv_sParentBranchName);
             crpt.SetParameterValue("BranchName", ManagementUnit.gv_sBranchName);
             crpt.SetParameterValue("sPrintDate", dtpDatePrint.Value.ToString("dd/MM/yyyy"));
             oForm.crptViewer.ReportSource = crpt;
             oForm.ShowDialog();
             oForm.Dispose();
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("Lỗi" + ex, "Thông Báo", MessageBoxIcon.Warning);
     }
 }
        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();
        }
        public static void InphieuHuythuoc(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_huythuoc");
               string tieude = "", reportname = "";
               var crpt = Utility.GetReport("thuoc_bienban_huythuoc", 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_huythuoc";

               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());
               objForm.crptViewer.ReportSource = crpt;
               objForm.ShowDialog();
               }
               catch (Exception ex)
               {
               if (globalVariables.IsAdmin)
               {
                   Utility.ShowMsg(ex.ToString());
               }
               }
        }
Exemple #8
0
 private void cmdINPHIEU_Click(object sender, EventArgs e)
 {
     try
     {
         string s = "";
         if (dtpFromDate.Value.Date == dtpToDate.Value.Date)
         {
             s = string.Format("{0}Ngày {1}", s, dtpFromDate.Value.ToString("dd/MM/yyyy"));
         }
         else
         {
             s = string.Format("{0}{1}", s,
                               string.Format("Từ ngày {0} đến ngày {1}", dtpFromDate.Value.ToString("dd/MM/yyyy"),
                                             dtpToDate.Value.ToString("dd/MM/yyyy")));
         }
         dtSoghichep = BaocaoSoghichep(dtpFromDate.Value,dtpToDate.Value).GetDataSet().Tables[0];
         int totalBN = dtSoghichep.Rows.Count;
         if (dtSoghichep.Rows.Count <= 0)
         {
             Utility.ShowMsg("Không có dữ liệu để in");
         }
         else
         {
             var crpt = new crpt_SoGhiChep();
             var objForm = new frmPrintPreview("In Báo Cáo", crpt, true, true);
             crpt.SetDataSource(dtSoghichep);
             crpt.DataDefinition.FormulaFields["Formula_1"].Text = "";
             crpt.SetParameterValue("BranchName", ManagementUnit.gv_sBranchName);
             crpt.SetParameterValue("ParentBranchName", ManagementUnit.gv_sParentBranchName);
             crpt.SetParameterValue("TestDate",s);
             crpt.SetParameterValue("PrintDate",dtpPrintDate.Value);
             crpt.SetParameterValue("TotalBN", totalBN);
             objForm.crptViewer.ReportSource = crpt;
             objForm.ShowDialog();
         }
     }
     catch (Exception exception)
     {
         Utility.ShowMsg("Lỗi trong quá trình xuất báo cáo" + exception);
     }
 }
        private void cmdINPHIEU_Click(object sender, EventArgs e)
        {
            try
            {
                dtPatient = SPs.BaocaoSluongXetnghiemTheodoituong(dtpFromDate.Value.Date, dtpToDate.Value.Date).GetDataSet().Tables[0];
                if (dtPatient.Rows.Count < 0)
                {
                    Utility.ShowMsg("Không có dữ liệu để in");
                }
                else
                {
                    string s = "";

                        s = string.Format("{0}{1}", s,
                                          string.Format("Từ ngày {0} đến ngày {1}",
                                                        dtpFromDate.Value.ToString("dd/MM/yyyy"),
                                                        dtpToDate.Value.ToString("dd/MM/yyyy")));
                        Utility.UpdateLogotoDatatable(ref dtPatient);
                        CRPT_GTVT_BAOCAO_SLUONG_BNHAN_THEODOITUONG crpt = new CRPT_GTVT_BAOCAO_SLUONG_BNHAN_THEODOITUONG();
                        var objForm = new frmPrintPreview("In Báo Cáo", crpt, true, true);
                        crpt.SetDataSource(dtPatient);

                        crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
                        crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                        crpt.SetParameterValue("sTitleReport", label7.Text);
                        crpt.SetParameterValue("sTuNgayDenNgay", s);
                        crpt.SetParameterValue("sCurrentDate", Utility.FormatDateTime(dtNgayInPhieu.Value));
                        objForm.crptViewer.ReportSource = crpt;
                        objForm.ShowDialog();
                        Utility.DefaultNow(this);

                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.ToString());
            }
        }
        public static void InphieuDutru(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_phieudutru");
               string tieude = "", reportname = "";
               var crpt = Utility.GetReport("thuoc_phieudutru", ref tieude, ref reportname);

               Utility.UpdateLogotoDatatable(ref m_dtReport);
               frmPrintPreview 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_phieudutru";

               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());
               }
               }
        }
        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();
        }
        private void IN_BAOCAO_TIENKHAM_DICHVU()
        {
            DataTable v_dtData = new DataTable();
            v_dtData =
                GtvtBaocaoTongsluongLoaixetnghiem(
                    chkFormDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                    chkFormDate.Checked ? dtToDate.Value : Utility.getSysDate(),
                    Utility.Int32Dbnull(cboObjectType.SelectedValue, -1),
                    Utility.Int32Dbnull(cboDepartment.SelectedValue, -1),
                    Utility.Int32Dbnull(cboLoaiXetnghiem.SelectedValue, -1),
                    Utility.Int32Dbnull(cboHos_Status.SelectedValue, -1),chkTongKhoa.Checked?1:0).GetDataSet().Tables[0];

               // SubSonic.StoredProcedure.
            if (v_dtData.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy bản ghi nào", "Thông báo");
                return;
            }
             string sTungayDenNgay = dtFromDate.Value.Date != dtToDate.Value.Date
                                      ? string.Format("{0} --- đến --- {1}", Getsday(dtFromDate.Value),
                                                      Getsday(dtToDate.Value))
                                      : Getsday(dtFromDate.Value);

            string tieude = "", reportname = "";
            string sTitleReport;
            var crpt = new ReportDocument();
                if(chkTongLoaiXN.Checked)
                {
                    crpt = Utility.GetReport("CRTP_GTVT_BAOCAO_SLUONG_XNGHIEM_THEO_TLOAI", ref tieude, ref reportname);
                }
                else
                {
                    crpt = Utility.GetReport("CRPT_GTVT_BAOCAO_SOLUONG_LOAIXETNGHIEM", ref tieude, ref reportname);
                }
                var objForm = new frmPrintPreview("Báo cáo thống kê số lượng xét nghiệm", crpt, true, v_dtData.Rows.Count <= 0 ? false : true);
                Utility.UpdateLogotoDatatable(ref v_dtData);
            crpt.SetDataSource(v_dtData);
            objForm.crptTrinhKyName = Path.GetFileName(reportname);
            crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
            crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
            crpt.SetParameterValue("sTitleReport", "BÁO CÁO SỐ LƯỢNG LOẠI XÉT NGHIỆM");
            crpt.SetParameterValue("sTuNgayDenNgay", sTungayDenNgay);
            crpt.SetParameterValue("sCurrentDate", Utility.FormatDateTime(dtCreatePrint.Value));
               /// crpt.SetParameterValue("NgayIn", "Ngày " + dtCreatePrint.Value.Day + " tháng " + dtCreatePrint.Value.Month + " năm " + dtCreatePrint.Value.Year);
               // crpt.SetParameterValue("TienBangChu", sMoneyByLetter.sMoneyToLetter(v_dtData.Compute("SUM(TONG)", "1=1").ToString()));
              //  crpt.SetParameterValue("DateTime", "Từ ngày: " + dtFromDate.Value.ToShortDateString() + " đến ngày: " + dtToDate.Value.ToShortDateString());
            objForm.crptViewer.ReportSource = crpt;
            objForm.ShowDialog();
            Utility.DefaultNow(this);
        }
 /// <summary>
 /// hàm thực hiện in báo cáo
 /// </summary>
 /// <param name="sTitleReport"></param>
 private void PrintReport(DataTable dtData)
 {
     string tieude="", reportname = "";
      var crpt = Utility.GetReport("thuoc_giathuoc_doituong", ref tieude, ref reportname);
     if (crpt == null) return;
     var objFromPre =
         new frmPrintPreview(PropertyLib._ThuocProperties.TieudeBaocaoGiathuoc, crpt, false, true);
     Utility.WaitNow(this);
     if (!PropertyLib._ThuocProperties.NhomthuocIngia)
         dtData.DefaultView.Sort = "ten_thuoc asc";
     else
         dtData.DefaultView.Sort = "stt_hthi_loaithuoc asc,ten_thuoc asc";
     crpt.SetDataSource(dtData.DefaultView);
     Utility.SetParameterValue(crpt,"ParentBranchName", globalVariables.ParentBranch_Name);
     Utility.SetParameterValue(crpt,"BranchName", globalVariables.Branch_Name);
     Utility.SetParameterValue(crpt,"Nhomthuoc", PropertyLib._ThuocProperties.NhomthuocIngia ? 1 : 0);
     Utility.SetParameterValue(crpt,"sTitleReport", PropertyLib._ThuocProperties.TieudeBaocaoGiathuoc);
     objFromPre.crptViewer.ReportSource = crpt;
     objFromPre.ShowDialog();
     Utility.DefaultNow(this);
 }
Exemple #14
0
        public void Print(bool Quick, string printerName)
        {
            try
            {
                if (Crpt == null && !string.IsNullOrEmpty(StrCode))
                {
                    Crpt = GetCrptFromAssembly(StrCode);
                }

                if (ValidData())
                {
                    bool hasSubReport = CheckHasSubReport(Crpt);
                    if (!hasSubReport)
                    {
                        Crpt.SetDataSource(ReportSourceTable);
                        if (Utility.sDbnull(printDateTime) != null)
                        {
                            Crpt.SetParameterValue("PrintDate", printDateTime);
                        }
                        //if(SysPara.ParamaterReport.ToUpper() == "THANHNHAN")
                        //{
                        //    var sFullName =
                        //        new Select(TblUser.Columns.SFullName).From(TblUser.Schema.Name).Where(
                        //            TblUser.Columns.PkSuid).IsEqualTo(globalVariables.UserName).ExecuteScalar();
                        //    if (sFullName != null)
                        //    {
                        //        Crpt.SetParameterValue("sTenUser", sFullName);
                        //    }
                        //    else
                        //    {
                        //        Crpt.SetParameterValue("sTenUser"," ");
                        //    }
                        //}
                        SetReportParameter(Crpt);
                        var oForm = new VNS.Libs.frmPrintPreview(FormPreviewTitle, Crpt, true, true);

                        oForm.ReportSourceTable = ReportSourceTable;
                        // FieldObject mv_oRptFieldObj = Crpt.ReportDefinition.ReportObjects["Field150181"] as FieldObject;
                        // Crpt.PrintToPrinter();
                        if (Quick)
                        {
                            //mv_oNguoiKy = new VietBaIT.LABLink.Reports.Class.cls_SignInfor(mv_oRptFieldObj, "", Crpt.ToString(), Crpt.DataDefinition.FormulaFields["Formula_1"].Text);
                            mv_oNguoiKy = new cls_SignInfor(Crpt.ToString(), "", ReportSourceTable);
                            //chkPrint_CheckedChanged(chkPrint, New System.EventArgs)
                            if (mv_oNguoiKy._TonTai)
                            {
                                Crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) +
                                                                                      mv_oNguoiKy.mv_NOI_DUNG.Replace(
                                    "&NHANVIEN",
                                    globalVariables.UserName)
                                                                                      .Replace("\t",
                                                                                               Strings.Chr(34) +
                                                                                               "&Chr(13)&" +
                                                                                               Strings.Chr(34)) +
                                                                                      Strings.Chr(34);
                            }
                            else
                            {
                                Crpt.DataDefinition.FormulaFields["Formula_1"].Text = "";
                            }
                            Crpt.PrintOptions.PrinterName = printerName;
                            Crpt.PrintToPrinter(0, true, 0, 0);

                            Crpt.Dispose();
                            CleanTemporaryFolders();
                        }
                        else
                        {
                            oForm.ShowDialog();
                            oForm.Dispose();
                        }
                    }
                    else
                    {
                        //DataTable dt = new Select().From(TblTrinhky.Schema.Name).Where(TblTrinhky.Columns.ReportName).
                        //                            IsEqualTo(Crpt.GetClassName()).ExecuteDataSet().Tables[0];

                        string sql = string.Format("SELECT * \n"
                                                   + "FROM   sys_Trinhky With (NOLOCK) \n"
                                                   + "WHERE  ReportName = N'{0}'", Crpt.GetClassName());

                        var x = new InlineQuery().ExecuteAsCollection <SysTrinhkyCollection>(sql);

                        if (x.Count > 0)
                        {
                            Utility.GetDataRow(ReportParameterTable, colName, "Formula_1")[colValue] = Strings.Chr(34) +
                                                                                                       Utility.sDbnull(
                                x[0]
                                .ObjectContent) +
                                                                                                       Strings.Chr(34);
                        }

                        Crpt.SetDataSource(ReportSourceTable);
                        SetReportParameter(Crpt);
                        if (!ReportSourceTable.Columns.Contains("ParentBranchName"))
                        {
                            ReportSourceTable.Columns.Add("ParentBranchName");
                        }
                        if (!ReportSourceTable.Columns.Contains("BranchName"))
                        {
                            ReportSourceTable.Columns.Add("BranchName");
                        }

                        DataTable dtHematology = ReportSourceTable.Clone();
                        DataTable dtOther      = ReportSourceTable.Clone();
                        DataTable dtImages     = ReportSourceTable.Clone();


                        //object objuserName =
                        //    new Select(TblUser.Columns.SFullName).From(TblUser.Schema).Where(TblUser.Columns.PkSuid).
                        //                                          IsEqualTo(globalVariables.UserName).ExecuteScalar();
                        string sql2 = string.Format("SELECT Sys_Users.sFullName \n"
                                                    + "FROM   Sys_Users  WITH (NOLOCK)  \n"
                                                    + "WHERE  Sys_Users.PK_sUID = '{0}'", globalVariables.UserName);

                        var objuserName = new InlineQuery().ExecuteScalar <string>(sql2);

                        string sNguoiDung = objuserName == null ? "" : objuserName;
                        foreach (DataRow row in ReportSourceTable.Rows)
                        {
                            row["ParentBranchName"] = ManagementUnit.gv_sParentBranchName;
                            row["BranchName"]       = ManagementUnit.gv_sBranchName;
                            row["Nguoidung"]        = sNguoiDung;

                            if (row["isHematology"].ToString() == "1")
                            {
                                if (row["Data_Sequence"].ToString().Contains("-"))
                                {
                                    string pvSImgPath = row["Test_Result"].ToString();
                                    if (File.Exists(pvSImgPath))
                                    {
                                        //row["BarcodeImg"] = Utility.bytGetImage(pvSImgPath);
                                        var bitmap = new Bitmap(pvSImgPath);
                                        Invert(ref bitmap);
                                        row["BarcodeImg"] = Utility.ConvertImageToByteArray(bitmap, ImageFormat.Tiff);
                                        dtImages.ImportRow(row);
                                    }
                                }
                                else
                                {
                                    dtHematology.ImportRow(row);
                                }
                            }
                            else
                            {
                                dtOther.ImportRow(row);
                            }
                        }

                        // đẹt me lam rieng cho noi tiet to su bo no(.)

                        // cho cai kho A5
                        if (StrCode == "A5")
                        {
                            Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Hematology_Images.rpt"
                            ].SetDataSource(dtImages);
                            Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]
                            .SetDataSource(dtHematology);
                            Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]
                            .SetDataSource(dtOther);
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]);
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]);
                            //Crpt.SetParameterValue("PrintDate", printDateTime, Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"].Name);
                            //Crpt.SetParameterValue("PrintDate", printDateTime, Crpt.Subreports["NoiTiet_A5_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"].Name);

                            SetReportParameter(Crpt);
                        }
                        // cho cai kho A4
                        else if (StrCode == "A4")
                        {
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]);
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]);

                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology_Images.rpt"
                            ].SetDataSource(dtImages);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]
                            .SetDataSource(dtHematology);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]
                            .SetDataSource(dtOther);
                            SetReportParameter(Crpt);
                            //  Crpt.SetParameterValue("Nguoidung", sNguoiDung);
                        }
                        //neu deo khai bao A4 hay A5 thi mac dinh lay cai nay nhung pai dung cai bao cao ko an cut no chay dc.
                        else if (StrCode == "LABREPORT")
                        {
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]);
                            SetReportParameter(
                                Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology_Images.rpt"
                            ].SetDataSource(dtImages);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Hematology.rpt"]
                            .SetDataSource(dtHematology);
                            Crpt.Subreports["NoiTiet_A4_General_crpt_DetailTestReport_ALL_New_Sub_Other.rpt"]
                            .SetDataSource(dtOther);
                            SetReportParameter(Crpt);
                        }
                        if (Quick)
                        {
                            Crpt.PrintToPrinter(0, false, 0, 0);
                        }
                        else
                        {
                            var oForm = new VNS.Libs.frmPrintPreview(FormPreviewTitle, Crpt, true, true);
                            oForm.ShowDialog();
                            oForm.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
        /// <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);
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {

            }
        }
Exemple #16
0
        public static void InPhieuKCB_DV(DataTable m_dtReport, string sTitleReport,string KhoGiay)
        {
            ReportDocument reportDocument=new ReportDocument();
             string tieude="", reportname = "";
            switch (KhoGiay)
            {
                case "A4":
                    reportDocument =Utility.GetReport("tiepdon_PhieuKCB_Dvu_A4",ref tieude,ref reportname);
                    break;
                case "A5":
                    reportDocument = Utility.GetReport("tiepdon_PhieuKCB_Dvu_A5" ,ref tieude,ref reportname);
                    break;

            }
            if (reportDocument == null) return;

            var crpt = reportDocument;
            var objForm = new frmPrintPreview(sTitleReport, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true);
            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);
                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", sTitleReport);
                Utility.SetParameterValue(crpt,"BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                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.TenMayInPhieuKCB;
                    crpt.PrintToPrinter(1, false, 0, 0);
                }

            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.ToString());
            }
        }
        private void InPhieuKCB()
        {
            try
            {
                int IdKham = -1;
                 string tieude="", reportname = "";
                ReportDocument crpt = Utility.GetReport("tiepdon_PHIEUKHAM_NHIET",ref tieude,ref reportname);
                if (crpt == null) return;
                var objPrint = new frmPrintPreview("IN PHIẾU KHÁM", crpt, true, true);
                IdKham = GetrealRegID();
                KcbDangkyKcb objRegExam = KcbDangkyKcb.FetchByID(IdKham);
                DmucKhoaphong lDepartment = DmucKhoaphong.FetchByID(objRegExam.IdPhongkham);
                Utility.SetParameterValue(crpt,"PHONGKHAM", Utility.sDbnull(lDepartment.MaKhoaphong));
                Utility.SetParameterValue(crpt,"STT", Utility.sDbnull(objRegExam.SttKham, ""));
                Utility.SetParameterValue(crpt,"BENHAN", Utility.sDbnull(grdList.CurrentRow.Cells[KcbLuotkham.Columns.MaLuotkham].Value, ""));
                Utility.SetParameterValue(crpt,"TENBN", Utility.sDbnull(grdList.CurrentRow.Cells[KcbDanhsachBenhnhan.Columns.TenBenhnhan].Value, ""));
                Utility.SetParameterValue(crpt,"GT_TUOI", Utility.sDbnull(grdList.CurrentRow.Cells[KcbDanhsachBenhnhan.Columns.GioiTinh].Value, "") + ", " + Utility.sDbnull(grdList.CurrentRow.Cells["Tuoi"].Value, "") + " tuổi");
                string SOTHE = "Không có thẻ";

                SOTHE = Utility.sDbnull(grdList.CurrentRow.Cells[KcbLuotkham.Columns.MatheBhyt].Value, "Không có thẻ");
                Utility.SetParameterValue(crpt,"SOTHE", SOTHE);
                if (Utility.isPrintPreview(PropertyLib._MayInProperties.TenMayInPhieuKCB, PropertyLib._MayInProperties.PreviewPhieuKCB))
                    objPrint.ShowDialog();
                else
                {
                    crpt.PrintOptions.PrinterName = PropertyLib._MayInProperties.TenMayInPhieuKCB;
                    crpt.PrintToPrinter(1, false, 0, 0);
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Có lỗi trong quá trình in phiếu khám-->\n" + ex.Message);
            }
        }
 /// <summary>
 /// hàm thực hiện việc in phieus thu của dệt may
 /// </summary>
 /// <param name="sTitleReport"></param>
 private void PrintPhieuThu_DM(string sTitleReport,decimal TONG_TIEN)
 {
     Utility.WaitNow(this);
      string tieude="", reportname = "";
     var crpt = Utility.GetReport("thanhtoan_PhieuThu_DM",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) + "    Nhân viên                                                                   ".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,"DateTime", Utility.FormatDateTime(globalVariables.SysDate));
     Utility.SetParameterValue(crpt,"CurrentDate", Utility.FormatDateTime(globalVariables.SysDate));
     Utility.SetParameterValue(crpt,"sTitleReport", sTitleReport);
     Utility.SetParameterValue(crpt,"CharacterMoney", new MoneyByLetter().sMoneyToLetter(TONG_TIEN.ToString()));
     objForm.crptViewer.ReportSource = crpt;
     objForm.ShowDialog();
     Utility.DefaultNow(this);
     }
     catch (Exception ex)
     {
         Utility.DefaultNow(this);
     }
 }
        /// <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.BaocaoMiengiam(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.SetDataSourceForDataGridEx(grdList, _dtData, false, true, "1=1", "");

            Utility.UpdateLogotoDatatable(ref _dtData);
            THU_VIEN_CHUNG.CreateXML(_dtData, "baocao_miengiam.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("baocao_miengiam", 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 = "baocao_miengiam";
                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(tongtien_chietkhau)", "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 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"));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception exception)
            {
            }
        }
        /// <summary>
        /// thực hiện in phieus bảo hiểm chi tiết theo mẫu của Y học hải quân
        /// </summary>
        private void YHHQ_InPhieuBH(bool IsTongHop)
        {
            TPayment objPayment = TPayment.FetchByID(Utility.Int32Dbnull(txtPayment_ID.Text, -1));
            if (IsTongHop) objPayment.PaymentId = -1;
            m_dtReportPhieuThu = _THANHTOAN.GetDataInphieuBH(objPayment,true);
                ///load thông tin của việc lấy dữ liệu vào datatable trong phiếu thanh toán

            if (m_dtReportPhieuThu.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy thông tin của bản ghi nào");
                return;
            }
            log.Info("Xu ly thong tin in phieu theo dung dinh dang cua Y hoc hai quan");

            YHHQ_ProcessData_INPHIEU_BH(ref m_dtReportPhieuThu);

            m_dtReportPhieuThu.DefaultView.Sort = "Service_ID asc";m_dtReportPhieuThu.AcceptChanges();
            Utility.WaitNow(this);
            var crpt = new crpt_PhieuBHYT_V2();
            var objForm = new frmPrintPreview("", 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);
            //crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
            crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);

            crpt.SetParameterValue("CurrentDate", Utility.FormatDateTime(dtNgayIn.Value));
            crpt.SetParameterValue("sTitleReport", "BẢNG KÊ CHI PHÍ KHÁM, CHỮA BỆNH NGOẠI TRÚ");
            crpt.SetParameterValue("sMoneyCharacter_Thanhtien",
                                   sMoneyByLetter.sMoneyToLetter(
                                       SumOfTotal_BH(m_dtReportPhieuThu, "ThanhTien").ToString()));
            crpt.SetParameterValue("sMoneyCharacter_Thanhtien_BH",
                                   sMoneyByLetter.sMoneyToLetter(
                                       SumOfTotal_BH(m_dtReportPhieuThu, "ThanhTien_BH").ToString()));
            crpt.SetParameterValue("sMoneyCharacter_Thanhtien_BN",
                                   sMoneyByLetter.sMoneyToLetter(
                                       SumOfTotal_BH(m_dtReportPhieuThu, "ThanhTien_BN").ToString()));
            crpt.SetParameterValue("sMoneyCharacter_Thanhtien_Khac",
                                   sMoneyByLetter.sMoneyToLetter(
                                       SumOfTotal_BH(m_dtReportPhieuThu, "ThanhTien_Khac").ToString()));
            objForm.crptViewer.ReportSource = crpt;
            objForm.ShowDialog();
            Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                log.Error("Loi trong qua trinh in bao cao {0}",ex);
                Utility.DefaultNow(this);
            }
        }
        void cmdPrint_Click(object sender, EventArgs e)
        {
            try
            {
                Utility.WaitNow(this);
                DataTable dtData = SPs.NoitruTonghopChiphiRavien(objLuotkham.MaLuotkham, (int)objLuotkham.IdBenhnhan,Utility.Bool2byte(!Khoanoitrutonghop),idkhoanoitru).GetDataSet().Tables[0];
                THU_VIEN_CHUNG.CreateXML(dtData, "noitru_tonghopchiphiravien.XML");
                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;
                }
                foreach (DataRow drv in dtData.Rows)
                {
                    if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "1"//Chi phí KCB
                        || drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "0"//Phí KCB kèm theo
                        || drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "4"//Buồng giường
                        || drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "8"//Gói dịch vụ
                        )
                    {

                        drv["ten_loaidichvu"] = string.Empty;
                        drv["STT"] = 1;
                        drv["id_loaidichvu"] = -1;
                    }
                    else if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "2")
                    {
                        string ma_loaidichvu = Utility.sDbnull(drv["id_loaidichvu"], -1);
                        //drv["id_loaidichvu"]-->Được xác định trong câu truy vấn

                        DmucChung objService = THU_VIEN_CHUNG.LaydoituongDmucChung("LOAIDICHVUCLS", ma_loaidichvu);
                        if (objService != null)
                        {
                            drv["ten_loaidichvu"] = Utility.sDbnull(objService.Ten);
                            drv["STT"] = Utility.sDbnull(objService.SttHthi);
                        }

                    }
                    else if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "3")
                    {
                        int Drug_ID = Utility.Int32Dbnull(drv["id_dichvu"], -1);
                        DmucThuoc objDrug = DmucThuoc.FetchByID(Drug_ID);
                        if (objDrug != null)
                        {
                            if (objDrug.KieuThuocvattu == "THUOC")
                            {
                                drv["id_loaidichvu"] = 1;
                                drv["STT"] = 1;
                                drv["ten_loaidichvu"] = "Thuốc và dịch truyền";
                            }
                            else
                            {
                                drv["id_loaidichvu"] = 2;
                                drv["STT"] = 2;
                                drv["ten_loaidichvu"] = "Vật tư y tế ";
                            }
                        }
                    }
                    if (drv[KcbThanhtoanChitiet.Columns.IdLoaithanhtoan].ToString() == "5")
                    {
                        drv["id_loaidichvu"] = 1;
                        drv["STT"] = 1;
                        drv["ten_loaidichvu"] = "Chi phí thêm  ";
                    }
                }
                THU_VIEN_CHUNG.Sapxepthutuin(ref dtData, true);
                dtData.DefaultView.Sort = "stt_in ,stt_hthi_dichvu,stt_hthi_chitiet,ten_chitietdichvu";
                dtData.AcceptChanges();

                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(Khoanoitrutonghop ? "noitru_tonghopchiphiravien_theokhoa" : "noitru_tonghopchiphiravien", ref tieude, ref reportname);
                if (crpt == null) return;
                frmPrintPreview objForm = new frmPrintPreview(baocaO_TIEUDE1.TIEUDE, crpt, true, dtData.Rows.Count <= 0 ? false : true);
                crpt.SetDataSource(dtData);
                objForm.crptViewer.ReportSource = crpt;
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode = Khoanoitrutonghop ? "noitru_tonghopchiphiravien_theokhoa" : "noitru_tonghopchiphiravien";
                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, "sTitleReport", baocaO_TIEUDE1.TIEUDE);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(DateTime.Now));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());

                objForm.ShowDialog();

            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
            finally
            {
                Utility.DefaultNow(this);
            }
        }
        /// <summary>
        /// thực hiện in phieus bảo hiểm chi tiết theo mẫu của Y học hải quân
        /// </summary>
        private void YHHQ_InPhieuBH_IN_BN(bool IsTongHop)
        {
            TPayment objPayment = TPayment.FetchByID(Utility.Int32Dbnull(txtPayment_ID.Text, -1));
            if (IsTongHop) objPayment.PaymentId = -1;
            m_dtReportPhieuThu = _THANHTOAN.INPHIEUBH_CHOBENHNHAN(objPayment);

            ///load thông tin của việc lấy dữ liệu vào datatable trong phiếu thanh toán

            if (m_dtReportPhieuThu.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy bản ghi ", "Thông báo");
                return;
            }
            if (m_dtReportPhieuThu.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy thông tin của bản ghi nào");
                return;
            }

              //  YHHQ_PrintBH_IN_BN("");

            Utility.WaitNow(this);
            var crpt = new crpt_PhieuBHYT_TRABNHAN();
            var objForm = new frmPrintPreview("", crpt, true, true);
            try
            {
                crpt.SetDataSource(m_dtReportPhieuThu);
                 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);
                //crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
                crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                //  crpt.SetParameterValue("DateTime", Utility.FormatDateTime(dtCreateDate.Value));
                crpt.SetParameterValue("CurrentDate", Utility.FormatDateTime(dtNgayIn.Value));
                crpt.SetParameterValue("sTitleReport", "BẢNG KÊ CHI PHÍ KHÁM, CHỮA BỆNH NGOẠI TRÚ");
                crpt.SetParameterValue("sMoneyCharacter",
                                       sMoneyByLetter.sMoneyToLetter(SumOfTotal(m_dtReportPhieuThu).ToString()));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
                Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                Utility.DefaultNow(this);
            }
        }
        private void IN_HOADON()
        {
            string LyDoIn = "0";
            try
            {
                if (!Utility.isValidGrid(grdPayment))
                    return;
                int payment_ID = Utility.Int32Dbnull(grdPayment.GetValue(KcbThanhtoan.Columns.IdThanhtoan), -1);

                try
                {
                    dtPatientPayment = _THANHTOAN.Laythongtinhoadondo(payment_ID);
                    dtPatientPayment.Rows[0]["sotien_bangchu"] =
                        new MoneyByLetter().sMoneyToLetter(Utility.sDbnull(dtPatientPayment.Rows[0]["TONG_TIEN"]));
                    int lengh = txtSerieDau.Text.Length;
                    string tieude="", reportname = "";
                    ReportDocument report = Utility.GetReport("thanhtoan_Hoadondo",ref tieude,ref reportname);
                    if (report == null) return;
                    frmPrintPreview objForm = new frmPrintPreview("", report, true, true);
                    objForm.mv_sReportFileName = Path.GetFileName(reportname);
                    objForm.mv_sReportCode = "thanhtoan_Hoadondo";
                    report.PrintOptions.PrinterName = cbomayinhoadon.Text;
                    report.SetDataSource(dtPatientPayment);
                    report.SetParameterValue("NGUOIIN", Utility.sDbnull(globalVariables.gv_strTenNhanvien, ""));

                    report.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
                    report.SetParameterValue("BranchName", globalVariables.Branch_Name);
                    report.SetParameterValue("DateTime", Utility.FormatDateTime(globalVariables.SysDate));
                    report.SetParameterValue("CurrentDate", Utility.FormatDateTime(globalVariables.SysDate));
                    report.SetParameterValue("sTitleReport", tieude);
                    //report.SetParameterValue("CharacterMoney", new MoneyByLetter().sMoneyToLetter(TONG_TIEN.ToString()));
                    objForm.crptViewer.ReportSource = report;

                    if (Utility.isPrintPreview(PropertyLib._MayInProperties.TenMayInHoadon, PropertyLib._MayInProperties.PreviewInHoadon))
                    {
                        objForm.SetDefaultPrinter(PropertyLib._MayInProperties.TenMayInHoadon, 1);
                        objForm.ShowDialog();
                    }
                    else
                    {
                        report.PrintOptions.PrinterName = PropertyLib._MayInProperties.TenMayInHoadon;
                        report.PrintToPrinter(1,false, 0, 0);
                    }
                }
                catch (Exception ex1)
                {
                    Utility.ShowMsg("Lỗi khi thực hiện in hóa đơn mẫu. Liên hệ IT để được trợ giúp-->" +
                                    ex1.Message);
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
 /// <summary>
 /// hàm thực hiện việc in phiếu thu của y học hải quân
 /// </summary>
 /// <param name="sTitleReport"></param>
 private void YHHQ_PrintPhieuThu(string sTitleReport)
 {
     var crpt = new ReportDocument();
     Utility.WaitNow(this);
     if(status ==0)
      crpt = new crpt_PhieuThu();
     else
     {
         crpt = new crpt_PhieuChi();
         sTitleReport = "PHIẾU CHI";
     }
     var objForm = new frmPrintPreview("", crpt, true, true);
     //try
     //{
     crpt.SetDataSource(m_dtReportPhieuThu);
     // 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);
     crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
     crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
     crpt.SetParameterValue("DateTime", Utility.FormatDateTime(dtCreateDate.Value));
     crpt.SetParameterValue("CurrentDate", Utility.FormatDateTime(dtNgayIn.Value));
     crpt.SetParameterValue("sTitleReport", sTitleReport);
     crpt.SetParameterValue("CharacterMoney", sMoneyByLetter.sMoneyToLetter(txtSO_TIEN.Text));
     DataRow dataRow = m_dtReportPhieuThu.Rows[0];
     //if (status != 0)
     //crpt.SetParameterValue("NguoiChi", THU_VIEN_CHUNG.GetStaffByUserName(dataRow["NGUOI_NOP"].ToString()));
     objForm.crptViewer.ReportSource = crpt;
     objForm.ShowDialog();
     Utility.DefaultNow(this);
     //}
     //catch (Exception ex)
     //{
     //    Utility.DefaultNow(this);
     //}
 }
        /// <summary>
        /// Tạm thời ko dùng do report ko có tables
        /// </summary>
        /// <param name="sTitleReport"></param>
        /// <param name="TONG_TIEN"></param>
        private void PrintPhieuThu_YHHQ(string sTitleReport, decimal TONG_TIEN)
        {
            var crpt = new ReportDocument();
            Utility.WaitNow(this);
             string tieude="", reportname = "";
            crpt = Utility.GetReport("thanhtoan_PhieuThu",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) + "    Nhân viên                                                                   ".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,"DateTime", Utility.FormatDateTime(globalVariables.SysDate));
            Utility.SetParameterValue(crpt,"CurrentDate", Utility.FormatDateTime(globalVariables.SysDate));
            Utility.SetParameterValue(crpt,"sTitleReport", sTitleReport);
            Utility.SetParameterValue(crpt,"CharacterMoney", new MoneyByLetter().sMoneyToLetter(TONG_TIEN.ToString()));
            DataRow dataRow = m_dtReportPhieuThu.Rows[0];
            //if (status != 0)
            //Utility.SetParameterValue(crpt,"NguoiChi", BusinessHelper.GetStaffByUserName(dataRow["NGUOI_NOP"].ToString()));
            objForm.crptViewer.ReportSource = crpt;
            objForm.ShowDialog();
            Utility.DefaultNow(this);
            //}
            //catch (Exception ex)
            //{
            //    Utility.DefaultNow(this);
            //}
        }
 /// <summary>
 /// hàm thực hiện việc in phieus thu của dệt may
 /// </summary>
 /// <param name="sTitleReport"></param>
 private void DM_PrintPhieuThu(string sTitleReport)
 {
     Utility.WaitNow(this);
     var crpt = new crpt_PhieuThu_DM();
     var objForm = new frmPrintPreview("", crpt, true, true);
     //try
     //{
     crpt.SetDataSource(m_dtReportPhieuThu);
     // 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);
     crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
     crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
     crpt.SetParameterValue("DateTime", Utility.FormatDateTime(dtCreateDate.Value));
     crpt.SetParameterValue("CurrentDate", Utility.FormatDateTime(dtNgayIn.Value));
     crpt.SetParameterValue("sTitleReport", sTitleReport);
     crpt.SetParameterValue("CharacterMoney", sMoneyByLetter.sMoneyToLetter(txtSO_TIEN.Text));
     objForm.crptViewer.ReportSource = crpt;
     objForm.ShowDialog();
     Utility.DefaultNow(this);
     //}
     //catch (Exception ex)
     //{
     //    Utility.DefaultNow(this);
     //}
 }
 private void InPhieuKCB()
 {
     try
     {
         int reg_id = -1;
          string tieude="", reportname = "";
         ReportDocument crpt = Utility.GetReport("tiepdon_PHIEUKHAM_NHIET",ref tieude,ref reportname);
         if (crpt == null) return;
         var objPrint = new frmPrintPreview("IN PHIẾU KHÁM", crpt, true, true);
         reg_id = GetrealRegID();
         new Update(KcbDangkyKcb.Schema)
                .Set(KcbDangkyKcb.Columns.TrangthaiIn).EqualTo(1)
                .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(reg_id).Execute();
         IEnumerable<GridEXRow> query = from kham in grdRegExam.GetDataRows()
                                        where
                                            kham.RowType == RowType.Record &&
                                            Utility.Int32Dbnull(kham.Cells[KcbDangkyKcb.Columns.IdKham].Value, -1) ==
                                            Utility.Int32Dbnull(reg_id)
                                        select kham;
         if (query.Count() > 0)
         {
             GridEXRow gridExRow = query.FirstOrDefault();
             gridExRow.BeginEdit();
             gridExRow.Cells[KcbDangkyKcb.Columns.TrangthaiIn].Value = 1;
             gridExRow.EndEdit();
             grdRegExam.UpdateData();
         }
         KcbDangkyKcb objRegExam = KcbDangkyKcb.FetchByID(reg_id);
         DmucKhoaphong lDepartment = DmucKhoaphong.FetchByID(objRegExam.IdPhongkham);
         Utility.SetParameterValue(crpt,"PHONGKHAM", Utility.sDbnull(lDepartment.MaKhoaphong));
         Utility.SetParameterValue(crpt,"STT", Utility.sDbnull(objRegExam.SttKham, ""));
         Utility.SetParameterValue(crpt,"BENHAN", txtMaLankham.Text);
         Utility.SetParameterValue(crpt,"TENBN", txtTEN_BN.Text);
         Utility.SetParameterValue(crpt,"GT_TUOI", cboPatientSex.Text + ", " + txtTuoi.Text + " tuổi");
         string SOTHE = "Không có thẻ";
         LaySoTheBHYT();
         if (pnlBHYT.Enabled)
             SOTHE = SoBHYT;
         Utility.SetParameterValue(crpt,"SOTHE", SOTHE);
         if (Utility.isPrintPreview(PropertyLib._MayInProperties.TenMayInPhieuKCB, PropertyLib._MayInProperties.PreviewPhieuKCB))
             objPrint.ShowDialog();
         else
         {
             crpt.PrintOptions.PrinterName = PropertyLib._MayInProperties.TenMayInPhieuKCB;
             crpt.PrintToPrinter(1, false, 0, 0);
         }
     }
     catch
     {
     }
 }
Exemple #29
0
        /// <summary>
        /// HÀM THỰC HIỆN IN BÁO CÁO
        /// </summary>
        /// <param name="m_dsReport"></param>
        private void INBAOCAO(DataTable m_dsReport)
        {
            //var DT = new ds_dailyDetailTestReport.dtDailyDetailTestReportDataTable();

            string sTungayDenNgay = dtpFromDate.Value.Date != dtpTodate.Value.Date
                                        ? string.Format("{0} --- đến --- {1}", Getsday(dtpFromDate.Value),
                                                        Getsday(dtpTodate.Value))
                                        : Getsday(dtpFromDate.Value);

            if (!InvaliData(m_dtDataReport)) return;
            var crpt = new crpt_DailyTotalTestReportDetailVNIO();
            var objForm = new frmPrintPreview("", crpt, true, true);
            try
            {
                crpt.SetDataSource(m_dsReport);
                crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "        NHÂN VIÊN                                             TRƯỞNG KHOA                   ".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
                crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
                crpt.SetParameterValue("sTungayDenNgay", sTungayDenNgay);
                // crpt.SetParameterValue("TotalTest", intGetTotalTest( DT));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
                Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                Utility.DefaultNow(this);
            }
        }
Exemple #30
0
        public static void InphieuChidinhCLS(int id_benhnhan,string ma_luotkham, int v_AssignId, string v_AssignCode,string  nhomincls,int selectedIndex, bool inTach ,ref string mayin)
        {
            try
            {
                mayin = "";
                KcbChidinhcl objAssignInfo = KcbChidinhcl.FetchByID(v_AssignId);

                DataTable dt = new KCB_THAMKHAM().KcbThamkhamLaydulieuInphieuCls(id_benhnhan, ma_luotkham, v_AssignCode, nhomincls).Tables[0];
                if (dt == null || dt.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không có dữ liệu in. Mời bạn kiểm tra lại");
                    return;
                }
                THU_VIEN_CHUNG.CreateXML(dt,"Thamkham_InphieuCLS.XML");
                Utility.UpdateLogotoDatatable(ref dt);
                Utility.CreateBarcodeData(ref dt, v_AssignCode);

                var crpt = new ReportDocument();
                string KhoGiay = "A5";
                bool inchung = false;
                string tieude = "", reportname = "";
                if (PropertyLib._MayInProperties.CoGiayInCLS == Papersize.A4) KhoGiay = "A4";
                if (KhoGiay == "A5")
                    if (inTach && selectedIndex == 0)//Nếu in riêng mà chọn tất
                        crpt = Utility.GetReport("thamkham_InphieuchidinhCLS_RIENG_A5", ref tieude, ref reportname);
                    else
                    {
                        inchung = true;
                        crpt = Utility.GetReport("thamkham_InphieuchidinhCLS_A5", ref tieude, ref reportname);
                    }
                else//Khổ giấy A4
                    if (inTach && selectedIndex == 0)//Nếu in riêng mà chọn tất-->Gọi báo cáo nhóm theo nhóm in
                        crpt = Utility.GetReport("thamkham_InphieuchidinhCLS_RIENG_A4", ref tieude, ref reportname);
                    else
                    {
                        inchung = true;
                        crpt = Utility.GetReport("thamkham_InphieuchidinhCLS_A4", ref tieude, ref reportname);
                    }

                if (crpt == null) return;
                if (inchung)
                {
                    List<string> lstNhominCLS = (from p in dt.AsEnumerable()
                                                 where Utility.DoTrim(Utility.sDbnull(p.Field<string>("nhom_in_cls"))) != ""
                                                 select p.Field<string>("nhom_in_cls")
                                               ).Distinct().ToList<string>();
                    if (lstNhominCLS.Count > 1)
                    {
                        string tenphieuchidinh = THU_VIEN_CHUNG.Laygiatrithamsohethong("CLS_TENPHIEU_INCHUNG", "PHIẾU CHỈ ĐỊNH CẬN LÂM SÀNG", true); ;
                        foreach (DataRow dr in dt.Rows)
                            dr["ten_nhominphieucls"] = tenphieuchidinh;
                    }
                }
                var objForm = new frmPrintPreview("IN PHIẾU CHỈ ĐỊNH", crpt, true, true);
                try
                {
                    crpt.SetDataSource(dt);
                    //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "    Nhân viên        Bác sĩ chỉ định     ".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);
                    if (!inTach && selectedIndex == 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                            dr[VKcbChidinhcl.Columns.TenNhominphieucls] = THU_VIEN_CHUNG.Laygiatrithamsohethong("TIEUDE_PHIEUCHIDNHCLS_INCHUNG", "PHIẾU CHỈ ĐỊNH", true);
                    }
                    else
                    {
                        Utility.SetParameterValue(crpt, "TitleReport", tieude);
                    }
                    Utility.SetParameterValue(crpt, "CurrentDate", Utility.FormatDateTimeWithLocation(globalVariables.SysDate, globalVariables.gv_strDiadiem));
                    objForm.crptViewer.ReportSource = crpt;
                    if (Utility.isPrintPreview(PropertyLib._MayInProperties.TenMayInBienlai, PropertyLib._MayInProperties.PreviewInCLS))
                    {
                        objForm.SetDefaultPrinter(PropertyLib._MayInProperties.TenMayInBienlai, 0);
                        objForm.ShowDialog();
                        mayin = PropertyLib._MayInProperties.TenMayInBienlai;
                    }
                    else
                    {
                        objForm.addTrinhKy_OnFormLoad();
                        crpt.PrintOptions.PrinterName = PropertyLib._MayInProperties.TenMayInBienlai;
                        mayin = PropertyLib._MayInProperties.TenMayInBienlai;
                        crpt.PrintToPrinter(1, false, 0, 0);
                    }
                }
                catch (Exception ex)
                {
                   // Utility.DefaultNow(this);
                }

            }
            catch
            {
            }
        }
 void cmdIndanhsachthuoc_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dtDmucThuoc = SPs.ThuocLaydanhmucthuocIn("THUOC", (Int16)cboloaithuoc.SelectedValue).GetDataSet().Tables[0];
         string tieude="", reportname = "";
        var crpt = Utility.GetReport("thuoc_danhmucthuoc",ref tieude,ref reportname);
        if (crpt == null) return;
        var objFromPre =
            new frmPrintPreview(PropertyLib._ThuocProperties.TieudeInDanhmucThuoc, crpt, false, true);
        Utility.WaitNow(this);
        if (!PropertyLib._ThuocProperties.NhomthuocIndanhmuc)
            dtDmucThuoc.DefaultView.Sort = "ten_thuoc asc";
        else
            dtDmucThuoc.DefaultView.Sort = "stt_hthi_loaithuoc asc,ten_thuoc asc";
        crpt.SetDataSource(dtDmucThuoc.DefaultView);
        Utility.SetParameterValue(crpt,"ParentBranchName", globalVariables.ParentBranch_Name);
        Utility.SetParameterValue(crpt,"BranchName", globalVariables.Branch_Name);
        Utility.SetParameterValue(crpt,"Nhomthuoc", PropertyLib._ThuocProperties.NhomthuocIndanhmuc?1:0);
        Utility.SetParameterValue(crpt,"sTitleReport", PropertyLib._ThuocProperties.TieudeInDanhmucThuoc);
        objFromPre.crptViewer.ReportSource = crpt;
        objFromPre.ShowDialog();
        Utility.DefaultNow(this);
     }
     catch
     {
     }
 }