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);
     }
 }
예제 #2
0
        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();
        }
        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);
            }
        }
예제 #4
0
 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);
     }
 }
 private void btnPrint_Click(object sender, EventArgs e)
 {
     PrintData();
     try
     {
         if(dt.Rows.Count<=0)
         {
             Utility.ShowMsg("Không có dữ liệu để báo cáo","Thông Báo",MessageBoxIcon.Information);
         }
         else
         {
             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 crpt = new Crpt_BaoCaoLuu_NoBarcode();
             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",s );
             crpt.SetParameterValue("ParentBranchName", ManagementUnit.gv_sParentBranchName);
             crpt.SetParameterValue("BranchName", ManagementUnit.gv_sBranchName);
             crpt.SetParameterValue("sCurrentDate", DateTime.Now.Date);
             oForm.crptViewer.ReportSource = crpt;
             oForm.ShowDialog();
             oForm.Dispose();
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("Lỗi" + ex,"Thông báo",MessageBoxIcon.Warning);
     }
 }
예제 #6
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(Utilities.gv_sUID).ExecuteScalar();
                        //    if (sFullName != null)
                        //    {
                        //        Crpt.SetParameterValue("sTenUser", sFullName);
                        //    }
                        //    else
                        //    {
                        //        Crpt.SetParameterValue("sTenUser"," ");
                        //    }
                        //}
                           ReportDocument reportDocument=new ReportDocument();
             string tieude="", reportname = "";
                        SetReportParameter(Crpt);
                        var oForm = new frmPrintPreview(FormPreviewTitle, Crpt, true, true);

                        oForm.ReportSourceTable = ReportSourceTable;
                        // FieldObject mv_oRptFieldObj = Crpt.ReportDefinition.ReportObjects["Field150181"] as FieldObject;
                        // Crpt.PrintToPrinter();
                        if (Quick)
                        {
                            oForm.crptTrinhKyName = Path.GetFileName(reportname);
                            //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(Utilities.gv_sUID).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);
            }
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
             {
                  string s ="";
                if (dtpFromDate.Value.Date == dtpToDate.Value.Date)
                {
                    s = string.Format(" Ngày {0} tháng {1} năm {2}",dtCreatePrint.Value.Day,dtCreatePrint.Value.Month,dtCreatePrint.Value.Year);
                }
                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")));
                }
                string tieude = "", reportname = "";
                string sTitleReport;
             var crpt = new ReportDocument();
             if (chkTongBNHoanTatXN.Checked)
             {
                 crpt = Utility.GetReport("crpt_BaoCaoSoLuongBN_TestType", ref tieude, ref reportname);

             }
             else
             {
                 crpt = Utility.GetReport("crpt_BaoCaoSoLuongBN_TestType", ref tieude, ref reportname);

             }
             var oForm = new frmPrintPreview("Báo cáo thống kê số lượng bệnh nhân", crpt, true, dt.Rows.Count <= 0 ? false : true);
             Utility.UpdateLogotoDatatable(ref dt);
             crpt.SetDataSource(dt);
             oForm.crptTrinhKyName = Path.GetFileName(reportname);
             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);
            }
        }
