示例#1
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            List <DataRow> checkedRows = _dictSymptom.Values.ToList();

            if (checkedRows.Count > 0)
            {
                string exportFileName = string.Format("{0}\\Temp\\Symptom.xls", Application.StartupPath);
                if (ExportExcel.ExportSymptomToExcel(exportFileName, checkedRows))
                {
                    try
                    {
                        if (isPreview)
                        {
                            ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.TrieuChungTemplate));
                        }
                        else
                        {
                            if (_printDialog.ShowDialog() == DialogResult.OK)
                            {
                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.TrieuChungTemplate));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những triệu chứng cần in.", IconType.Information);
            }
        }
示例#2
0
        private void OnPrint(DataRow drKetQuaSoiCTC)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (_printDialog.ShowDialog() == DialogResult.OK)
            {
                string exportFileName = string.Format("{0}\\Temp\\KetQuaSoiCTC.xls", Application.StartupPath);

                if (!ExportExcel.ExportKetQuaSoiCTCToExcel(exportFileName, _patientRow, drKetQuaSoiCTC))
                {
                    return;
                }
                else
                {
                    try
                    {
                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaSoiCTCTemplate));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        return;
                    }
                }
            }
        }
示例#3
0
        private void OnPrint()
        {
            if (MsgBox.Question(Application.ProductName, "Bạn có muốn in phiếu thu ?") == DialogResult.Yes)
            {
                string exportFileName = string.Format("{0}\\Temp\\Receipt.xls", Application.StartupPath);

                try
                {
                    string receiptGUID = _drReceipt["ReceiptGUID"].ToString();
                    if (ExportExcel.ExportReceiptToExcel(exportFileName, receiptGUID))
                    {
                        if (_printDialog.ShowDialog() == DialogResult.OK)
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.PhieuThuDichVuTemplate));
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                }
            }
        }
示例#4
0
        private void OnPrint(string receiptGUID)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (dgServiceHistory.RowCount <= 0)
            {
                return;
            }

            string exportFileName = string.Format("{0}\\Temp\\Receipt.xls", Application.StartupPath);

            if (ExportExcel.ExportReceiptToExcel(exportFileName, receiptGUID))
            {
                try
                {
                    if (_printDialog.ShowDialog() == DialogResult.OK)
                    {
                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.PhieuThuDichVuTemplate));
                    }
                }
                catch (Exception ex)
                {
                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                }
            }
        }
示例#5
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            List <DataRow> checkedRows = GetCheckedRows();

            if (checkedRows.Count > 0)
            {
                string exportFileName = string.Format("{0}\\Temp\\BenhNhanNgoaiGoiKham.xls", Application.StartupPath);
                if (isPreview)
                {
                    if (!ExportExcel.ExportDanhSachBenhNhanNgoaiGoiKhamToExcel(exportFileName, checkedRows))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.BenhNhanNgoaiGoiKhamTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }
                    }
                }
                else
                {
                    if (_printDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (!ExportExcel.ExportDanhSachBenhNhanNgoaiGoiKhamToExcel(exportFileName, checkedRows))
                        {
                            return;
                        }
                        else
                        {
                            try
                            {
                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.BenhNhanNgoaiGoiKhamTemplate));
                            }
                            catch (Exception ex)
                            {
                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                return;
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những bệnh nhân ngoài gói khám cần in.", IconType.Information);
            }
        }
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            string template = string.Empty;

            DateTime tuNgay       = new DateTime(dtpkTuNgay.Value.Year, dtpkTuNgay.Value.Month, dtpkTuNgay.Value.Day, 0, 0, 0);
            DateTime denNgay      = new DateTime(dtpkDenNgay.Value.Year, dtpkDenNgay.Value.Month, dtpkDenNgay.Value.Day, 23, 59, 59);
            string   docStaffGUID = cboDocStaff.SelectedValue.ToString();

            string exportFileName = string.Format("{0}\\Temp\\ThongKeChiDinhCuaBacSi.xls", Application.StartupPath);

            if (isPreview)
            {
                if (!ExportExcel.ExportChiDinhCuaBacSi(exportFileName, tuNgay, denNgay, docStaffGUID))
                {
                    return;
                }

                try
                {
                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(template));
                }
                catch (Exception ex)
                {
                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    return;
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (!ExportExcel.ExportChiDinhCuaBacSi(exportFileName, tuNgay, denNgay, docStaffGUID))
                    {
                        return;
                    }

                    try
                    {
                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(template));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        return;
                    }
                }
            }
        }
示例#7
0
        private void OnPrint()
        {
            Cursor.Current = Cursors.WaitCursor;
            List <string> checkedReceiptList = new List <string>();
            DataTable     dt = dgReceipt.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    checkedReceiptList.Add(row["ReceiptGUID"].ToString());
                }
            }

            if (checkedReceiptList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn in những phiếu thu mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    string exportFileName = string.Format("{0}\\Temp\\Receipt.xls", Application.StartupPath);
                    foreach (string receiptGUID in checkedReceiptList)
                    {
                        try
                        {
                            if (ExportExcel.ExportReceiptToExcel(exportFileName, receiptGUID))
                            {
                                if (_printDialog.ShowDialog() == DialogResult.OK)
                                {
                                    ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.PhieuThuDichVuTemplate));
                                }
                                //ExcelPrintPreview.PrintPreview(exportFileName);
                            }
                            else
                            {
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những phiếu thu cần in.", IconType.Information);
            }
        }
