protected void DgPortalUsersEditCommand(Object source, DataGridCommandEventArgs e)
        {
            if (!(Page.User.IsInRole("PortalAdmin") || Page.User.IsInRole("SiteAdmin")))
            {
                ErrorDisplay1.ShowError("Sorry: You do not have access to this module!");
                return;
            }
            ErrorDisplay1.ClearError();
            dgPortalUsers.SelectedIndex = e.Item.ItemIndex;
            var userId = (DataCheck.IsNumeric(dgPortalUsers.DataKeys[e.Item.ItemIndex].ToString())) ? long.Parse(dgPortalUsers.DataKeys[e.Item.ItemIndex].ToString()) : 0;

            if (userId < 1)
            {
                ErrorDisplay1.ShowError("Invalid Selection");
                return;
            }

            Session["_selectedUser"] = null;
            if (!BindUSer(userId))
            {
                return;
            }

            btnSubmit.CommandArgument = "2";     // Update Item
            btnSubmit.Text            = "Update User";
            mpeDisplayJobDetails.Show();
        }
        private void LoadDepartments()
        {
            try
            {
                var beneficiariesList = ServiceProvider.Instance().GetStaffBeneficiaryServices().GetOrderedStaffDepartments();

                if (beneficiariesList == null || !beneficiariesList.Any())
                {
                    ErrorDisplay1.ShowError("Department list is empty");
                    ddlDepartment.DataSource = new List <Department>();
                    ddlDepartment.Items.Insert(0, new ListItem("--List is empty--", "0"));
                    ddlDepartment.SelectedIndex = 0;
                    return;
                }

                ddlDepartment.DataSource     = beneficiariesList;
                ddlDepartment.DataTextField  = "Name";
                ddlDepartment.DataValueField = "DepartmentId";
                ddlDepartment.DataBind();
                ddlDepartment.Items.Insert(0, new ListItem("--Select Department--", "0"));
                ddlDepartment.SelectedIndex = 0;
            }
            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.");
            }
        }
        protected void LnkFilterByUnApprovedClick(object sender, EventArgs e)
        {
            try
            {
                ErrorDisplay1.ClearError();
                var expTransactions = ServiceProvider.Instance().GetStaffExpenseTransactionServices().GetUnApprovedctiveExpenseTransactions();

                if (!expTransactions.Any())
                {
                    ErrorDisplay1.ShowError("Unapproved Expense Transaction list is empty.");
                    dgExpenseTransaction.DataSource = new List <StaffExpenseTransaction>();
                    dgExpenseTransaction.DataBind();
                    return;
                }

                dgExpenseTransaction.DataSource = expTransactions;
                dgExpenseTransaction.DataBind();
                Session["_expTransactions"] = expTransactions;
            }
            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.");
            }
        }
        protected void DdlDepartmentIndexChanged(object sender, EventArgs e)
        {
            ErrorDisplay1.ClearError();

            try
            {
                ddlPortalUser.SelectedIndex = 0;
                txtEndDate.Text             = string.Empty;
                txtStart.Text = string.Empty;
                if (int.Parse(ddlDepartment.SelectedValue) < 1)
                {
                    ErrorDisplay1.ShowError("Please select a Department.");
                    dgExpenseTransaction.DataSource = new List <StaffExpenseTransaction>();
                    dgExpenseTransaction.DataBind();
                    return;
                }

                if (!LoadTransactionsByDepartment())
                {
                }
            }
            catch
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
            }
        }
示例#5
0
        protected void BtnSubmitClick(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateTransactionPaymentControl())
                {
                    return;
                }

                var k = UpdateTransactionPayment();
                if (k < 1)
                {
                    ErrorDisplay1.ShowError("The Transaction Payment information could not be Updated.");
                    return;
                }

                if (!AddTransactionPaymentHistory(k))
                {
                    ErrorDisplay1.ShowError("The Transaction Payment information could not be Updated.");
                    return;
                }

                ErrorDisplay1.ShowSuccess("The Transaction Payment information was updated successfully.");

                if (!LoadTransactionPayments())
                {
                }
            }

            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.");
            }
        }
