private void gridPrintoutView_DoubleClick(object sender, EventArgs e) { PrintLogMeta printLogMeta = (PrintLogMeta)gridView5.GetFocusedRow(); int ID = printLogMeta.ID; HCMIS.Core.Distribution.Services.PrintLogService printout = new HCMIS.Core.Distribution.Services.PrintLogService(); using (SaveFileDialog SaveDialog = new SaveFileDialog()) { SaveDialog.DefaultExt = ".pdf"; if (SaveDialog.ShowDialog() != DialogResult.Cancel) { printout.ToFile(ID, SaveDialog.FileName); XtraMessageBox.Show("Your PDF is Exported", "Thanks"); } } }
private void gridPrintLogView_DoubleClick(object sender, EventArgs e) { PrintLogMeta printLog = (PrintLogMeta)gridPrintLogView.GetFocusedRow(); if (printLog != null) { int ID = printLog.ID; HCMIS.Core.Distribution.Services.PrintLogService printout = new HCMIS.Core.Distribution.Services.PrintLogService(); using (SaveFileDialog SaveDialog = new SaveFileDialog()) { SaveDialog.DefaultExt = ".pdf"; if (SaveDialog.ShowDialog() != DialogResult.Cancel) { printout.ToFile(ID, SaveDialog.FileName); XtraMessageBox.Show("Your PDF is Exported", "Thanks"); } } } }
private void btnPrintLogSaveAll_Click(object sender, EventArgs e) { using (SaveFileDialog SaveDialog = new SaveFileDialog()) { if (SaveDialog.ShowDialog() != DialogResult.Cancel) { HCMIS.Core.Distribution.Services.PrintLogService printout = new HCMIS.Core.Distribution.Services.PrintLogService(); IEnumerable <HCMIS.Core.Distribution.Services.PrintLogMeta> logs = (IEnumerable <HCMIS.Core.Distribution.Services.PrintLogMeta>)gridPrintLog.DataSource; if (logs != null) { foreach (var log in logs) { string fileName = SaveDialog.FileName + "_" + ((log.PrintedID != null) ?log.PrintedID : log.Reference) + "_" + MakeValidFileName(log.Description) + ".pdf"; printout.ToFile(log.ID, fileName); } XtraMessageBox.Show("All PDFs Exported", "Thanks"); } } } }
private static void SavePdfReport(PrintLogService pLogService, XtraReport stvReport) { // This STV Log is Highly experimental, // TODO: remove this try catch when the method is stable. try { DataTable dtbl = (DataTable)stvReport.DataSource; var refNumber = (from v in dtbl.AsEnumerable() select Convert.ToInt32(v["STVNumber"])).Distinct().ToList(); int i = 0; foreach (DevExpress.XtraPrinting.Page page in stvReport.Pages) { HCMIS.Desktop.Reports.STVonHeadedPaper xReport = new HCMIS.Desktop.Reports.STVonHeadedPaper(); xReport.Pages.Add(page); MemoryStream stream = new MemoryStream(); xReport.ExportToPdf(stream); pLogService.SaveLog(stream, "STV", true, refNumber[i], CurrentContext.UserId, BLL.DateTimeHelper.ServerDateTime); i++; } } catch { // } }
/// <summary> /// Saves the and print STV. /// </summary> /// <param name="pickListDetail">The pick list detail.</param> /// <param name="deliveryNotePrinter">The delivery note printer.</param> /// <param name="stvPrinterName">Name of the STV printer.</param> /// <param name="dtDate">The dt date.</param> /// <param name="dtCurrent">The dt current.</param> /// <exception cref="System.Exception"></exception> private XtraReport SaveAndPrintSTV(DataView pickListDetail, bool isDeliveryNote, string printerName, DateTimePickerEx dtDate, DateTime dtCurrent) { HCMIS.Core.Distribution.Services.PrintLogService pLogService = new HCMIS.Core.Distribution.Services.PrintLogService(); pLogService.StartPrintingSession(); Order ord = IssueDoc.SaveIssueTransaction(_orderID, ref pickListDetail, txtRemarks.Text, CurrentContext.LoggedInUserName, dtCurrent); if (pickListDetail.Count == 0) throw new Exception("An error occurred during saving the issue. Please contact your administrator."); string sendToString = ""; BLL.Order ordr = new BLL.Order(); ordr.LoadByPrimaryKey(_orderID); BLL.Institution rus = new Institution(); if (!ordr.IsColumnNull("RequestedBy")) { rus.LoadByPrimaryKey(ordr.RequestedBy); sendToString = rus.Name; } else if (!ordr.IsColumnNull("OrderTypeID") && ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER) { BLL.Transfer transfer = new Transfer(); transfer.LoadByOrderID(_orderID); var activity = new Activity(); activity.LoadByPrimaryKey(transfer.ToStoreID); sendToString = activity.FullActivityName; } PickList pl = new PickList(); pl.LoadByOrderID(ord.ID); var xtraReport = new XtraReport(); if (ord.PaymentTypeID == PaymentType.Constants.CASH) { xtraReport = FormatCashInvoice(ord, pickListDetail.Table, rus, pl, isDeliveryNote, printerName, pLogService); } else if (ord.PaymentTypeID == PaymentType.Constants.CREDIT) { xtraReport = FormatCreditInvoice(ord, pickListDetail.Table, rus, pl, isDeliveryNote, printerName, pLogService); } else if (ord.PaymentTypeID == PaymentType.Constants.STV) { xtraReport = FormatSTV(ord, pickListDetail.Table, sendToString, pl, isDeliveryNote, printerName, pLogService, _orderID); } SavePdfReport(pLogService, xtraReport); pLogService.CommitPrintLog(); return xtraReport; }
private void btnPrintLogSaveAll_Click(object sender, EventArgs e) { using (SaveFileDialog SaveDialog = new SaveFileDialog()) { if (SaveDialog.ShowDialog() != DialogResult.Cancel) { HCMIS.Core.Distribution.Services.PrintLogService printout = new HCMIS.Core.Distribution.Services.PrintLogService(); IEnumerable<HCMIS.Core.Distribution.Services.PrintLogMeta> logs = (IEnumerable<HCMIS.Core.Distribution.Services.PrintLogMeta>) gridPrintLog.DataSource; if (logs != null) { foreach (var log in logs) { string fileName = SaveDialog.FileName + "_" + ((log.PrintedID != null) ?log.PrintedID : log.Reference) + "_" + MakeValidFileName(log.Description) + ".pdf"; printout.ToFile(log.ID, fileName); } XtraMessageBox.Show("All PDFs Exported","Thanks"); } } } }
/// <summary> /// Formats the cash invoice. /// </summary> /// <param name="ord">The ord.</param> /// <param name="dvPriced">The dv priced.</param> /// <param name="rus">The rus.</param> /// <param name="pl">The pl.</param> /// <param name="deliveryNote">if set to <c>true</c> [delivery note].</param> /// <param name="allowCancelByUser">if set to <c>true</c> [allow cancel by user].</param> /// <exception cref="System.Exception"></exception> private XtraReport FormatCashInvoice_Smaller(Order ord, DataTable dvPriced, BLL.Institution rus, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService) { string activityName = txtConfirmFromStore.Text; bool hasInsurnance = chkIncludeInsurance.Checked; return(WorkflowReportFactory.CreateCashInvoiceSmaller(ord, dvPriced, rus, pl, deliveryNote, hasInsurnance, activityName)); }
/// <summary> /// Formats the cash invoice. /// </summary> /// <param name="ord">The ord.</param> /// <param name="dvPriced">The dv priced.</param> /// <param name="rus">The rus.</param> /// <param name="pl">The pl.</param> /// <param name="deliveryNote">if set to <c>true</c> [delivery note].</param> /// <param name="allowCancelByUser">if set to <c>true</c> [allow cancel by user].</param> /// <exception cref="System.Exception"></exception> private XtraReport FormatCashInvoice(Order ord, DataTable dvPriced, BLL.Institution rus, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService) { if (BLL.Settings.UseSmallerCashPrintout) { return(FormatCashInvoice_Smaller(ord, dvPriced, rus, pl, deliveryNote, printerName, pLogService)); } return(FormatCashInvoice_Larger(ord, dvPriced, rus, pl, deliveryNote, printerName, pLogService)); }
private XtraReport FormatCreditInvoice_Larger(DataTable dvPriced, Order ord, PickList pl, Institution rus, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService) { bool hasInsurance = chkIncludeInsurance.Checked; string activityName = txtConfirmFromStore.Text; return(WorkflowReportFactory.CreateCreditInvoice(dvPriced, ord, pl, rus, deliveryNote, hasInsurance, activityName, true, null)); }
/// <summary> /// Formats the STV. /// </summary> /// <param name="ord">The ord.</param> /// <param name="dvPriced">The dv priced.</param> /// <param name="stvSentTo">The STV sent to.</param> /// <param name="pl">The pl.</param> /// <param name="deliveryNote">if set to <c>true</c> [delivery note].</param> /// <param name="allowCancelByUser">if set to <c>true</c> [allow cancel by user].</param> /// <exception cref="System.Exception"></exception> private XtraReport FormatSTV(Order ord, DataTable dvPriced, string stvSentTo, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int orderID) { bool hasInsurance = chkIncludeInsurance.Checked; string accountName = txtConfirmFromStore.Text; string transferType = null; int?orderTypeID = null; BLL.Order order = new Order(); order.LoadByPrimaryKey(orderID); if (!order.IsColumnNull("OrderTypeID")) { orderTypeID = Convert.ToInt32(ord.GetColumn("OrderTypeID")); } string transferDetail = ""; if (orderTypeID.HasValue) { BLL.Transfer transfer = new Transfer(); if (orderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER) { transfer.LoadByOrderID(orderID); PhysicalStore toStore = new PhysicalStore(); toStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID); BLL.Warehouse toWarehouse = new BLL.Warehouse(); toWarehouse.LoadByPrimaryKey(toStore.PhysicalStoreTypeID); transferType = "Store to Store Transfer"; stvSentTo = toWarehouse.Name; } if (orderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER) { transfer.LoadByOrderID(orderID); Activity fromActivity = new Activity(); fromActivity.LoadByPrimaryKey(transfer.FromStoreID); Activity toActivity = new Activity(); toActivity.LoadByPrimaryKey(transfer.ToStoreID); transferType = "Account to Account Transfer"; transferDetail = string.Format("From: {0} To: {1}", fromActivity.FullActivityName, toActivity.FullActivityName); } } if (!deliveryNote) { if (InstitutionIType.IsVaccine(GeneralInfo.Current)) { return(WorkflowReportFactory.CreateModel22(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType)); } var stvReport = WorkflowReportFactory.CreateSTVonHeadedPaper(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType); if (transferDetail != "") { stvReport.TransferDetails.Text = transferDetail; stvReport.TransferDetails.Visible = true; } else { stvReport.TransferDetails.Visible = false; } return(stvReport); } else { return(WorkflowReportFactory.CreateDeliveryNote(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType)); } }
/// <summary> /// Saves the and print STV. /// </summary> /// <param name="pickListDetail">The pick list detail.</param> /// <param name="deliveryNotePrinter">The delivery note printer.</param> /// <param name="stvPrinterName">Name of the STV printer.</param> /// <param name="dtDate">The dt date.</param> /// <param name="dtCurrent">The dt current.</param> /// <exception cref="System.Exception"></exception> private XtraReport SaveAndPrintSTV(DataView pickListDetail, bool isDeliveryNote, string printerName, DateTimePickerEx dtDate, DateTime dtCurrent) { HCMIS.Core.Distribution.Services.PrintLogService pLogService = new HCMIS.Core.Distribution.Services.PrintLogService(); pLogService.StartPrintingSession(); Order ord = IssueDoc.SaveIssueTransaction(_orderID, ref pickListDetail, txtRemarks.Text, CurrentContext.LoggedInUserName, dtCurrent); if (pickListDetail.Count == 0) { throw new Exception("An error occurred during saving the issue. Please contact your administrator."); } string sendToString = ""; BLL.Order ordr = new BLL.Order(); ordr.LoadByPrimaryKey(_orderID); BLL.Institution rus = new Institution(); if (!ordr.IsColumnNull("RequestedBy")) { rus.LoadByPrimaryKey(ordr.RequestedBy); sendToString = rus.Name; } else if (!ordr.IsColumnNull("OrderTypeID") && ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER) { BLL.Transfer transfer = new Transfer(); transfer.LoadByOrderID(_orderID); var activity = new Activity(); activity.LoadByPrimaryKey(transfer.ToStoreID); sendToString = activity.FullActivityName; } PickList pl = new PickList(); pl.LoadByOrderID(ord.ID); var xtraReport = new XtraReport(); if (ord.PaymentTypeID == PaymentType.Constants.CASH) { xtraReport = FormatCashInvoice(ord, pickListDetail.Table, rus, pl, isDeliveryNote, printerName, pLogService); } else if (ord.PaymentTypeID == PaymentType.Constants.CREDIT) { xtraReport = FormatCreditInvoice(ord, pickListDetail.Table, rus, pl, isDeliveryNote, printerName, pLogService); } else if (ord.PaymentTypeID == PaymentType.Constants.STV) { xtraReport = FormatSTV(ord, pickListDetail.Table, sendToString, pl, isDeliveryNote, printerName, pLogService, _orderID); } SavePdfReport(pLogService, xtraReport); pLogService.CommitPrintLog(); return(xtraReport); }