/// <summary> /// Print Tender Removal Receipt /// </summary> /// <param name="posTransaction">RemoveTenderTransaction</param> public void PrintRemoveTenderReceipt(IPosTransaction posTransaction) { if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled()) { FiscalPrinter.FiscalPrinter.Instance.PrintRemoveTender(posTransaction); return; } bool copyReceipt = false; PrintingActions.Print(FormType.RemoveTender, copyReceipt, false, delegate(FormModulation formMod, FormInfo formInfo) { StringBuilder reportLayout = new StringBuilder(); PrintingActions.PrepareReceiptHeader(reportLayout, posTransaction, 10063, copyReceipt); reportLayout.AppendLine(PrintingActions.SingleLine); reportLayout.AppendLine(); RemoveTenderTransaction asRemoveTenderTransaction = (RemoveTenderTransaction)posTransaction; reportLayout.AppendLine(PrintingActions.FormatTenderLine(ApplicationLocalizer.Language.Translate(10064), Printing.InternalApplication.Services.Rounding.Round(asRemoveTenderTransaction.Amount, true))); reportLayout.AppendLine(asRemoveTenderTransaction.Description.ToString()); reportLayout.AppendLine(); reportLayout.AppendLine(PrintingActions.DoubleLine); formMod = new FormModulation(Application.Settings.Database.Connection); formInfo = formMod.GetInfoForForm(FormType.FloatEntry, copyReceipt, LSRetailPosis.Settings.HardwareProfiles.Printer.ReceiptProfileId); return(reportLayout.ToString()); }); }
/// <summary> /// Print Float Entry Receipt /// </summary> /// <param name="posTransaction">FloatEntryTransaction</param> public void PrintFloatEntryReceipt(IPosTransaction posTransaction) { if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled()) { FiscalPrinter.FiscalPrinter.Instance.PrintFloatEntry(posTransaction); return; } bool copyReceipt = false; PrintingActions.Print(FormType.FloatEntry, copyReceipt, false, delegate(FormModulation formMod, FormInfo formInfo) { StringBuilder reportLayout = new StringBuilder(); FloatEntryTransaction asFloatEntryTransaction = (FloatEntryTransaction)posTransaction; PrintingActions.PrepareReceiptHeader(reportLayout, posTransaction, 10061, copyReceipt); reportLayout.AppendLine(PrintingActions.SingleLine); reportLayout.AppendLine(); reportLayout.AppendLine(PrintingActions.FormatTenderLine(ApplicationLocalizer.Language.Translate(10062), Printing.InternalApplication.Services.Rounding.Round(asFloatEntryTransaction.Amount, true))); reportLayout.AppendLine(asFloatEntryTransaction.Description.ToString()); reportLayout.AppendLine(); reportLayout.AppendLine(PrintingActions.DoubleLine); return(reportLayout.ToString()); }); }
/// <summary> /// Print pack slip. /// </summary> /// <param name="posTransaction">Transaction instance.</param> public void PrintPackSlip(IPosTransaction posTransaction) { bool copyReceipt = false; FormType formType = FormType.PackingSlip; PrintingActions.Print(formType, copyReceipt, true, delegate(FormModulation formMod, FormInfo formInfo) { formMod.GetTransformedTransaction(formInfo, (RetailTransaction)posTransaction); return(formInfo.Header + formInfo.Details + formInfo.Footer); }); }
/// <summary> /// Print Tender Decaraton Receipt /// </summary> /// <param name="posTransaction">TenderDeclarationTransaction</param> public void PrintTenderDeclaration(IPosTransaction posTransaction) { bool copyReceipt = false; PrintingActions.Print(FormType.TenderDeclaration, copyReceipt, false, delegate(FormModulation formMod, FormInfo formInfo) { StringBuilder reportLayout = new StringBuilder(); PrintingActions.PrepareReceiptHeader(reportLayout, posTransaction, 10065, copyReceipt); reportLayout.AppendLine(PrintingActions.SingleLine); PrintingActions.PrepareReceiptTenders(reportLayout, posTransaction); reportLayout.AppendLine(PrintingActions.DoubleLine); return(reportLayout.ToString()); }); }
/// <summary> /// Print balance of credit card memo. /// </summary> /// <param name="formType"></param> /// <param name="balance"></param> /// <param name="copyReceipt"></param> public void PrintCreditMemoBalance(FormType formType, Decimal balance, bool copyReceipt) { PrintingActions.Print(formType, copyReceipt, true, delegate(FormModulation formMod, FormInfo formInfo) { IRetailTransaction tr = Printing.InternalApplication.BusinessLogic.Utility.CreateRetailTransaction( ApplicationSettings.Terminal.StoreId, ApplicationSettings.Terminal.StoreCurrency, ApplicationSettings.Terminal.TaxIncludedInPrice, Printing.InternalApplication.Services.Rounding); tr.AmountToAccount = balance; formMod.GetTransformedTransaction(formInfo, (RetailTransaction)tr); return(formInfo.Header); }); }
/// <summary> /// Prints to printer. /// </summary> /// <param name="printerMap">The printer map.</param> /// <param name="formMod">The form mod.</param> /// <param name="formType">Type of the form.</param> /// <param name="posTransaction">The pos transaction.</param> /// <param name="copyReceipt">if set to <c>true</c> [copy receipt].</param> /// <returns></returns> internal static bool PrintFormTransaction( PrinterAssociation printerMap, FormModulation formMod, FormType formType, IPosTransaction posTransaction, bool copyReceipt) { FormInfo formInfo = printerMap.PrinterFormInfo; bool result = false; // Checking for header only. if (formInfo.HeaderTemplate == null) { // Note: This is allowed now that we have multiple printers... result = false; } else if (PrintingActions.ShouldWePrint(formInfo, formType, copyReceipt, printerMap)) { result = true; try { formMod.GetTransformedTransaction(formInfo, (RetailTransaction)posTransaction); if (formInfo.PrintAsSlip) { printerMap.Printer.PrintSlip(formInfo.Header, formInfo.Details, formInfo.Footer); } else { // Note: In this API Errors are handled in the printer and exceptions do not bubble up. printerMap.Printer.PrintReceipt(formInfo.Header + formInfo.Details + formInfo.Footer); } } catch (Exception ex) { NetTracer.Warning("Printing [Printing] - Exception while printing receipt"); POSFormsManager.ShowPOSErrorDialog(new PosisException(1003, ex)); result = false; } } return(result); }
/// <summary> /// Print form layout with specified content /// </summary> /// <param name="formType">Form type.</param> /// <param name="copyReceipt">Flag to identify if this is a copy.</param> /// <param name="getPrintTextHandler">Handler that is called to construct text for printing.</param> internal static void Print( FormType formType, bool copyReceipt, bool formInfoTemplateRequired, GetTextHandler getPrintTextHandler) { if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled() && (formType == FormType.GiftCertificate || formType == FormType.TenderDeclaration)) { FiscalPrinter.FiscalPrinter.Instance.PrintReceipt(getPrintTextHandler(null, null)); } FormModulation formMod = new FormModulation(Printing.InternalApplication.Settings.Database.Connection); IList <PrinterAssociation> printerMapping = PrintingActions.GetActivePrinters(formMod, formType, copyReceipt); foreach (PrinterAssociation printerMap in printerMapping) { PrintFormLayout(printerMap, formMod, formType, copyReceipt, formInfoTemplateRequired, getPrintTextHandler); } }
public void PrintGiftCertificate(FormType formType, IPosTransaction posTransaction, IGiftCardLineItem giftCardLineItem, bool copyReceipt) { PrintingActions.Print(formType, copyReceipt, false, delegate(FormModulation formMod, FormInfo formInfo) { StringBuilder reportLayout = new StringBuilder(); PrintingActions.PrepareReceiptHeader(reportLayout, posTransaction, 10068, copyReceipt); reportLayout.AppendLine(PrintingActions.SingleLine); reportLayout.AppendLine(); reportLayout.AppendLine(PrintingActions.FormatTenderLine(ApplicationLocalizer.Language.Translate(10070), giftCardLineItem.SerialNumber)); reportLayout.AppendLine(PrintingActions.FormatTenderLine(ApplicationLocalizer.Language.Translate(10071), Printing.InternalApplication.Services.Rounding.RoundForDisplay(giftCardLineItem.Balance, true, true))); reportLayout.AppendLine(); reportLayout.AppendLine(PrintingActions.DoubleLine); return(reportLayout.ToString()); }); }
/// <summary> /// Print safe drop Receipt /// </summary> /// <param name="posTransaction">SafeDropTransaction</param> public void PrintSafeDrop(IPosTransaction posTransaction) { if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled()) { FiscalPrinter.FiscalPrinter.Instance.PrintSafeDrop(posTransaction); return; } bool copyReceipt = false; PrintingActions.Print(FormType.SafeDrop, copyReceipt, false, delegate(FormModulation formMod, FormInfo formInfo) { StringBuilder reportLayout = new StringBuilder(); PrintingActions.PrepareReceiptHeader(reportLayout, posTransaction, 10067, copyReceipt); reportLayout.AppendLine(PrintingActions.SingleLine); PrintingActions.PrepareReceiptTenders(reportLayout, posTransaction); reportLayout.AppendLine(PrintingActions.DoubleLine); return(reportLayout.ToString()); }); }
/// <summary> /// Print declare starting amount receipt /// </summary> /// <param name="posTransaction">FloatEntryTransaction</param> public void PrintStartngAmountReceipt(IPosTransaction posTransaction) { bool copyReceipt = false; PrintingActions.Print(FormType.FloatEntry, copyReceipt, false, delegate(FormModulation formMod, FormInfo formInfo) { StringBuilder reportLayout = new StringBuilder(); StartingAmountTransaction startingAmountTransaction = (StartingAmountTransaction)posTransaction; PrintingActions.PrepareReceiptHeader(reportLayout, posTransaction, 10077, false); reportLayout.AppendLine(PrintingActions.SingleLine); reportLayout.AppendLine(); reportLayout.AppendLine(PrintingActions.FormatTenderLine(ApplicationLocalizer.Language.Translate(10078), Printing.InternalApplication.Services.Rounding.Round(startingAmountTransaction.Amount, true))); reportLayout.AppendLine(startingAmountTransaction.Description.ToString()); reportLayout.AppendLine(); reportLayout.AppendLine(PrintingActions.DoubleLine); return(reportLayout.ToString()); }); }
/// <summary> /// Print form layout with specified content. /// </summary> /// <param name="formMod">Form modulation.</param> /// <param name="formInfo">Form info.</param> /// <param name="formType">Form type.</param> /// <param name="copyReceipt">Flag to identify if this is a copy.</param> /// <param name="getPrintTextHandler">Handler that is called to construct text for printing.</param> private static void PrintFormLayout( PrinterAssociation printerMap, FormModulation formMod, FormType formType, bool copyReceipt, bool formInfoTemplateRequired, GetTextHandler getPrintTextHandler) { FormInfo formInfo = printerMap.PrinterFormInfo; // Checking if formType requires template. if (formInfoTemplateRequired && (formInfo.HeaderTemplate == null)) { // 13038: Could not print the receipt because the receipt format could not be found. Printing.InternalApplication.Services.Dialog.ShowMessage(13038, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (PrintingActions.ShouldWePrint(formInfo, formType, copyReceipt, printerMap)) { try { string textToPrint = getPrintTextHandler(formMod, formInfo); if (formInfo.PrintAsSlip) { printerMap.Printer.PrintSlip(textToPrint); } else { printerMap.Printer.PrintReceipt(textToPrint); } } catch (Exception ex) { NetTracer.Warning("Printing [Print] - Exception while printing receipt"); POSFormsManager.ShowPOSErrorDialog(new PosisException(1003, ex)); } } }
/// <summary> /// Print invoice receipt. /// </summary> /// <param name="posTransaction">The pos transaction.</param> /// <param name="copyInvoice">if set to <c>true</c> [copy invoice].</param> /// <param name="printPreview">Not supported.</param> /// <returns></returns> public bool PrintInvoice(IPosTransaction posTransaction, bool copyInvoice, bool printPreview) { if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled()) { FiscalPrinter.FiscalPrinter.Instance.PrintInvoice(posTransaction, copyInvoice, printPreview); return(true); } FormModulation formMod = new FormModulation(Application.Settings.Database.Connection); bool noPrinterDefined = true; // Initilize as error IList <PrinterAssociation> printerMapping = PrintingActions.GetActivePrinters(formMod, FormType.Invoice, copyInvoice); bool result = true; foreach (PrinterAssociation printerMap in printerMapping) { noPrinterDefined = noPrinterDefined && (printerMap.Type == DeviceTypes.None); if ((printerMap.Type == DeviceTypes.OPOS) || (printerMap.Type == DeviceTypes.Windows)) { bool printResult = PrintingActions.PrintFormTransaction(printerMap, formMod, FormType.Invoice, posTransaction, copyInvoice); result = result && printResult; } } if (noPrinterDefined) { // 10060 - No printer type has been defined. this.Application.Services.Dialog.ShowMessage(ApplicationLocalizer.Language.Translate(10060), MessageBoxButtons.OK, MessageBoxIcon.Stop); result = false; } return(result); }
/// <summary> /// Print the standard slip, returns false if printing should be aborted altogether. /// </summary> /// <param name="formType"></param> /// <param name="posTransaction"></param> /// <param name="copyReceipt"></param> /// <returns></returns> public bool PrintReceipt(FormType formType, IPosTransaction posTransaction, bool copyReceipt) { bool result = false; if (formType == FormType.Receipt) { //SqlConnection SqlCon = new SqlConnection(ApplicationSettings.Database.LocalConnectionString); SqlConnection connection = new SqlConnection(); if (application != null) { connection = application.Settings.Database.Connection; } else { connection = ApplicationSettings.Database.LocalConnection; } //Start :02/07/2014 if (posTransaction is IRetailTransaction) { RetailTransaction retailTransaction = (RetailTransaction)posTransaction; SaleLineItem item = retailTransaction.SaleItems.Last.Value; if (item.Description == "Add to gift card") { //==== if (application != null) { connection = application.Settings.Database.Connection; } else { connection = ApplicationSettings.Database.LocalConnection; } string sTransactionId = retailTransaction.TransactionId; string sTerminalId = retailTransaction.TerminalId; string sCardNo = string.Empty; decimal sAmt = 0; DataTable dt = GetGiftCardAmountInfo(connection, sTransactionId, sTerminalId); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i <= dt.Rows.Count - 1; i++) { if (string.IsNullOrEmpty(sCardNo)) { sAmt = Convert.ToDecimal(dt.Rows[i]["AMOUNT"]); sCardNo = Convert.ToString(dt.Rows[i]["COMMENT"]); sCardNo = new String('x', Convert.ToInt16(sCardNo.Length) - 4) + sCardNo.Substring(Convert.ToInt16(sCardNo.Length) - 4); } else { sCardNo = sCardNo + " / " + new String('x', Convert.ToInt16(Convert.ToString(dt.Rows[i]["COMMENT"]).Length) - 4) + Convert.ToString(dt.Rows[i]["COMMENT"]).Substring(Convert.ToInt16(Convert.ToString(dt.Rows[i]["COMMENT"]).Length) - 4); sAmt = sAmt + Convert.ToDecimal(dt.Rows[i]["AMOUNT"]); } } } frmR_ProductAdvanceReceipt objProdAdv = new frmR_ProductAdvanceReceipt(posTransaction, connection, sTransactionId, Convert.ToString(sAmt), sTerminalId, item.Description, sCardNo); objProdAdv.ShowDialog(); } else { if (retailTransaction.RefundReceiptId == "1") { string sTransactionId = retailTransaction.TransactionId; string sTerminalId = retailTransaction.TerminalId; string sCardNo = string.Empty; decimal sAmt = 0; DataTable dt = GetGiftCardAmountInfo(connection, sTransactionId, sTerminalId); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i <= dt.Rows.Count - 1; i++) { if (string.IsNullOrEmpty(sCardNo)) { sAmt = Convert.ToDecimal(dt.Rows[i]["AMOUNT"]); sCardNo = Convert.ToString(dt.Rows[i]["COMMENT"]); sCardNo = new String('x', Convert.ToInt16(sCardNo.Length) - 4) + sCardNo.Substring(Convert.ToInt16(sCardNo.Length) - 4); } else { sCardNo = sCardNo + " / " + new String('x', Convert.ToInt16(Convert.ToString(dt.Rows[i]["COMMENT"]).Length) - 4) + Convert.ToString(dt.Rows[i]["COMMENT"]).Substring(Convert.ToInt16(Convert.ToString(dt.Rows[i]["COMMENT"]).Length) - 4); sAmt = sAmt + Convert.ToDecimal(dt.Rows[i]["AMOUNT"]); } } } frmR_ProductAdvanceReceipt objProdAdv = new frmR_ProductAdvanceReceipt(posTransaction, connection, sTransactionId, Convert.ToString(sAmt), sTerminalId, item.Description, sCardNo, 1); objProdAdv.ShowDialog(); } else { if (retailTransaction.SaleIsReturnSale) { frmSaleInv reportfrm = new frmSaleInv(posTransaction, connection, copyReceipt, 0, 0, iPrintFromShowJournal); reportfrm.ShowDialog(); frmSaleInvAccountsCopy reportfrmAcc = new frmSaleInvAccountsCopy(posTransaction, connection, copyReceipt, 0, 0, iPrintFromShowJournal); reportfrmAcc.ShowDialog(); //frmSaleInvControlCopy reportfrmCon = new frmSaleInvControlCopy(posTransaction, connection, copyReceipt, 0, 0, iPrintFromShowJournal); //reportfrmCon.ShowDialog();// commented on 080819/ req by Soudip paul } else { //Microsoft.Dynamics.Retail.Pos.BlankOperations.WinFormsTouch.frmLanguageForInvoice // objLI = new BlankOperations.WinFormsTouch.frmLanguageForInvoice(); //objLI.ShowDialog(); //int iLanguage = 0; //if (objLI.isEnglish == true) // iLanguage = 1; //else if (objLI.isArabic == true) // iLanguage = 2; //else if (objLI.isBoth == true) // iLanguage = 3; if (iPrintFromShowJournal == 1) { using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Is this a gift invoice?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); if (Convert.ToString(dialog.DialogResult).ToUpper().Trim() == "YES") { frmSaleInv reportfrm = new frmSaleInv(posTransaction, connection, copyReceipt, 1, 0, iPrintFromShowJournal);//Default English for Sales Return reportfrm.ShowDialog(); frmSaleInv reportfrm1 = new frmSaleInv(posTransaction, connection, copyReceipt, 0, 1, iPrintFromShowJournal); reportfrm1.ShowDialog(); } else { ChooseInvoiceLanguage(posTransaction, copyReceipt, connection, iPrintFromShowJournal); } } iPrintFromShowJournal = 0; } else { ChooseInvoiceLanguage(posTransaction, copyReceipt, connection, iPrintFromShowJournal); } } } } //retailTransaction } //End : 02/07/2014 } else if (formType == FormType.CustomerAccountDeposit) { RetailTransaction retailTransaction = posTransaction as RetailTransaction; string sGSSNo = string.Empty; if (retailTransaction != null) { SqlConnection connection = new SqlConnection(); if (application != null) { connection = application.Settings.Database.Connection; } else { connection = ApplicationSettings.Database.LocalConnection; } string sTransactionId = retailTransaction.TransactionId; // string sTerminalId = ApplicationSettings.Terminal.TerminalId; string sTerminalId = retailTransaction.TerminalId; DataTable dtAdv = GetAdvanceInfo(connection, sTransactionId, sTerminalId); if (dtAdv != null && dtAdv.Rows.Count > 0) { sGSSNo = Convert.ToString(dtAdv.Rows[0]["GSSNUMBER"]); if (sGSSNo != string.Empty) { frmR_GSSInstalmentReceipt objRGSS = new frmR_GSSInstalmentReceipt(posTransaction, connection, sTransactionId, Convert.ToString(dtAdv.Rows[0]["AMOUNT"]), sGSSNo, sTerminalId); objRGSS.ShowDialog(); } else { Microsoft.Dynamics.Retail.Pos.BlankOperations.WinFormsTouch.frmLanguageForInvoice objLI = new BlankOperations.WinFormsTouch.frmLanguageForInvoice(); objLI.ShowDialog(); int iLanguage = 0; if (objLI.isEnglish == true) { iLanguage = 1; } else if (objLI.isArabic == true) { iLanguage = 2; } else if (objLI.isBoth == true) { iLanguage = 3; } frmR_ProductAdvanceReceipt objProdAdv = new frmR_ProductAdvanceReceipt(posTransaction, connection, sTransactionId, Convert.ToString(dtAdv.Rows[0]["AMOUNT"]), sTerminalId, "", "", 0, iLanguage); objProdAdv.ShowDialog(); } } } } else { if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled()) { return(FiscalPrinter.FiscalPrinter.Instance.PrintReceipt(formType, posTransaction, copyReceipt)); } FormModulation formMod = new FormModulation(Application.Settings.Database.Connection); IList <PrinterAssociation> printerMapping = PrintingActions.GetActivePrinters(formMod, formType, copyReceipt); // bool result = false; foreach (PrinterAssociation printerMap in printerMapping) { bool printResult = PrintingActions.PrintFormTransaction(printerMap, formMod, formType, posTransaction, copyReceipt); result = result || printResult; } } return(result); }