private void CalculateTotalPayment() { FMainDS.AApDocumentPayment.DefaultView.RowFilter = String.Format("{0}={1}", AApDocumentPaymentTable.GetPaymentNumberDBName(), FSelectedPaymentRow.PaymentNumber); FSelectedPaymentRow.Amount = 0m; foreach (DataRowView rv in FMainDS.AApDocumentPayment.DefaultView) { AccountsPayableTDSAApDocumentPaymentRow DocPaymentRow = (AccountsPayableTDSAApDocumentPaymentRow)rv.Row; FSelectedPaymentRow.Amount += DocPaymentRow.Amount; } UpdateTotalAmount(null, null); }
private void MakePayment(object sender, EventArgs e) { //FSelectedDocumentRow.Amount = Decimal.Parse(txtAmountToPay.Text); FSelectedDocumentRow.Amount = txtAmountToPay.NumberValueDecimal.Value; FSelectedPaymentRow.BankAccount = cmbBankAccount.GetSelectedString(); AccountsPayableTDSAApPaymentTable AApPayment = FMainDS.AApPayment; // // I want to check whether the user is paying more than the due amount on any of these payments... // foreach (AccountsPayableTDSAApPaymentRow PaymentRow in AApPayment.Rows) { FMainDS.AApDocumentPayment.DefaultView.RowFilter = String.Format("{0}={1}", AApDocumentPaymentTable.GetPaymentNumberDBName(), PaymentRow.PaymentNumber); foreach (DataRowView rv in FMainDS.AApDocumentPayment.DefaultView) { AccountsPayableTDSAApDocumentPaymentRow DocPaymentRow = (AccountsPayableTDSAApDocumentPaymentRow)rv.Row; Boolean overPayment = (DocPaymentRow.DocType == "INVOICE") ? (DocPaymentRow.Amount > DocPaymentRow.InvoiceTotal) : (DocPaymentRow.Amount < DocPaymentRow.InvoiceTotal); if (overPayment) { String strMessage = String.Format(Catalog.GetString( "Payment of {0} {1} to {2}: Payment cannot be more than the due amount."), StringHelper.FormatUsingCurrencyCode(DocPaymentRow.Amount, PaymentRow.CurrencyCode), PaymentRow.CurrencyCode, PaymentRow.SupplierName); System.Windows.Forms.MessageBox.Show(strMessage, Catalog.GetString("OverPayment")); return; } } } TDlgGLEnterDateEffective dateEffectiveDialog = new TDlgGLEnterDateEffective( FMainDS.AApDocument[0].LedgerNumber, Catalog.GetString("Select payment date"), Catalog.GetString("The date effective for the payment") + ":"); if (dateEffectiveDialog.ShowDialog() != DialogResult.OK) { MessageBox.Show(Catalog.GetString("The payment was cancelled."), Catalog.GetString( "No Success"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DateTime PaymentDate = dateEffectiveDialog.SelectedDate; TVerificationResultCollection Verifications; this.Cursor = Cursors.WaitCursor; if (!TRemote.MFinance.AP.WebConnectors.PostAPPayments( ref FMainDS, PaymentDate, out Verifications)) { this.Cursor = Cursors.Default; string ErrorMessages = String.Empty; foreach (TVerificationResult verif in Verifications) { ErrorMessages += "[" + verif.ResultContext + "] " + verif.ResultTextCaption + ": " + verif.ResultText + Environment.NewLine; } System.Windows.Forms.MessageBox.Show(ErrorMessages, Catalog.GetString("Payment failed")); } else { this.Cursor = Cursors.Default; PrintPaymentReport(sender, e); PrintRemittanceAdvice(); // TODO: show posting register of GL Batch? // After the payments screen, The status of this document may have changed. TFormsMessage broadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcAPTransactionChanged); broadcastMessage.SetMessageDataAPTransaction(String.Empty); TFormsList.GFormsList.BroadcastFormMessage(broadcastMessage); Close(); } }