示例#1
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);
            }
        }
示例#2
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;
            }
        }
示例#3
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);
            }
        }
示例#4
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.");
            }
        }
        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.");
            }
        }
        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);
            }
        }
示例#9
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.");
            }
        }
示例#10
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.");
            }
        }
示例#11
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 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;
     }
 }
 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.");
            }
        }
        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.");
            }
        }
        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 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);
            }
        }
示例#18
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);
            }
        }
        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);
            }
        }
 protected void BindSitemMapItemList()
 {
     try
     {
         ErrorDisplay1.ClearError();
         List <sitemap> mList = (new PortalServiceManager()).GetSiteMapList();
         if (mList == null || mList.Count == 0)
         {
             dgPortalSiteMap.DataSource = new List <sitemap>();
             dgPortalSiteMap.DataBind();
         }
         if (mList != null)
         {
             mList[0].Title             = "ROOT";
             mList[0].Description       = "ROOT";
             dgPortalSiteMap.DataSource = mList;
         }
         dgPortalSiteMap.DataBind();
         //HideMainDvs();
         //this.listDV.Visible = true;
         Session["_mlist"] = mList;
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
     }
 }
 protected void BindSiteMapItems()
 {
     try
     {
         ErrorDisplay1.ClearError();
         List <sitemap> mList = (new PortalServiceManager()).GetSiteMapList();
         if (mList == null || mList.Count == 0)
         {
             dgPortalSiteMap.DataSource = new List <sitemap>();
             dgPortalSiteMap.DataBind();
         }
         if (mList != null)
         {
             mList[0].Title          = "ROOT";
             ddlTabParent.DataSource = mList;
         }
         ddlTabParent.DataTextField  = "Title";
         ddlTabParent.DataValueField = "ID";
         ddlTabParent.DataBind();
         ddlTabParent.Items.Insert(0, (new ListItem("-- Please Select --", "0")));
         ddlTabParent.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
     }
 }
 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);
            }
        }
示例#24
0
        public void ResourcesDistributionList(string category)
        {
            try
            {
                ErrorDisplay1.ClearError();

                //var res = _db.Resources.Where(m => m.Status == 2).ToList();
                var res = _db.Resources.ToList();


                //if (int.Parse(ageClass) > 0)
                //{
                //    res = res.Where(m => m.AgeId == int.Parse(ageClass)).ToList();
                //}

                if (int.Parse(category) > 0)
                {
                    res = res.Where(m => m.CategoryId == int.Parse(category)).ToList();
                }

                if (!res.Any())
                {
                    grdReports.DataSource = new List <Resource>();
                    grdReports.DataBind();
                    ErrorDisplay1.ShowWarning("No record found");
                    return;
                }
                grdReports.DataSource = res;
                grdReports.DataBind();
            }
            catch (Exception ex)
            {
            }
        }
        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");
            }
        }
 protected void BtnRefreshClick(object sender, EventArgs e)
 {
     ErrorDisplay1.ClearError();
     if (!LoadBeneficiaries())
     {
     }
 }
        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;
            }
        }
 protected void BtnAddItemClick(Object sender, EventArgs e)
 {
     ErrorDisplay1.ClearError();
     ErrorDisplay2.ClearError();
     ErrorDisplay1.ClearControls(tbUserInfo);
     btnSubmit.CommandArgument = "1";
     btnSubmit.Text            = "Add Role";
     mpeDisplayJobDetails.Show();
 }
 protected void BtnRefreshClick(object sender, EventArgs e)
 {
     ErrorDisplay1.ClearError();
     txtEndDate.Text = string.Empty;
     txtEndDate.Text = string.Empty;
     if (!LoadAllTransactions())
     {
     }
 }
 protected void BtnAddNewAssetCategoryClick(object sender, EventArgs e)
 {
     ErrorDisplay1.ClearError();
     ClearControls();
     btnProcessAssetCategory.CommandArgument = "1";
     btnProcessAssetCategory.Text            = "Submit";
     lgAssetCategoryTitle.InnerHtml          = "Create a new Asset Category";
     mpeProcessAssetCategory.Show();
 }