예제 #1
0
 private void UpdateWithChqueOnly(ExpenseTransactionPayment transactionPayment)
 {
     try
     {
         var expenseTransaction = transactionPayment.ExpenseTransaction;
         txtChequeTotalPayableAmount.Text = expenseTransaction.TotalApprovedAmount.ToString(CultureInfo.InvariantCulture);
         txtOldChequeBalance.Text         = transactionPayment.Balance.ToString(CultureInfo.InvariantCulture);
         lgChequeUpdate.InnerText         = transactionPayment.ExpenseTransaction.ExpenseTitle;
         btnSubmit.Text                   = "Update";
         btnSubmit.CommandArgument        = "2";
         btnUpdatePayment.CommandArgument = "2";
         ErrorDispChequePayment.ClearError();
         txtChequeAmountToPay.Value              = String.Empty;
         ddChequeBank.SelectedIndex              = 0;
         txtUpdatePaymentComment.Text            = string.Empty;
         txtChequNo.Value                        = String.Empty;
         mpeSelectDateRangePopup.CancelControlID = btnChequeClose.ID;
         mpeSelectDateRangePopup.PopupControlID  = dvChequePayment.ID;
         mpeSelectDateRangePopup.Show();
         Session["_expenseTransactionPayment"] = transactionPayment;
         ErrorDispChequePayment.ShowSuccess("Transaction Payment Information was successfully updated. \nPlease kindly continue the update by providing the needed cheque information, <b>OR</b> click the <b>Close</b> button to make updates later.");
     }
     catch (Exception)
     {
         ConfirmAlertBox1.ShowMessage("Transaction cash Payment Information was successfully updated but an error was encountered while trying to initialize the cheque payment process. \nPlease try again or contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error);
     }
 }
예제 #2
0
        private bool ValidateTransactionPaymentControl()
        {
            try
            {
                if (Session["_expenseTransactionPayment"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                var expenseTransactionPayment = Session["_expenseTransactionPayment"] as ExpenseTransactionPayment;

                if (expenseTransactionPayment == null || expenseTransactionPayment.ExpenseTransactionId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (int.Parse(btnSubmit.CommandArgument) == 1)
                {
                    if (string.IsNullOrEmpty(txtUpdateAmount.Value.Trim()))
                    {
                        ErrorDisplayCashPayment.ShowError("Please supply the amount to be paid.");
                        txtUpdateAmount.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (txtUpdateAmount.Value.Trim().Contains('-') || txtUpdateAmount.Value.Trim().Contains('+') || txtUpdateAmount.Value.Trim().Contains('*') || txtUpdateAmount.Value.Trim().Contains('/'))
                    {
                        ErrorDisplayCashPayment.ShowError("Invalid entry!");
                        txtUpdateAmount.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (double.Parse(txtUpdateAmount.Value.Trim()) > expenseTransactionPayment.Balance)
                    {
                        ErrorDisplayCashPayment.ShowError("Please enter an amount less than or equal to the Balance.");
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (!DataCheck.IsNumeric(txtUpdateAmount.Value.Trim()))
                    {
                        ErrorDisplayCashPayment.ShowError("Invalid entry!");
                        txtUpdateAmount.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }
                }

                if (int.Parse(btnSubmit.CommandArgument) == 2)
                {
                    if (string.IsNullOrEmpty(txtChequeAmountToPay.Value.Trim()))
                    {
                        ErrorDispChequePayment.ShowError("Please supply Cheque amount.");
                        txtChequeAmountToPay.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }
                    if (string.IsNullOrEmpty(txUpdateChequePaymentChequeComment.Text.Trim()))
                    {
                        ErrorDispChequePayment.ShowError("Please a comment .");
                        txUpdateChequePaymentChequeComment.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (txtChequeAmountToPay.Value.Trim().Contains('-') || txtChequeAmountToPay.Value.Trim().Contains('+') || txtChequeAmountToPay.Value.Trim().Contains('*') || txtChequeAmountToPay.Value.Trim().Contains('/'))
                    {
                        ErrorDispChequePayment.ShowError("Invalid entry!");
                        txtChequeAmountToPay.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (double.Parse(txtChequeAmountToPay.Value.Trim()) > expenseTransactionPayment.Balance)
                    {
                        ErrorDispChequePayment.ShowError("Please enter an amount less than or equal to the Transaction Balance.");
                        txtChequeAmountToPay.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (!DataCheck.IsNumeric(txtChequeAmountToPay.Value.Trim()))
                    {
                        ErrorDispChequePayment.ShowError("Invalid entry!");
                        txtChequeAmountToPay.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (string.IsNullOrEmpty(txtChequNo.Value.Trim()))
                    {
                        ErrorDispChequePayment.ShowError("Please supply Cheque Number.");
                        txtChequNo.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (int.Parse(ddChequeBank.Value) < 1)
                    {
                        ErrorDispChequePayment.ShowError("Please select a bank.");
                        ddChequeBank.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
예제 #3
0
        private bool AddTransactionPaymentHistory(long transactionPaymentId)
        {
            try
            {
                if (Session["_expenseTransactionPayment"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);

                    return(false);
                }
                var expenseTransactionPayment = Session["_expenseTransactionPayment"] as ExpenseTransactionPayment;

                if (expenseTransactionPayment == null || expenseTransactionPayment.ExpenseTransactionId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);

                    return(false);
                }
                var expenseTransaction = expenseTransactionPayment.ExpenseTransaction;
                ExpenseTransactionPaymentHistory newOrModifiedExpenseTransactioPaymentHistory;
                long paymentHistoryId = 0;

                int paymentModeId;
                switch (int.Parse(btnUpdatePayment.CommandArgument))
                {
                case 1:
                    paymentModeId = 1;
                    newOrModifiedExpenseTransactioPaymentHistory = new ExpenseTransactionPaymentHistory
                    {
                        BeneficiaryId               = expenseTransaction.BeneficiaryId,
                        PaymentModeId               = paymentModeId,
                        ExpenseTransactionId        = expenseTransaction.ExpenseTransactionId,
                        ExpenseTransactionPaymentId = transactionPaymentId,
                        PaymentDate = DateMap.GetLocalDate(),
                        PaymentTime = DateMap.GetLocalTime(),
                        Status      = 1,
                        AmountPaid  = double.Parse(txtUpdateAmount.Value.Trim().Replace(",", string.Empty)),
                        PaidById    = new PortalServiceManager().GetUserIdByUsername(HttpContext.Current.User.Identity.Name),
                        Comment     = txtUpdatePaymentComment.Text.Trim(),
                    };

                    paymentHistoryId = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().AddTransactionPaymentHistoryAndPcv(newOrModifiedExpenseTransactioPaymentHistory);

                    if (paymentHistoryId < 1)
                    {
                        ErrorDisplayCashPayment.ShowError("The Transaction Payment Information could not be submitted");
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }
                    break;

                case 2:

                    if (!updateFileUploadControl.HasFile)
                    {
                        ConfirmAlertBox1.ShowMessage("Select the path to the cheque scanned copy", ConfirmAlertBox.PopupMessageType.Warning);
                        return(false);
                    }

                    var imgBytes = FileUploader();

                    if (imgBytes == null)
                    {
                        ErrorDispChequePayment.ShowError("The Cheque information could not be submitted. Payment was not made.");
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    paymentModeId = 2;
                    newOrModifiedExpenseTransactioPaymentHistory = new ExpenseTransactionPaymentHistory
                    {
                        BeneficiaryId               = expenseTransaction.BeneficiaryId,
                        PaymentModeId               = paymentModeId,
                        ExpenseTransactionId        = expenseTransaction.ExpenseTransactionId,
                        ExpenseTransactionPaymentId = transactionPaymentId,
                        PaymentDate = DateMap.GetLocalDate(),
                        PaymentTime = DateMap.GetLocalTime(),
                        Status      = 1,
                        AmountPaid  = double.Parse(txtChequeAmountToPay.Value.Trim().Replace(",", string.Empty)),
                        PaidById    = new PortalServiceManager().GetUserIdByUsername(HttpContext.Current.User.Identity.Name),
                        Comment     = txUpdateChequePaymentChequeComment.Text.Trim(),
                    };


                    paymentHistoryId = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().AddTransactionPaymentHistoryAndPcv(newOrModifiedExpenseTransactioPaymentHistory);

                    if (paymentHistoryId < 1)
                    {
                        ErrorDispChequePayment.ShowError("The Transaction Payment Information could not be submitted");
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    var newChequeInfo = new Cheque
                    {
                        Amount   = double.Parse(txtChequeAmountToPay.Value.Trim()),
                        ChequeNo = txtChequNo.Value.Trim(),
                        ExpenseTransactionPaymentHistoryId = paymentHistoryId,
                        BankId      = int.Parse(ddChequeBank.Value),
                        ScannedCopy = imgBytes
                    };
                    var x = ServiceProvider.Instance().GetChequeServices().AddCheque(newChequeInfo);
                    if (x < 1)
                    {
                        ErrorDispChequePayment.ShowError("The Cheque information could not be submitted. Payment was not made");
                        mpeSelectDateRangePopup.Show();
                        if (!ServiceProvider.Instance().GetExpenseTransactionPaymentServices().DeleteExpenseTransactionPayment(transactionPaymentId))
                        {
                            return(false);
                        }

                        if (!ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().DeleteExpenseTransactionPaymentHistory(paymentModeId))
                        {
                            return(false);
                        }

                        return(false);
                    }

                    break;

                default:
                    ErrorDispChequePayment.ShowError("The Cheque information could not be submitted. Payment was not made.");
                    break;
                }

                Session["_paymentHistoryId"]          = paymentHistoryId;
                Session["_expenseTransactionPayment"] = null;
                return(true);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again or contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
예제 #4
0
        private long UpdateTransactionPayment()
        {
            try
            {
                if (Session["_expenseTransactionPayment"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return(0);
                }

                var expenseTransactionPayment = Session["_expenseTransactionPayment"] as ExpenseTransactionPayment;

                if (expenseTransactionPayment == null || expenseTransactionPayment.ExpenseTransactionId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid selection!", ConfirmAlertBox.PopupMessageType.Error);
                    return(0);
                }

                long k = 0;

                if (int.Parse(btnUpdatePayment.CommandArgument) == 1)
                {
                    var balance = expenseTransactionPayment.Balance - double.Parse(txtUpdateAmount.Value.Trim().Replace(",", string.Empty));

                    if (balance.ToString(CultureInfo.InvariantCulture).Trim().Contains("-") || balance < 0)
                    {
                        ErrorDisplayCashPayment.ShowError("Please supply an amount less than or equal to the Transaction Old Balance.");
                        txtUpdateAmount.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(0);
                    }

                    var status = 0;

                    if (balance > 0 && balance < expenseTransactionPayment.ExpenseTransaction.TotalApprovedAmount)
                    {
                        status = 0;
                    }
                    else if (balance.Equals(0.0))
                    {
                        status = 1;
                    }

                    //if (balance.Equals(expenseTransactionPayment.ExpenseTransaction.TotalApprovedAmount))
                    //{
                    //    status = 1;
                    //}

                    expenseTransactionPayment.Balance = balance;
                    expenseTransactionPayment.ExpenseTransactionId = expenseTransactionPayment.ExpenseTransactionId;
                    expenseTransactionPayment.LastPaymentDate      = DateMap.GetLocalDate();
                    expenseTransactionPayment.LastPaymentTime      = DateMap.GetLocalTime();
                    expenseTransactionPayment.Status     = status;
                    expenseTransactionPayment.AmountPaid = double.Parse(txtUpdateAmount.Value.Trim()) + expenseTransactionPayment.AmountPaid;

                    k = ServiceProvider.Instance().GetExpenseTransactionPaymentServices().UpdateTransactionPayment(expenseTransactionPayment);

                    if (k < 1)
                    {
                        ConfirmAlertBox1.ShowMessage("The Transaction information could not be updated", ConfirmAlertBox.PopupMessageType.Error);
                        return(0);
                    }
                }

                if (int.Parse(btnUpdatePayment.CommandArgument) == 2)
                {
                    if (!updateFileUploadControl.HasFile)
                    {
                        ErrorDispChequePayment.ShowError("Please select a scanned copy of the cheque.");
                        updateFileUploadControl.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(0);
                    }

                    var imgBytes = FileUploader();

                    if (imgBytes == null)
                    {
                        ErrorDispChequePayment.ShowError("The Cheque information could not be submitted. Payment was not made.");
                        mpeSelectDateRangePopup.Show();
                        return(0);
                    }

                    var chequBalance = expenseTransactionPayment.Balance - double.Parse(txtChequeAmountToPay.Value.Trim().Replace(",", string.Empty));

                    if (chequBalance.ToString(CultureInfo.InvariantCulture).Trim().Contains("-") || chequBalance < 0)
                    {
                        ErrorDispChequePayment.ShowError("Please supply an amount less than or equal to the Transaction Old Balance.");
                        txtChequeAmountToPay.Focus();
                        mpeSelectDateRangePopup.Show();
                        return(0);
                    }

                    var status = 0;

                    if (chequBalance > 0 && chequBalance < expenseTransactionPayment.ExpenseTransaction.TotalApprovedAmount)
                    {
                        status = 0;
                    }
                    else if (chequBalance.Equals(0.0))
                    {
                        status = 1;
                    }

                    //if (chequBalance.Equals(expenseTransactionPayment.ExpenseTransaction.TotalApprovedAmount))
                    //{
                    //    status = 1;
                    //}
                    expenseTransactionPayment.Balance = chequBalance;
                    expenseTransactionPayment.ExpenseTransactionId = expenseTransactionPayment.ExpenseTransactionId;
                    expenseTransactionPayment.LastPaymentDate      = DateMap.GetLocalDate();
                    expenseTransactionPayment.LastPaymentTime      = DateMap.GetLocalTime();
                    expenseTransactionPayment.Status     = status;
                    expenseTransactionPayment.AmountPaid = double.Parse(txtChequeAmountToPay.Value.Trim()) + expenseTransactionPayment.AmountPaid;

                    k = ServiceProvider.Instance().GetExpenseTransactionPaymentServices().UpdateTransactionPayment(expenseTransactionPayment);

                    if (k < 1)
                    {
                        ConfirmAlertBox1.ShowMessage("The Transaction information could not be updated", ConfirmAlertBox.PopupMessageType.Error);
                        return(0);
                    }
                }
                Session["_expenseTransactionPayment"] = expenseTransactionPayment;
                return(k);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                return(0);
            }
        }
예제 #5
0
        protected void DgBeneficiaryPaymentTrackCommand(object source, DataGridCommandEventArgs e)
        {
            ErrorDisplayCashPayment.ClearError();
            ErrorDispChequePayment.ClearError();
            try
            {
                if (int.Parse(ddlPaymentMode.SelectedValue) < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Please select a Payment mode.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }
                ClearControls();
                dgBeneficiaryPaymentTrack.SelectedIndex = e.Item.ItemIndex;

                long id = (DataCheck.IsNumeric(dgBeneficiaryPaymentTrack.DataKeys[e.Item.ItemIndex].ToString()))
                                  ? long.Parse(dgBeneficiaryPaymentTrack.DataKeys[e.Item.ItemIndex].ToString())
                                  : 0;

                if (id < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid Record Selection!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var expenseTransactionPayment = ServiceProvider.Instance().GetExpenseTransactionPaymentServices().GetExpenseTransactionPayment(id);

                if (expenseTransactionPayment == null || expenseTransactionPayment.ExpenseTransactionPaymentId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (expenseTransactionPayment.Balance <= 0)
                {
                    ConfirmAlertBox1.ShowMessage("Transaction Payment has been completed", ConfirmAlertBox.PopupMessageType.Error);
                    btnSubmit.Enabled = false;
                }

                else
                {
                    var expenseTransaction = expenseTransactionPayment.ExpenseTransaction;

                    if (expenseTransaction == null || expenseTransaction.ExpenseTransactionId < 1)
                    {
                        ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error);
                        return;
                    }
                    if (int.Parse(ddlPaymentMode.SelectedValue) == 1 || int.Parse(ddlPaymentMode.SelectedValue) == 3)
                    {
                        txtTotalPayableAmount.Text              = expenseTransaction.TotalApprovedAmount.ToString(CultureInfo.InvariantCulture);
                        txtOldBalance.Text                      = expenseTransactionPayment.Balance.ToString(CultureInfo.InvariantCulture);
                        lgUpdatePayment.InnerText               = expenseTransactionPayment.ExpenseTransaction.ExpenseTitle;
                        btnUpdatePayment.Text                   = "Update";
                        btnUpdatePayment.CommandArgument        = "1";
                        btnSubmit.CommandArgument               = "1";
                        mpeSelectDateRangePopup.CancelControlID = btnReset.ID;
                        mpeSelectDateRangePopup.PopupControlID  = dvExpensePayment.ID;
                        mpeSelectDateRangePopup.Show();
                        Session["_expenseTransactionPayment"] = expenseTransactionPayment;
                        return;
                    }

                    if (int.Parse(ddlPaymentMode.SelectedValue) == 2)
                    {
                        txtChequeTotalPayableAmount.Text = expenseTransaction.TotalApprovedAmount.ToString(CultureInfo.InvariantCulture);
                        txtOldChequeBalance.Text         = expenseTransactionPayment.Balance.ToString(CultureInfo.InvariantCulture);
                        lgChequeUpdate.InnerText         = expenseTransactionPayment.ExpenseTransaction.ExpenseTitle;
                        btnSubmit.Text = "Update";
                        btnUpdatePayment.CommandArgument = "2";
                        btnSubmit.CommandArgument        = "2";
                        ErrorDispChequePayment.ClearError();
                        mpeSelectDateRangePopup.CancelControlID = btnChequeClose.ID;
                        mpeSelectDateRangePopup.PopupControlID  = dvChequePayment.ID;
                        mpeSelectDateRangePopup.Show();
                        Session["_expenseTransactionPayment"] = expenseTransactionPayment;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorDispChequePayment.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                mpeSelectDateRangePopup.Show();
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
            }
        }