Exemple #1
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
            {
            }
        }