示例#8
0
        private void OnPrint(bool isPreview)
        {
            if (dgBenhNhan.RowCount <= 0)
            {
                return;
            }
            DataTable dt = dgBenhNhan.DataSource as DataTable;

            if (dt == null || dt.Rows.Count <= 0)
            {
                return;
            }

            string exportFileName = string.Format("{0}\\Temp\\DanhSachBenhNhanDenKham.xls", Application.StartupPath);

            if (isPreview)
            {
                if (ExportExcel.ExportDanhSachBenhNhanDenKhamToExcel(exportFileName, dt, raDenKham.Checked))
                {
                    try
                    {
                        ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.DanhSachBenhNhanDenKhamTemplate));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    }
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (ExportExcel.ExportDanhSachBenhNhanDenKhamToExcel(exportFileName, dt, raDenKham.Checked))
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.DanhSachBenhNhanDenKhamTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }
                    }
                }
            }
        }
示例#9
0
        private void OnPrint(bool isPreview)
        {
            if (!CheckInfo())
            {
                return;
            }

            string exportFileName = string.Format("{0}\\Temp\\KhamSucKhoeTongQuat.xls", Application.StartupPath);

            if (isPreview)
            {
                DateTime tuNgay  = new DateTime(dtpkTuNgay.Value.Year, dtpkTuNgay.Value.Month, dtpkTuNgay.Value.Day, 0, 0, 0);
                DateTime denNgay = new DateTime(dtpkDenNgay.Value.Year, dtpkDenNgay.Value.Month, dtpkDenNgay.Value.Day, 23, 59, 59);
                if (ExportExcel.ExportKhamSucKhoeTongQuatToExcel(exportFileName, _patientRow, tuNgay, denNgay))
                {
                    try
                    {
                        ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KhamSucKhoeTongQuatTemplate));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    }
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    DateTime tuNgay  = new DateTime(dtpkTuNgay.Value.Year, dtpkTuNgay.Value.Month, dtpkTuNgay.Value.Day, 0, 0, 0);
                    DateTime denNgay = new DateTime(dtpkDenNgay.Value.Year, dtpkDenNgay.Value.Month, dtpkDenNgay.Value.Day, 23, 59, 59);
                    if (ExportExcel.ExportKhamSucKhoeTongQuatToExcel(exportFileName, _patientRow, tuNgay, denNgay))
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KhamSucKhoeTongQuatTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }
                    }
                }
            }
        }
示例#10
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            string template = Const.ThongKeThuocXuatHoaDonTemplate;

            string exportFileName = string.Format("{0}\\Temp\\ThongKeThuocXuatHoaDon.xls", Application.StartupPath);

            if (isPreview)
            {
                if (!ExportExcel.ExportThuocXuatHoaDonToExcel(exportFileName, dtpkTuNgay.Value, dtpkDenNgay.Value))
                {
                    return;
                }

                try
                {
                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(template));
                }
                catch (Exception ex)
                {
                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    return;
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (!ExportExcel.ExportThuocXuatHoaDonToExcel(exportFileName, dtpkTuNgay.Value, dtpkDenNgay.Value))
                    {
                        return;
                    }

                    try
                    {
                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(template));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        return;
                    }
                }
            }
        }
示例#11
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            List <DataRow> checkedRows = new List <DataRow>();
            DataTable      dt          = dgMembers.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    checkedRows.Add(row);
                }
            }

            if (checkedRows.Count > 0)
            {
                string exportFileName = string.Format("{0}\\Temp\\DanhSachBenhNhan.xls", Application.StartupPath);
                if (ExportExcel.ExportDanhSachBenhNhanToExcel(exportFileName, checkedRows))
                {
                    try
                    {
                        if (isPreview)
                        {
                            ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.DanhSachBenhNhanTemplate));
                        }
                        else
                        {
                            if (_printDialog.ShowDialog() == DialogResult.OK)
                            {
                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.DanhSachBenhNhanTemplate));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những bệnh nhân cần in.", IconType.Information);
            }
        }
示例#12
0
        private void OnPrint(bool isPreview)
        {
            if (dgLichKham.RowsCount <= 2)
            {
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            string exportFileName = string.Format("{0}\\Temp\\LichKham.xls", Application.StartupPath);

            if (isPreview)
            {
                if (ExportExcel.ExportLichKhamToExcel(exportFileName, dgLichKham, _thangStr, _namStr))
                {
                    try
                    {
                        ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.LichKhamTemplate));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        return;
                    }
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (ExportExcel.ExportLichKhamToExcel(exportFileName, dgLichKham, _thangStr, _namStr))
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.LichKhamTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }
                    }
                }
            }
        }
