コード例 #1
0
        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);
        }
コード例 #2
0
        /// <summary>
        /// If asked to remove a payment,
        /// I need to modify the ApPayment to reflect the removed ApDocumentPayment row.
        /// If there's nothing left to pay, I should remove the ApPayment row.
        /// </summary>
        private void RemoveSelectedDocument(Object sender, EventArgs e)
        {
            if (FSelectedDocumentRow != null)
            {
                FSelectedPaymentRow.Amount -= FSelectedDocumentRow.Amount;

                FMainDS.AApDocumentPayment.Rows.Remove(FSelectedDocumentRow);
                FSelectedDocumentRow = null;
                FocusedRowChangedDetails(null, null);

                if (FSelectedPaymentRow.Amount <= 0)
                {
                    FMainDS.AApPayment.Rows.Remove(FSelectedPaymentRow);
                    FSelectedPaymentRow = null;
                    FocusedRowChanged(null, null);
                }
            }
        }
コード例 #3
0
        private void FocusedRowChangedDetails(System.Object sender, SourceGrid.RowEventArgs e)
        {
            DataRowView[] SelectedGridRow = grdDocuments.SelectedDataRowsAsDataRowView;

            if (FSelectedDocumentRow != null)  // unload amount to pay into currently selected record
            {
                FSelectedDocumentRow.Amount = Decimal.Parse(txtAmountToPay.Text);
            }

            if (SelectedGridRow.Length == 0)
            {
                FSelectedDocumentRow = null;
                CalculateTotalPayment();
            }
            else
            {
                FSelectedDocumentRow = (AccountsPayableTDSAApDocumentPaymentRow)SelectedGridRow[0].Row;
                rbtPayFullOutstandingAmount.Checked = FSelectedDocumentRow.PayFullInvoice;
                rbtPayPartialAmount.Checked         = !rbtPayFullOutstandingAmount.Checked;

                EnablePartialPayment(null, null);
            }
        }
コード例 #4
0
        private void FocusedRowChangedDetails(System.Object sender, SourceGrid.RowEventArgs e)
        {
            DataRowView[] SelectedGridRow = grdDocuments.SelectedDataRowsAsDataRowView;

            if (FSelectedDocumentRow != null)  // unload amount to pay into currently selected record
            {
                FSelectedDocumentRow.Amount = Decimal.Parse(txtAmountToPay.Text);
            }

            if (SelectedGridRow.Length == 0)
            {
                FSelectedDocumentRow = null;
                CalculateTotalPayment();
            }
            else
            {
                FSelectedDocumentRow = (AccountsPayableTDSAApDocumentPaymentRow)SelectedGridRow[0].Row;
                rbtPayFullOutstandingAmount.Checked = FSelectedDocumentRow.PayFullInvoice;
                rbtPayPartialAmount.Checked = !rbtPayFullOutstandingAmount.Checked;

                EnablePartialPayment(null, null);
            }
        }
コード例 #5
0
        /// <summary>
        /// If asked to remove a payment,
        /// I need to modify the ApPayment to reflect the removed ApDocumentPayment row.
        /// If there's nothing left to pay, I should remove the ApPayment row.
        /// </summary>
        private void RemoveSelectedDocument(Object sender, EventArgs e)
        {
            if (FSelectedDocumentRow != null)
            {
                FSelectedPaymentRow.Amount -= FSelectedDocumentRow.Amount;

                FMainDS.AApDocumentPayment.Rows.Remove(FSelectedDocumentRow);
                FSelectedDocumentRow = null;
                FocusedRowChangedDetails(null, null);

                if (FSelectedPaymentRow.Amount <= 0)
                {
                    FMainDS.AApPayment.Rows.Remove(FSelectedPaymentRow);
                    FSelectedPaymentRow = null;
                    FocusedRowChanged(null, null);
                }
            }
        }
コード例 #6
0
        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();
            }
        }