Esempio n. 1
0
        private void INPHIEU_XETNGHIEM(bool IsQuick, string sTitleReport, DateTime NgayIn)
        {
            string strPatient_ID = string.Empty;
            var    DTPrint       = new DataTable();
            string vTestTypeId   = GetCheckTestType();
            string vTestID       = GetcheckTestID();

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

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

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

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

                objForm.ShowDialog();
                // Utility.DefaultNow(this);
            }
            catch (Exception ex)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(ex.ToString());
                }
            }
            //StrCode = reporttype.Trim();
            //// neu rpt A4 hoac A5 ma chua khai bao thi lay me no cai mac dinh(.)
            //if (StrCode == "")
            //{
            //    crptBusiness.StrCode = rdoNoheader.Checked ? "LABNOHEADER" : "LABREPORT";
            //}
            //else
            //{
            //    crptBusiness.StrCode = StrCode;
            //}
            //crptBusiness.FormPreviewTitle = "In kết quả xét nghiệm";
            //crptBusiness.Print(IsQuick, printDocument.PrinterSettings.PrinterName);
        }
Esempio n. 2
0
        private void InPhieuChiDinh(bool IsQuick, string sTitleReport, DateTime NgayIn)
        {
            int    strPatient_ID = -1;
            var    DTPrint       = new DataTable();
            string vTestTypeId   = GetCheckTestType();
            string vTestID       = GetcheckTestID();

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

            //if (grdList.GetCheckedRows().Length > 0)
            //{
            //    foreach (GridEXRow gridExRow in grdList.GetCheckedRows())
            //    {
            //        strPatient_ID += "," + Utility.Int32Dbnull(gridExRow.Cells["Patient_ID"].Value, -1);
            //    }
            //    strPatient_ID = strPatient_ID.Remove(0, 1);
            //}
            //else
            {
                strPatient_ID = Utility.Int32Dbnull(grdList.GetValue("Patient_ID"));
            }
            DTPrint =
                SPs.InPhieuChiDinhXetNghiem(strPatient_ID, vTestTypeId, vTestID).GetDataSet().Tables[0];
            if (DTPrint.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy bản ghi nào", "Thông báo");
                return;
            }
            string tieude = "", reportname = "";
            var    crpt    = Utility.GetReport("crpt_InPhieuChiDinhXetNghiem", ref tieude, ref reportname);
            var    objForm = new frmPrintPreview(sTitleReport, crpt, true, DTPrint.Rows.Count <= 0 ? false : true);

            Utility.UpdateLogotoDatatable(ref DTPrint);
            Utility.AddColumToDataTable(ref DTPrint, "BarcodeImg", typeof(byte[]));
            foreach (DataRow dr in DTPrint.Rows)
            {
                dr["BarcodeImg"] =
                    Utility.GenerateBarCode(
                        BarcodeInfo.CreateNewBarcode(Utility.sDbnull(dr["Barcode"], "0000000000")));
            }
            try
            {
                DTPrint.AcceptChanges();
                crpt.SetDataSource(DTPrint);
                objForm.crptViewer.ReportSource = crpt;
                objForm.crptTrinhKyName         = Path.GetFileName(reportname);
                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(NgayIn));
                Utility.SetParameterValue(crpt, "sTitleReport", sTitleReport);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                if (!IsQuick)
                {
                    objForm.ShowDialog();
                    // Utility.DefaultNow(this);
                }
                else
                {
                    objForm.addTrinhKy_OnFormLoad();
                    crpt.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName;
                    crpt.PrintToPrinter(0, true, 0, 0);
                    crpt.Dispose();
                    CleanTemporaryFolders();
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.ToString());
            }
        }