private void SetPayments(int C_Payment_ID, int C_Currency_ID, string _PaymentRule) { if (pDetails == null) { pDetails = new PaymentMetohdDetails(); } // Existing Payment if (C_Payment_ID != 0) { if (C_Payment_ID != 0) { _mPayment = new MPayment(ctx, C_Payment_ID, null); _mPaymentOriginal = new MPayment(ctx, _C_Payment_ID, null); // full copy // CreditCard pDetails.CCType = _mPayment.GetCreditCardType(); pDetails.StrKNumber = _mPayment.GetCreditCardNumber(); pDetails.StrKExp = _mPayment.GetCreditCardExp(null); pDetails.StrKApproval = _mPayment.GetVoiceAuthCode(); pDetails.StrKStatus = _mPayment.GetR_PnRef(); pDetails.CanChange = !_mPayment.IsApproved() || !(_PaymentRule == MOrder.PAYMENTRULE_CreditCard); // if approved/paid, don't let it change // Check _C_BankAccount_ID = _mPayment.GetC_BankAccount_ID(); pDetails.StrSRouting = _mPayment.GetRoutingNo(); pDetails.StrSNumber = _mPayment.GetAccountNo(); pDetails.StrSCheck = _mPayment.GetCheckNo(); pDetails.StrSStatus = _mPayment.GetR_PnRef(); // Transfer pDetails.StrTStatus = _mPayment.GetR_PnRef(); } } if (_mPayment == null) { _mPayment = new MPayment(ctx, 0, null); _mPayment.SetAD_Org_ID(_AD_Org_ID); _mPayment.SetIsReceipt(_isSOTrx); _mPayment.SetAmount(C_Currency_ID, _Amount); } }
public PaymentMetohdDetails DynInit() { pDetails = new PaymentMetohdDetails(); SetPayments(_C_Payment_ID, _C_Currency_ID, _PaymentRule); if (_C_CashLine_ID == 0) { _cashLine = null; } else { _cashLine = new MCashLine(ctx, _C_CashLine_ID, null); pDetails._DateAcct = DateTime.SpecifyKind(Convert.ToDateTime(_cashLine.GetStatementDate()), DateTimeKind.Utc); } if (pDetails._Currencies == null) { LoadCurrencies(); } //Load Payment Terms String SQL = MRole.GetDefault(ctx).AddAccessSQL( "SELECT C_PaymentTerm_ID, Name FROM C_PaymentTerm WHERE IsActive='Y' ORDER BY Name", "C_PaymentTerm", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); IDataReader idr = null; DataTable dt = null; try { idr = DB.ExecuteReader(SQL, null, null); dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { int key = Util.GetValueOfInt(dr[0]); //.getInt(1); String name = dr[1].ToString(); //.getString(2); KeyNamePair pp = new KeyNamePair(key, name); //cmbPTerm.Items.Add(pp); if (pDetails.loadPaymentTerms == null) { pDetails.loadPaymentTerms = new List <KeyNamePair>(); } pDetails.loadPaymentTerms.Add(pp); if (key == _C_PaymentTerm_ID) { kp = pp; } } } catch (Exception) { if (idr != null) { idr.Close(); } // log.Log(Level.SEVERE, SQL, ept); } finally { if (idr != null) { idr.Close(); } dt = null; } //Load Accounts SQL = "SELECT a.C_BP_BankAccount_ID, NVL(b.Name, ' ')||a.AccountNo AS Acct " + "FROM C_BP_BankAccount a,C_Bank b " + "WHERE C_BPartner_ID=" + _C_BPartner_ID + " AND a.IsActive='Y'"; kp = null; IDataReader idr1 = null; try { idr1 = DB.ExecuteReader(SQL, null, null); dt = new DataTable(); dt.Load(idr1); idr1.Close(); foreach (DataRow dr in dt.Rows) { int key = Util.GetValueOfInt(dr[0]); // dr.getInt(1); String name = dr[1].ToString(); //.getString(2); KeyNamePair pp = new KeyNamePair(key, name); // cmbTAccount.Items.Add(pp); if (pDetails.loadAccounts == null) { pDetails.loadAccounts = new List <KeyNamePair>(); } pDetails.loadAccounts.Add(pp); /* kp = pp;*/ } } catch (Exception) { if (idr1 != null) { idr1.Close(); } // log.Log(Level.SEVERE, SQL, eac); } finally { if (idr1 != null) { idr1.Close(); } dt = null; } //Load Credit Cards pDetails.ccs = _mPayment.GetCreditCards(); //Load Bank Accounts SQL = MRole.GetDefault(ctx).AddAccessSQL( "SELECT C_BankAccount_ID, Name || ' ' || AccountNo, IsDefault " + "FROM C_BankAccount ba" + " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) " + "WHERE b.IsActive='Y'", "ba", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); kp = null; IDataReader idr2 = null; try { idr2 = DB.ExecuteReader(SQL, null, null); dt = new DataTable(); dt.Load(idr2); idr2.Close(); foreach (DataRow dr in dt.Rows) { int key = Util.GetValueOfInt(dr[0]); // dr.getInt(1); String name = dr[1].ToString(); //.getString(2); KeyNamePair pp = new KeyNamePair(key, name); //cmbSBankAccount.Items.Add(pp); if (pDetails.loadBankAccounts == null) { pDetails.loadBankAccounts = new List <KeyNamePair>(); } pDetails.loadBankAccounts.Add(pp); if (key == _C_BankAccount_ID) { pDetails.Checkbook_ID = key; } } if (pDetails.Checkbook_ID == 0) // Default { DataRow[] drs = dt.Select("IsDefault='Y'"); if (drs != null && drs.Count() > 0) { pDetails.Checkbook_ID = Convert.ToInt32(drs.ElementAt(0)["C_BankAccount_ID"]); } } } catch (Exception) { if (idr2 != null) { idr2.Close(); } // log.Log(Level.SEVERE, SQL, ept); } finally { if (idr2 != null) { idr2.Close(); } dt = null; } //Load Cash Books SQL = MRole.GetDefault(ctx).AddAccessSQL( "SELECT C_CashBook_ID, Name, AD_Org_ID FROM C_CashBook WHERE IsActive='Y'", "C_CashBook", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); kp = null; IDataReader idr3 = null; try { idr3 = DB.ExecuteReader(SQL, null, null); dt = new DataTable(); dt.Load(idr3); idr3.Close(); foreach (DataRow dr in dt.Rows) { int key = Util.GetValueOfInt(dr[0]); // dr.getInt(1); String name = dr[1].ToString(); //.getString(2); KeyNamePair pp = new KeyNamePair(key, name); //cmbBCashBook.Items.Add(pp); if (pDetails.loadCashBooks == null) { pDetails.loadCashBooks = new List <KeyNamePair>(); } pDetails.loadCashBooks.Add(pp); if (key == _C_CashBook_ID) { kp = pp; } if (kp == null && key == _AD_Org_ID) // Default Org { kp = pp; } } } catch (Exception) { if (idr3 != null) { idr3.Close(); } // log.Log(Level.SEVERE, SQL, epc); } finally { if (idr3 != null) { idr3.Close(); } dt = null; } return(pDetails); }