on 07-06-2012 1:20 PM
How do i post Payments, PaymentOnInvoice and PaymentCheques at the same time ? using sdk ? in c#.net vs 2010
Hi,
What do you refer as posting them at the same time? Give an example.
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
SAPbobsCOM.Payments oPay = default(SAPbobsCOM.Payments); oPay = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments); try { SqlConnection conInv; conInv = new SqlConnection(connV); SqlCommand com; SqlDataReader redInv; com = new SqlCommand("SELECT * FROM tblPayments WHERE AutoId='" + AutoId + "' AND Posted='" + "False" + "' AND Confirmed='" + "True" + "'", conInv); conInv.Open(); redInv = com.ExecuteReader(); if (redInv.HasRows && redInv.Read()) { oPay.DocNum = int.Parse(redInv["DocNum"].ToString()); string DocType = redInv["DocType"].ToString(); string HandWritten = redInv["HandWritten"].ToString(); string Printed = redInv["Printed"].ToString(); if (DocType == "C") { oPay.DocType = BoRcptTypes.rCustomer; } if (HandWritten == "Y") { oPay.HandWritten = BoYesNoEnum.tYES; } else if (HandWritten == "N") { oPay.HandWritten = BoYesNoEnum.tNO; } oPay.DocDate = DateTime.Parse(DocDate);//DateTime.Parse(redInv["DocDate"].ToString()); oPay.CardCode = redInv["CardCode"].ToString(); oPay.Address = redInv["Address"].ToString(); oPay.CashAccount = redInv["CashAccount"].ToString(); oPay.DocCurrency = redInv["DocCurrency"].ToString(); oPay.CashSum = double.Parse(redInv["CashSum"].ToString()); oPay.TransferAccount = redInv["TransferAccount"].ToString(); oPay.TransferSum = double.Parse(redInv["TransferSum"].ToString()); oPay.TransferDate = DateTime.Parse(TransferDate);//DateTime.Parse(redInv["TransferDate"].ToString()); oPay.TransferReference = redInv["TransferReference"].ToString(); oPay.Reference1 = redInv["Reference1"].ToString(); oPay.Reference2 = redInv["Reference2"].ToString(); oPay.Remarks = redInv["Remarks"].ToString(); oPay.BankCode = redInv["BankCode"].ToString(); oPay.BankAccount = redInv["BankAccount"].ToString(); oPay.UserFields.Fields.Item("U_Walkin_CardName").Value = redInv["U_Walkin_CardName"].ToString(); } redInv.Close(); redInv.Dispose(); conInv.Close(); conInv.Dispose(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + ex.Source + ex.StackTrace); } try { SqlConnection ConnLines; ConnLines = new SqlConnection(connV); SqlCommand comLines; SqlDataReader redLines; comLines = new SqlCommand("SELECT * FROM tblPaymentsOnInvoices WHERE ParentKey='" + RecordKey + "' AND Posted='" + "False" + "' AND Confirmed='" + "True" + "'", ConnLines); ConnLines.Open(); redLines = comLines.ExecuteReader(); while (redLines.HasRows && redLines.Read()) { oPay.Invoices.DocEntry =int.Parse(redLines["NewDocEntry"].ToString()); oPay.DocNum =int.Parse(redLines["DocNum"].ToString()); oPay.Invoices.Add(); } redLines.Close(); redLines.Dispose(); ConnLines.Close(); ConnLines.Dispose(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + ex.Source + ex.StackTrace); // throw ex; } try { SqlConnection ConnLines; ConnLines = new SqlConnection(connV); SqlCommand comLines; SqlDataReader redLines; comLines = new SqlCommand("SELECT * FROM tblPaymentsCheque WHERE DocNum='" + RecordKey + "' AND Posted='" + "False" + "' AND Confirmed='" + "True" + "'", ConnLines); ConnLines.Open(); redLines = comLines.ExecuteReader(); while (redLines.HasRows && redLines.Read()) { oPay.Checks.CheckNumber =int.Parse(redLines["CheckNumber"].ToString()); oPay.Checks.BankCode =redLines["BankCode"].ToString(); oPay.Checks.CheckSum = double.Parse(redLines["CheckSum"].ToString()); oPay.Checks.CountryCode = redLines["CountryCode"].ToString(); oPay.Checks.CheckAccount = redLines["CheckAccount"].ToString(); oPay.Checks.Add(); } redLines.Close(); redLines.Dispose(); ConnLines.Close(); ConnLines.Dispose(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + ex.Source + ex.StackTrace); // throw ex; } int ith = 0; try { ith = oPay.Add(); //oINV.Add(); }
Hi Dickson,
in Payment Object below :
oPay.Checks -> fill in all the check information.
oPay.Invoices -> fill in all the invoices that you are paying against
oPay.CashSum -> fill in the total amount paid by check
oPay.TransferSum -> fill in the total amount paid by bank transfer.
And i notice that you place the oPay.Checks.Add() everytime you add the checks.
The last loop you need not put the oPay.Checks.Add().
Regards
Edy
User | Count |
---|---|
105 | |
14 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.