示例#13
0
 private void OnPrint(bool isPreview)
 {
     try
     {
         string exportFileName = string.Format("{0}\\Temp\\DichVuXetNghiem.xls", Application.StartupPath);
         if (isPreview)
         {
             if (ExportExcel.ExportDichVuXetNghiemToExcel(exportFileName, _tuNgay, _denNgay, _dtSource))
             {
                 try
                 {
                     MethodInvoker method = delegate
                     {
                         ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.PhieuThuThuocTemplate));
                     };
                     if (InvokeRequired)
                     {
                         BeginInvoke(method);
                     }
                     else
                     {
                         method.Invoke();
                     }
                 }
                 catch (Exception ex)
                 {
                     MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                 }
             }
         }
         else
         {
             if (ExportExcel.ExportDichVuXetNghiemToExcel(exportFileName, _tuNgay, _denNgay, _dtSource))
             {
                 MethodInvoker method = delegate
                 {
                     if (_printDialog.ShowDialog() == DialogResult.OK)
                     {
                         try
                         {
                             ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.PhieuThuThuocTemplate));
                         }
                         catch (Exception ex)
                         {
                             MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                         }
                     }
                 };
                 if (InvokeRequired)
                 {
                     BeginInvoke(method);
                 }
                 else
                 {
                     method.Invoke();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MsgBox.Show(Application.ProductName, ex.Message, IconType.Error);
         Utility.WriteToTraceLog(ex.Message);
     }
 }
