Пример #1
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);
            }
        }
Пример #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);
            }
        }