示例#6
0
        protected void DdlBeneficiariesIndexChanged(object sender, EventArgs e)
        {
            ErrorDisplay1.ClearError();
            try
            {
                if (int.Parse(ddlBeneficiaries.SelectedValue) < 1)
                {
                    ErrorDisplay1.ShowError("Please select a StaffBeneficiary");
                    return;
                }

                if (!LoadTransactionPayments())
                {
                    return;
                }

                // LoadExpenseTransactions();
                divBeneficiary.Visible  = false;
                divPaymentTrack.Visible = 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.");
            }
        }
 private void LoadProfile()
 {
     try
     {
         string     username = HttpContext.Current.User.Identity.Name.ToString(CultureInfo.InvariantCulture);
         portaluser mUser    = new PortalServiceManager().GetPortalUser(username);
         if (mUser != null)
         {
             if (mUser.PortalUserId > 0)
             {
                 Session["defaultUserProfile"] = mUser;
                 this.txtDesignation.Text      = mUser.Designation;
                 try
                 {
                     var membershipUser = Membership.GetUser(username);
                     if (membershipUser != null)
                     {
                         this.txtEmail.Text = membershipUser.Email;
                     }
                 }
                 catch { }
                 this.txtFirstName.Text    = mUser.FirstName;
                 this.txtLastName.Text     = mUser.LastName;
                 this.txtMobileNumber.Text = mUser.MobileNumber;
                 this.txtSex.Text          = Enum.Parse(typeof(kPortal.Common.EnumControl.Enums.Sex), mUser.SexId.ToString(CultureInfo.InvariantCulture)).ToString();
             }
         }
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         ErrorDisplay1.ShowError(ex.Message);
         return;
     }
 }