示例#14
0
        private bool OnPrint(string hoaDonXetNghiemGUID)
        {
            Cursor.Current = Cursors.WaitCursor;
            dlgPrintType dlg = new dlgPrintType();

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string exportFileName = string.Format("{0}\\Temp\\HoaDonXetNghiemYKhoaTemplate.xls", Application.StartupPath);
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (dlg.Lien1)
                    {
                        if (ExportExcel.ExportHoaDonXetNghiemToExcel(exportFileName, hoaDonXetNghiemGUID, "                                                                              Liên 1: Lưu"))
                        {
                            try
                            {
                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.HoaDonXetNghiemYKhoaTemplate));
                            }
                            catch (Exception ex)
                            {
                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }

                    if (dlg.Lien2)
                    {
                        if (ExportExcel.ExportHoaDonXetNghiemToExcel(exportFileName, hoaDonXetNghiemGUID, "                                                                Liên 2: Giao cho người mua"))
                        {
                            try
                            {
                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.HoaDonXetNghiemYKhoaTemplate));
                            }
                            catch (Exception ex)
                            {
                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }

                    if (dlg.Lien3)
                    {
                        if (ExportExcel.ExportHoaDonXetNghiemToExcel(exportFileName, hoaDonXetNghiemGUID, "                                                                        Liên 3: Nội bộ"))
                        {
                            try
                            {
                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.HoaDonXetNghiemYKhoaTemplate));
                            }
                            catch (Exception ex)
                            {
                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
示例#15
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;

            int type = 0;

            if (raDaThuTien.Checked)
            {
                type = 1;
            }
            else if (raChuaThuTien.Checked)
            {
                type = 2;
            }

            string exportFileName = string.Format("{0}\\Temp\\BaoCaoDoanhThuThuocTheoPhieuThu.xls", Application.StartupPath);

            if (isPreview)
            {
                if (!chkGiaNhap.Checked)
                {
                    if (!ExportExcel.ExportDoanhThuThuocTheoPhieuThuKhongGiaNhapToExcel(exportFileName, dtpkTuNgay.Value, dtpkDenNgay.Value, type))
                    {
                        return;
                    }
                }
                else
                {
                    if (!ExportExcel.ExportDoanhThuThuocTheoPhieuThuCoGiaNhapToExcel(exportFileName, dtpkTuNgay.Value, dtpkDenNgay.Value, type))
                    {
                        return;
                    }
                }


                try
                {
                    ExcelPrintPreview.PrintPreview(exportFileName, null);
                }
                catch (Exception ex)
                {
                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    return;
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (!chkGiaNhap.Checked)
                    {
                        if (!ExportExcel.ExportDoanhThuThuocTheoPhieuThuKhongGiaNhapToExcel(exportFileName, dtpkTuNgay.Value, dtpkDenNgay.Value, type))
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (!ExportExcel.ExportDoanhThuThuocTheoPhieuThuCoGiaNhapToExcel(exportFileName, dtpkTuNgay.Value, dtpkDenNgay.Value, type))
                        {
                            return;
                        }
                    }

                    try
                    {
                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        return;
                    }
                }
            }
        }
示例#16
0
        private void OnPrint(bool isPreview)
        {
            List <string> checkedInvoicetList = new List <string>();
            DataTable     dt = dgInvoice.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    checkedInvoicetList.Add(row["HoaDonThuocGUID"].ToString());
                }
            }

            if (checkedInvoicetList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn in những hóa đơn mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    dlgPrintType dlg = new dlgPrintType();
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        string exportFileName = string.Format("{0}\\Temp\\HDGTGT.xls", Application.StartupPath);
                        if (isPreview)
                        {
                            foreach (string hoaDonThuocGUID in checkedInvoicetList)
                            {
                                if (dlg.Lien1)
                                {
                                    if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 1: Lưu"))
                                    {
                                        try
                                        {
                                            ExcelPrintPreview.PrintPreview(exportFileName, null);
                                        }
                                        catch (Exception ex)
                                        {
                                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }

                                if (dlg.Lien2)
                                {
                                    if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                               Liên 2: Giao cho người mua"))
                                    {
                                        try
                                        {
                                            ExcelPrintPreview.PrintPreview(exportFileName, null);
                                        }
                                        catch (Exception ex)
                                        {
                                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }

                                if (dlg.Lien3)
                                {
                                    if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 3: Nội bộ"))
                                    {
                                        try
                                        {
                                            ExcelPrintPreview.PrintPreview(exportFileName, null);
                                        }
                                        catch (Exception ex)
                                        {
                                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (_printDialog.ShowDialog() == DialogResult.OK)
                            {
                                foreach (string hoaDonThuocGUID in checkedInvoicetList)
                                {
                                    if (dlg.Lien1)
                                    {
                                        if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 1: Lưu"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }

                                    if (dlg.Lien2)
                                    {
                                        if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                               Liên 2: Giao cho người mua"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }

                                    if (dlg.Lien3)
                                    {
                                        if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 3: Nội bộ"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những hóa đơn cần in.", IconType.Information);
            }
        }
示例#17
0
        private void OnPrint()
        {
            List <string> checkedInvoicetList = new List <string>();
            List <string> loaiHoaDonList      = new List <string>();
            DataTable     dt = dgInvoice.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    string loaiHoaDon = row["LoaiHoaDon"].ToString();
                    switch (loaiHoaDon)
                    {
                    case "Hóa đơn dịch vụ":
                        if (!Global.AllowPrintHoaDonDichVu)
                        {
                            MsgBox.Show(Application.ProductName, "Bạn không có quyền in hóa đơn dịch vụ. Vui lòng kiểm tra lại", IconType.Information);
                            return;
                        }
                        break;

                    case "Hóa đơn thuốc":
                        if (!Global.AllowPrintHoaDonThuoc)
                        {
                            MsgBox.Show(Application.ProductName, "Bạn không có quyền in hóa đơn thuốc. Vui lòng kiểm tra lại", IconType.Information);
                            return;
                        }
                        break;

                    case "Hóa đơn hợp đồng":
                        if (!Global.AllowPrintHoaDonHopDong)
                        {
                            MsgBox.Show(Application.ProductName, "Bạn không có quyền in hóa đơn hợp đồng. Vui lòng kiểm tra lại", IconType.Information);
                            return;
                        }
                        break;

                    case "Hóa đơn xuất trước":
                        if (!Global.AllowPrintHoaDonXuatTruoc)
                        {
                            MsgBox.Show(Application.ProductName, "Bạn không có quyền in hóa đơn xuất trước. Vui lòng kiểm tra lại", IconType.Information);
                            return;
                        }
                        break;
                    }

                    checkedInvoicetList.Add(row["HoaDonThuocGUID"].ToString());
                    loaiHoaDonList.Add(loaiHoaDon);
                }
            }

            if (checkedInvoicetList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn in những hóa đơn mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    dlgPrintType dlg = new dlgPrintType();
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (_printDialog.ShowDialog() == DialogResult.OK)
                        {
                            string exportFileName = string.Format("{0}\\Temp\\HDGTGT.xls", Application.StartupPath);
                            int    index          = 0;
                            foreach (string hoaDonThuocGUID in checkedInvoicetList)
                            {
                                string loaiHoaDon = loaiHoaDonList[index];
                                if (dlg.Lien1)
                                {
                                    if (loaiHoaDon == "Hóa đơn thuốc")
                                    {
                                        if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 1: Lưu"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else if (loaiHoaDon == "Hóa đơn dịch vụ")
                                    {
                                        if (ExportExcel.ExportInvoiceToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 1: Lưu"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else if (loaiHoaDon == "Hóa đơn xuất trước")
                                    {
                                        if (ExportExcel.ExportHoaDonXuatTruocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 1: Lưu"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        if (ExportExcel.ExportHoaDonHopDongToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 1: Lưu"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }

                                if (dlg.Lien2)
                                {
                                    if (loaiHoaDon == "Hóa đơn thuốc")
                                    {
                                        if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 2: Giao người mua"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else if (loaiHoaDon == "Hóa đơn dịch vụ")
                                    {
                                        if (ExportExcel.ExportInvoiceToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 2: Giao người mua"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else if (loaiHoaDon == "Hóa đơn xuất trước")
                                    {
                                        if (ExportExcel.ExportHoaDonXuatTruocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 2: Giao người mua"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        if (ExportExcel.ExportHoaDonHopDongToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 2: Giao người mua"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }

                                if (dlg.Lien3)
                                {
                                    if (loaiHoaDon == "Hóa đơn thuốc")
                                    {
                                        if (ExportExcel.ExportHoaDonThuocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 3: Nội bộ"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else if (loaiHoaDon == "Hóa đơn dịch vụ")
                                    {
                                        if (ExportExcel.ExportInvoiceToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 3: Nội bộ"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else if (loaiHoaDon == "Hóa đơn xuất trước")
                                    {
                                        if (ExportExcel.ExportHoaDonXuatTruocToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 3: Nội bộ"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        if (ExportExcel.ExportHoaDonHopDongToExcel(exportFileName, hoaDonThuocGUID, "                                   Liên 3: Nội bộ"))
                                        {
                                            try
                                            {
                                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, null);
                                            }
                                            catch (Exception ex)
                                            {
                                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }

                                index++;
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những hóa đơn cần in.", IconType.Information);
            }
        }
示例#18
0
        private void OnPrint(bool isPreview)
        {
            string exportFileName = string.Format("{0}\\Temp\\DoanhThuTheoNgay.xls", Application.StartupPath);

            if (isPreview)
            {
                DateTime tuNgay  = new DateTime(dtpkTuNgay.Value.Year, dtpkTuNgay.Value.Month, dtpkTuNgay.Value.Day, 0, 0, 0);
                DateTime denNgay = new DateTime(dtpkDenNgay.Value.Year, dtpkDenNgay.Value.Month, dtpkDenNgay.Value.Day, 23, 59, 59);
                int      type    = 0;
                if (raAll.Checked)
                {
                    type = 0;
                }
                else if (raDaThuTien.Checked)
                {
                    type = 1;
                }
                else
                {
                    type = 2;
                }
                if (ExportExcel.ExportDoanhThuTheoNgayToExcel(exportFileName, tuNgay, denNgay, type))
                {
                    try
                    {
                        ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.DoanhThuTheoNgayTemplate));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                    }
                }
            }
            else
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    DateTime tuNgay  = new DateTime(dtpkTuNgay.Value.Year, dtpkTuNgay.Value.Month, dtpkTuNgay.Value.Day, 0, 0, 0);
                    DateTime denNgay = new DateTime(dtpkDenNgay.Value.Year, dtpkDenNgay.Value.Month, dtpkDenNgay.Value.Day, 23, 59, 59);
                    int      type    = 0;
                    if (raAll.Checked)
                    {
                        type = 0;
                    }
                    else if (raDaThuTien.Checked)
                    {
                        type = 1;
                    }
                    if (ExportExcel.ExportDoanhThuTheoNgayToExcel(exportFileName, tuNgay, denNgay, type))
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.DoanhThuTheoNgayTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }
                    }
                }
            }
        }
示例#19
0
        private void OnPrint(DataRow drKetQuaNoiSoi)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (_printDialog.ShowDialog() == DialogResult.OK)
            {
                string     exportFileName = string.Format("{0}\\Temp\\KetQuaNoiSoi.xls", Application.StartupPath);
                LoaiNoiSoi type           = (LoaiNoiSoi)Convert.ToByte(drKetQuaNoiSoi["LoaiNoiSoi"]);
                switch (type)
                {
                case LoaiNoiSoi.Tai:
                    if (!ExportExcel.ExportKetQuaNoiSoiTaiToExcel(exportFileName, _patientRow, drKetQuaNoiSoi))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTaiTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }

                        break;
                    }

                case LoaiNoiSoi.Mui:
                    if (!ExportExcel.ExportKetQuaNoiSoiMuiToExcel(exportFileName, _patientRow, drKetQuaNoiSoi))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiMuiTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }

                        break;
                    }

                case LoaiNoiSoi.Hong_ThanhQuan:
                    if (!ExportExcel.ExportKetQuaNoiSoiHongThanhQuanToExcel(exportFileName, _patientRow, drKetQuaNoiSoi))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiHongThanhQuanTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }

                        break;
                    }

                case LoaiNoiSoi.TaiMuiHong:
                    if (!ExportExcel.ExportKetQuaNoiSoiTaiMuiHongToExcel(exportFileName, _patientRow, drKetQuaNoiSoi))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTaiMuiHongTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }

                        break;
                    }

                case LoaiNoiSoi.TongQuat:
                    if (!ExportExcel.ExportKetQuaNoiSoiTongQuatToExcel(exportFileName, _patientRow, drKetQuaNoiSoi))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTongQuatTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }

                        break;
                    }

                case LoaiNoiSoi.DaDay:
                    if (!ExportExcel.ExportKetQuaNoiSoiDaDayToExcel(exportFileName, _patientRow, drKetQuaNoiSoi))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiDaDayTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }

                        break;
                    }

                case LoaiNoiSoi.TrucTrang:
                    if (!ExportExcel.ExportKetQuaNoiSoiTrucTrangToExcel(exportFileName, _patientRow, drKetQuaNoiSoi))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTrucTrangTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }

                        break;
                    }
                }
            }
        }
示例#20
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            List <DataRow> checkedRows = GetCheckedRows();

            if (checkedRows.Count > 0)
            {
                string exportFileName = string.Format("{0}\\Temp\\KetQuaNoiSoi.xls", Application.StartupPath);
                if (isPreview)
                {
                    foreach (DataRow row in checkedRows)
                    {
                        LoaiNoiSoi type = (LoaiNoiSoi)Convert.ToByte(row["LoaiNoiSoi"]);
                        switch (type)
                        {
                        case LoaiNoiSoi.Tai:
                            if (!ExportExcel.ExportKetQuaNoiSoiTaiToExcel(exportFileName, _patientRow, row))
                            {
                                return;
                            }
                            else
                            {
                                try
                                {
                                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTaiTemplate));
                                }
                                catch (Exception ex)
                                {
                                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                    return;
                                }

                                break;
                            }

                        case LoaiNoiSoi.Mui:
                            if (!ExportExcel.ExportKetQuaNoiSoiMuiToExcel(exportFileName, _patientRow, row))
                            {
                                return;
                            }
                            else
                            {
                                try
                                {
                                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiMuiTemplate));
                                }
                                catch (Exception ex)
                                {
                                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                    return;
                                }

                                break;
                            }

                        case LoaiNoiSoi.Hong_ThanhQuan:
                            if (!ExportExcel.ExportKetQuaNoiSoiHongThanhQuanToExcel(exportFileName, _patientRow, row))
                            {
                                return;
                            }
                            else
                            {
                                try
                                {
                                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiHongThanhQuanTemplate));
                                }
                                catch (Exception ex)
                                {
                                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                    return;
                                }

                                break;
                            }

                        case LoaiNoiSoi.TaiMuiHong:
                            if (!ExportExcel.ExportKetQuaNoiSoiTaiMuiHongToExcel(exportFileName, _patientRow, row))
                            {
                                return;
                            }
                            else
                            {
                                try
                                {
                                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTaiMuiHongTemplate));
                                }
                                catch (Exception ex)
                                {
                                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                    return;
                                }

                                break;
                            }

                        case LoaiNoiSoi.TongQuat:
                            if (!ExportExcel.ExportKetQuaNoiSoiTongQuatToExcel(exportFileName, _patientRow, row))
                            {
                                return;
                            }
                            else
                            {
                                try
                                {
                                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTongQuatTemplate));
                                }
                                catch (Exception ex)
                                {
                                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                    return;
                                }

                                break;
                            }

                        case LoaiNoiSoi.DaDay:
                            if (!ExportExcel.ExportKetQuaNoiSoiDaDayToExcel(exportFileName, _patientRow, row))
                            {
                                return;
                            }
                            else
                            {
                                try
                                {
                                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiDaDayTemplate));
                                }
                                catch (Exception ex)
                                {
                                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                    return;
                                }

                                break;
                            }

                        case LoaiNoiSoi.TrucTrang:
                            if (!ExportExcel.ExportKetQuaNoiSoiTrucTrangToExcel(exportFileName, _patientRow, row))
                            {
                                return;
                            }
                            else
                            {
                                try
                                {
                                    ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTrucTrangTemplate));
                                }
                                catch (Exception ex)
                                {
                                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                    return;
                                }

                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (_printDialog.ShowDialog() == DialogResult.OK)
                    {
                        foreach (DataRow row in checkedRows)
                        {
                            LoaiNoiSoi type = (LoaiNoiSoi)Convert.ToByte(row["LoaiNoiSoi"]);
                            switch (type)
                            {
                            case LoaiNoiSoi.Tai:
                                if (!ExportExcel.ExportKetQuaNoiSoiTaiToExcel(exportFileName, _patientRow, row))
                                {
                                    return;
                                }
                                else
                                {
                                    try
                                    {
                                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTaiTemplate));
                                    }
                                    catch (Exception ex)
                                    {
                                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                        return;
                                    }

                                    break;
                                }

                            case LoaiNoiSoi.Mui:
                                if (!ExportExcel.ExportKetQuaNoiSoiMuiToExcel(exportFileName, _patientRow, row))
                                {
                                    return;
                                }
                                else
                                {
                                    try
                                    {
                                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiMuiTemplate));
                                    }
                                    catch (Exception ex)
                                    {
                                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                        return;
                                    }

                                    break;
                                }

                            case LoaiNoiSoi.Hong_ThanhQuan:
                                if (!ExportExcel.ExportKetQuaNoiSoiHongThanhQuanToExcel(exportFileName, _patientRow, row))
                                {
                                    return;
                                }
                                else
                                {
                                    try
                                    {
                                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiHongThanhQuanTemplate));
                                    }
                                    catch (Exception ex)
                                    {
                                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                        return;
                                    }

                                    break;
                                }

                            case LoaiNoiSoi.TaiMuiHong:
                                if (!ExportExcel.ExportKetQuaNoiSoiTaiMuiHongToExcel(exportFileName, _patientRow, row))
                                {
                                    return;
                                }
                                else
                                {
                                    try
                                    {
                                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTaiMuiHongTemplate));
                                    }
                                    catch (Exception ex)
                                    {
                                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                        return;
                                    }

                                    break;
                                }

                            case LoaiNoiSoi.TongQuat:
                                if (!ExportExcel.ExportKetQuaNoiSoiTongQuatToExcel(exportFileName, _patientRow, row))
                                {
                                    return;
                                }
                                else
                                {
                                    try
                                    {
                                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTongQuatTemplate));
                                    }
                                    catch (Exception ex)
                                    {
                                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                        return;
                                    }

                                    break;
                                }

                            case LoaiNoiSoi.DaDay:
                                if (!ExportExcel.ExportKetQuaNoiSoiDaDayToExcel(exportFileName, _patientRow, row))
                                {
                                    return;
                                }
                                else
                                {
                                    try
                                    {
                                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiDaDayTemplate));
                                    }
                                    catch (Exception ex)
                                    {
                                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                        return;
                                    }

                                    break;
                                }

                            case LoaiNoiSoi.TrucTrang:
                                if (!ExportExcel.ExportKetQuaNoiSoiTrucTrangToExcel(exportFileName, _patientRow, row))
                                {
                                    return;
                                }
                                else
                                {
                                    try
                                    {
                                        ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaNoiSoiTrucTrangTemplate));
                                    }
                                    catch (Exception ex)
                                    {
                                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                        return;
                                    }

                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những kết quả nội soi cần in.", IconType.Information);
            }
        }