예제 #8
0
        private void cmdINPHIEU_Click(object sender, EventArgs e)
        {
            try
            {
                //string sTenKhoa = cboDepartment.Text;
                //var dt = new DataTable();
                //dt.Columns.Add("Barcode");
                //dt.Columns.Add("Patient_ID");
                //dt.Columns.Add("Patient_Name");
                //dt.Columns.Add("AGE");
                //dt.Columns.Add("Sex");
                //dt.Columns.Add("Department");
                //dt.Columns.Add("Diagnostic");
                //dt.Columns.Add("AllResult");
                //dt.Columns.Add("Test_Date");

                //LDepartment objDepartment = LDepartment.FetchByID(Utility.Int32Dbnull(cboDepartment.SelectedValue));
                //if (objDepartment != null)
                //    sTenKhoa = Utility.sDbnull(objDepartment.SName, "");

                //if (dtRawResult == null)
                //{
                //    dtRawResult =
                //        SPs.SpRptBaoCaoLuu(dtpFromDate.Value,
                //                           dtpToDate.Value,
                //                           Utility.Int32Dbnull(cboDepartment.SelectedValue), chkPrintAll.Checked).
                //            GetDataSet().Tables[0];
                //    if (dtRawResult.Rows.Count == 0) dtRawResult = null;
                //}
                //if (dtRawResult != null && dtRawResult.Rows.Count <= 0)
                //{
                //    Utility.ShowMsg("Không tồn tại dữ liệu");
                //    return;
                //}
                //bool forVd = SysPara.BarcodeType.ToUpper() == "VIETDUC";
                ////Xử lý các giá trị bình thường
                //Utilities.ProcessNormalResult(ref dtRawResult, "Test_Result", "Normal_Level", "+",
                //                              "+", "-", "flag", forVd);

                //var patientResult = new StringBuilder();

                //dtRawResult.Rows.InsertAt(dtRawResult.NewRow(), 0);
                //dtRawResult.Rows[0]["Patient_ID"] = dtRawResult.Rows[1]["Patient_ID"];
                //dtRawResult.Rows.Add(dtRawResult.NewRow());
                //for (int i = 1; i <= dtRawResult.Rows.Count - 1; i++)
                //{
                //    if (Utility.sDbnull(dtRawResult.Rows[i]["Patient_ID"]) !=
                //        Utility.sDbnull(dtRawResult.Rows[i - 1]["Patient_ID"]))
                //    {
                //        //patientResult.Remove(patientResult.Length - 2, 1);
                //        DataRow newdr = dt.NewRow();
                //        newdr["Patient_ID"] = dtRawResult.Rows[i - 1]["Patient_ID"];
                //        newdr["Barcode"] = dtRawResult.Rows[i - 1]["Barcode"];
                //        newdr["Patient_Name"] = dtRawResult.Rows[i - 1]["Patient_Name"];
                //        newdr["AGE"] = dtRawResult.Rows[i - 1]["AGE"];
                //        newdr["Sex"] = dtRawResult.Rows[i - 1]["Sex"];
                //        newdr["Department"] = dtRawResult.Rows[i - 1]["Department"];
                //        newdr["Diagnostic"] = dtRawResult.Rows[i - 1]["Diagnostic"];
                //        if (dtRawResult.Rows[i - 1]["Test_Date"] != null)
                //            newdr["Test_Date"] = ((DateTime) dtRawResult.Rows[i - 1]["Test_Date"]).ToString("dd/MM/yyyy");
                //        //newdr["Test_Date"] = DateTime.Parse(dtRawResult.Rows[i - 1]["Test_Date"].ToString()).ToString("dd/MM/yyyy");
                //        newdr["AllResult"] = patientResult.ToString();
                //        dt.Rows.Add(newdr);
                //        patientResult = new StringBuilder();
                //    }
                //    if ((Utility.sDbnull(dtRawResult.Rows[i]["TestType_Name"]) !=
                //         Utility.sDbnull(dtRawResult.Rows[i - 1]["TestType_Name"])) |
                //        (Utility.sDbnull(dtRawResult.Rows[i]["Patient_ID"]) !=
                //         Utility.sDbnull(dtRawResult.Rows[i - 1]["Patient_ID"])))
                //    {
                //        patientResult.Append("</p>");
                //        patientResult.Append(string.Format("</p><b>{0}</b>: ",
                //                                           Utility.sDbnull(dtRawResult.Rows[i]["TestType_Name"]).ToUpper
                //                                               ()));
                //    }
                //    string value;
                //    if (Utility.sDbnull(dtRawResult.Rows[i]["flag"]).Trim() == "+")
                //        value = string.Format("<font color=\"red\"><b>{0}({1}) {2};</b></font> ",
                //                              Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                //                              Utility.sDbnull(dtRawResult.Rows[i]["flag"]),
                //                              dtRawResult.Rows[i]["Test_result"]);
                //    else if (Utility.sDbnull(dtRawResult.Rows[i]["flag"]).Trim() == "-")
                //        value = string.Format("{0}({1}) {2}; ",
                //                              Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                //                              Utility.sDbnull(dtRawResult.Rows[i]["flag"]),
                //                              dtRawResult.Rows[i]["Test_result"]);
                //    else
                //        value = string.Format(
                //            Utility.sDbnull(dtRawResult.Rows[i]["Test_result"]).Trim() != ""
                //                ? "{0} {1};"
                //                : "<i>{0}&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</i> ",
                //            Utility.sDbnull(dtRawResult.Rows[i]["Test_Name"]),
                //            dtRawResult.Rows[i]["Test_result"]);

                //    patientResult.Append(value);
                //}

                //dt.AcceptChanges();

                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("sTenKhoa", sTenKhoa);
                crpt.SetParameterValue("TongSoBenhNhan", dt.Rows.Count);
                crpt.SetParameterValue("sFromDateToDate", s);
                crpt.SetParameterValue("ParentBranchName", ManagementUnit.gv_sParentBranchName);
                crpt.SetParameterValue("BranchName", ManagementUnit.gv_sBranchName);
                //crpt.SetParameterValue("Address", ManagementUnit.gv_sAddress);
                //crpt.SetParameterValue("sPhone", ManagementUnit.gv_sPhone);
                crpt.SetParameterValue("sPrintDate", dtCreatePrint.Value.ToString("dd/MM/yyyy"));
                oForm.crptViewer.ReportSource = crpt;
                oForm.ShowDialog();
                oForm.Dispose();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
예제 #9
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);
            }
        }
