Beispiel #1
0
        private bool AddDepartment()
        {
            try
            {
                var newDepartment = new Department
                {
                    Name   = txtName.Text.Trim(),
                    Status = chkDepartment.Checked ? 1 : 0
                };

                var k = ServiceProvider.Instance().GetDepartmentServices().AddDepartmentCheckDuplicate(newDepartment);

                if (k < 1)
                {
                    if (k == -3)
                    {
                        ConfirmAlertBox1.ShowMessage("Department Information already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                    ConfirmAlertBox1.ShowMessage("Department Information could not be added.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                ConfirmAlertBox1.ShowSuccessAlert("Department Information was added to successfully.");
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplayProcessDepartment.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                throw;
            }
        }
Beispiel #2
0
        private bool AddExpenseCategory()
        {
            try
            {
                var newxpenseCategory = new ExpenseCategory
                {
                    Title  = txtTitle.Text.Trim(),
                    Code   = txtCode.Text.Trim(),
                    Status = chkCategory.Checked ? 1 : 0
                };

                var k = ServiceProvider.Instance().GetExpenseCategoryServices().AddExpenseCategoryCheckDuplicate(newxpenseCategory);

                if (k < 1)
                {
                    if (k == -3)
                    {
                        ConfirmAlertBox1.ShowMessage("Expense Category Information already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                    ConfirmAlertBox1.ShowMessage("Expense Category Information could not be added.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                ConfirmAlertBox1.ShowSuccessAlert("ExpenseCategory Information was added to successfully.");
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplayProcessExpenseCategory.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
        protected void BtnProcessTransactionItemsClick(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateExpenseItemControls())
                {
                    mpeExpenseItemsPopup.Show();
                    return;
                }

                switch (int.Parse(btnProcessTransactionItems.CommandArgument))
                {
                case 1:     //Add
                    if (!AddExpenseItem())
                    {
                        ConfirmAlertBox1.ShowMessage("Expense Item information could not be added. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                        return;
                    }
                    ConfirmAlertBox1.ShowSuccessAlert("Expense Item information was Added Successfully.");


                    break;

                case 2:     //Update
                    if (!UpdateExpenseItem())
                    {
                        ConfirmAlertBox1.ShowMessage("Expense Item information could not be updated. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                        return;
                    }

                    ConfirmAlertBox1.ShowSuccessAlert("Expense Item information was updated Successfully.");

                    break;

                default:
                    ConfirmAlertBox1.ShowMessage("Invalid process call!", ConfirmAlertBox.PopupMessageType.Error);
                    break;
                }

                if (int.Parse((ddlAccountsHeads.SelectedValue)) < 1)
                {
                    LoadAllExpenseItems();
                }

                if (int.Parse((ddlAccountsHeads.SelectedValue)) > 0)
                {
                    LoadFilteredExpenseItems();
                }
            }

            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ErrorDisplayProcessTransactionItems.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
            }
        }
Beispiel #4
0
        protected void BtnUpdatePaymentClick(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateTransactionPaymentControl())
                {
                    return;
                }
                var k = UpdateTransactionPayment();

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

                if (!AddTransactionPaymentHistory(k))
                {
                    ConfirmAlertBox1.ShowMessage("The Transaction Payment information could not be Updated.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                //var popup = "<script language='javascript' ID='updatePaymentVoucher'>" + "window.open('ExpenseMgt/Voucher/VoucherManager.aspx?data=" + HttpUtility.UrlEncode(k.ToString(CultureInfo.InvariantCulture)) + "','newwindow', 'top=0,left=50,width=900,height=650,dependant = no, alwaysRaised = no, menubar=yes, resizable=no ,scrollbars=yes, toolbar=no,status=no');</script>";

                //ScriptManager.RegisterStartupScript((Page)HttpContext.Current.Handler, typeof(Page), "updatePaymentVoucher", popup, false);

                if (int.Parse(ddlPaymentMode.SelectedValue) == 3)
                {
                    var transactionPayment = ServiceProvider.Instance().GetExpenseTransactionPaymentServices().GetUncompltedTransactionPayment(k);

                    if (transactionPayment != null && transactionPayment.ExpenseTransactionPaymentId > 1 && transactionPayment.Balance < transactionPayment.TotalAmountPayable && transactionPayment.Balance > 0)
                    {
                        UpdateWithChqueOnly(transactionPayment);
                        return;
                    }
                }

                if (!LoadTransactionPayments())
                {
                    ddlPaymentMode.SelectedIndex = 0;
                    return;
                }
                Session["_expenseTransactionPayment"] = null;
                btnSubmit.CommandArgument             = "0";
                btnUpdatePayment.CommandArgument      = "0";
                ConfirmAlertBox1.ShowSuccessAlert("Transaction Payment Information was successfully updated");
            }

            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);
            }
        }
        private bool UpdateExpenseItem()
        {
            try
            {
                if (Session["_expenseItem"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Expense Item list is empty or session has expired", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                var expenseItem = Session["_expenseItem"] as ExpenseItem;

                if (expenseItem == null || expenseItem.ExpenseItemId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("The requested process failed!", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                expenseItem.Description       = txtDescription.Text.Trim();
                expenseItem.Title             = txtTitle.Text.Trim();
                expenseItem.ExpenseCategoryId = int.Parse(ddlExpenseCategory.SelectedValue);
                expenseItem.AccountsHeadId    = int.Parse(ddlAccountsHead.SelectedValue);
                expenseItem.Status            = chkActivateTransactionItem.Checked ? 1 : 0;

                var k = ServiceProvider.Instance().GetExpenseItemServices().UpdateExpenseItemCheckDuplicate(expenseItem);

                if (k < 1)
                {
                    if (k == -3)
                    {
                        ErrorDisplayProcessTransactionItems.ShowError("Expense Item information already exists.");
                        txtTitle.Focus();
                        mpeExpenseItemsPopup.Show();
                        return(false);
                    }

                    ErrorDisplayProcessTransactionItems.ShowError("Expense Item could not be updated.");
                    mpeExpenseItemsPopup.Show();
                    return(false);
                }

                ConfirmAlertBox1.ShowSuccessAlert("ExpenseItem Information Was updated successfully.");
                return(true);
            }
            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(false);
            }
        }
Beispiel #6
0
        protected void BtnProcessExpenseTransactionsClick(object sender, EventArgs e)
        {
            if (!ValidateTransactionItemsControls())
            {
                return;
            }

            if (!UpdateTransactionItem())
            {
                return;
            }

            ConfirmAlertBox1.ShowSuccessAlert("Transaction Item was successfully updated");
        }
Beispiel #7
0
        protected void BtnProcessUnitClick(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateControls())
                {
                    return;
                }

                switch (int.Parse(btnProcessUnit.CommandArgument))
                {
                case 1:
                    if (!AddUnit())
                    {
                        return;
                    }

                    break;

                case 2:
                    if (!UpdateUnit())
                    {
                        return;
                    }
                    break;

                default:
                    ConfirmAlertBox1.ShowMessage("Invalid process call!", ConfirmAlertBox.PopupMessageType.Error);
                    mpeProcessUnit.Show();
                    break;
                }

                if (!LoadUnits())
                {
                    ConfirmAlertBox1.ShowMessage("Unit information was processed successfully but an error was encountered while trying to refresh the list.\n Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                ConfirmAlertBox1.ShowSuccessAlert("Unit information was processed successfully.");
            }

            catch (Exception ex)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                throw;
            }
        }
Beispiel #8
0
        protected void BtnprocessCategoryClick(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateControls())
                {
                    return;
                }

                switch (int.Parse(btnProcessCategory.CommandArgument))
                {
                case 1:
                    if (!AddExpenseCategory())
                    {
                        return;
                    }
                    break;

                case 2:
                    if (!UpdateExpenseCategory())
                    {
                        return;
                    }

                    break;

                default:
                    ErrorDisplayProcessExpenseCategory.ShowError("Invalid process call!");
                    mpeProcessExpenseCategory.Show();
                    break;
                }


                if (!LoadExpenseCategories())
                {
                    return;
                }

                ConfirmAlertBox1.ShowSuccessAlert("Expense Category information was processed successfully.");
            }

            catch (Exception ex)
            {
                ErrorDisplayProcessExpenseCategory.ShowError("An unknown error was encountered. Please try again soon or contact the Admin. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
            }
        }
Beispiel #9
0
        private bool SendNotification()
        {
            try
            {
                if (Session["_transaction"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired. A notification of your decision on the Transaction request cannot be sent.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

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

                if (transaction == null || transaction.ExpenseTransactionId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired. A notification of your decision on the Transaction request cannot be sent.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                var user = Membership.GetUser(transaction.RegisteredById);

                if (user == null)
                {
                    ConfirmAlertBox1.ShowMessage("The Transaction requester's details could not be retrieved. A notification of your decision on the Transaction request cannot be sent.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                const string subject = "Transaction Approval Notification!";

                var message = "Your Transaction request: " + transaction.ExpenseTitle + " has been attended to.";

                if (!Mailsender(user.Email, subject, message))
                {
                    ConfirmAlertBox1.ShowMessage("The mailing process failed.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                ConfirmAlertBox1.ShowSuccessAlert("A notification of your decision on the Transaction was successfully sent to the requester.");

                return(true);
            }
            catch (Exception)
            {
                ConfirmAlertBox1.ShowMessage("A notification of your decision on the Transaction request could not be sent.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
Beispiel #10
0
        protected void BtnSubmitClick(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateControls())
                {
                    return;
                }

                switch (int.Parse(btnSubmit.CommandArgument))
                {
                case 1:
                    if (!AddTransactionType())
                    {
                        return;
                    }

                    break;

                case 2:
                    if (!UpdateTransactionType())
                    {
                        return;
                    }

                    break;

                default:
                    ConfirmAlertBox1.ShowMessage("Invalid Process call!", ConfirmAlertBox.PopupMessageType.Error);
                    break;
                }

                if (!LoadTransactionTypes())
                {
                }

                ConfirmAlertBox1.ShowSuccessAlert("The Expense Type information was processed successfully.");
            }
            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);
            }
        }
        protected void BtnSubmitAccountsHeadClick(object sender, EventArgs e)
        {
            ErrorDisplayProcessAccountsHead.ClearError();
            try
            {
                if (!ValidateControls())
                {
                    return;
                }

                switch (int.Parse(btnSubmitAccountsHead.CommandArgument))
                {
                case 1:     //Add
                    if (!AddAccountsHead())
                    {
                        ConfirmAlertBox1.ShowMessage("Accounts Head information could not be added. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                        return;
                    }
                    break;

                case 2:     //Update
                    if (!UpdateAccountsHead())
                    {
                        ConfirmAlertBox1.ShowMessage("Accounts Head information could not be updated. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                    }
                    break;

                default:
                    ErrorDisplayProcessAccountsHead.ShowError("Invalid process call!");
                    mpeProcessAccountsHead.Show();
                    break;
                }

                LoadAccountsHeads();

                ConfirmAlertBox1.ShowSuccessAlert("Accounts Head was Saved Successfully.");
            }

            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);
            }
        }
        protected void DgPortalUsersItemCommand(object source, DataGridCommandEventArgs e)
        {
            dgPortalUsers.SelectedIndex = e.Item.ItemIndex;

            var id = (DataCheck.IsNumeric(dgPortalUsers.DataKeys[e.Item.ItemIndex].ToString())) ? int.Parse(dgPortalUsers.DataKeys[e.Item.ItemIndex].ToString()) : 0;

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

            var portalUser = new PortalServiceManager().GetPortalUserById(id);

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

            var user = Membership.GetUser(portalUser.UserId);

            if (user == null)
            {
                ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error);
                return;
            }

            var status = (portalUser.Status) ? 1 : 0;
            var email  = user.Email;

            var delegateService = new ApprovalDelegateService();

            if (!delegateService.AddDelegateApprover(portalUser.PortalUserId, status, email))
            {
                ConfirmAlertBox1.ShowMessage("User could not be added as an Approver. Please try again later or contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error);
                return;
            }

            ConfirmAlertBox1.ShowSuccessAlert("User was successfully assigned the Approver role.");
        }
Beispiel #13
0
        private bool AddUnit()
        {
            try
            {
                var newUnit = new xPlug.BusinessObject.Unit
                {
                    Name         = txtName.Text.Trim(),
                    DepartmentId = int.Parse(ddlDepartment.SelectedValue),
                    Status       = chkUnit.Checked ? 1 : 0
                };

                var k = ServiceProvider.Instance().GetUnitServices().AddUnitCheckDuplicate(newUnit);

                if (k < 1)
                {
                    if (k == -3)
                    {
                        ErrorDispManageUnit.ShowError("Unit Information already exists.");
                        txtName.Focus();
                        mpeProcessUnit.Show();
                        return(false);
                    }
                    ErrorDispManageUnit.ShowError("Unit Information could not be added. Please try again later or contact the Administrator.");
                    mpeProcessUnit.Show();
                    return(false);
                }

                ConfirmAlertBox1.ShowSuccessAlert("Unit Information was added to successfully.");
                return(true);
            }
            catch (Exception ex)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                throw;
            }
        }
Beispiel #14
0
        protected void DgUnitsDeleteCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                dgUnits.SelectedIndex = e.Item.ItemIndex;

                var id = (DataCheck.IsNumeric(dgUnits.DataKeys[e.Item.ItemIndex].ToString()))
                             ? int.Parse(dgUnits.DataKeys[e.Item.ItemIndex].ToString())
                             : 0;

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

                if (!ServiceProvider.Instance().GetUnitServices().DeleteUnit(id))
                {
                    ConfirmAlertBox1.ShowMessage("The requested operation could not be completed. The Unit is likely being referenced by a Beneficiary.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (!LoadUnits())
                {
                    ConfirmAlertBox1.ShowMessage("Unit information was successfully deleted but an error was encountered while trying to refresh the list.\n Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                ConfirmAlertBox1.ShowSuccessAlert("Unit information was successfully deleted.");
            }

            catch (Exception)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
            }
        }
Beispiel #15
0
        protected void DgDepartmentsDeleteCommand(object source, DataGridCommandEventArgs e)
        {
            ErrorDisplayProcessDepartment.ClearError();


            try
            {
                if (Session["_departmentsList"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Department list is empty or session has expired!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var departmentsList = Session["_departmentsList"] as List <Department>;

                if (departmentsList == null || !departmentsList.Any())
                {
                    ConfirmAlertBox1.ShowMessage("Department list is empty or session has expired!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                dgDepartments.SelectedIndex = e.Item.ItemIndex;

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

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

                var department = departmentsList.Find(m => m.DepartmentId == id);
                if (department == null)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid selection!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }
                if (department.DepartmentId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid selection!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (!ServiceProvider.Instance().GetDepartmentServices().DeleteDepartment(department.DepartmentId))
                {
                    ConfirmAlertBox1.ShowMessage("The requested operation could not be completed. The Department is likely being referenced by a Beneficiary.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (!LoadDepartments())
                {
                    ConfirmAlertBox1.ShowMessage("Department information was successfully deleted but an error was encountered while trying to refresh the list.\n Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                ConfirmAlertBox1.ShowSuccessAlert("Department information was successfully deleted.");
            }

            catch (Exception)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
            }
        }
        protected void BtnVoidTransactionClick(object sender, EventArgs e)
        {
            if (!ValidateApprovalControls())
            {
                return;
            }

            const string subject = "Transaction Approval Notification!";

            string message = "";

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

            if (transaction == null || transaction.ExpenseTransactionId < 1)
            {
                ConfirmAlertBox1.ShowMessage("Session has expired. A notification of your decision on the Transaction request cannot be sent.", ConfirmAlertBox.PopupMessageType.Error);
                return;
            }

            if (rdVoidItems.Checked)
            {
                if (Session["_idArrays"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Please <b>select at least one item</b> on the grid or click the <b>Select All</b> checkbox.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var idArrays = Session["_idArrays"] as List <int>;

                if (idArrays == null || !idArrays.Any())
                {
                    ConfirmAlertBox1.ShowMessage("Please use the <b>checkboxes to select at least one item on the grid or click the <b>Select All</b> checkbox.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (Session["_transactionItems"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var transactionItems = Session["_transactionItems"] as List <TransactionItem>;

                if (transactionItems == null || !transactionItems.Any())
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var voidedTransactionItemList = (from int id in idArrays select transactionItems.Find(m => m.TransactionItemId == id)).ToList();

                if (!voidedTransactionItemList.Any())
                {
                    ConfirmAlertBox1.ShowMessage("An unknown error was encountered. The process call was invalid.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (voidedTransactionItemList.Count == transactionItems.Count)
                {
                    transaction.Status = 3;
                }

                if (!UpdateTransactionAndItems(voidedTransactionItemList))
                {
                    return;
                }

                message = "One or more Items of your Transaction request: " + transaction.ExpenseTitle +
                          " has been VOIDED.";
            }

            if (rdVoidTransaction.Checked)
            {
                if (!UpdateTransaction())
                {
                    return;
                }

                message = "Your Transaction request: " + transaction.ExpenseTitle + " was VOIDED.";
            }

            if (Session["_transaction"] == null)
            {
                ConfirmAlertBox1.ShowMessage("Session has expired. A notification of your decision on the Transaction request cannot be sent.", ConfirmAlertBox.PopupMessageType.Error);
                return;
            }

            var user = Membership.GetUser(transaction.RegisteredById);

            if (user == null)
            {
                ConfirmAlertBox1.ShowMessage("The Transaction requester's details could not be retrieved. A notification of your decision on the Transaction request cannot be sent.", ConfirmAlertBox.PopupMessageType.Error);
                return;
            }


            if (!Mailsender(user.Email, subject, message))
            {
                ConfirmAlertBox1.ShowMessage("A notification of your decision on the Transaction request could not be sent.", ConfirmAlertBox.PopupMessageType.Error);
            }

            if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
            {
                if (ValidateDateControls())
                {
                    GetTransactionsByDate();
                }
            }
            else
            {
                LoadTransactions();
            }
            Session["_transaction"] = null;
            SetTransactionsStyle();
            dvUserEntries.Visible    = true;
            dgExpenseItem.DataSource = new List <TransactionItem>();
            dgExpenseItem.DataBind();
            dvTransactionItems.Visible = false;
            dvUserEntries.Visible      = true;
            ConfirmAlertBox1.ShowSuccessAlert("Your decision on the Transaction was successfully submitted and a notification was successfully sent to the requester.");
        }
Beispiel #17
0
        protected void BtnApproveTransactionClick(object sender, EventArgs e)
        {
            if (!ValidateApprovalControls())
            {
                return;
            }

            if (radApprove.Checked)
            {
                if (Session["_idArrays"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Please select at least one item on the grid or click the <b>Select All</b> checkbox.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var idArrays = Session["_idArrays"] as List <int>;

                if (idArrays == null || !idArrays.Any())
                {
                    ConfirmAlertBox1.ShowMessage("Please use the <b>checkboxes to select at least one item on the grid or click the <b>Select All</b> checkbox.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (Session["_transactionItems"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var transactionItems = Session["_transactionItems"] as List <TransactionItem>;

                if (transactionItems == null || !transactionItems.Any())
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                var updatedTransactionItemList = (from int id in idArrays select transactionItems.Find(m => m.TransactionItemId == id)).ToList();
                //var rejectedItemList = (from int id in idArrays select transactionItems.Find(m => m.TransactionItemId != id)).ToList();

                if (!updatedTransactionItemList.Any())
                {
                    ConfirmAlertBox1.ShowMessage("An unknown error was encountered. The process call was invalid.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (!UpdateTransactionAndItems(updatedTransactionItemList))
                {
                    return;
                }
            }

            else
            {
                if (!UpdateTransaction())
                {
                    return;
                }
            }

            if (!SendNotification())
            {
                ConfirmAlertBox1.ShowMessage("A notification of your decision on the Transaction request could not be sent.", ConfirmAlertBox.PopupMessageType.Error);
            }

            if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
            {
                if (ValidateDateControls())
                {
                    GetTransactionsByDate();
                }
            }
            else
            {
                LoadTransactions();
            }
            SetTransactionsStyle();
            Session["_idArrays"]         = null;
            Session["_transaction"]      = null;
            Session["_transactionItem"]  = null;
            Session["_transactionItems"] = null;
            dgExpenseItem.DataSource     = new List <TransactionItem>();
            dgExpenseItem.DataBind();
            dvUserEntries.Visible      = true;
            dvTransactionItems.Visible = false;
            dvUserEntries.Visible      = true;
            ConfirmAlertBox1.ShowSuccessAlert("Your decision on the Transaction was successfully submitted and a notification was sent to the requester.");
        }
Beispiel #18
0
        private bool UpdateTransactionItem()
        {
            try
            {
                if (Session["_transactionItems"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                var transactionItems = Session["_transactionItems"] as List <TransactionItem>;

                if (transactionItems == null || !transactionItems.Any())
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (string.IsNullOrEmpty(textApprouvedQuantity.Value.Trim()) && string.IsNullOrEmpty(textApprovedUnitPrice.Value.Trim()))
                {
                    ConfirmAlertBox1.ShowSuccessAlert("No changes was made.");
                    return(true);
                }

                if (Session["_transactionItem"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired!", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                var transactionItem = Session["_transactionItem"] as TransactionItem;

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

                var newTransactionItem = transactionItems.Find(m => m.TransactionItemId == transactionItem.TransactionItemId);

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

                if (!string.IsNullOrEmpty(textApprovedUnitPrice.Value.Trim()) || double.Parse(textApprouvedQuantity.Value.Trim()) > 0)
                {
                    if (!string.IsNullOrEmpty(textApprouvedQuantity.Value.Trim()) && int.Parse(textApprouvedQuantity.Value.Trim()) > 0)
                    {
                        newTransactionItem.ApprovedQuantity = int.Parse(textApprouvedQuantity.Value.Trim());
                    }

                    if (!string.IsNullOrEmpty(textApprovedUnitPrice.Value.Trim()) && double.Parse(textApprovedUnitPrice.Value.Trim()) > 0)
                    {
                        newTransactionItem.ApprovedUnitPrice = double.Parse(textApprovedUnitPrice.Value.Replace(",", string.Empty).Replace(".", string.Empty).Trim());
                    }

                    newTransactionItem.ApprovedTotalPrice = newTransactionItem.ApprovedQuantity * newTransactionItem.ApprovedUnitPrice;
                }

                if (string.IsNullOrEmpty(textApprovedUnitPrice.Value.Trim()) && double.Parse(textApprovedUnitPrice.Value.Trim()) < 1)
                {
                    newTransactionItem.ApprovedTotalPrice = 0;
                }

                transactionItems.Remove(transactionItem);
                transactionItems.Add(newTransactionItem);
                dgExpenseItem.DataSource = transactionItems.OrderBy(m => m.ExpenseItem.Title);
                dgExpenseItem.DataBind();
                LoadTransactionsFooter();
                Session["_transactionItems"] = transactionItems;
                Session["_transactionItem"]  = null;
                return(true);
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("The Edit process could not be completed. Please try again.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
Beispiel #19
0
        protected void DgTypesOfExpenseTransactionsDeleteCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                if (Session["_transactionTypesList"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Expense Types list is empty or session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }
                var transactionTypesList = (List <ExpenseType>)Session["_transactionTypesList"];

                if (transactionTypesList == null)
                {
                    ConfirmAlertBox1.ShowMessage("Expense Types list is empty or session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (!transactionTypesList.Any())
                {
                    ConfirmAlertBox1.ShowMessage("Expense Types list is empty or session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                dgTypesOfExpenseTransactions.SelectedIndex = e.Item.ItemIndex;

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

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

                var expenseType = transactionTypesList.Find(m => m.ExpenseTypeId == id);

                if (expenseType == null)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (expenseType.ExpenseTypeId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Invalid record selection.", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                if (!ServiceProvider.Instance().GetExpenseTypeServices().DeleteExpenseType(expenseType.ExpenseTypeId))
                {
                    ConfirmAlertBox1.ShowMessage("The Expense Type information could not be deleted!", ConfirmAlertBox.PopupMessageType.Error);
                    return;
                }

                ConfirmAlertBox1.ShowSuccessAlert("Expense Type information was deleted successfully.");
                if (!LoadTransactionTypes())
                {
                }
            }
            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);
            }
        }