示例#21
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            List <DataRow> checkedRows = GetCheckedRows();

            if (checkedRows.Count > 0)
            {
                string exportFileName = string.Format("{0}\\Temp\\KetQuaSoiCTC.xls", Application.StartupPath);
                if (isPreview)
                {
                    foreach (DataRow row in checkedRows)
                    {
                        if (!ExportExcel.ExportKetQuaSoiCTCToExcel(exportFileName, _patientRow, row))
                        {
                            return;
                        }
                        else
                        {
                            try
                            {
                                ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaSoiCTCTemplate));
                            }
                            catch (Exception ex)
                            {
                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                return;
                            }
                        }
                    }
                }
                else
                {
                    if (_printDialog.ShowDialog() == DialogResult.OK)
                    {
                        foreach (DataRow row in checkedRows)
                        {
                            if (!ExportExcel.ExportKetQuaSoiCTCToExcel(exportFileName, _patientRow, row))
                            {
                                return;
                            }
                            else
                            {
                                try
                                {
                                    ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.KetQuaSoiCTCTemplate));
                                }
                                catch (Exception ex)
                                {
                                    MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những kết quả soi cần in.", IconType.Information);
            }
        }
示例#22
0
        private void OnPrint()
        {
            List <DataRow> checkedRows = _dictPatient.Values.ToList();

            if (checkedRows.Count > 0)
            {
                if (_printDialog.ShowDialog() == DialogResult.OK)
                {
                    foreach (DataRow row in checkedRows)
                    {
                        string contractMemberGUID = row["ContractMemberGUID"].ToString();
                        Result result             = MauHoSoBus.GetMauChayHoSo(contractMemberGUID, _hopDongGUID);
                        if (!result.IsOK)
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("MauHoSoBus.GetMauChayHoSo"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("MauHoSoBus.GetMauChayHoSo"));
                            return;
                        }

                        List <MauHoSo> mauHoSoList = result.QueryResult as List <MauHoSo>;
                        if (mauHoSoList == null || mauHoSoList.Count <= 0)
                        {
                            continue;
                        }

                        result = MauHoSoBus.GetDichVuChayMauHoSo(contractMemberGUID, _hopDongGUID);
                        if (!result.IsOK)
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("MauHoSoBus.GetDichVuChayMauHoSo"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("MauHoSoBus.GetDichVuChayMauHoSo"));
                            return;
                        }

                        DataTable dtAllService = result.QueryResult as DataTable;
                        DataRow[] serviceRows3 = dtAllService.Select(string.Format("Loai=3"));
                        if (serviceRows3 != null && serviceRows3.Length > 0)
                        {
                            foreach (DataRow r in serviceRows3)
                            {
                                string serviceName         = r["Name"].ToString();
                                bool   isNormal_Abnormal   = Convert.ToBoolean(r["Normal_Abnormal"]);
                                bool   isNegative_Positive = Convert.ToBoolean(r["Negative_Positive"]);
                                if (!isNormal_Abnormal && !isNegative_Positive)
                                {
                                    MsgBox.Show(Application.ProductName, string.Format("Dịch vụ: '{0}' chưa được cấu hình. Vui lòng cấu hình cho dịch vụ này.", serviceName),
                                                IconType.Information);
                                    return;
                                }
                            }
                        }

                        foreach (MauHoSo mauHoSo in mauHoSoList)
                        {
                            try
                            {
                                object fileName = GetMauHoSoTemplate(mauHoSo);
                                Utility.CopyTemplates(fileName.ToString());

                                object reportFileName = string.Format("{0}\\Temp\\{1}", Application.StartupPath, Path.GetFileName(fileName.ToString()));
                                File.Copy(fileName.ToString(), reportFileName.ToString(), true);

                                if (mauHoSo.Loai == 1)
                                {
                                    DataRow[] serviceRows = dtAllService.Select(string.Format("Loai=1"));
                                    ExportWord.PrintXetNghiem(reportFileName, row, serviceRows,
                                                              ExcelPrintPreview.ConvertToExcelPrinterFriendlyName(_printDialog.PrinterSettings.PrinterName), true);
                                }
                                else if (mauHoSo.Loai == 2)
                                {
                                    DataRow[] serviceRows = dtAllService.Select(string.Format("Loai=2"));
                                    ExportWord.PrintChecklist(reportFileName, row, serviceRows,
                                                              ExcelPrintPreview.ConvertToExcelPrinterFriendlyName(_printDialog.PrinterSettings.PrinterName), true);
                                }
                                else if (mauHoSo.Loai == 3)
                                {
                                    DataRow[] serviceRows = dtAllService.Select(string.Format("Loai=3"));
                                    ExportWord.PrintKetQuaCanLamSang(reportFileName, row, serviceRows,
                                                                     ExcelPrintPreview.ConvertToExcelPrinterFriendlyName(_printDialog.PrinterSettings.PrinterName), true);
                                }
                                else
                                {
                                    ExportWord.PrintMauHoSoChung(reportFileName, row,
                                                                 ExcelPrintPreview.ConvertToExcelPrinterFriendlyName(_printDialog.PrinterSettings.PrinterName), true);
                                }
                            }
                            catch (Exception ex)
                            {
                                MsgBox.Show(Application.ProductName, ex.Message, IconType.Error);
                                Utility.WriteToTraceLog(ex.Message);
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những bệnh nhân cần in.", IconType.Information);
            }
        }
示例#23
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            //List<DataRow> checkedRows = GetChiDinhDuocXacNhan();
            List <DataRow> checkedRows = new List <DataRow>();
            DataTable      dt          = dgChiTiet.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    string chiTietChiDinhGUID = row["ChiTietChiDinhGUID"].ToString();
                    if (_dtDichVuChiDinh == null && _dtDichVuChiDinh.Rows.Count <= 0)
                    {
                        MsgBox.Show(Application.ProductName, "Không thể in vì có 1 số chỉ định chưa được xác nhận.", IconType.Information);
                        return;
                    }
                    else
                    {
                        DataRow[] rows = _dtDichVuChiDinh.Select(string.Format("ChiTietChiDinhGUID='{0}'", chiTietChiDinhGUID));
                        if (rows != null && rows.Length > 0)
                        {
                            checkedRows.Add(row);
                        }
                        else
                        {
                            MsgBox.Show(Application.ProductName, "Không thể in vì có 1 số chỉ định chưa được xác nhận.", IconType.Information);
                            return;
                        }
                    }
                }
            }

            if (checkedRows.Count > 0)
            {
                string exportFileName = string.Format("{0}\\Temp\\ChiDinh.xls", Application.StartupPath);
                if (isPreview)
                {
                    if (!ExportExcel.ExportChiDinhToExcel(exportFileName, _patientRow, checkedRows))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.ChiDinhTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        }
                    }
                }
                else
                {
                    if (_printDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (!ExportExcel.ExportChiDinhToExcel(exportFileName, _patientRow, checkedRows))
                        {
                            return;
                        }
                        else
                        {
                            try
                            {
                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.ChiDinhTemplate));
                            }
                            catch (Exception ex)
                            {
                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những chỉ định cần in.", IconType.Information);
            }
        }