예제 #10
0
        private void InphieuDv()
        {
            foreach (GridEXRow GridEXRow in grdTestInfo.GetCheckedRows())
            {
                xmen += "," + Utility.sDbnull(GridEXRow.Cells["id_chidinh"].Value, -1);
            }
            idDichvu = xmen.Remove(0, 1);
            int patient_id = Utility.Int32Dbnull(grdTestInfo.GetValue("id_benhnhan"));
            // KcbChidinhcl objAssignInfo = KcbChidinhcl.FetchByID(v_AssignId);
            DataTable dt = SPs.DLayThongTinBNChiDinhDV(idDichvu, patient_id).GetDataSet().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);

            idDichvu = "";
            string KhoGiay = "A5";
            bool inchung = false;
            string tieude = "", reportname = "";
            MoneyByLetter _moneyByLetter = new MoneyByLetter();
            var tinhtong = Utility.sDbnull(TinhTong(dt, KcbChidinhclsChitiet.DonGiaColumn.ColumnName));
            var smstinh = dt.Compute("SUM(TT_PHUTHU)","");
            string tongcong = Utility.sDbnull(TinhTong(dt, "tongcong"));
            string thanhtien = Utility.sDbnull(TinhTong(dt, "thanhtien"));
              //  int tongcong = Utility.Int16Dbnull(tinhtong )+ Utility.Int16Dbnull(smstinh);
            var crpt = Utility.GetReport("thanhtoan_Bienlai_Dichvu_A5", ref tieude, ref reportname);
            var objForm = new frmPrintPreview("IN PHIẾU THANH TOAN", crpt, true, true);
            try
            {
                //Utility.AddColumToDataTable(ref dt,"TinhTong",typeof(string));
                //   foreach (DataRow  drRow in dt.Rows)
                //   {
                //       drRow["tinhtong"] = tinhtong;
                //   }
                //   dt.AcceptChanges();
                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);
                objForm.crptTrinhKyName = Path.GetFileName(reportname);
                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, "CurrentDate", Utility.FormatDateTimeWithLocation(globalVariables.SysDate, globalVariables.gv_strDiadiem));
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "tinhtong", tinhtong);
                Utility.SetParameterValue(crpt, "tongcong", tongcong);
                Utility.SetParameterValue(crpt, "thanhtien", thanhtien);

                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "sMoneyCharacter", _moneyByLetter.sMoneyToLetter(Utility.sDbnull(tinhtong)));
                objForm.crptViewer.ReportSource = crpt;
                objForm.SetDefaultPrinter(PropertyLib._MayInProperties.TenMayInBienlai, 0);
                objForm.ShowDialog();

                objForm.Dispose();
                //  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);
            }
        }
예제 #11
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")));
         }
         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("sTenKhoa", sTenKhoa);
         crpt.SetParameterValue("TongSoBenhNhan", dt.Rows.Count);
         crpt.SetParameterValue("sFromDateToDate", s);
         crpt.SetParameterValue("ParentBranchName", globalVariables.ParentBranch_Name);
         crpt.SetParameterValue("BranchName", globalVariables.Branch_Name);
         //crpt.SetParameterValue("Address", ManagementUnit.gv_sAddress);
         //crpt.SetParameterValue("sPhone", ManagementUnit.gv_sPhone);
         crpt.SetParameterValue("sPrintDate", dtCreatePrint.Value.ToString("dd/MM/yyyy"));
         oForm.crptViewer.ReportSource = crpt;
         oForm.ShowDialog();
         oForm.Dispose();
     }
     catch (Exception ex)
     {
         Utility.ShowMsg(ex.Message);
     }
 }