private void SetDataSource(ReportDocument Report) { AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset(); foreach (Data.SalesTransactionDetails details in salesDetails) { DataRow drNew = rptds.Transactions.NewRow(); drNew["TransactionID"] = details.TransactionID; drNew["TransactionNo"] = details.TransactionNo; drNew["CustomerID"] = details.CustomerID; drNew["CashierID"] = details.CashierID; drNew["CashierName"] = details.CashierName; drNew["TerminalNo"] = details.TerminalNo; drNew["TransactionDate"] = details.TransactionDate; drNew["DateSuspended"] = details.DateSuspended; drNew["DateResumed"] = details.DateResumed; drNew["TransactionStatus"] = details.TransactionStatus; drNew["SubTotal"] = details.SubTotal; drNew["Discount"] = details.Discount; drNew["TransDiscount"] = details.TransDiscount; drNew["TransDiscountType"] = details.TransDiscountType; drNew["VAT"] = details.VAT; drNew["VatableAmount"] = details.VATableAmount; drNew["EVAT"] = details.EVAT; drNew["EVatableAmount"] = details.EVATableAmount; drNew["LocalTax"] = details.LocalTax; drNew["AmountPaid"] = details.AmountPaid; drNew["CashPayment"] = details.CashPayment; drNew["ChequePayment"] = details.ChequePayment; drNew["CreditCardPayment"] = details.CreditCardPayment; drNew["CreditPayment"] = details.CreditPayment; drNew["BalanceAmount"] = details.BalanceAmount; drNew["ChangeAmount"] = details.ChangeAmount; drNew["DateClosed"] = details.DateClosed; drNew["PaymentType"] = details.PaymentType; rptds.Transactions.Rows.Add(drNew); foreach (Data.SalesTransactionItemDetails item in details.TransactionItems) { DataRow drNewItem = rptds.SalesTransactionItems.NewRow(); drNewItem["TransactionItemsID"] = item.TransactionItemsID; drNewItem["TransactionID"] = item.TransactionID; drNewItem["ProductID"] = item.ProductID; drNewItem["ProductCode"] = item.ProductCode; drNewItem["BarCode"] = item.BarCode; drNewItem["Description"] = item.Description; drNewItem["ProductUnitID"] = item.ProductUnitID; drNewItem["ProductUnitCode"] = item.ProductUnitCode; drNewItem["Quantity"] = item.Quantity; drNewItem["Price"] = item.Price; drNewItem["Discount"] = item.Discount; drNewItem["ItemDiscount"] = item.ItemDiscount; drNewItem["ItemDiscountType"] = item.ItemDiscountType; // if (item.TransactionItemStatus == TransactionItemStatus.Return) // drNewItem["Amount"] = - item.Amount; // else if (item.TransactionItemStatus == TransactionItemStatus.Refund) // drNewItem["Amount"] = - item.Amount; // else if (item.TransactionItemStatus == TransactionItemStatus.Void) // drNewItem["Amount"] = 0; // else drNewItem["Amount"] = item.Amount; drNewItem["VAT"] = item.VAT; drNewItem["EVAT"] = item.EVAT; drNewItem["LocalTax"] = item.LocalTax; drNewItem["VariationsMatrixID"] = item.VariationsMatrixID; drNewItem["MatrixDescription"] = item.MatrixDescription; drNewItem["ProductGroup"] = item.ProductGroup; drNewItem["ProductSubGroup"] = item.ProductSubGroup; drNewItem["TransactionDate"] = item.TransactionDate; drNewItem["TransactionItemStatus"] = item.TransactionItemStatus; drNewItem["DiscountCode"] = item.DiscountCode; drNewItem["DiscountRemarks"] = item.DiscountRemarks; drNewItem["ProductPackageID"] = item.ProductPackageID; drNewItem["MatrixPackageID"] = item.MatrixPackageID; drNewItem["PackageQuantity"] = item.PackageQuantity; drNewItem["PromoQuantity"] = item.PromoQuantity; drNewItem["PromoValue"] = item.PromoValue; drNewItem["PromoInPercent"] = item.PromoInPercent; drNewItem["PromoType"] = item.PromoType; drNewItem["PromoApplied"] = item.PromoApplied; drNewItem["PurchasePrice"] = item.PurchasePrice; drNewItem["PurchaseAmount"] = item.PurchaseAmount; drNewItem["IncludeInSubtotalDiscount"] = item.IncludeInSubtotalDiscount; rptds.SalesTransactionItems.Rows.Add(drNewItem); } } Report.SetDataSource(rptds); }
public void PrintCollectionReceipt() { try { if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto) { MessageBox.Show("Sorry this option is not applicable for Auto-Print receipt.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); return; } if (!mboIsInTransaction) { MessageBox.Show("No active transaction is found! Please transact first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); return; } DialogResult loginresult = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.CloseTransaction); if (loginresult == DialogResult.None) { LogInWnd login = new LogInWnd(); login.AccessType = AccessTypes.CloseTransaction; login.Header = "Print Collection Receipt"; login.TerminalDetails = mclsTerminalDetails; login.ShowDialog(this); loginresult = login.Result; login.Close(); login.Dispose(); } if (loginresult == DialogResult.OK) { CRSReports.CR rpt = new CRSReports.CR(); AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset(); System.Data.DataRow drNew; /****************************sales transaction *****************************/ Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; Data.SalesTransactionDetails clsSalesTransactionDetails = clsSalesTransactions.Details(mclsSalesTransactionDetails.TransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID); Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); Data.ContactDetails clsContactDetails = clsContact.Details(clsSalesTransactionDetails.CustomerID); if (clsSalesTransactionDetails.isExist) { drNew = rptds.Transactions.NewRow(); drNew["TransactionID"] = clsSalesTransactionDetails.TransactionID; drNew["TransactionNo"] = clsSalesTransactionDetails.TransactionNo; drNew["ORNo"] = clsSalesTransactionDetails.ORNo; drNew["CustomerName"] = clsSalesTransactionDetails.CustomerName; drNew["CustomerAddress"] = clsContactDetails.Address; drNew["CustomerTerms"] = clsSalesTransactionDetails.Terms; drNew["CustomerModeOfterms"] = clsSalesTransactionDetails.ModeOfTerms; drNew["CustomerBusinessName"] = clsContactDetails.BusinessName; drNew["CustomerTelNo"] = clsContactDetails.TelephoneNo; drNew["CashierName"] = clsSalesTransactionDetails.CashierName; drNew["CreatedByName"] = clsSalesTransactionDetails.CreatedByName; drNew["AgentName"] = clsSalesTransactionDetails.AgentName; drNew["TerminalNo"] = clsSalesTransactionDetails.TerminalNo; drNew["TransactionDate"] = clsSalesTransactionDetails.TransactionDate; drNew["DateSuspended"] = clsSalesTransactionDetails.DateSuspended.ToString(); drNew["DateResumed"] = clsSalesTransactionDetails.DateResumed; drNew["TransactionStatus"] = clsSalesTransactionDetails.TransactionStatus; drNew["SubTotal"] = clsSalesTransactionDetails.SubTotal; drNew["ItemsDiscount"] = clsSalesTransactionDetails.ItemsDiscount; //drNew["SNRItemsDiscount"] = clsSalesTransactionDetails.SNRItemsDiscount; //drNew["PWDItemsDiscount"] = clsSalesTransactionDetails.PWDItemsDiscount; //drNew["OtherItemsDiscount"] = clsSalesTransactionDetails.OtherItemsDiscount; drNew["Discount"] = clsSalesTransactionDetails.Discount; drNew["VAT"] = clsSalesTransactionDetails.VAT; drNew["VATableAmount"] = clsSalesTransactionDetails.VATableAmount; //drNew["ZeroRatedSales"] = clsSalesTransactionDetails.ZeroRatedSales; drNew["LocalTax"] = clsSalesTransactionDetails.LocalTax; drNew["AmountPaid"] = clsSalesTransactionDetails.AmountPaid; drNew["CashPayment"] = clsSalesTransactionDetails.CashPayment; drNew["ChequePayment"] = clsSalesTransactionDetails.ChequePayment; drNew["CreditCardPayment"] = clsSalesTransactionDetails.CreditCardPayment; drNew["CreditPayment"] = clsSalesTransactionDetails.CreditPayment; drNew["DebitPayment"] = clsSalesTransactionDetails.DebitPayment; drNew["BalanceAmount"] = clsSalesTransactionDetails.BalanceAmount; drNew["ChangeAmount"] = clsSalesTransactionDetails.ChangeAmount; drNew["DateClosed"] = clsSalesTransactionDetails.DateClosed; drNew["PaymentType"] = clsSalesTransactionDetails.PaymentType.ToString("d"); drNew["Charge"] = clsSalesTransactionDetails.Charge; drNew["isConsignment"] = clsSalesTransactionDetails.isConsignment; drNew["CRNo"] = clsSalesTransactionDetails.CRNo.ToString().PadLeft(15, '0'); rptds.Transactions.Rows.Add(drNew); /****************************sales transaction items*****************************/ Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction); mConnection = clsSalesTransactionItems.Connection; mTransaction = clsSalesTransactionItems.Transaction; System.Data.DataTable dt = clsSalesTransactionItems.List(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.TransactionDate, "TransactionItemsID", SortOption.Ascending); foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.SalesTransactionItems.NewRow(); foreach (System.Data.DataColumn dc in rptds.SalesTransactionItems.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.SalesTransactionItems.Rows.Add(drNew); } } clsSalesTransactions.CommitAndDispose(); rpt.SetDataSource(rptds); CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField; CrystalDecisions.Shared.ParameterValues currentValues; CrystalDecisions.Shared.ParameterDiscreteValue discreteParam; paramField = rpt.DataDefinition.ParameterFields["CompanyName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.CompanyName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PrintedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.CashierName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PackedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.WaiterName; // grpItems.Text.Remove(0, 11); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.Address1 + ((!string.IsNullOrEmpty(CompanyDetails.Address2) ? Environment.NewLine + CompanyDetails.Address2 + ", " : " ")) + CompanyDetails.City + " " + CompanyDetails.Country + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " " : " ")) + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "FaxPhone #: " + CompanyDetails.FaxPhone + " " : " ")); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["BIRInfo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = "TIN : " + CompanyDetails.TIN + " VAT Reg." + Environment.NewLine + "BIR Acc #: " + CONFIG.AccreditationNo + " SN#: " + CONFIG.MachineSerialNo + Environment.NewLine + "Permit No: FP102014-064-0015149-00000"; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["TINNo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.CustomerDetails.TINNo; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["LTONo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.CustomerDetails.LTONo; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); //foreach (CrystalDecisions.CrystalReports.Engine.ReportObject objPic in rpt.Section1.ReportObjects) //{ // if (objPic.Name.ToUpper() == "PICLOGO1") // { // objPic = new Bitmap(Application.StartupPath + "/images/ReportLogo.jpg"); // } //} //CRViewer.Visible = true; //CRViewer.ReportSource = rpt; //CRViewer.Show(); try { DateTime logdate = DateTime.Now; string logsdir = System.Configuration.ConfigurationManager.AppSettings["logsdir"].ToString(); if (!Directory.Exists(logsdir + logdate.ToString("MMM"))) { Directory.CreateDirectory(logsdir + logdate.ToString("MMM")); } string logFile = logsdir + logdate.ToString("MMM") + "/CR_" + clsSalesTransactionDetails.TransactionNo + logdate.ToString("yyyyMMddhhmmss") + ".doc"; rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile); } catch { } if (isPrinterOnline(mclsTerminalDetails.SalesInvoicePrinterName)) { rpt.PrintOptions.PrinterName = mclsTerminalDetails.SalesInvoicePrinterName; rpt.PrintToPrinter(1, false, 0, 0); } else { clsEvent.AddEventLn("will not print delivery receipt. printer is offline.", true, mclsSysConfigDetails.WillWriteSystemLog); } rpt.Close(); rpt.Dispose(); } } catch (Exception ex) { InsertErrorLogToFile(ex); } }
private void PrintSOA() { Cursor.Current = Cursors.WaitCursor; try { CRSReports.SOA rpt = new CRSReports.SOA(); AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset(); System.Data.DataRow drNew; /****************************report logo *****************************/ try { System.IO.FileStream fs = new System.IO.FileStream(Application.StartupPath + "/images/ReportLogo.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.FileInfo fi = new System.IO.FileInfo(Application.StartupPath + "/images/ReportLogo.jpg"); byte[] propimg = new byte[fi.Length]; fs.Read(propimg, 0, Convert.ToInt32(fs.Length)); fs.Close(); drNew = rptds.CompanyLogo.NewRow(); drNew["Picture"] = propimg; rptds.CompanyLogo.Rows.Add(drNew); } catch { } /****************************datatable*****************************/ Data.Contacts clsContacts = new Data.Contacts(); System.Data.DataTable dt = clsContacts.ListAsDataTable(ContactID: mclsCustomerDetails.ContactID); clsContacts.CommitAndDispose(); foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.Customer.NewRow(); foreach (System.Data.DataColumn dc in rptds.Customer.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.Customer.Rows.Add(drNew); } dt = (System.Data.DataTable) dgvItems.DataSource; foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.CustomerCredit.NewRow(); foreach (System.Data.DataColumn dc in rptds.CustomerCredit.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.CustomerCredit.Rows.Add(drNew); } rpt.SetDataSource(rptds); CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField; CrystalDecisions.Shared.ParameterValues currentValues; CrystalDecisions.Shared.ParameterDiscreteValue discreteParam; paramField = rpt.DataDefinition.ParameterFields["CompanyName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.CompanyName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PrintedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CashierName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PackedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CashierName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.Address1 + ((!string.IsNullOrEmpty(CompanyDetails.Address2) ? Environment.NewLine + CompanyDetails.Address2 + ", " : " ")) + CompanyDetails.City + " " + CompanyDetails.Country + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " " : " ")) + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "FaxPhone #: " + CompanyDetails.FaxPhone + " " : " ")); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["BIRInfo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = ""; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); //foreach (CrystalDecisions.CrystalReports.Engine.ReportObject objPic in rpt.Section1.ReportObjects) //{ // if (objPic.Name.ToUpper() == "PICLOGO1") // { // objPic = new Bitmap(Application.StartupPath + "/images/ReportLogo.jpg"); // } //} //CRViewer.Visible = true; //CRViewer.ReportSource = rpt; //CRViewer.Show(); try { DateTime logdate = DateTime.Now; string logsdir = System.Configuration.ConfigurationManager.AppSettings["logsdir"].ToString(); if (!Directory.Exists(logsdir + logdate.ToString("MMM"))) { Directory.CreateDirectory(logsdir + logdate.ToString("MMM")); } string logFile = logsdir + logdate.ToString("MMM") + "/SOA_" + logdate.ToString("yyyyMMddhhmmss") + ".doc"; rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile); } catch { } if (isPrinterOnline(TerminalDetails.SalesInvoicePrinterName)) { rpt.PrintOptions.PrinterName = TerminalDetails.SalesInvoicePrinterName; rpt.PrintToPrinter(1, false, 0, 0); rpt.Close(); rpt.Dispose(); Cursor.Current = Cursors.Default; MessageBox.Show("Statement Of Account for " + mclsCustomerDetails.ContactName + " has been printed.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { rpt.Close(); rpt.Dispose(); Cursor.Current = Cursors.Default; MessageBox.Show("Sorry, will not print sales invoice. printer is offline.", "RetailPlus"); } } catch (Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Sorry an error was encountered during printing, please reprint again." + Environment.NewLine + "Details: " + ex.Message, "RetailPlus"); } }
public void PrintOfficialReceipt() { try { CRSReports.OR rpt = new CRSReports.OR(); AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset(); System.Data.DataRow drNew; /****************************report logo *****************************/ try { System.IO.FileStream fs = new System.IO.FileStream(Application.StartupPath + "/images/ReportLogo.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.FileInfo fi = new System.IO.FileInfo(Application.StartupPath + "/images/ReportLogo.jpg"); byte[] propimg = new byte[fi.Length]; fs.Read(propimg, 0, Convert.ToInt32(fs.Length)); fs.Close(); drNew = rptds.CompanyLogo.NewRow(); drNew["Picture"] = propimg; rptds.CompanyLogo.Rows.Add(drNew); } catch { } /****************************sales transaction *****************************/ Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; Data.SalesTransactionDetails clsSalesTransactionDetails = clsSalesTransactions.Details(mclsSalesTransactionDetails.TransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID); Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; Data.ContactDetails clsContactDetails = clsContact.Details(clsSalesTransactionDetails.CustomerID); if (clsSalesTransactionDetails.isExist) { /****************************sales transaction details*****************************/ drNew = rptds.Transactions.NewRow(); drNew["TransactionID"] = clsSalesTransactionDetails.TransactionID; drNew["TransactionNo"] = clsSalesTransactionDetails.TransactionNo; drNew["ORNo"] = clsSalesTransactionDetails.ORNo; drNew["CustomerName"] = clsSalesTransactionDetails.CustomerName; drNew["CustomerAddress"] = clsContactDetails.Address; drNew["CustomerTerms"] = clsSalesTransactionDetails.Terms; drNew["CustomerModeOfterms"] = clsSalesTransactionDetails.ModeOfTerms; drNew["CustomerBusinessName"] = clsContactDetails.BusinessName; drNew["CustomerTelNo"] = clsContactDetails.TelephoneNo; drNew["CashierName"] = clsSalesTransactionDetails.CashierName; drNew["CreatedByName"] = clsSalesTransactionDetails.CreatedByName; drNew["AgentName"] = clsSalesTransactionDetails.AgentName; drNew["TerminalNo"] = clsSalesTransactionDetails.TerminalNo; drNew["TransactionDate"] = clsSalesTransactionDetails.TransactionDate; drNew["DateSuspended"] = clsSalesTransactionDetails.DateSuspended.ToString(); drNew["DateResumed"] = clsSalesTransactionDetails.DateResumed; drNew["TransactionStatus"] = clsSalesTransactionDetails.TransactionStatus; drNew["SubTotal"] = clsSalesTransactionDetails.SubTotal; drNew["ItemsDiscount"] = clsSalesTransactionDetails.ItemsDiscount; //drNew["SNRItemsDiscount"] = clsSalesTransactionDetails.SNRItemsDiscount; //drNew["PWDItemsDiscount"] = clsSalesTransactionDetails.PWDItemsDiscount; //drNew["OtherItemsDiscount"] = clsSalesTransactionDetails.OtherItemsDiscount; drNew["Discount"] = clsSalesTransactionDetails.Discount; drNew["VAT"] = clsSalesTransactionDetails.VAT; drNew["VATableAmount"] = clsSalesTransactionDetails.VATableAmount; //drNew["ZeroRatedSales"] = clsSalesTransactionDetails.ZeroRatedSales; drNew["LocalTax"] = clsSalesTransactionDetails.LocalTax; drNew["AmountPaid"] = clsSalesTransactionDetails.AmountPaid; drNew["CashPayment"] = clsSalesTransactionDetails.CashPayment; drNew["ChequePayment"] = clsSalesTransactionDetails.ChequePayment; drNew["CreditCardPayment"] = clsSalesTransactionDetails.CreditCardPayment; drNew["CreditPayment"] = clsSalesTransactionDetails.CreditPayment; drNew["DebitPayment"] = clsSalesTransactionDetails.DebitPayment; drNew["BalanceAmount"] = clsSalesTransactionDetails.BalanceAmount; drNew["ChangeAmount"] = clsSalesTransactionDetails.ChangeAmount; drNew["DateClosed"] = clsSalesTransactionDetails.DateClosed; drNew["PaymentType"] = clsSalesTransactionDetails.PaymentType.ToString("d"); drNew["Charge"] = clsSalesTransactionDetails.Charge; drNew["isConsignment"] = clsSalesTransactionDetails.isConsignment; drNew["CRNo"] = clsSalesTransactionDetails.CRNo; rptds.Transactions.Rows.Add(drNew); /****************************sales transaction items*****************************/ Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; System.Data.DataTable dt = clsSalesTransactionItems.List(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.TransactionDate, "TransactionItemsID", SortOption.Ascending); foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.SalesTransactionItems.NewRow(); foreach (System.Data.DataColumn dc in rptds.SalesTransactionItems.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.SalesTransactionItems.Rows.Add(drNew); } } clsSalesTransactions.CommitAndDispose(); rpt.SetDataSource(rptds); CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField; CrystalDecisions.Shared.ParameterValues currentValues; CrystalDecisions.Shared.ParameterDiscreteValue discreteParam; paramField = rpt.DataDefinition.ParameterFields["CompanyName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.CompanyName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PrintedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.CashierName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PackedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.WaiterName; // grpItems.Text.Remove(0, 11); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.Address1 + ((!string.IsNullOrEmpty(CompanyDetails.Address2) ? Environment.NewLine + CompanyDetails.Address2 + ", " : " ")) + CompanyDetails.City + " " + CompanyDetails.Country + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " " : " ")) + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "FaxPhone #: " + CompanyDetails.FaxPhone + " " : " ")); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["BIRInfo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = "TIN : " + CompanyDetails.TIN + " VAT Reg." + Environment.NewLine + "BIR Acc #: " + CONFIG.AccreditationNo + " SN#: " + CONFIG.MachineSerialNo + Environment.NewLine + "Permit No: FP102014-064-0015149-00000"; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); //foreach (CrystalDecisions.CrystalReports.Engine.ReportObject objPic in rpt.Section1.ReportObjects) //{ // if (objPic.Name.ToUpper() == "PICLOGO1") // { // objPic = new Bitmap(Application.StartupPath + "/images/ReportLogo.jpg"); // } //} //CRViewer.Visible = true; //CRViewer.ReportSource = rpt; //CRViewer.Show(); try { DateTime logdate = DateTime.Now; string logsdir = System.Configuration.ConfigurationManager.AppSettings["logsdir"].ToString(); if (!Directory.Exists(logsdir + logdate.ToString("MMM"))) { Directory.CreateDirectory(logsdir + logdate.ToString("MMM")); } string logFile = logsdir + logdate.ToString("MMM") + "/OR_" + clsSalesTransactionDetails.TransactionNo + logdate.ToString("yyyyMMddhhmmss") + ".doc"; rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile); } catch { } if (isPrinterOnline(mclsTerminalDetails.SalesInvoicePrinterName)) { rpt.PrintOptions.PrinterName = mclsTerminalDetails.SalesInvoicePrinterName; rpt.PrintToPrinter(1, false, 0, 0); } else { clsEvent.AddEventLn("will not print sales invoice. printer is offline.", true, mclsSysConfigDetails.WillWriteSystemLog); } rpt.Close(); rpt.Dispose(); } catch (Exception ex) { InsertErrorLogToFile(ex); MessageBox.Show("Sorry an error was encountered during printing, please reprint again." + Environment.NewLine + "Details: " + ex.Message, "RetailPlus"); } }