示例#8
0
        private bool LoadTransactionPayments()
        {
            try
            {
                var expenseTransactionPaymentList = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().GetStaffBeneficiaryUncompletedExpenseTransactionPayments(int.Parse(ddlBeneficiaries.SelectedValue));

                if (!expenseTransactionPaymentList.Any())
                {
                    ErrorDisplay1.ShowError(" There are no uncompleted Transaction Payments for this Staff Beneficiary");
                    dgBeneficiaryPaymentTrack.DataSource = new List <StaffExpenseTransactionPayment>();
                    dgBeneficiaryPaymentTrack.DataBind();
                    hBeneficiary.InnerHtml  = ddlBeneficiaries.SelectedItem.Text;
                    divPaymentTrack.Visible = true;
                    return(false);
                }

                dgBeneficiaryPaymentTrack.DataSource = expenseTransactionPaymentList;
                dgBeneficiaryPaymentTrack.DataBind();
                hBeneficiary.InnerHtml = ddlBeneficiaries.SelectedItem.Text;
                Session["_staffTransactionPaymentList"] = expenseTransactionPaymentList;
                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);
            }
        }
 private bool ValidateControls()
 {
     if (this.txtFirstName.Text.Trim() == "")
     {
         ErrorDisplay1.ShowError("First Name is required");
         return(false);
     }
     if (this.txtLastName.Text.Trim() == "")
     {
         ErrorDisplay1.ShowError("Last Name is required");
         return(false);
     }
     if (this.txtMobileNumber.Text.Trim() == "")
     {
         ErrorDisplay1.ShowError("Mobile Number is required");
         return(false);
     }
     if (this.txtDesignation.Text == "")
     {
         ErrorDisplay1.ShowError("Specify the designation");
         return(false);
     }
     if (this.txtEmail.Text.Trim() == "")
     {
         ErrorDisplay1.ShowError("Specify email address");
         return(false);
     }
     return(true);
 }
        private void LoadFilterdAssetCategories()
        {
            ErrorDisplay1.ClearError();
            try
            {
                ddlAssetCategories.DataSource = new List <AssetCategory>();
                ddlAssetCategories.DataBind();
                ddlAssetCategories.Items.Insert(0, new ListItem("--List is empty--", "0"));
                ddlAssetCategories.SelectedIndex = 0;

                var assetCategoryList = ServiceProvider.Instance().GetAssetCategoryServices().LoadFilterdAssetCategories();

                if (!assetCategoryList.Any())
                {
                    return;
                }

                ddlAssetCategories.DataSource     = assetCategoryList;
                ddlAssetCategories.DataValueField = "AssetCategoryId";
                ddlAssetCategories.DataTextField  = "Name";
                ddlAssetCategories.DataBind();
                ddlAssetCategories.Items.Insert(0, new ListItem("---Select an Asset Category---", "0"));
                ddlAssetCategories.SelectedIndex = 0;
            }

            catch
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
            }
        }
        private bool LoadAssetType()
        {
            ErrorDisplay1.ClearError();
            try
            {
                var assetTypesList = ServiceProvider.Instance().GetAssetTypeServices().GetAllAssetTypes();

                if (!assetTypesList.Any())
                {
                    dgAssetTypes.DataSource = new List <AssetType>();
                    dgAssetTypes.DataBind();
                    return(false);
                }

                dgAssetTypes.DataSource = assetTypesList;
                dgAssetTypes.DataBind();
                return(true);
            }

            catch (Exception ex)
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
示例#12
0
        private bool GetcompletedPayments()
        {
            try
            {
                var completedList = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().GetStaffCompletedExpenseTransactionPayments();

                if (!completedList.Any())
                {
                    ErrorDisplay1.ShowError("Completed payment list is empty.");
                    lblFilterReport.InnerHtml           = "No record found";
                    dgAllTransactionPayments.DataSource = new List <StaffExpenseTransactionPayment>();
                    dgAllTransactionPayments.DataBind();
                    return(false);
                }

                var itemCount = completedList.Count;
                lblFilterReport.InnerHtml = itemCount + " " + " Completed Payment(s) found!";

                dgAllTransactionPayments.DataSource = completedList;
                dgAllTransactionPayments.DataBind();
                Session["_completedPaymentsList"] = completedList;
                Session["_expensePaymentsList"]   = null;
                Session["_expensePaymentsList"]   = completedList;
                LoadTransactionPaymentFooter();
                SetApprovedTransactionStyle();
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
示例#13
0
        private void SetApprovedTransactionStyle()
        {
            try
            {
                if (dgAllTransactionPayments.Items.Count > 0)
                {
                    for (var i = 0; i < dgAllTransactionPayments.Items.Count; i++)
                    {
                        var approvedLabel   = ((Label)dgAllTransactionPayments.Items[i].FindControl("lblTransactionStatus"));
                        var linkViewHistory = ((LinkButton)dgAllTransactionPayments.Items[i].FindControl("lblViewHistory"));
                        if (approvedLabel.Text == "Completed")
                        {
                            approvedLabel.Style.Add("color", "darkcyan");
                            approvedLabel.Style.Add("font-weight", "bold");
                        }

                        if (approvedLabel.Text == "Uncompleted")
                        {
                            approvedLabel.Style.Add("color", "maroon");
                            approvedLabel.Style.Add("font-weight", "bold");
                        }

                        linkViewHistory.Style.Add("color", "rgba(35, 6, 35, 0.65)");
                    }
                }
            }
            catch
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
            }
        }
示例#14
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                manager.PasswordValidator = new PasswordValidator
                {
                    RequireNonLetterOrDigit = false,
                    RequireDigit            = false,
                    RequireLowercase        = false,
                    RequireUppercase        = false,
                };
                var user = new ApplicationUser()
                {
                    UserName = txtName.Text, Email = txtEmail.Text, Admin = false, PhoneNumber = txtPhone.Text, EmailConfirmed = true,
                };
                IdentityResult result = manager.Create(user, txtPassword.Text.Trim());
                if (result.Succeeded)
                {
                    ;
                    manager.AddToRole(user.Id, ddlUserType.SelectedItem.Text);

                    Response.Redirect("Success.aspx");
                    //ErrorDisplay.ShowSuccess("User added successfully");
                }
                else
                {
                    ErrorDisplay1.ShowError(result.Errors.FirstOrDefault());
                }
            }
            catch (Exception ex)
            {
                //ErrorDisplay1.ShowError(DefaultResponses.exception);
            }
        }
 protected void DgPortalRoleEditCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     ErrorDisplay1.ClearError();
     try
     {
         dgPortalRole.SelectedIndex = e.Item.ItemIndex;
         int id = (DataCheck.IsNumeric(dgPortalRole.DataKeys[e.Item.ItemIndex].ToString())) ? int.Parse(dgPortalRole.DataKeys[e.Item.ItemIndex].ToString()) : 0;
         if (id < 1)
         {
             ErrorDisplay1.ShowError("Invalid Item Selection");
             return;
         }
         ErrorDisplay1.ClearControls(tbUserInfo);
         txtRoleName.Text       = ((LinkButton)dgPortalRole.SelectedItem.FindControl("lblRole")).Text;
         ViewState["mRoleName"] = ((LinkButton)dgPortalRole.SelectedItem.FindControl("lblRole")).Text;
         ViewState["mRecordID"] = id;
         HideTables();
         btnSubmit.CommandArgument = "2"; //Update
         btnSubmit.Text            = "Update Role";
         mpeDisplayJobDetails.Show();
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         ErrorDisplay1.ShowError(ex.Message);
     }
 }
        private bool Mailsender(string to, string subject, string body)
        {
            try
            {
                var emailUtility = new ExpensemanagerEmailSenderUtility();
                var config       = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
                var settings     = (System.Net.Configuration.MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");

                if (settings != null)
                {
                    var fromAddress = new MailAddress(settings.Smtp.From);
                    ThreadPool.QueueUserWorkItem(s =>
                    {
                        if (!emailUtility.SendMail(fromAddress, to, subject, body, settings.Smtp.Network.UserName, settings.Smtp.Network.Password))
                        {
                            ErrorDisplay1.ShowError("A notification could not be sent to the User.");
                            return;
                        }
                    });
                    return(true);
                }

                return(false);
            }
            catch (Exception)
            {
                ErrorDisplay1.ShowError("Your Transactions request notification could not be sent. Approval of your request might be delayed.");
                return(false);
            }
        }
        protected void BtnUpdateRecordClick(Object sender, EventArgs e)
        {
            ErrorDisplay1.ClearError();
            if (txtEmail.Text == "")
            {
                ErrorDisplay1.ShowError("Email Address is required");
                return;
            }
            int k = ValidateRole();

            if (k < 1)
            {
                ErrorDisplay1.ShowError("User must belong to at least a role");
                return;
            }

            var mUser = Membership.GetUser(txtUserName.Text.Trim());

            if (mUser == null)
            {
                ErrorDisplay1.ShowError("Fatal Error occurred! Please try again soon");
                return;
            }
            mUser.Email      = txtEmail.Text.Trim();
            mUser.IsApproved = chkActive.Checked;
            Membership.UpdateUser(mUser);
            string[] mRoles = Roles.GetRolesForUser(txtUserName.Text.Trim());

            if (mRoles != null)
            {
                if (mRoles.Length > 0)
                {
                    Roles.RemoveUserFromRoles(txtUserName.Text.Trim(), mRoles);
                }
            }

            var mNewRoles = new string[k];
            int h         = 0;

            for (int i = 0; i < chkRoles.Items.Count; i++)
            {
                if (chkRoles.Items[i].Selected)
                {
                    mNewRoles[h] = chkRoles.Items[i].Value.Trim();
                    h           += 1;
                }
            }
            if (mNewRoles[0].Length > 0)
            {
                Roles.AddUserToRoles(txtUserName.Text.Trim(), mNewRoles);
                BindUsersList();
                HideTables();
                listDV.Visible = true;
                ErrorDisplay1.ShowSuccess("User Information was updated successfully.");
            }
            else
            {
                ErrorDisplay1.ShowError("Fatal Error occurred! User information could not be updated");
            }
        }
        private void LoadAccountsHead()
        {
            try
            {
                var filteredAccountsHeadsList = ServiceProvider.Instance().GetAccountsHeadServices().GetFilteredAccountsHeads();

                if (!filteredAccountsHeadsList.Any())
                {
                    ErrorDisplay1.ShowError("Accounts Head list is empty or session has expired.");
                    ddlAccountsHead.DataSource = new List <AccountsHead>();
                    ddlAccountsHead.DataBind();
                    ddlAccountsHead.Items.Insert(0, new ListItem("--List is empty--", "0"));
                    ddlAccountsHead.SelectedIndex = 0;
                    return;
                }

                ddlAccountsHead.DataSource     = filteredAccountsHeadsList;
                ddlAccountsHead.DataValueField = "AccountsHeadId";
                ddlAccountsHead.DataTextField  = "Title";
                ddlAccountsHead.DataBind();
                ddlAccountsHead.Items.Insert(0, new ListItem("---Select an Accounts Head---", "0"));
                ddlAccountsHead.SelectedIndex = 0;
            }

            catch (Exception ex)
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
            }
        }
        private bool LoadAssetCategories()
        {
            try
            {
                dgAssetCategories.DataSource = new List <AssetCategory>();
                dgAssetCategories.DataBind();

                var assetCategories = ServiceProvider.Instance().GetAssetCategoryServices().GetAssetCategoryList();
                if (assetCategories == null)
                {
                    ErrorDisplay1.ShowError("Asset Category List is empty.");
                    return(false);
                }

                if (!assetCategories.Any())
                {
                    ErrorDisplay1.ShowError("Asset Category List is empty.");
                    return(false);
                }

                dgAssetCategories.DataSource = assetCategories;
                dgAssetCategories.DataBind();
                Session["_assetCategories"] = assetCategories;
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplay1.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);
                return(false);
            }
        }
