private void cmdInv_Click(System.Object eventSender, System.EventArgs eventArgs) { CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); int personID = 0; int posID = 0; string[] lArray = null; string lAddress = null; //On Error Resume Next ADODB.Connection cn = default(ADODB.Connection); short x = 0; string databaseName = null; int lID = 0; CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); ADODB.Recordset rs = default(ADODB.Recordset); ADODB.Recordset rsItems = default(ADODB.Recordset); string sql = null; //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"' System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; if (lvTransaction.FocusedItem == null) return; //lID = Mid(Split(Me.lvTransaction.SelectedItem.Key, "_")(0), 2) if (Convert.ToDouble(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[2]) == 0) { Interaction.MsgBox("There is no Sale document attached!", MsgBoxStyle.Information); System.Windows.Forms.Cursor.Current = Cursors.Default; return; } lID = Convert.ToInt32(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[2]); //If openConnection() Then // frmMain.lblPath.Caption = serverPath // closeConnection //End If //Set cn = openConnectionInstance() //lMonth = cmbMonth.ItemData(cmbMonth.ListIndex) //Dim lLineitem As lineitem //If lMonth = gMonthEnd Then // databaseName = "" //Else // databaseName = "Month" & lMonth & ".mdb" //End If databaseName = Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[1]; cn = modRecordSet.openConnectionInstance(ref databaseName); if (cn == null) { return; } transaction lTransaction = new transaction(); lineItem lLineitem = null; customer lCustomer = new customer(); transactionSpecial lSpecial = new transactionSpecial(); if (Convert.ToDouble(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[3]) == 2) { //sale //Dim Report As New cryReceipt //Set Report = New cryReceipt rs = new ADODB.Recordset(); sql = "SELECT Sale.* From Sale WHERE (((SaleID)=" + lID + "));"; rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); if (rs.RecordCount) { lTransaction.cashierID = rs.Fields("Sale_PersonID").Value; lTransaction.channelID = rs.Fields("Sale_ChannelID").Value; lTransaction.managerID = rs.Fields("Sale_ManagerID").Value; lTransaction.paymentDiscount = rs.Fields("Sale_Discount").Value; lTransaction.paymentSlip = rs.Fields("Sale_Slip").Value; lTransaction.paymentSubTotal = rs.Fields("Sale_SubTotal").Value; lTransaction.paymentTender = rs.Fields("Sale_Tender").Value; lTransaction.paymentTotal = rs.Fields("Sale_Total").Value; lTransaction.paymentType = rs.Fields("Sale_PaymentType").Value; lTransaction.posID = rs.Fields("Sale_POSID").Value; lTransaction.transactionDate = rs.Fields("Sale_DatePOS").Value; lTransaction.transactionID = rs.Fields("Sale_Reference").Value + ""; lTransaction.transactionType = "Sale"; //If prPrevSerial_p = True Then strSerial = rs("Sale_Serialref") rs.Close(); rs = modRecordSet.getRS(ref "SELECT * FROM Company"); lTransaction.companyName = rs.Fields("Company_Name").Value; //gParameters.companyName lTransaction.footer = " "; //gParameters.footer & "" lTransaction.heading1 = rs.Fields("Company_PhysicalAddress").Value; //gParameters.heading1 & "" lTransaction.heading2 = " "; //gParameters.heading2 & "" lTransaction.heading3 = " "; //gParameters.heading3 & "" lTransaction.taxNumber = rs.Fields("Company_TaxNumber").Value; //gParameters.taxNumber & "" rs.Close(); sql = "SELECT [Person_FirstName] & ' ' & [Person_LastName] AS personName From Person WHERE (((PersonID)=" + lTransaction.cashierID + "));"; rs = modRecordSet.getRS(ref sql); //rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText if (rs.RecordCount) { lTransaction.cashierName = rs.Fields("personName").Value + ""; } rs.Close(); sql = "SELECT [Person_FirstName] & ' ' & [Person_LastName] AS personName From Person WHERE (((PersonID)=" + lTransaction.managerID + "));"; rs = modRecordSet.getRS(ref sql); //rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText if (rs.RecordCount) { lTransaction.managerName = rs.Fields("personName").Value + ""; } rs.Close(); sql = "SELECT POS_Name From POS WHERE (((POS.POSID)=" + lTransaction.posID + "));"; rs = modRecordSet.getRS(ref sql); //rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText if (rs.RecordCount) { lTransaction.posName = rs.Fields("POS_Name").Value + ""; } rs.Close(); //sql = "SELECT SaleItem.*, StockItem.StockItem_Name AS longName, StockItem.StockItem_ReceiptName AS receiptName, Catalogue.Catalogue_Barcode AS code,'Sale' as saleType FROM (StockItem INNER JOIN SaleItem ON StockItem.StockItemID = SaleItem.SaleItem_StockItemID) INNER JOIN Catalogue ON (Catalogue.Catalogue_Quantity = SaleItem.SaleItem_ShrinkQuantity) AND (SaleItem.SaleItem_StockItemID = Catalogue.Catalogue_StockItemID) WHERE (((SaleItem.SaleItem_DepositType)=0) AND ((SaleItem.SaleItem_SaleID)=" & lID & "))" //sql = sql & " UNION " //sql = sql & "SELECT SaleItem.*, Deposit.Deposit_Name AS longName, Deposit.Deposit_ReceiptName AS receiptName, Deposit.Deposit_Key AS code,'Deposit' as saleType FROM Deposit INNER JOIN SaleItem ON Deposit.DepositID = SaleItem.SaleItem_StockItemID WHERE (((SaleItem.SaleItem_DepositType)<>0) AND ((SaleItem.SaleItem_SaleID)=" & lID & "));" sql = "SELECT SaleItem.*, 'Sale' AS saleType From SaleItem Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_SaleID) = " + lID + "))"; sql = sql + " UNION "; sql = sql + "SELECT SaleItem.*, 'Deposit' AS saleType From SaleItem WHERE (((SaleItem.SaleItem_DepositType)<>0) AND ((SaleItem.SaleItem_SaleID)=" + lID + "));"; rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); while (!(rs.EOF)) { lLineitem = new lineItem(); lLineitem.build = 0; lLineitem.depositType = rs.Fields("SaleItem_DepositType").Value; lLineitem.id = rs.Fields("SaleItem_StockItemID").Value; lLineitem.lineNo = rs.Fields("SaleItem_LineNo").Value; lLineitem.originalPrice = rs.Fields("SaleItem_PriceOriginal").Value; lLineitem.price = rs.Fields("SaleItem_Price").Value; lLineitem.quantity = rs.Fields("SaleItem_Quantity").Value; lLineitem.reversal = rs.Fields("SaleItem_Reversal").Value; lLineitem.revoke = rs.Fields("SaleItem_Revoke").Value; lLineitem.setBuild = rs.Fields("SaleItem_SetID").Value; lLineitem.shrink = rs.Fields("SaleItem_ShrinkQuantity").Value; lLineitem.vat = rs.Fields("SaleItem_Vat").Value; lLineitem.transactionType = rs.Fields("SaleType").Value + ""; //lLineitem.code = rs("Code") & "" switch (lLineitem.depositType) { case 0: sql = "SELECT StockItem.StockItem_Name AS longName, StockItem.StockItem_ReceiptName AS receiptName From StockItem WHERE (((StockItemID)=" + rs.Fields("SaleItem_StockItemID").Value + "));"; rsItems = modRecordSet.getRS(ref sql); if (rsItems.RecordCount) { lLineitem.name = rs.Fields("SaleItem_ShrinkQuantity").Value + " x " + rsItems.Fields("longName").Value; lLineitem.receiptName = rs.Fields("SaleItem_ShrinkQuantity").Value + "x" + rsItems.Fields("receiptName").Value; } rsItems.Close(); sql = "SELECT Catalogue.Catalogue_Barcode AS code FROM Catalogue WHERE (Catalogue.Catalogue_Quantity = " + rs.Fields("SaleItem_ShrinkQuantity").Value + ") AND (Catalogue.Catalogue_StockItemID = " + rs.Fields("SaleItem_StockItemID").Value + ");"; rsItems = modRecordSet.getRS(ref sql); if (rsItems.RecordCount) { lLineitem.code = rsItems.Fields("Code").Value + ""; } rsItems.Close(); break; case 1: sql = "SELECT Deposit.Deposit_Name AS longName, Deposit.Deposit_ReceiptName AS receiptName, Deposit.Deposit_Key AS code From Deposit WHERE (((DepositID)=" + rs.Fields("SaleItem_StockItemID").Value + "));"; rsItems = modRecordSet.getRS(ref sql); if (rsItems.RecordCount) { lLineitem.name = rs.Fields("longName").Value + "-Unit"; lLineitem.receiptName = rs.Fields("receiptName").Value + "(U)"; lLineitem.code = rsItems.Fields("Code").Value + ""; } rsItems.Close(); break; case 2: sql = "SELECT Deposit.Deposit_Name AS longName, Deposit.Deposit_ReceiptName AS receiptName, Deposit.Deposit_Key AS code From Deposit WHERE (((DepositID)=" + rs.Fields("SaleItem_StockItemID").Value + "));"; rsItems = modRecordSet.getRS(ref sql); if (rsItems.RecordCount) { lLineitem.name = rs.Fields("longName").Value + "-Empty Crate"; lLineitem.receiptName = rs.Fields("receiptName").Value + "(E)"; lLineitem.code = rsItems.Fields("Code").Value + ""; } rsItems.Close(); break; case 3: sql = "SELECT Deposit.Deposit_Name AS longName, Deposit.Deposit_ReceiptName AS receiptName, Deposit.Deposit_Key AS code From Deposit WHERE (((DepositID)=" + rs.Fields("SaleItem_StockItemID").Value + "));"; rsItems = modRecordSet.getRS(ref sql); if (rsItems.RecordCount) { lLineitem.name = rs.Fields("longName").Value + "-Full Case"; lLineitem.receiptName = rs.Fields("receiptName").Value + "(F)"; lLineitem.code = rsItems.Fields("Code").Value + ""; } rsItems.Close(); break; } lTransaction.lineItems.Add(ref lLineitem); rs.MoveNext(); } rs.Close(); sql = "SELECT Customer.*, CustomerTransaction.* FROM (CustomerTransaction INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) INNER JOIN Customer ON CustomerTransaction.CustomerTransaction_CustomerID = Customer.CustomerID WHERE (((Sale.SaleID)=" + lID + "));"; rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); if (rs.RecordCount) { lCustomer.channelID = lTransaction.channelID; lCustomer.creditLimit = rs.Fields("Customer_ChannelID").Value; lCustomer.department = rs.Fields("Customer_DepartmentName").Value + ""; lCustomer.fax = rs.Fields("Customer_Fax").Value + ""; lCustomer.Key = rs.Fields("CustomerID").Value; lCustomer.name = rs.Fields("Customer_InvoiceName").Value + ""; lCustomer.outstanding = 0; lCustomer.person = rs.Fields("Customer_FirstName").Value + " " + rs.Fields("Customer_Surname").Value; lCustomer.physical = rs.Fields("Customer_PhysicalAddress").Value + ""; lCustomer.postal = rs.Fields("Customer_PostalAddress").Value + ""; lCustomer.signed_Renamed = rs.Fields("CustomerTransaction_PersonName").Value; lCustomer.telephone = rs.Fields("Customer_Telephone").Value + ""; lCustomer.terms = Convert.ToInt16(rs.Fields("Customer_Terms").Value + ""); lCustomer.tax = rs.Fields("Customer_VatNumber").Value + ""; if (rs.Fields("CustomerTransaction_TransactionTypeID").Value == 3) { lTransaction.transactionType = "Payment"; lTransaction.paymentDiscount = 0; } lTransaction.customer_Renamed = lCustomer; } rs.Close(); sql = "SELECT Consignment.* FROM Consignment INNER JOIN Sale ON Consignment.Consignment_SaleID = Sale.SaleID WHERE (((Sale.SaleID)=" + lID + "));"; rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); if (rs.BOF & rs.EOF) { } else { lSpecial.address = rs.Fields("Consignment_Address").Value; lSpecial.mobile = rs.Fields("Consignment_Mobile").Value; lSpecial.name = rs.Fields("Consignment_Name").Value; lSpecial.quote = 0; lSpecial.saleID = lID; lSpecial.telephone = rs.Fields("Consignment_Number").Value; lSpecial.transactionType = "Consignment"; lTransaction.transactionSpecial_Renamed = lSpecial; } rs.Close(); sql = "SELECT Consignment.* FROM Consignment INNER JOIN Sale ON Consignment.Consignment_CompleteSaleID = Sale.SaleID WHERE (((Sale.SaleID)=" + lID + "));"; rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); if (rs.BOF & rs.EOF) { } else { lSpecial.address = rs.Fields("Consignment_Address").Value; lSpecial.mobile = rs.Fields("Consignment_Mobile").Value; lSpecial.name = rs.Fields("Consignment_Name").Value; lSpecial.quote = 0; lSpecial.saleID = lID; lSpecial.telephone = rs.Fields("Consignment_Number").Value; lSpecial.transactionType = "Consignment Complete"; lTransaction.transactionSpecial_Renamed = lSpecial; } printTransactionA4(ref lTransaction); } } else if (Convert.ToDouble(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[3]) == 3) { //payment //Dim Report As New cryPayment Report.Load("cryPayment.rpt"); rs = modRecordSet.getRS(ref "SELECT * FROM Company"); Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name")); if (Information.IsDBNull(rs.Fields("Company_PhysicalAddress").Value)) { } else { lAddress = Strings.Replace(rs.Fields("Company_PhysicalAddress").Value, Constants.vbCrLf, ", "); if (Strings.Right(lAddress, 2) == ", ") { lAddress = Strings.Left(lAddress, Strings.Len(lAddress) - 2); } } Report.SetParameterValue("txtCompanyDetails1", lAddress); if (Information.IsDBNull(rs.Fields("Company_Telephone").Value)) { } else { Report.SetParameterValue("txtCompanyDetails2", rs.Fields("Company_Telephone")); } if (Information.IsDBNull(rs.Fields("Company_TaxNumber").Value)) { } else { Report.SetParameterValue("txtCompanyDetails4", "TAX NO :" + rs.Fields("Company_TaxNumber").Value); } //If lTransaction.heading2 <> "" Then // Report.txtCompanyDetails2.SetText lTransaction.heading2 // If lTransaction.heading3 <> "" Then // Report.txtCompanyDetails3.SetText lTransaction.heading3 // // Else // If lTransaction.taxNumber <> "" Then // Report.txtCompanyDetails4.SetText "TAX NO :" & lTransaction.taxNumber // End If // End If //Else // If lTransaction.heading3 <> "" Then // Report.txtCompanyDetails2.SetText lTransaction.heading3 // Else // If lTransaction.taxNumber <> "" Then // Report.txtCompanyDetails2.SetText "TAX NO :" & lTransaction.taxNumber // End If // End If //End If rs.Close(); Report.SetParameterValue("txtCustomer", _txtFields_2.Text); if (!string.IsNullOrEmpty(_txtFields_6.Text)) { lArray = Strings.Split(_txtFields_6.Text, Constants.vbCrLf); Report.SetParameterValue("txtCustAddress1", lArray[0]); if (Information.UBound(lArray) >= 1) Report.SetParameterValue("txtCustAddress2", lArray[1]); if (Information.UBound(lArray) >= 2) Report.SetParameterValue("txtCustAddress3", lArray[2]); if (Information.UBound(lArray) >= 3) Report.SetParameterValue("txtCustAddress4", lArray[3]); } if (!string.IsNullOrEmpty(_txtFields_0.Text)) Report.SetParameterValue("txtCustAddress5", "TAX NO: " + _txtFields_0.Text); //If LCase(databaseName) = "pricing.mdb" Then // sql = "SELECT Sale.SaleID, POS.POS_Name, Person.Person_FirstName, Person.Person_LastName, Sale.Sale_Date, Sale.Sale_DatePOS, Sale.Sale_Reference, Sale.Sale_Total, Sale.Sale_Tender FROM (Sale INNER JOIN POS ON Sale.Sale_PosID = POS.POSID) INNER JOIN Person ON Sale.Sale_PersonID = Person.PersonID WHERE (((Sale.SaleID)=" & lID & "));" //Else // sql = "SELECT Sale.SaleID, POS.POS_Name, M_Person.Person_FirstName, M_Person.Person_LastName, Sale.Sale_Date, Sale.Sale_DatePOS, Sale.Sale_Reference, Sale.Sale_Total, Sale.Sale_Tender FROM (Sale INNER JOIN POS ON Sale.Sale_PosID = POS.POSID) INNER JOIN M_Person ON Sale.Sale_PersonID = M_Person.PersonID WHERE (((Sale.SaleID)=" & lID & "));" //End If //sql = "SELECT Sale.SaleID, POS.POS_Name, Person.Person_FirstName, Person.Person_LastName, Sale.Sale_Date, Sale.Sale_DatePOS, Sale.Sale_Reference, Sale.Sale_Total, Sale.Sale_Tender FROM (Sale INNER JOIN POS ON Sale.Sale_PosID = POS.POSID) INNER JOIN Person ON Sale.Sale_PersonID = Person.PersonID WHERE (((Sale.SaleID)=" & lID & "));" sql = "SELECT Sale.* From Sale WHERE (((SaleID)=" + lID + "));"; rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); if (rs.RecordCount) { posID = rs.Fields("Sale_PosID").Value; personID = rs.Fields("Sale_PersonID").Value; Report.SetParameterValue("txtInvoiceNumber", rs.Fields("Sale_Reference")); Report.SetParameterValue("txtInvoiceDate", Strings.Format(rs.Fields("Sale_DatePOS").Value, "dd mmm yyyy hh:mm")); //Report.txtPOS.SetText rs("POS_Name") //Report.txtCashier.SetText rs("Person_FirstName") & rs("Person_LastName") Report.SetParameterValue("txtAmount", Strings.FormatNumber(rs.Fields("Sale_Total").Value, 2)); Report.SetParameterValue("txtChange", Strings.FormatNumber(rs.Fields("Sale_Tender").Value - rs.Fields("Sale_Total").Value, 2)); // lTransaction.paymentTotal - lTransaction.paymentTender, 2) Report.SetParameterValue("txtTender", Strings.FormatNumber(rs.Fields("Sale_Tender").Value, 2)); // lTransaction.paymentTender, 2) //Report.txtPaidBy.SetText lTransaction.customer.signed Report.ReportDefinition.Sections("txtPaidBy").SectionFormat.EnableSuppress = true; rs.Close(); sql = "SELECT [Person_FirstName] & ' ' & [Person_LastName] AS personName From Person WHERE (((PersonID)=" + personID + "));"; rs = modRecordSet.getRS(ref sql); if (rs.RecordCount) { Report.SetParameterValue("txtCashier", rs.Fields("personName").Value + ""); } rs.Close(); sql = "SELECT POS_Name From POS WHERE (((POS.POSID)=" + posID + "));"; rs = modRecordSet.getRS(ref sql); if (rs.RecordCount) { Report.SetParameterValue("txtPOS", rs.Fields("POS_Name").Value + ""); } rs.Close(); sql = "SELECT CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_ReferenceID From CustomerTransaction WHERE (((CustomerTransaction.CustomerTransaction_TransactionTypeID)=8) AND ((CustomerTransaction.CustomerTransaction_ReferenceID)=" + lID + "));"; Debug.Print(sql); rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText); if (rs.RecordCount) { Report.SetParameterValue("txtSettlement", Strings.FormatNumber(rs.Fields("CustomerTransaction_Amount").Value, 2)); } else { Report.SetParameterValue("txtSettlement", Strings.FormatNumber("0.00", 2)); } My.MyProject.Forms.frmReportShow.Text = "Customer Statement"; My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report; My.MyProject.Forms.frmReportShow.mReport = Report; My.MyProject.Forms.frmReportShow.sMode = "0"; My.MyProject.Forms.frmReportShow.CRViewer1.Refresh(); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; My.MyProject.Forms.frmReportShow.ShowDialog(); } else { ReportNone.Load("cryNoRecords.rpt"); ReportNone.SetParameterValue("txtCompanyName", rs.Fields("Company_Name")); ReportNone.SetParameterValue("txtTitle", "Customer Statement"); //UPGRADE_WARNING: Couldn't resolve default property of object ReportNone.txtTitle. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' My.MyProject.Forms.frmReportShow.Text = ReportNone.ParameterFields("txtTitle").ToString; My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = ReportNone; My.MyProject.Forms.frmReportShow.mReport = ReportNone; My.MyProject.Forms.frmReportShow.sMode = "0"; My.MyProject.Forms.frmReportShow.CRViewer1.Refresh(); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; My.MyProject.Forms.frmReportShow.ShowDialog(); return; } } }
private void printTransactionA4(ref transaction lTransaction) { string typeQuote = null; string typeAccountPayment = null; string typeConsignment = null; string typeConsignmentReturn = null; string typeAccountSaleCOD = null; string typeAccountSale = null; int lRetVal = 0; int hkey = 0; string vValue = null; decimal lnVat = default(decimal); string gPath = null; ADODB.Recordset rs = default(ADODB.Recordset); customer customer_Renamed = null; string sql = null; ADODB.Recordset rsNew = new ADODB.Recordset(); //Dim rsNew2 As New Recordset lineItem lineitem_Renamed = null; string lString = null; CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); short lPaymentType = 0; string[] lArray = null; decimal TCurrency = default(decimal); decimal QuoteTotal = default(decimal); // ERROR: Not supported in C#: OnErrorStatement //Set which invoice is required string sPrintGST = null; sPrintGST = ""; QuoteTotal = 0; //lRetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\4POS\pos", 0, KEY_QUERY_VALUE, hkey) //lRetVal = QueryValueEx(hkey, "printGST", sPrintGST) //RegCloseKey (hkey) //If sPrintGST = "" Then sPrintGST = "0" // If gParameters.A4Exclusive = True Then // Set Report = New cryReceipt1 // ElseIf sPrintGST = "1" Then // Set Report = New cryReceipt1 // Else Report.Load("cryReceipt.rpt"); // End If //lPaymentType = getPaymentType(lTransaction) //If lPaymentType And typeAccountPayment Then // printTransactionPaymentA4 lTransaction // Exit Sub //End If //Dim lnVat As Currency gPath = "C:\\4POS\\pos\\"; int lVatAmount = 0; int lAmount = 0; rsNew.Open(gPath + "data\\item.rs", , ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic); //, adOpenStatic, adLockOptimistic lnVat = 0; //a = rsNew.RecordCount //rsNew.Close //rsNew2.source = rsNew.source //rsNew("transactionItem_quantity").Type = rsNew("transactionItem_price").Type //rsNew("transactionItem_quantity").DefinedSize = rsNew("transactionItem_price").DefinedSize //rsNew2("transactionItem_quantity").Attributes = rsNew("transactionItem_price").Attributes //rsNew2("transactionItem_quantity").NumericScale = rsNew("transactionItem_price").NumericScale //rsNew2("transactionItem_quantity").Precision = rsNew("transactionItem_price").Precision foreach (lineItem lineitem_Renamed_loopVariable in lTransaction.lineItems) { lineitem_Renamed = lineitem_Renamed_loopVariable; rsNew.AddNew(); if (lineitem_Renamed.revoke) { } else { rsNew.Fields("transactionItem_build").Value = lineitem_Renamed.build; rsNew.Fields("transactionItem_code").Value = lineitem_Renamed.code; rsNew.Fields("transactionItem_depositType").Value = lineitem_Renamed.depositType; rsNew.Fields("transactionItem_id").Value = lineitem_Renamed.id; rsNew.Fields("transactionItem_lineNo").Value = lineitem_Renamed.lineNo; rsNew.Fields("transactionItem_name").Value = lineitem_Renamed.name; rsNew.Fields("transactionItem_originalPrice").Value = lineitem_Renamed.originalPrice; rsNew.Fields("transactionItem_price").Value = lineitem_Renamed.price; rsNew.Fields("transactionItem_quantity").Value = lineitem_Renamed.quantity; rsNew.Fields("transactionItem_receiptName").Value = Strings.LTrim(Strings.Mid(lineitem_Renamed.receiptName, Strings.InStr(1, lineitem_Renamed.receiptName, "x") + 1, Strings.Len(lineitem_Renamed.receiptName))); //lineitem.receiptName rsNew.Fields("transactionItem_reversal").Value = lineitem_Renamed.reversal; rsNew.Fields("transactionItem_revoke").Value = lineitem_Renamed.revoke; rsNew.Fields("transactionItem_set").Value = lineitem_Renamed.setBuild; rsNew.Fields("transactionItem_shrink").Value = lineitem_Renamed.shrink; rsNew.Fields("transactionItem_type").Value = lineitem_Renamed.transactionType; rsNew.Fields("transactionItem_vat").Value = lineitem_Renamed.vat; if (lineitem_Renamed.vat > 0) lnVat = lnVat + ((lineitem_Renamed.quantity * lineitem_Renamed.price) - ((lineitem_Renamed.quantity * lineitem_Renamed.price) / (1 + (lineitem_Renamed.vat / 100)))); QuoteTotal = QuoteTotal + (lineitem_Renamed.quantity * lineitem_Renamed.price); //If gParameters.A4Exclusive = True Then TCurrency = TCurrency + ((lineitem.quantity * lineitem.price) / (1 + (lineitem.vat) / 100)) //TCurrency = 0 'TCurrency + ((lineitem.quantity * lineitem.price) / (1 + (lineitem.vat) / 100)) rsNew.update(); } } //rsNew.MoveFirst //vValue = rsNew("transactionItem_quantity") vValue = ""; lRetVal = modUtilities.RegOpenKeyEx(modUtilities.HKEY_LOCAL_MACHINE, "Software\\4POS\\pos", 0, modUtilities.KEY_QUERY_VALUE, ref hkey); lRetVal = modUtilities.QueryValueEx(hkey, "A4Items", ref vValue); modUtilities.RegCloseKey(hkey); if (string.IsNullOrEmpty(vValue)) vValue = "0"; if (vValue == "1") { rsNew.Sort = "transactionItem_receiptName"; } else if (vValue == "0") { } Report.Database.Tables(1).SetDataSource(rsNew); //Report.Database.Tables(2).SetDataSource rsNew, 3 Report.SetParameterValue("txtCompanyName", lTransaction.companyName); Report.SetParameterValue("txtCompanyDetails1", lTransaction.heading1); if (!string.IsNullOrEmpty(lTransaction.heading2)) { Report.SetParameterValue("txtCompanyDetails2", lTransaction.heading2); if (!string.IsNullOrEmpty(lTransaction.heading3)) { Report.SetParameterValue("txtCompanyDetails3", lTransaction.heading3); //If gParameters.tr_PrintInvoice = False Then if (!string.IsNullOrEmpty(lTransaction.taxNumber)) { Report.SetParameterValue("txtCompanyDetails4", "TAX NO :" + lTransaction.taxNumber); } //End If } else { //If gParameters.tr_PrintInvoice = False Then if (!string.IsNullOrEmpty(lTransaction.taxNumber)) { Report.SetParameterValue("txtCompanyDetails3", "TAX NO :" + lTransaction.taxNumber); } //End If } } else { if (!string.IsNullOrEmpty(lTransaction.heading3)) { Report.SetParameterValue("txtCompanyDetails2", lTransaction.heading3); //If gParameters.tr_PrintInvoice = False Then if (!string.IsNullOrEmpty(lTransaction.taxNumber)) { Report.SetParameterValue("txtCompanyDetails3", "TAX NO :" + lTransaction.taxNumber); } //End If } else { //If gParameters.tr_PrintInvoice = False Then if (!string.IsNullOrEmpty(lTransaction.taxNumber)) { Report.SetParameterValue("txtCompanyDetails2", "TAX NO :" + lTransaction.taxNumber); } //End If } } lString = lString + lTransaction.heading1 + Strings.Chr(13); lString = lString + lTransaction.heading2 + Strings.Chr(13); lString = lString + lTransaction.heading3 + Strings.Chr(13); if (!string.IsNullOrEmpty(lTransaction.taxNumber)) lString = lString + "TAX NO :" + lTransaction.taxNumber; lString = Strings.Replace(lString, Strings.Chr(13) + Strings.Chr(13), Strings.Chr(13)); lString = Strings.Replace(lString, Strings.Chr(13) + Strings.Chr(13), Strings.Chr(13)); Report.SetParameterValue("txtInvoiceNumber", lTransaction.transactionID); Report.SetParameterValue("txtInvoiceDate", Strings.Format(lTransaction.transactionDate, "dd mmm yyyy hh:mm")); Report.SetParameterValue("txtPOS", lTransaction.posName); Report.SetParameterValue("txtCashier", lTransaction.cashierName); if (Strings.LCase(lTransaction.transactionType) == "deposit credit") { Report.SetParameterValue("txtType", "DEPOSIT CREDIT"); Report.SetParameterValue("txtTypeSpecial", ""); Report.SetParameterValue("txtInvoiceNumber", "[" + lTransaction.transactionID + "]"); } else { if (lTransaction.transactionSpecial_Renamed == null) { if (lTransaction.customer_Renamed == null) { Report.SetParameterValue("txtCustomer", "Cash Sale"); switch (lTransaction.paymentType) { case Convert.ToString(1): Report.SetParameterValue("txtCustomer", "Cash Sale"); break; case Convert.ToString(2): Report.SetParameterValue("txtCustomer", "Credit Card Sale"); break; case Convert.ToString(3): Report.SetParameterValue("txtCustomer", "Debit Card Sale"); break; case Convert.ToString(4): Report.SetParameterValue("txtCustomer", "Cheque Sale"); break; case Convert.ToString(7): Report.SetParameterValue("txtCustomer", "Split Tender"); break; default: Report.SetParameterValue("txtCustomer", "Cash Sale"); break; } Report.SetParameterValue("txtType", "TAX INVOICE"); Report.SetParameterValue("txtTypeSpecial", ""); } else { Report.SetParameterValue("txtSigned", lTransaction.customer_Renamed.signed_Renamed); Report.SetParameterValue("txtCustomer", lTransaction.customer_Renamed.name); if (!string.IsNullOrEmpty(lTransaction.customer_Renamed.physical)) { lArray = Strings.Split(lTransaction.customer_Renamed.physical, Constants.vbCrLf); Report.SetParameterValue("txtCustAddress1", lArray[0]); if (Information.UBound(lArray) >= 1) Report.SetParameterValue("txtCustAddress2", lArray[1]); if (Information.UBound(lArray) >= 2) Report.SetParameterValue("txtCustAddress3", lArray[2]); if (Information.UBound(lArray) >= 3) Report.SetParameterValue("txtCustAddress4", lArray[3]); } if (!string.IsNullOrEmpty(lTransaction.customer_Renamed.tax)) Report.SetParameterValue("txtCustAddress5", "TAX NO: " + lTransaction.customer_Renamed.tax); //Report.txtCustomerAddress.SetText lTransaction.customer.name & Chr(13) & Chr(13) & Replace(lTransaction.customer.physical, Chr(10), "") & Chr(13) & Chr(13) & "TAX NO: " & lTransaction.customer.tax Report.SetParameterValue("txtType", "TAX INVOICE"); if (lTransaction.customer_Renamed.terms) { Report.SetParameterValue("txtTypeSpecial", "Account Sale"); } else { Report.SetParameterValue("txtTypeSpecial", "Cash Sale"); } } } else { Report.SetParameterValue("txtType", ""); Report.SetParameterValue("txtTypeSpecial", ""); if (lPaymentType & typeQuote) { Report.SetParameterValue("txtType", "QUOTE"); if (lPaymentType & typeConsignment) { if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) { Report.SetParameterValue("txtTypeSpecial", "Account Consignment"); } else { Report.SetParameterValue("txtTypeSpecial", "Consignment"); } } else if (lPaymentType & typeConsignmentReturn) { if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) { Report.SetParameterValue("txtTypeSpecial", "Account Consignment Return Quote"); } else { Report.SetParameterValue("txtTypeSpecial", "Consignment Return"); } } else { if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) { Report.SetParameterValue("txtTypeSpecial", "Account"); } else { Report.SetParameterValue("txtTypeSpecial", ""); } } } else if (lPaymentType & typeConsignment) { if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) { Report.SetParameterValue("txtType", "Account Consignment Sale"); } else { Report.SetParameterValue("txtType", "Consignment Sale"); } } else if (lPaymentType & typeConsignmentReturn) { if (lPaymentType & typeAccountSale | lPaymentType & typeAccountSaleCOD) { Report.SetParameterValue("txtType", "Account Consignment Return"); } else { Report.SetParameterValue("txtType", "Consignment Return"); } } else if (lPaymentType & typeAccountSale) { Report.SetParameterValue("txtType", "Account Sale"); } else if (lPaymentType & typeAccountPayment) { Report.SetParameterValue("txtType", "Account Payment"); } if (lTransaction.customer_Renamed == null) { if (!string.IsNullOrEmpty(lTransaction.transactionSpecial_Renamed.address)) { lArray = Strings.Split(lTransaction.transactionSpecial_Renamed.address, Constants.vbCrLf); Report.SetParameterValue("txtCustAddress1", lArray[0]); if (Information.UBound(lArray) >= 1) Report.SetParameterValue("txtCustAddress2", lArray[1]); if (Information.UBound(lArray) >= 2) Report.SetParameterValue("txtCustAddress3", lArray[2]); if (Information.UBound(lArray) >= 3) Report.SetParameterValue("txtCustAddress4", lArray[3]); } Report.SetParameterValue("txtSigned", lTransaction.transactionSpecial_Renamed.name); Report.SetParameterValue("txtCustomer", lTransaction.transactionSpecial_Renamed.name); } else { if (!string.IsNullOrEmpty(lTransaction.customer_Renamed.tax)) lTransaction.customer_Renamed.physical = lTransaction.customer_Renamed.physical; if (!string.IsNullOrEmpty(lTransaction.customer_Renamed.physical)) { lArray = Strings.Split(lTransaction.customer_Renamed.physical, Constants.vbCrLf); Report.SetParameterValue("txtCustAddress1", lArray[0]); if (Information.UBound(lArray) >= 1) Report.SetParameterValue("txtCustAddress2", lArray[1]); if (Information.UBound(lArray) >= 2) Report.SetParameterValue("txtCustAddress3", lArray[2]); if (Information.UBound(lArray) >= 3) Report.SetParameterValue("txtCustAddress4", lArray[3]); } Report.SetParameterValue("txtSigned.", lTransaction.customer_Renamed.signed_Renamed); Report.SetParameterValue("txtCustomer", lTransaction.customer_Renamed.name); } } } //do report reference..... if (!string.IsNullOrEmpty(lTransaction.CardRefer)) { Report.SetParameterValue("txtCard", "Card Reference : " + lTransaction.CardRefer); //ElseIf gParameters.CardRefer = True Then // Report.txtCard.SetText "Card Reference : " & stCard } if (!string.IsNullOrEmpty(lTransaction.OrderRefer)) { Report.SetParameterValue("txtOrder", "Order Reference : " + lTransaction.OrderRefer); //ElseIf gParameters.OrderRefer = True Then // Report.txtOrder.SetText "Order Reference : " & stOrder } if (!string.IsNullOrEmpty(lTransaction.SerialRefer)) { Report.SetParameterValue("txtSerial", "Serial Reference : " + lTransaction.SerialRefer); //ElseIf gParameters.SerialRefer = True Then // Report.txtSerial.SetText "Serial Reference : " & stSerial } Report.SetParameterValue("txtDiscount", Strings.FormatNumber(lTransaction.paymentDiscount, 2)); //If gParameters.A4Exclusive = True Then // Report.txtAText.SetText FormatNumber(TCurrency - lTransaction.paymentDiscount, 2) //End If //If frmMain.lblChange.Caption = "" Then frmMain.lblChange.Caption = "0.00" if (lPaymentType & typeQuote) { Report.SetParameterValue("txtTender", Strings.FormatNumber("0.00", 2)); } else { Report.SetParameterValue("txtTender", Strings.FormatNumber(lTransaction.paymentTender, 2)); // lTransaction.paymentTender, 2) } Report.SetParameterValue("txtVAT", Strings.FormatNumber(lnVat, 2)); Report.SetParameterValue("txtChange", Strings.FormatNumber("0.00", 2)); //Report.txtTotal.SetText FormatNumber(lTransaction.paymentTotal, 2) if (lPaymentType & typeQuote) { //FIXED: it was calculating twice Report.txtTotal.SetText FormatNumber((QuoteTotal - lTransaction.paymentDiscount), 2) Report.SetParameterValue("txtTotal", Strings.FormatNumber(QuoteTotal, 2)); //a = QuoteTotal } else { Report.SetParameterValue("txtTotal", Strings.FormatNumber(lTransaction.paymentTotal, 2)); } if (lPaymentType & typeQuote | lPaymentType & typeConsignment | lPaymentType & typeConsignmentReturn | lPaymentType & typeAccountSale) { Report.ReportDefinition.Sections("Section7").SectionFormat.EnableSuppress = true; } //New banking details ADODB.Recordset rsCompBank = default(ADODB.Recordset); rsCompBank = modRecordSet.getRS(ref "select * from Company;"); if (rsCompBank.RecordCount) { if (Information.IsDBNull(rsCompBank.Fields("Company_BankName").Value)) { } else { Report.SetParameterValue("txtBankName", rsCompBank.Fields("Company_BankName")); } if (Information.IsDBNull(rsCompBank.Fields("Company_BranchName").Value)) { } else { Report.SetParameterValue("txtBranchName", rsCompBank.Fields("Company_BranchName")); } if (Information.IsDBNull(rsCompBank.Fields("Company_BranchCode").Value)) { } else { Report.SetParameterValue("txtBranchCode", rsCompBank.Fields("Company_BranchCode")); } if (Information.IsDBNull(rsCompBank.Fields("Company_AccountNumber").Value)) { } else { Report.SetParameterValue("txtAccountNumber", rsCompBank.Fields("Company_AccountNumber")); } } //................... //Report.selectPrinter "", Printer.DeviceName, "" //'Report.VerifyOnEveryPrint = True //Report.PrintOut False System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report; My.MyProject.Forms.frmReportShow.mReport = Report; My.MyProject.Forms.frmReportShow.sMode = "0"; My.MyProject.Forms.frmReportShow.CRViewer1.Refresh(); My.MyProject.Forms.frmReportShow.ShowDialog(); return; ptA4: Interaction.MsgBox(Err().Number + Err().Description); // ERROR: Not supported in C#: ResumeStatement }