示例#24
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;
            List <DataRow> checkedRows = GetCheckedRows();

            if (!AllowExportAll)
            {
                foreach (DataRow row in checkedRows)
                {
                    string userGUID = row["CreatedBy"].ToString();
                    if (userGUID != Global.UserGUID)
                    {
                        MsgBox.Show(Application.ProductName, "Bạn chỉ có thể in được liên hệ công ty do mình tạo. Vui lòng chọn lại.", IconType.Information);
                        return;
                    }
                }
            }

            if (checkedRows.Count > 0)
            {
                string exportFileName = string.Format("{0}\\Temp\\NhatKyLienHeCongTy.xls", Application.StartupPath);
                if (isPreview)
                {
                    if (!ExportExcel.ExportNhatKyLienHeCongTyToExcel(exportFileName, checkedRows))
                    {
                        return;
                    }
                    else
                    {
                        try
                        {
                            ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(Const.NhatKyLienHeCongTyTemplate));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }
                    }
                }
                else
                {
                    if (_printDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (!ExportExcel.ExportNhatKyLienHeCongTyToExcel(exportFileName, checkedRows))
                        {
                            return;
                        }
                        else
                        {
                            try
                            {
                                ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(Const.NhatKyLienHeCongTyTemplate));
                            }
                            catch (Exception ex)
                            {
                                MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                                return;
                            }
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những nhật ký liên hệ cần in.", IconType.Information);
            }
        }