示例#20
0
        private bool LoadExpenseCategories()
        {
            try
            {
                var expenseCategoriesList =
                    ServiceProvider.Instance().GetExpenseCategoryServices().GetExpenseCategories();

                if (expenseCategoriesList == null || !expenseCategoriesList.Any())
                {
                    ErrorDisplay1.ShowError("Expense Category list is empty!");
                    dgExpCatCollections.DataSource = new List <ExpenseCategory>();
                    dgExpCatCollections.DataBind();
                    return(false);
                }

                expenseCategoriesList          = expenseCategoriesList.OrderBy(m => m.Title).ToList();
                dgExpCatCollections.DataSource = expenseCategoriesList;
                dgExpCatCollections.DataBind();
                Session["_expenseCategoriesList"] = expenseCategoriesList;
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                throw;
            }
        }
        private bool LoadAllExpenseItems()
        {
            try
            {
                var expenseItemList = ServiceProvider.Instance().GetExpenseItemServices().GetExpenseItems();

                if (!expenseItemList.Any())
                {
                    ErrorDisplay1.ShowError("Expense Item list is empty.");
                    dgExpenseItem.DataSource = new List <ExpenseItem>();
                    dgExpenseItem.DataBind();
                    return(false);
                }

                dgExpenseItem.DataSource = expenseItemList;
                dgExpenseItem.DataBind();
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
示例#22
0
        private bool LoadAllTransactionPayments()
        {
            try
            {
                dgAllTransactionPayments.DataSource = new List <StaffExpenseTransactionPayment>();
                dgAllTransactionPayments.DataBind();

                var allTransactionsList = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().GetStaffOrderedExpenseTransactionPayments();

                if (!allTransactionsList.Any())
                {
                    ErrorDisplay1.ShowError("Transaction Payment list is empty.");
                    dgAllTransactionPayments.DataSource = new List <StaffExpenseTransactionPayment>();
                    dgAllTransactionPayments.DataBind();
                    return(false);
                }

                dgAllTransactionPayments.DataSource = allTransactionsList;
                dgAllTransactionPayments.DataBind();
                LoadTransactionPaymentFooter();
                SetApprovedTransactionStyle();
                Session["_expensePaymentsList"] = null;
                Session["_expensePaymentsList"] = allTransactionsList;
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplay1.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 DgPortalRoleDeleteCommand(Object source, DataGridCommandEventArgs e)
        {
            ErrorDisplay1.ClearError();
            try
            {
                dgPortalRole.SelectedIndex = e.Item.ItemIndex;
                int    id       = (DataCheck.IsNumeric(dgPortalRole.DataKeys[e.Item.ItemIndex].ToString())) ? int.Parse(dgPortalRole.DataKeys[e.Item.ItemIndex].ToString()) : 0;
                string roleName = ((LinkButton)dgPortalRole.SelectedItem.FindControl("lblRole")).Text;
                if (roleName.Length == 0)
                {
                    ErrorDisplay1.ShowError("Process Error! Please try again later");
                    return;
                }

                //Check if the role name is PortalAdmin, then terminate the process
                if (roleName.ToLower() == "PortalAdmin".ToLower())
                {
                    ErrorDisplay1.ShowError("Sorry, you can not delete this role");
                    return;
                }
                //Check to see that the current user has right to delete role
                if (!Page.User.IsInRole("PortalAdmin"))
                {
                    ErrorDisplay1.ShowError("Sorry, you are not authorized to delete a role");
                }

                //If role has registered users, remove the users from the role.
                try
                {
                    if (Roles.GetUsersInRole(roleName).Length > 0)
                    {
                        string[] mUsersInRole = Roles.GetUsersInRole(roleName);
                        Roles.RemoveUsersFromRole(mUsersInRole, roleName);
                    }
                }
                catch (Exception ex)
                {
                    ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                    ErrorDisplay1.ShowError(ex.Message);
                    return;
                }
                //'Now delete the role!
                if (Roles.DeleteRole(roleName, false))
                {
                    BindRoleItems();
                    ErrorDisplay1.ShowSuccess("Role Item Was Removed");
                }
                else
                {
                    ErrorDisplay1.ShowError("Role Item could not be removed");
                }
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ErrorDisplay1.ShowError(ex.Message);
                return;
            }
        }
        private bool UpdateAssetType()
        {
            ErrorDisplay1.ClearError();
            try
            {
                if (Session["_assetType"] == null)
                {
                    ErrorDisplay1.ShowError("Session has expired");
                    return(false);
                }

                var assetType = (AssetType)Session["_assetType"];

                if (assetType == null)
                {
                    ErrorDisplayProcessAssetType.ShowError("Session has expired");
                    mpeProcessAssetType.Show();
                    return(false);
                }

                if (assetType.AssetTypeId < 1)
                {
                    ErrorDisplay1.ShowError("Invalid selection!");
                    return(false);
                }

                assetType.Name            = txtAssetType.Text.Trim();
                assetType.AssetCategoryId = int.Parse(ddlAssetCategory.SelectedValue.ToString(CultureInfo.InvariantCulture));
                assetType.Status          = chkAssetType.Checked ? 1 : 0;

                var k = ServiceProvider.Instance().GetAssetTypeServices().UpdateAssetType(assetType);

                if (k < 1)
                {
                    if (k == -3)
                    {
                        ErrorDisplayProcessAssetType.ShowError("Asset Type already exists.");
                        txtAssetType.Focus();
                        mpeProcessAssetType.Show();
                        return(false);
                    }

                    ErrorDisplayProcessAssetType.ShowError("The Asset Type information could not be updated. Please try again soon or contact the Admin.");
                    mpeProcessAssetType.Show();
                    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);
            }
        }
示例#25
0
        protected void DgPaymentHistoryCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                if (Session["_paymentHistoryList"] == null)
                {
                    ErrorDisplay1.ShowError("Transaction Payment History is empty or session has expired.");
                    return;
                }

                var expenseTransactionPaymentHistoryList = Session["_paymentHistoryList"] as List <StaffExpenseTransactionPaymentHistory>;

                if (expenseTransactionPaymentHistoryList == null || !expenseTransactionPaymentHistoryList.Any())
                {
                    ErrorDisplay1.ShowError("Transaction Payment History is empty or session has expired.");
                    return;
                }

                dgPaymentHistory.SelectedIndex = e.Item.ItemIndex;

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

                if (id < 1)
                {
                    ErrorDisplay1.ShowError("Invalid Record Selection!");
                    return;
                }

                var transactionHistory =
                    expenseTransactionPaymentHistoryList.Find(m => m.StaffExpenseTransactionPaymentHistoryId == id);

                if (transactionHistory == null || transactionHistory.StaffExpenseTransactionPaymentHistoryId < 1)
                {
                    ErrorDisplay1.ShowError("Invalid selection");
                    return;
                }

                if (transactionHistory.Comment == null)
                {
                    ErrorDisplay1.ShowError("There is no comment for the selected transaction");
                }

                else
                {
                    lgTransactionTitle.InnerHtml           = transactionHistory.StaffExpenseTransaction.ExpenseTitle;
                    txtHistoryComment.Text                 = transactionHistory.Comment;
                    mpePaymentCommentPopup.PopupControlID  = dvTransactionComment.ID;
                    mpePaymentCommentPopup.CancelControlID = btnCloseComment.ID;
                    mpePaymentCommentPopup.Show();
                }
            }
            catch
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
            }
        }
 protected void DdlAccountsHeadSelectedChanged(object sender, EventArgs e)
 {
     if (int.Parse(ddlAccountsHead.SelectedValue) < 1)
     {
         ErrorDisplay1.ShowError("Invalid selection!");
         return;
     }
     if (!LoadExpenseItemsByAccountHead(int.Parse(ddlAccountsHead.SelectedValue)))
     {
     }
 }
        protected void DdlAssetCategoriesSelectedChanged(object sender, EventArgs e)
        {
            ErrorDisplay1.ClearError();
            if (int.Parse(ddlAssetCategories.SelectedValue) < 1)
            {
                ErrorDisplay1.ShowError("Please select an Asset Category");
                ddlAssetCategories.Focus();
                return;
            }

            GetOrderedAssetTypeByAssetCategory(int.Parse(ddlAssetCategories.SelectedValue));
        }
示例#28
0
        private void LoadTransactionPaymentFooter()
        {
            try
            {
                if (dgAllTransactionPayments.Items.Count > 0)
                {
                    double expAmountPayableTotal = 0;
                    double expAmountPaidTotal    = 0;
                    double totalBalance          = 0;
                    for (var i = 0; i < dgAllTransactionPayments.Items.Count; i++)
                    {
                        expAmountPayableTotal += DataCheck.IsNumeric(((Label)dgAllTransactionPayments.Items[i].FindControl("lblTotalAmountPaid")).Text)
                                      ? double.Parse(((Label)dgAllTransactionPayments.Items[i].FindControl("lblTotalAmountPaid")).Text)
                                      : 0;
                        expAmountPaidTotal += DataCheck.IsNumeric(((Label)dgAllTransactionPayments.Items[i].FindControl("lblAmountPaid")).Text)
                                     ? double.Parse(((Label)dgAllTransactionPayments.Items[i].FindControl("lblAmountPaid")).Text)
                                     : 0;
                        totalBalance += DataCheck.IsNumeric(((Label)dgAllTransactionPayments.Items[i].FindControl("lblBalance")).Text)
                                     ? double.Parse(((Label)dgAllTransactionPayments.Items[i].FindControl("lblBalance")).Text)
                                     : 0;
                    }

                    foreach (var item in dgAllTransactionPayments.Controls[0].Controls)
                    {
                        if (item.GetType() == typeof(DataGridItem))
                        {
                            var itmType = ((DataGridItem)item).ItemType;
                            if (itmType == ListItemType.Footer)
                            {
                                if (((DataGridItem)item).FindControl("lblTotalAmountPaidFooter") != null)
                                {
                                    ((Label)((DataGridItem)item).FindControl("lblTotalAmountPaidFooter")).Text = "N" + NumberMap.GroupToDigits(expAmountPayableTotal.ToString(CultureInfo.InvariantCulture));
                                }
                                if (((DataGridItem)item).FindControl("lblAmountPaidFooter") != null)
                                {
                                    ((Label)((DataGridItem)item).FindControl("lblAmountPaidFooter")).Text = "N" + NumberMap.GroupToDigits(expAmountPaidTotal.ToString(CultureInfo.InvariantCulture));
                                }
                                if (((DataGridItem)item).FindControl("lblBalanceFooter") != null)
                                {
                                    ((Label)((DataGridItem)item).FindControl("lblBalanceFooter")).Text = "N" + NumberMap.GroupToDigits(totalBalance.ToString(CultureInfo.InvariantCulture));
                                }
                            }
                        }
                    }
                }
            }
            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.");
            }
        }
