private void PrintDocumentDetails() { try { List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("DocumentDate", Resx.global_date, 11, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("DocumentNumber", Resx.global_document_number_acronym, 0, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("DocumentTotal", Resx.global_document_total, 10, TicketColumnsAlign.Right, typeof(decimal), "{0:00.00}")); columns.Add(new TicketColumn("TotalPayed", Resx.global_total_payed_acronym, 10, TicketColumnsAlign.Right, typeof(decimal), "{0:00.00}")); columns.Add(new TicketColumn("Payed", "L", 1, TicketColumnsAlign.Right, typeof(bool))); //Prepare Table with Padding DataTable dataTable = TicketTable.InitDataTableFromTicketColumns(columns); TicketTable ticketTable = new TicketTable(dataTable, columns, _maxCharsPerLineNormal - _ticketTablePaddingLeftLength); string paddingLeftFormat = " {0,-" + ticketTable.TableWidth + "}";//" {0,-TableWidth}" //Print Table Headers ticketTable.Print(_thermalPrinterGeneric, paddingLeftFormat); foreach (FRBODocumentFinancePaymentDocumentView item in _documentFinancePaymentDocumentList) { //Recreate/Reset Table for Item Details Loop ticketTable = new TicketTable(dataTable, columns, _maxCharsPerLineNormal - _ticketTablePaddingLeftLength); PrintDocumentDetail(ticketTable, item, paddingLeftFormat); } //Line Feed _thermalPrinterGeneric.LineFeed(); } catch (Exception ex) { throw ex; } }
//Detail Row Block public void PrintDocumentDetail(TicketTable pTicketTable, FRBODocumentFinancePaymentDocumentView pFinancePaymentDocument, string pPaddingLeftFormat) { try { //Trim Data string documentNumber = (pFinancePaymentDocument.DocumentNumber.Length <= _maxCharsPerLineNormalBold) ? pFinancePaymentDocument.DocumentNumber : pFinancePaymentDocument.DocumentNumber.Substring(0, _maxCharsPerLineNormalBold) ; //Print Document Number : Bold _thermalPrinterGeneric.WriteLine(documentNumber, WriteLineTextMode.Bold); //Document Details DataRow dataRow; dataRow = pTicketTable.NewRow(); dataRow[0] = pFinancePaymentDocument.DocumentDate; dataRow[1] = pFinancePaymentDocument.DocumentNumber; //dataRow[2] = (item.CreditAmount > 0 && item.DocumentTotal > item.CreditAmount) // ? FrameworkUtils.DecimalToString((item.DocumentTotal - item.CreditAmount) * _documentFinancePayment.ExchangeRate) // : string.Empty; dataRow[2] = pFinancePaymentDocument.DocumentTotal * _documentFinancePayment.ExchangeRate; dataRow[3] = pFinancePaymentDocument.CreditAmount * _documentFinancePayment.ExchangeRate; dataRow[4] = (pFinancePaymentDocument.Payed) ? "*" : string.Empty; //Add DataRow to Table, Ready for Print pTicketTable.Rows.Add(dataRow); //Print Table Rows pTicketTable.Print(_thermalPrinterGeneric, WriteLineTextMode.Normal, true, pPaddingLeftFormat); } catch (Exception ex) { throw ex; } }
//Totals, with TotalDelivery and TotalChange private void PrintMasterTotals() { try { //Init DataTable DataRow dataRow = null; DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("Label", typeof(string))); dataTable.Columns.Add(new DataColumn("Value", typeof(string))); //Add Row : TotalFinal dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_total; dataRow[1] = FrameworkUtils.DecimalToString(_documentFinancePaymentList[0].PaymentAmount * _documentFinancePaymentList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //Configure Ticket Column Properties List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Label", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("Value", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Right)); //TicketTable(DataTable pDataTable, List<TicketColumn> pColumnsProperties, int pTableWidth) TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormalBold); ticketTable.Print(_thermalPrinterGeneric, WriteLineTextMode.DoubleHeightBold); //Line Feed _thermalPrinterGeneric.LineFeed(); } catch (Exception ex) { throw ex; } }
private void PrintDocumentDetails() { List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Designation", Resx.global_designation, 0, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("Quantity", Resx.global_quantity_acronym, 8, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("UnitMeasure", Resx.global_unit_measure_acronym, 3, TicketColumnsAlign.Right)); //Prepare Table with Padding DataTable dataTable = TicketTable.InitDataTableFromTicketColumns(columns); TicketTable ticketTable = new TicketTable(dataTable, columns, _maxCharsPerLineNormal); //Print Items DataRow dataRow; foreach (FIN_DocumentOrderDetail item in _orderTicket.OrderDetail) { //Add All Rows if Normal Mode without explicit ArticlePrinter defined, or print Printer Articles for explicit defined ArticlePrinter if (!_enableArticlePrinter || _thermalPrinterGeneric.Printer == item.Article.Printer) { //Add Rows to main Ticket dataRow = ticketTable.NewRow(); dataRow[0] = item.Designation; dataRow[1] = item.Quantity; dataRow[2] = item.UnitMeasure; //Add DataRow to Table, Ready for Print ticketTable.Rows.Add(dataRow); } } //Print Table ticketTable.Print(_thermalPrinterGeneric); }
//Detail Row Block public void PrintDocumentDetail(TicketTable pTicketTable, FRBODocumentFinanceDetail pFinanceDetail, string pPaddingLeftFormat) { try { //Trim Data string designation = (pFinanceDetail.Designation.Length <= _maxCharsPerLineNormalBold) ? pFinanceDetail.Designation : pFinanceDetail.Designation.Substring(0, _maxCharsPerLineNormalBold) ; //Print Item Designation : Bold _thermalPrinterGeneric.WriteLine(designation, WriteLineTextMode.Bold); //Prepare ExemptionReason string exemptionReason = string.Empty; if (pFinanceDetail.VatExemptionReasonDesignation != null && pFinanceDetail.VatExemptionReasonDesignation != string.Empty) { //Replaced Code : Remove Cut Exception Reason......its better not to cut VatExemptionReason..... //exemptionReason = (pFinanceDetail.VatExemptionReasonDesignation.Length <= pTicketTable.TableWidth) // ? pFinanceDetail.VatExemptionReasonDesignation // : pFinanceDetail.VatExemptionReasonDesignation.Substring(0, pTicketTable.TableWidth) //; //Replace Code exemptionReason = pFinanceDetail.VatExemptionReasonDesignation; //Always Format Data, its appens in first line only exemptionReason = string.Format(pPaddingLeftFormat, exemptionReason); } //Item Details DataRow dataRow = pTicketTable.NewRow(); dataRow[0] = pFinanceDetail.Vat; dataRow[1] = pFinanceDetail.Quantity; dataRow[2] = pFinanceDetail.UnitMeasure; dataRow[3] = pFinanceDetail.Price * _documentFinanceMasterList[0].ExchangeRate; dataRow[4] = pFinanceDetail.Discount; //dataRow[5] = pFinanceDetail.TotalNet * _documentFinanceMasterList[0].ExchangeRate; dataRow[5] = pFinanceDetail.TotalFinal * _documentFinanceMasterList[0].ExchangeRate; //Add DataRow to Table, Ready for Print pTicketTable.Rows.Add(dataRow); //Print Table Rows pTicketTable.Print(_thermalPrinterGeneric, WriteLineTextMode.Normal, true, pPaddingLeftFormat); //VatExemptionReason if (!string.IsNullOrEmpty(exemptionReason)) { _thermalPrinterGeneric.WriteLine(exemptionReason); } } catch (Exception ex) { throw ex; } }
private void PrintMasterTotalTax() { try { //Init DataTable DataRow dataRow = null; DataTable dataTable = new DataTable(); DataColumn dcDesignation = new DataColumn("Designation", typeof(String)); DataColumn dcTax = new DataColumn("Tax", typeof(String)); DataColumn dcTaxBase = new DataColumn("TaxBase", typeof(String)); DataColumn dcTotal = new DataColumn("Total", typeof(String)); dataTable.Columns.Add(dcDesignation); dataTable.Columns.Add(dcTax); dataTable.Columns.Add(dcTaxBase); dataTable.Columns.Add(dcTotal); foreach (FRBODocumentFinanceMasterTotalView item in _documentFinanceMasterTotalList) { dataRow = dataTable.NewRow(); dataRow[0] = item.Designation; dataRow[1] = string.Format("{0}%", FrameworkUtils.DecimalToString(item.Value)); dataRow[2] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].ExchangeRate * item.TotalBase); dataRow[3] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].ExchangeRate * item.Total); dataTable.Rows.Add(dataRow); } //Configure Ticket Column Properties List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Designation", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_designation"), 0, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("Tax", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_tax"), 8, TicketColumnsAlign.Right)); columns.Add(new TicketColumn("TotalBase", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total_tax_base"), 12, TicketColumnsAlign.Right)); columns.Add(new TicketColumn("Total", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_totaltax_acronym"), 10, TicketColumnsAlign.Right)); //TicketTable(DataTable pDataTable, List<TicketColumn> pColumnsProperties, int pTableWidth) TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormal); //Print Table Buffer ticketTable.Print(_thermalPrinterGeneric); //Line Feed _thermalPrinterGeneric.LineFeed(); } catch (Exception ex) { _log.Debug("void PrintMasterTotalTax() :: Thermal Printer: " + ex.Message, ex); throw ex; } }
protected void PrintDocumentPaymentDetails(string pPaymentCondition, string pPaymentMethod, string pCurrency) { //Init DataTable DataRow dataRow = null; DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("Label", typeof(string))); dataTable.Columns.Add(new DataColumn("Value", typeof(string))); //Add Row : PaymentConditions if (!string.IsNullOrEmpty(pPaymentCondition)) { dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_payment_conditions; dataRow[1] = pPaymentCondition; dataTable.Rows.Add(dataRow); } //Add Row : PaymentMethod if (!string.IsNullOrEmpty(pPaymentMethod)) { dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_payment_method; dataRow[1] = pPaymentMethod; dataTable.Rows.Add(dataRow); } //Add Row : Currency dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_currency; dataRow[1] = pCurrency; dataTable.Rows.Add(dataRow); //Configure Ticket Column Properties List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Label", "", _thermalPrinterGeneric.MaxCharsPerLineNormal / 2, TicketColumnsAlign.Right)); columns.Add(new TicketColumn("Value", "", _thermalPrinterGeneric.MaxCharsPerLineNormal / 2, TicketColumnsAlign.Left)); //TicketTable(DataTable pDataTable, List<TicketColumn> pColumnsProperties, int pTableWidth) TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormal); //Create Table Buffer, With Bigger TextMode ticketTable.Print(_thermalPrinterGeneric, true); //Line Feed _thermalPrinterGeneric.LineFeed(); }
//Loop Details public void PrintDocumentDetails() { try { List <TicketColumn> columns = new List <TicketColumn>(); //columns.Add(new TicketColumn("Article", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_article_acronym, 0, TicketColumnsAlign.Right, typeof(string), "{0:0.00}")); /* IN009211 block - begin * * We opt for "(%)" symbol to be added to value itself because of column title lenght limit, and for this, we changed from Decimal to String here. * The conversion will be done when printing the DataRow for VatRate and Discount fields (FrameworkUtils.DecimalToString(pFinanceDetail.Vat)). */ columns.Add(new TicketColumn("VatRate", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_vat_rate") + "%", 6, TicketColumnsAlign.Right, typeof(decimal), "{0:00.00}")); columns.Add(new TicketColumn("Quantity", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quantity_acronym"), 8, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("UnitMeasure", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_unit_measure_acronym"), 3, TicketColumnsAlign.Right)); columns.Add(new TicketColumn("Price", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_price"), 11, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("Discount", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_discount_acronym") + "%", 6, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); //columns.Add(new TicketColumn("TotalNet", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_totalnet_acronym, 9, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("TotalFinal", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total_per_item"), 0, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}"));//Dynamic /* IN009211 - end */ //Prepare Table with Padding DataTable dataTable = TicketTable.InitDataTableFromTicketColumns(columns); TicketTable ticketTable = new TicketTable(dataTable, columns, _maxCharsPerLineNormal - _ticketTablePaddingLeftLength); string paddingLeftFormat = " {0,-" + ticketTable.TableWidth + "}";//" {0,-TableWidth}" //Print Table Headers ticketTable.Print(_thermalPrinterGeneric, paddingLeftFormat); //Print Items foreach (FRBODocumentFinanceDetail item in _documentFinanceDetailList) { //Recreate/Reset Table for Item Details Loop ticketTable = new TicketTable(dataTable, columns, _maxCharsPerLineNormal - _ticketTablePaddingLeftLength); PrintDocumentDetail(ticketTable, item, paddingLeftFormat); } //Line Feed _thermalPrinterGeneric.LineFeed(); } catch (Exception ex) { _log.Debug("void PrintDocumentDetails() :: Thermal Printer: " + ex.Message, ex); throw ex; } }
//Loop Details public void PrintDocumentDetails() { try { List <TicketColumn> columns = new List <TicketColumn>(); //columns.Add(new TicketColumn("Article", Resx.global_article_acronym, 0, TicketColumnsAlign.Right, typeof(string), "{0:0.00}")); columns.Add(new TicketColumn("VatRate", Resx.global_vat_rate, 6, TicketColumnsAlign.Right, typeof(decimal), "{0:00.00}")); columns.Add(new TicketColumn("Quantity", Resx.global_quantity_acronym, 8, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("UnitMeasure", Resx.global_unit_measure_acronym, 3, TicketColumnsAlign.Right)); columns.Add(new TicketColumn("Price", Resx.global_price, 11, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("Discount", Resx.global_discount_acronym, 6, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); //columns.Add(new TicketColumn("TotalNet", Resx.global_totalnet_acronym, 9, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("TotalFinal", Resx.global_totalfinal_acronym, 0, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}"));//Dynamic //Prepare Table with Padding DataTable dataTable = TicketTable.InitDataTableFromTicketColumns(columns); TicketTable ticketTable = new TicketTable(dataTable, columns, _maxCharsPerLineNormal - _ticketTablePaddingLeftLength); string paddingLeftFormat = " {0,-" + ticketTable.TableWidth + "}";//" {0,-TableWidth}" //Print Table Headers ticketTable.Print(_thermalPrinterGeneric, paddingLeftFormat); //Print Items foreach (FRBODocumentFinanceDetail item in _documentFinanceDetailList) { //Recreate/Reset Table for Item Details Loop ticketTable = new TicketTable(dataTable, columns, _maxCharsPerLineNormal - _ticketTablePaddingLeftLength); PrintDocumentDetail(ticketTable, item, paddingLeftFormat); } //Line Feed _thermalPrinterGeneric.LineFeed(); } catch (Exception ex) { throw ex; } }
public bool PrintWorkSessionMovement(sys_configurationprinters pPrinter, pos_worksessionperiod pWorkSessionPeriod, SplitCurrentAccountMode pSplitCurrentAccountMode) { bool result = false; if (pPrinter != null) { sys_configurationprinters printer = pPrinter; sys_configurationprinterstemplates template = (sys_configurationprinterstemplates)FrameworkUtils.GetXPGuidObject(typeof(sys_configurationprinterstemplates), SettingsApp.XpoOidConfigurationPrintersTemplateWorkSessionMovement); string splitCurrentAccountFilter = string.Empty; string fileTicket = template.FileTemplate; switch (pSplitCurrentAccountMode) { case SplitCurrentAccountMode.All: break; case SplitCurrentAccountMode.NonCurrentAcount: //Diferent from DocumentType CC splitCurrentAccountFilter = string.Format("AND DocumentType <> '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput); break; case SplitCurrentAccountMode.CurrentAcount: //Only DocumentType CC splitCurrentAccountFilter = string.Format("AND DocumentType = '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput); break; } try { //Shared Where for details and totals Queries string sqlWhere = string.Empty; if (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) { sqlWhere = string.Format("PeriodParent = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter); } else { sqlWhere = string.Format("Period = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter); } //Shared for Both Modes if (sqlWhere != string.Empty) { sqlWhere = string.Format(" AND {0}", sqlWhere); } //Format to Display Vars string dateCloseDisplay = (pWorkSessionPeriod.SessionStatus == WorkSessionPeriodStatus.Open) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_in_progress") : pWorkSessionPeriod.DateEnd.ToString(SettingsApp.DateTimeFormat); //Get Session Period Details Hashtable resultHashTable = ProcessWorkSessionPeriod.GetSessionPeriodSummaryDetails(pWorkSessionPeriod); //Print Header Summary DataRow dataRow = null; DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("Label", typeof(string))); dataTable.Columns.Add(new DataColumn("Value", typeof(string))); //Open DateTime dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_datetime")); dataRow[1] = pWorkSessionPeriod.DateStart.ToString(SettingsApp.DateTimeFormat); dataTable.Rows.Add(dataRow); //Close DataTime dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_datetime")); dataRow[1] = dateCloseDisplay; dataTable.Rows.Add(dataRow); //Open Total CashDrawer dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_total_cashdrawer")); dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawerOnOpen"]); dataTable.Rows.Add(dataRow); //Close Total CashDrawer dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_total_cashdrawer")); dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawer"]); dataTable.Rows.Add(dataRow); //Total Money In dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_in")); dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyIn"]); dataTable.Rows.Add(dataRow); //Total Money Out dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_out")); dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyOut"]); dataTable.Rows.Add(dataRow); //Configure Ticket Column Properties List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Label", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Right)); columns.Add(new TicketColumn("Value", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Left)); TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormalBold); //Print Ticket Table ticketTable.Print(_thermalPrinterGeneric); //Line Feed _thermalPrinterGeneric.LineFeed(); //Get Final Rendered DataTable Groups Dictionary <DataTableGroupPropertiesType, DataTableGroupProperties> dictGroupProperties = GenDataTableWorkSessionMovementResume(pWorkSessionPeriod.PeriodType, pSplitCurrentAccountMode, sqlWhere); //Prepare Local vars for Group Loop XPSelectData xPSelectData = null; string designation = string.Empty; decimal quantity = 0.0m; decimal total = 0.0m; string unitMeasure = string.Empty; //Store Final Totals decimal summaryTotalQuantity = 0.0m; decimal summaryTotal = 0.0m; //Used to Custom Print Table Ticket Rows List <string> tableCustomPrint = new List <string>(); //Start to process Group int groupPosition = -1; //Assign Position to Print Payment Group Split Title int groupPositionTitlePayments = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) ? 9 : 8; //If CurrentAccount Mode decrease 1, it dont have PaymentMethods if (pSplitCurrentAccountMode == SplitCurrentAccountMode.CurrentAcount) { groupPositionTitlePayments--; } foreach (KeyValuePair <DataTableGroupPropertiesType, DataTableGroupProperties> item in dictGroupProperties) //foreach (DataTableGroupProperties item in dictGroupProperties.Values) { if (item.Value.Enabled) { //Increment Group Position groupPosition++; //Print Group Titles (FinanceDocuments|Payments) if (groupPosition == 0) { _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_finance_documents"), WriteLineTextMode.Big); _thermalPrinterGeneric.LineFeed(); } else if (groupPosition == groupPositionTitlePayments) { //When finish FinanceDocuemnts groups, print Last Row, the Summary Totals Row _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight); _thermalPrinterGeneric.LineFeed(); _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_paymens_documents"), WriteLineTextMode.Big); _thermalPrinterGeneric.LineFeed(); } //Reset Totals summaryTotalQuantity = 0.0m; summaryTotal = 0.0m; //Get Group Data from group Query xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(item.Value.Sql); //Generate Columns columns = new List <TicketColumn>(); columns.Add(new TicketColumn("GroupTitle", item.Value.Title, 0, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("Quantity", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quantity_acronym"), 8, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); //columns.Add(new TicketColumn("UnitMeasure", string.Empty, 3)); columns.Add(new TicketColumn("Total", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_totalfinal_acronym"), 10, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); //Init DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("GroupDesignation", typeof(string))); dataTable.Columns.Add(new DataColumn("Quantity", typeof(decimal))); //dataTable.Columns.Add(new DataColumn("UnitMeasure", typeof(string))); dataTable.Columns.Add(new DataColumn("Total", typeof(decimal))); //If Has data if (xPSelectData.Data.Length > 0) { foreach (SelectStatementResultRow row in xPSelectData.Data) { designation = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("Designation")]); quantity = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Quantity")]); unitMeasure = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("UnitMeasure")]); total = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Total")]); // Override Encrypted values if (GlobalFramework.PluginSoftwareVendor != null && item.Key.Equals(DataTableGroupPropertiesType.DocumentsUser) || item.Key.Equals(DataTableGroupPropertiesType.PaymentsUser)) { designation = GlobalFramework.PluginSoftwareVendor.Decrypt(designation); } //Sum Summary Totals summaryTotalQuantity += quantity; summaryTotal += total; //_log.Debug(string.Format("Designation: [{0}], quantity: [{1}], unitMeasure: [{2}], total: [{3}]", designation, quantity, unitMeasure, total)); //Create Row dataRow = dataTable.NewRow(); dataRow[0] = designation; dataRow[1] = quantity; //dataRow[2] = unitMeasure; dataRow[2] = total; dataTable.Rows.Add(dataRow); } } else { //Create Row dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cashdrawer_without_movements"); dataRow[1] = 0.0m; //dataRow[2] = string.Empty;//UnitMeasure dataRow[2] = 0.0m; dataTable.Rows.Add(dataRow); } //Add Final Summary Row dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total"); dataRow[1] = summaryTotalQuantity; //dataRow[2] = string.Empty; dataRow[2] = summaryTotal; dataTable.Rows.Add(dataRow); //Prepare TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormal); //Custom Print Loop, to Print all Table Rows, and Detect Rows to Print in DoubleHeight (Title and Total) tableCustomPrint = ticketTable.GetTable(); WriteLineTextMode rowTextMode; //Dynamic Print All except Last One (Totals), Double Height in Titles for (int i = 0; i < tableCustomPrint.Count - 1; i++) { //Prepare TextMode Based on Row rowTextMode = (i == 0) ? WriteLineTextMode.DoubleHeight : WriteLineTextMode.Normal; //Print Row _thermalPrinterGeneric.WriteLine(tableCustomPrint[i], rowTextMode); } //Line Feed _thermalPrinterGeneric.LineFeed(); } } //When finish all groups, print Last Row, the Summary Totals Row, Ommited in Custom Print Loop _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight); result = true; } catch (Exception ex) { _log.Error(ex.Message, ex); throw new Exception(ex.Message); } } return(result); }
public static void Print(sys_configurationprinters pPrinter) { try { ThermalPrinterGeneric thermalPrinterGeneric = new ThermalPrinterGeneric(pPrinter); List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Code", "Code", 6, TicketColumnsAlign.Right)); columns.Add(new TicketColumn("Designation", CustomFunctions.Res("global_designation"), 0)); columns.Add(new TicketColumn("Quantity", "Qnt", 7, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("UnitMeasure", "UM", 3)); columns.Add(new TicketColumn("Price", "Preço", 10, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("Tax", "Taxa", 7, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("Discount", "Desc", 7, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); columns.Add(new TicketColumn("Total", "Total", 11, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); string sql = string.Format(@" SELECT Code,Designation,Quantity,UnitMeasure,Price,Vat,Discount,TotalFinal FROM fin_documentfinancedetail WHERE DocumentMaster = '{0}' ORDER BY Ord ;", SettingsApp.XpoPrintFinanceDocument ); TicketTable ticketTable = new TicketTable(sql, columns, thermalPrinterGeneric.MaxCharsPerLineSmall); ticketTable.Print(thermalPrinterGeneric); //Cut thermalPrinterGeneric.Cut(true); //Print Buffer thermalPrinterGeneric.PrintBuffer(); //Get Result Objects ResultFRBODocumentFinanceMaster FRBOHelperResponseProcessReportFinanceDocument = FRBOHelper.GetFRBOFinanceDocument(SettingsApp.XpoPrintFinanceDocument); List <FRBODocumentFinanceMasterView> gcDocumentFinanceMaster = FRBOHelperResponseProcessReportFinanceDocument.DocumentFinanceMaster.List; List <FRBODocumentFinanceDetail> gcDocumentFinanceDetail = FRBOHelperResponseProcessReportFinanceDocument.DocumentFinanceMaster.List[0].DocumentFinanceDetail; List <FRBODocumentFinanceMasterTotalView> gcDocumentFinanceMasterTotal = FRBOHelperResponseProcessReportFinanceDocument.DocumentFinanceMaster.List[0].DocumentFinanceMasterTotal;; _log.Debug(string.Format("DocumentNumber: [{0}]", gcDocumentFinanceMaster[0].DocumentNumber)); foreach (FRBODocumentFinanceDetail item in gcDocumentFinanceDetail) { _log.Debug(string.Format("Designation: [{0}], Price: [{1}]", item.Designation, item.Price)); } foreach (FRBODocumentFinanceMasterTotalView item in gcDocumentFinanceMasterTotal) { _log.Debug(string.Format("Designation: [{0}], Value :[{1}]", item.Designation, item.Value)); } Dictionary <string, string> CustomVars = GlobalFramework.FastReportCustomVars; _log.Debug(string.Format("Company_Name: [{0}]", CustomVars["Company_Name"])); //ThermalPrinterFinanceDocument thermalPrinterFinanceDocument = new ThermalPrinterFinanceDocument(pPrinter); //thermalPrinterFinanceDocument.Print(); } catch (Exception ex) { throw ex; } }
//Detail Row Block public void PrintDocumentDetail(TicketTable pTicketTable, FRBODocumentFinanceDetail pFinanceDetail, string pPaddingLeftFormat) { try { //Trim Data string designation = (pFinanceDetail.Designation.Length <= _maxCharsPerLineNormalBold) ? pFinanceDetail.Designation : pFinanceDetail.Designation.Substring(0, _maxCharsPerLineNormalBold) ; //Print Item Designation : Bold _thermalPrinterGeneric.WriteLine(designation, WriteLineTextMode.Bold); //Prepare ExemptionReason string exemptionReason = string.Empty; if (!string.IsNullOrEmpty(pFinanceDetail.VatExemptionReasonDesignation)) { //Replaced Code : Remove Cut Exception Reason......its better not to cut VatExemptionReason..... //exemptionReason = (pFinanceDetail.VatExemptionReasonDesignation.Length <= pTicketTable.TableWidth) // ? pFinanceDetail.VatExemptionReasonDesignation // : pFinanceDetail.VatExemptionReasonDesignation.Substring(0, pTicketTable.TableWidth) //; //Replace Code exemptionReason = pFinanceDetail.VatExemptionReasonDesignation; //Always Format Data, its appens in first line only exemptionReason = string.Format(pPaddingLeftFormat, exemptionReason); } //Item Details DataRow dataRow = pTicketTable.NewRow(); /* IN009211 block - begin * Method "FrameworkUtils.DecimalToString(pFinanceDetail.Vat)" is safe for "%" format */ dataRow[0] = pFinanceDetail.Vat; dataRow[1] = pFinanceDetail.Quantity; dataRow[2] = pFinanceDetail.UnitMeasure; dataRow[3] = pFinanceDetail.Price * _documentFinanceMasterList[0].ExchangeRate; dataRow[4] = pFinanceDetail.Discount; //dataRow[5] = pFinanceDetail.TotalNet * _documentFinanceMasterList[0].ExchangeRate; /* fix for item total before CustomerDiscount: (TotalGross - ItemDiscount) + ItemVAT */ Decimal amountItemDiscount = pFinanceDetail.TotalGross * pFinanceDetail.Discount / 100; Decimal amountDueBeforeTax = (pFinanceDetail.TotalGross - amountItemDiscount); Decimal totalItemTax = amountDueBeforeTax * pFinanceDetail.Vat / 100; Decimal amountDueAfterTax = amountDueBeforeTax + totalItemTax; dataRow[5] = _documentFinanceMasterList[0].ExchangeRate * amountDueAfterTax; /* IN009211 block - end */ //Add DataRow to Table, Ready for Print pTicketTable.Rows.Add(dataRow); //Print Table Rows pTicketTable.Print(_thermalPrinterGeneric, WriteLineTextMode.Normal, true, pPaddingLeftFormat); //VatExemptionReason _thermalPrinterGeneric.WriteLine(exemptionReason, WriteLineTextMode.Small); /* IN009211 - WriteLine() already checks for empties and nulls */ } catch (Exception ex) { _log.Debug("void PrintDocumentDetail(TicketTable pTicketTable, FRBODocumentFinanceDetail pFinanceDetail, string pPaddingLeftFormat) :: Thermal Printer: " + ex.Message, ex); throw ex; } }