示例#25
0
        private void OnPrint(bool isPreview)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (cboHopDong.SelectedValue != null && cboHopDong.Text.Trim() != string.Empty)
            {
                string  hopDongGUID = cboHopDong.SelectedValue.ToString();
                DataRow row         = GetHopDongRow(hopDongGUID);
                string  template    = raTongHop.Checked ? Const.BaoCaoCongNoHopDongTongHopTemplate : Const.BaoCaoCongNoHopDongChiTietTemplate;

                string exportFileName = string.Format("{0}\\Temp\\BaoCaoCongNoHopDong.xls", Application.StartupPath);
                if (isPreview)
                {
                    //if (raTongHop.Checked)
                    //{
                    //    if (!ExportExcel.ExportCongNoHopDongTongHopToExcel(exportFileName, hopDongGUID, row["ContractCode"].ToString(), cboHopDong.Text))
                    //        return;
                    //}
                    //else
                    //{
                    //    if (!ExportExcel.ExportCongNoHopDongChiTietToExcel(exportFileName, hopDongGUID, row["ContractCode"].ToString(), cboHopDong.Text))
                    //        return;
                    //}

                    if (!ExportExcel.ExportCongNoHopDongToExcel(exportFileName, hopDongGUID, row["ContractCode"].ToString(), cboHopDong.Text))
                    {
                        return;
                    }

                    try
                    {
                        ExcelPrintPreview.PrintPreview(exportFileName, Global.PageSetupConfig.GetPageSetup(template));
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                        return;
                    }
                }
                else
                {
                    if (_printDialog.ShowDialog() == DialogResult.OK)
                    {
                        //if (raTongHop.Checked)
                        //{
                        //    if (!ExportExcel.ExportCongNoHopDongTongHopToExcel(exportFileName, hopDongGUID, row["ContractCode"].ToString(), cboHopDong.Text))
                        //    return;
                        //}
                        //else
                        //{
                        //    if (!ExportExcel.ExportCongNoHopDongChiTietToExcel(exportFileName, hopDongGUID, row["ContractCode"].ToString(), cboHopDong.Text))
                        //    return;
                        //}

                        if (!ExportExcel.ExportCongNoHopDongToExcel(exportFileName, hopDongGUID, row["ContractCode"].ToString(), cboHopDong.Text))
                        {
                            return;
                        }

                        try
                        {
                            ExcelPrintPreview.Print(exportFileName, _printDialog.PrinterSettings.PrinterName, Global.PageSetupConfig.GetPageSetup(template));
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show(Application.ProductName, "Vui lòng kiểm tra lại máy in.", IconType.Error);
                            return;
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng chọn hợp đồng cần xem.", IconType.Information);
            }
        }