Ejemplo n.º 1
0
        public static ActionResult NoitruInTachToanBoPhieuCls(int idBenhnhan, string maLuotkham, int vAssignId,
                                                              string vAssignCode, List <string> listnhomincls,
                                                              int selectedIndex, bool inTach, DateTime ngayin, ref string mayin)
        {
            using (var scope = new TransactionScope())
            {
                using (new SharedDbConnectionScope())
                {
                    try
                    {
                        mayin = "";
                        DataTable dtAll =
                            new KCB_THAMKHAM().KcbThamkhamLaydulieuInphieuCls(idBenhnhan, maLuotkham, vAssignCode,
                                                                              "ALL").Tables[0];
                        foreach (string nhomcls in listnhomincls.ToList())
                        {
                            //   KcbChidinhcl objAssignInfo = KcbChidinhcl.FetchByID(v_AssignId);
                            DataTable dt = dtAll.Select("nhom_in_cls = '" + nhomcls + "'").CopyToDataTable();
                            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;
                            }
                            else
                            {
                                //   THU_VIEN_CHUNG.CreateXML(dt, "Thamkham_InTachToanBophieuCLS.XML");
                                Utility.UpdateLogotoDatatable(ref dt);

                                string         manhomcls = nhomcls;
                                string         tieude    = "";
                                ReportDocument crpt      = Utility.GetReport(manhomcls, ref tieude, ref manhomcls);
                                if (crpt == null)
                                {
                                    return(ActionResult.Error);
                                }
                                try
                                {
                                    var objForm = new frmPrintPreview("IN PHIẾU CHỈ ĐỊNH", crpt, true, true)
                                    {
                                        mv_sReportFileName = Path.GetFileName(manhomcls),
                                        mv_sReportCode     = manhomcls
                                    };
                                    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, "sTitleReport", tieude);
                                    Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address);
                                    Utility.SetParameterValue(crpt, "txtTrinhky",
                                                              Utility.getTrinhky(objForm.mv_sReportFileName,
                                                                                 globalVariables.SysDate));
                                    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(
                                                                  ngayin, 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.ShowMsg("Lỗi:" + ex.Message);
                                    // Utility.DefaultNow(this);
                                }
                                finally
                                {
                                    Utility.FreeMemory(crpt);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Utility.ShowMsg("Lỗi:" + ex.Message);
                        return(ActionResult.Error);
                    }
                }
                scope.Complete();
                return(ActionResult.Success);
            }
        }
Ejemplo n.º 2
0
        public void txtMaluotkham_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter && Utility.DoTrim(txtMaluotkham.Text) != "")
                {
                    AllowTextChanged = false;
                    var dtPatient = new DataTable();

                    objLuotkham = null;
                    string _patient_Code = Utility.AutoFullPatientCode(txtMaluotkham.Text);
                    ClearControls();

                    dtPatient = new KCB_THAMKHAM().TimkiemBenhnhan(txtMaluotkham.Text,
                                                                   -1, 1, 0);

                    DataRow[] arrPatients = dtPatient.Select(KcbLuotkham.Columns.MaLuotkham + "='" + _patient_Code + "'");
                    if (arrPatients.GetLength(0) <= 0)
                    {
                        if (dtPatient.Rows.Count > 1)
                        {
                            var frm = new frm_DSACH_BN_TKIEM("ALL");
                            frm.MaLuotkham = txtMaluotkham.Text;
                            frm.dtPatient  = dtPatient;
                            frm.ShowDialog();
                            if (!frm.has_Cancel)
                            {
                                txtMaluotkham.Text = frm.MaLuotkham;
                            }
                        }
                    }
                    else
                    {
                        txtMaluotkham.Text = _patient_Code;
                    }
                    DataTable dt_Patient =
                        new KCB_THAMKHAM().NoitruTimkiemThongtinBenhnhansaukhigoMaBN(txtMaluotkham.Text, -1, "ALL");
                    if (dt_Patient != null && dt_Patient.Rows.Count > 0)
                    {
                        txtIdBn.Text = Utility.sDbnull(dt_Patient.Rows[0][KcbDanhsachBenhnhan.Columns.IdBenhnhan], "");
                        objLuotkham  =
                            new Select().From(KcbLuotkham.Schema)
                            .Where(KcbLuotkham.Columns.IdBenhnhan)
                            .IsEqualTo(txtIdBn.Text)
                            .And(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(txtMaluotkham.Text)
                            .ExecuteSingle <KcbLuotkham>();
                        dtpNgaynhapvien.Value = objLuotkham.NgayNhapvien.Value;
                        txtTenBN.Text         = Utility.sDbnull(dt_Patient.Rows[0][KcbDanhsachBenhnhan.Columns.TenBenhnhan], "");
                        txttuoi.Text          = Utility.sDbnull(dt_Patient.Rows[0]["Tuoi"], "");
                        txtgioitinh.Text      = Utility.sDbnull(dt_Patient.Rows[0][KcbDanhsachBenhnhan.Columns.GioiTinh], "");
                        txtDiachi.Text        = Utility.sDbnull(dt_Patient.Rows[0][KcbDanhsachBenhnhan.Columns.DiaChi], "");
                        txtmatheBhyt.Text     = Utility.sDbnull(dt_Patient.Rows[0][KcbLuotkham.Columns.MatheBhyt], "");
                        txtKhoanoitru.Text    = Utility.sDbnull(dt_Patient.Rows[0]["ten_khoaphong_noitru"], "");
                        txtBuong.Text         = Utility.sDbnull(dt_Patient.Rows[0][NoitruDmucBuong.Columns.TenBuong], "");
                        txtGiuong.Text        = Utility.sDbnull(dt_Patient.Rows[0][NoitruDmucGiuongbenh.Columns.TenGiuong], "");
                        txtBenhchinh.SetCode(Utility.sDbnull(dt_Patient.Rows[0]["mabenh_chinh"], ""));
                        txtIdkhoanoitru.Text = Utility.sDbnull(dt_Patient.Rows[0][KcbLuotkham.Columns.IdKhoanoitru], "-1");
                        txtIdravien.Text     = Utility.sDbnull(dt_Patient.Rows[0][KcbLuotkham.Columns.IdRavien], "-1");
                        txtidBuong.Text      = Utility.sDbnull(dt_Patient.Rows[0][KcbLuotkham.Columns.IdBuong], "-1");
                        txtidgiuong.Text     = Utility.sDbnull(dt_Patient.Rows[0][KcbLuotkham.Columns.IdGiuong], "-1");
                        cmdChuyen.Enabled    = true;
                        if (objLuotkham.TrangthaiNoitru == 0)
                        {
                            Utility.ShowMsg(
                                "Bệnh nhân chưa vào nội trú nên không thể lập phiếu ra viện. Đề nghị bạn kiểm tra lại");
                            cmdChuyen.Enabled = false;
                            return;
                        }
                        cmdChuyen.Enabled = objLuotkham != null && objLuotkham.TrangthaiNoitru <= 3;
                        LoadData();
                        dtpNgayravien.Focus();
                    }
                }
            }
            catch (Exception)
            {
                Utility.ShowMsg("Có lỗi trong quá trình lấy thông tin bệnh nhân");
            }
            finally
            {
                AllowTextChanged = true;
            }
        }