示例#29
0
        private bool GetAccountsHeadsCostsByDateRange()
        {
            try
            {
                dgCostItems.DataSource = new List <ExpenseTransaction>();
                dgCostItems.DataBind();
                var accountHeadId = int.Parse(ddlAccountsHeads.SelectedValue);
                if (accountHeadId < 1)
                {
                    ErrorDisplay1.ShowError("Please select an Expense Item.");
                    return(false);
                }

                var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                var startDate       = DateTime.Parse(startDateString);
                var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                var endDate         = DateTime.Parse(endDateString);
                if (endDate < startDate || startDate > endDate)
                {
                    ErrorDisplay1.ShowError("The 'From' date must not be LATER than the 'To' date.");
                    return(false);
                }

                var transactionItems =
                    ServiceProvider.Instance()
                    .GetTransactionItemServices()
                    .GetAccountsHeadsCostsByDateRange(accountHeadId, startDateString, endDateString);

                if (!transactionItems.Any())
                {
                    ErrorDisplay1.ShowError("No Record found!");
                    return(false);
                }

                //dgCostItems.DataSource = transactionItems;
                //dgCostItems.DataBind();

                Session["_accountsHeadeadCosts"] = null;
                Session["_accountsHeadeadCosts"] = transactionItems;
                lblGrandTotal.InnerText          = "N" + NumberMap.GroupToDigits(transactionItems[0].GrandTotalApprovedPrice.ToString(CultureInfo.InvariantCulture));
                headTitle.InnerText = ddlAccountsHeads.SelectedItem.Text;
                Limit = int.Parse(ddlLimit.SelectedValue);
                FillRepeater <TransactionItem>(dgCostItems, "_accountsHeadeadCosts", Navigation.None, Limit, LoadMethod);
                return(true);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
        protected void BtnSearchClick(object sender, EventArgs e)
        {
            ErrorDisplay1.ClearError();
            var beneficiaries = ServiceProvider.Instance().GetBeneficiaryServices().GeteBeneficiaryBySearchText(txtSearch.Text.Trim());

            if (beneficiaries == null || !beneficiaries.Any())
            {
                ErrorDisplay1.ShowError("No record found");
                return;
            }

            dgBeneficiaries.DataSource = beneficiaries;
            dgBeneficiaries.DataBind();
        }