コード例 #1
0
        private bool UpdateTransaction()
        {
            try
            {
                if (Session["_transaction"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                var transaction = Session["_transaction"] as ExpenseTransaction;

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

                transaction.ApproverComment     = txtApproverComment.Text.Trim();
                transaction.DateApproved        = DateMap.GetLocalDate();
                transaction.TimeApproved        = DateMap.GetLocalTime();
                transaction.ApproverId          = int.Parse(new PortalServiceManager().GetUserIdByUsername(HttpContext.Current.User.Identity.Name).ToString(CultureInfo.InvariantCulture));
                transaction.TotalApprovedAmount = 0;

                if (radReject.Checked)
                {
                    transaction.Status = 2;
                }

                if (radVoid.Checked)
                {
                    transaction.Status = 3;
                }

                if (!ServiceProvider.Instance().GetExpenseTransactionServices().UpdateExpenseTransaction(transaction))
                {
                    ConfirmAlertBox1.ShowMessage("The process could not be completed. Please try again.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                return(true);
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("The required process failed. Please try again.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
コード例 #2
0
        private bool AddTransactionPaymentHistory(long transactionPaymentId)
        {
            try
            {
                if (Session["_staffExpenseTransactionPayment"] == null)
                {
                    ErrorDisplay1.ShowError("Expense Transaction list is empty or session has expired.");
                    return(false);
                }

                var expenseTransactionPayment = Session["_staffExpenseTransactionPayment"] as StaffExpenseTransactionPayment;

                if (expenseTransactionPayment == null || expenseTransactionPayment.StaffExpenseTransactionId < 1)
                {
                    ErrorDisplay1.ShowError("Expense Transaction list is empty or session has expired.");
                    return(false);
                }

                var newOrModifiedTransactioPaymentHistory = new StaffExpenseTransactionPaymentHistory
                {
                    StaffExpenseTransactionId        = expenseTransactionPayment.StaffExpenseTransactionId,
                    StaffExpenseTransactionPaymentId = transactionPaymentId,
                    PaymentDate = DateMap.GetLocalDate(),
                    PaymentTime = DateMap.GetLocalTime(),
                    Status      = 1,
                    AmountPaid  = double.Parse(txtAmountPaid.Value.Trim()),
                    PaidById    = new PortalServiceManager().GetUserIdByUsername(HttpContext.Current.User.Identity.Name),
                    Comment     = txtPaymentComment.Text.Trim(),
                };

                var k = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentHistoryServices().AddStaffExpenseTransactionPaymentHistory(newOrModifiedTransactioPaymentHistory);

                if (k < 1)
                {
                    ErrorDisplay1.ShowError("The Transaction Payment Information could not be Updated");
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                return(false);
            }
        }
コード例 #3
0
        private long UpdateTransactionPayment()
        {
            ErrorDisplay1.ClearError();
            try
            {
                if (Session["_staffExpenseTransactionPayment"] == null)
                {
                    ErrorDisplay1.ShowError("Expense Transaction Payment list is empty or session has expired.");
                    return(0);
                }

                var expenseTransactionPayment = Session["_staffExpenseTransactionPayment"] as StaffExpenseTransactionPayment;

                if (expenseTransactionPayment == null || expenseTransactionPayment.StaffExpenseTransactionId < 1)
                {
                    ErrorDisplayCompletePayment.ShowError("Invalid record selection.");
                    mpeSelectDateRangePopup.Show();
                    return(0);
                }

                expenseTransactionPayment.Balance                   = expenseTransactionPayment.Balance - double.Parse(txtAmountPaid.Value.Trim());
                expenseTransactionPayment.TotalAmountPayable        = double.Parse(txtApprovedTotalAmount.Text.Trim());
                expenseTransactionPayment.StaffExpenseTransactionId = expenseTransactionPayment.StaffExpenseTransactionId;
                expenseTransactionPayment.LastPaymentDate           = DateMap.GetLocalDate();
                expenseTransactionPayment.LastPaymentTime           = DateMap.GetLocalTime();
                expenseTransactionPayment.Status     = 1;
                expenseTransactionPayment.AmountPaid = double.Parse(txtAmountPaid.Value.Trim()) + expenseTransactionPayment.AmountPaid;

                var k = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().UpdateStaffExpenseTransactionPayment(expenseTransactionPayment);

                if (k < 1)
                {
                    ErrorDisplay1.ShowError("The Transaction information could not be updated");
                    return(0);
                }

                ErrorDisplay1.ShowSuccess("Expense Transaction Information was successfully updated");
                return(k);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                return(0);
            }
        }
コード例 #4
0
        private bool AddBeneficiary()
        {
            try
            {
                var newBeneficiary = new Beneficiary
                {
                    FullName       = txtFullName.Text.Trim(),
                    CompanyName    = txtCompanyName.Text.Trim(),
                    GSMNO1         = txtPhone1.Text,
                    GSMNO2         = txtPhone2.Text,
                    Email          = txtEmail.Text,
                    Sex            = int.Parse(ddlSex.SelectedValue),
                    Status         = chkBeneficiary.Checked ? 1 : 0,
                    DateRegistered = DateMap.GetLocalDate(),
                    TimeRegistered = DateMap.GetLocalTime()
                };

                var k = ServiceProvider.Instance().GetBeneficiaryServices().AddBeneficiaryCheckDuplicate(newBeneficiary);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                        ConfirmAlertBox1.ShowMessage("The Beneficiary information already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (k == -4)
                    {
                        ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                        ConfirmAlertBox1.ShowMessage("Another Beneficiary with similar email already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }
                    if (k == -5)
                    {
                        ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                        ConfirmAlertBox1.ShowMessage("Another Beneficiary with similar phone number already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }
                    //if (k == -6)
                    //{
                    //    ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                    //    ConfirmAlertBox1.ShowMessage("Another Beneficiary with similar second phone number already exists.", ConfirmAlertBox.PopupMessageType.Error);
                    //    mpeSelectDateRangePopup.Show();
                    //    return false;
                    //}

                    ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                    ConfirmAlertBox1.ShowMessage("The Beneficiary Information could not be Added.", ConfirmAlertBox.PopupMessageType.Error);
                    mpeSelectDateRangePopup.Show();
                    return(false);
                }
                ClearControls();
                return(true);
            }


            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
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);
            }
        }