Ejemplo n.º 1
0
        private void bindGrid(int roleId)
        {
            resRoleModule = SecRoleModuleManager.getRoleModule(roleId);

            grdModule.DataSource = resRoleModule.Where(x => (x.ParentId == 0 || x.ParentId == null)).ToList();
            grdModule.DataBind();
        }
Ejemplo n.º 2
0
        private void processTreeView(TreeNodeCollection parentNode)
        {
            SecRoleModule roleModule = null;

            if (parentNode != null && parentNode != null && parentNode.Count > 0)
            {
                foreach (TreeNode node in parentNode)
                {
                    if (node.Checked)
                    {
                        roleModule          = new SecRoleModule();
                        roleModule.ModuleID = Convert.ToInt32(node.Value);
                        roleModule.RoleID   = Convert.ToInt32(ViewState["RoleID"]);
                        roleModule.Status   = 1;

                        roleModule.ViewPermission   = true;
                        roleModule.AddPermssion     = false;
                        roleModule.DeletePermission = false;
                        roleModule.EditPermission   = false;

                        SecRoleModuleManager.SaveRoleModule(roleModule);
                    }
                    processTreeView(node.ChildNodes);
                }
            }
        }
Ejemplo n.º 3
0
        private void saveChildrenModules(SecRoleModule parentModule, GridView gvModulePermission)
        {
            SecRoleModule roleModule = null;

            foreach (GridViewRow row in gvModulePermission.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox cbxViewPermission   = row.FindControl("cbxViewPermission") as CheckBox;
                    CheckBox cbxEditPermission   = row.FindControl("cbxEditPermission") as CheckBox;
                    CheckBox cbxAddPermission    = row.FindControl("cbxAddPermission") as CheckBox;
                    CheckBox cbxDeletePermission = row.FindControl("cbxDeletePermission") as CheckBox;

                    if (cbxViewPermission.Checked || cbxEditPermission.Checked || cbxEditPermission.Checked || cbxDeletePermission.Checked)
                    {
                        // save child
                        roleModule = new SecRoleModule();

                        roleModule.ClientID = parentModule.ClientID;
                        roleModule.RoleID   = parentModule.RoleID;

                        roleModule.ModuleID = (int)gvModulePermission.DataKeys[row.RowIndex].Value;
                        roleModule.Status   = 1;

                        roleModule.ViewPermission   = cbxViewPermission.Checked;
                        roleModule.AddPermssion     = cbxAddPermission != null ? cbxAddPermission.Checked : false;
                        roleModule.DeletePermission = cbxDeletePermission != null ? cbxDeletePermission.Checked : false;;
                        roleModule.EditPermission   = cbxEditPermission != null ? cbxEditPermission.Checked : false;

                        SecRoleModuleManager.SaveRoleModule(roleModule);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void saveRoleModules(int clientID, int roleID)
        {
            SecRoleModule roleModule = null;

            foreach (GridViewRow row in gvModules.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox cbxModule = row.FindControl("cbxModule") as CheckBox;

                    if (cbxModule.Checked)
                    {
                        roleModule = new SecRoleModule();

                        roleModule.ClientID = clientID;
                        roleModule.RoleID   = roleID;

                        roleModule.ModuleID = (int)gvModules.DataKeys[row.RowIndex].Value;
                        roleModule.Status   = 1;

                        roleModule.ViewPermission   = cbxModule.Checked;
                        roleModule.AddPermssion     = true;
                        roleModule.DeletePermission = false;
                        roleModule.EditPermission   = true;

                        SecRoleModuleManager.SaveRoleModule(roleModule);

                        GridView gvModulePermission = row.FindControl("gvModulePermission") as GridView;

                        // save
                        saveChildrenModules(roleModule, gvModulePermission);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private List <vw_InvoiceApprovalQueue> getInvoicesFromQueue()
        {
            int clientID = SessionHelper.getClientId();
            int roleID   = SessionHelper.getUserRoleId();

            IQueryable <vw_InvoiceApprovalQueue>    invoices       = null;
            List <vw_InvoiceApprovalQueue>          filterInvoices = null;
            List <SecRoleInvoiceApprovalPermission> rules          = null;

            // load invoices
            invoices = InvoiceManager.GetInvoiceApprovalQueue(clientID);

            SecRoleModule accountingList = null;

            accountingList = SecRoleModuleManager.GetByRoleIdAccounting(roleID);//NEW OC 10/14/14 added to show invoices depending on role manager(not by client only)

            if (roleID == (int)UserRole.Client || accountingList.ViewPermission == true)
            {
                //InvoiceType invoiceType = null;
                // foreach(vw_InvoiceApprovalQueue ipq in invoices)
                // {
                //     int typeID = Convert.ToInt32( ipq.InvoiceTypeID);
                //     invoiceType = InvoiceTypeManager.GetByID(typeID);
                //     string invoiceTypeDescription = invoiceType.InvoiceTypes;

                //     Label lblInv = (Label)gvInvoiceQ.FindControl("lblInvoiceType") as Label;
                //     lblInv.Text = invoiceTypeDescription;
                //     //Session["invoiceTypeDescription"] = invoiceType.InvoiceTypes;

                // }
                // load all invoices for client
                filterInvoices = invoices.ToList();
            }
            else
            {
                filterInvoices = new List <vw_InvoiceApprovalQueue>();

                // get invoice approval rules for role
                rules = InvoiceApprovalRuleManager.GetAll(roleID);

                // enforce approval rules
                if (rules != null && rules.Count > 0)
                {
                    foreach (SecRoleInvoiceApprovalPermission rule in rules)
                    {
                        foreach (vw_InvoiceApprovalQueue invoiceq in invoices)
                        {
                            if (invoiceq.TotalAmount >= rule.AmountFrom && invoiceq.TotalAmount <= rule.AmountTo)
                            {
                                filterInvoices.Add(invoiceq);
                            }
                        }
                    }
                }
            }

            return(filterInvoices);
        }
Ejemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int roleID = Convert.ToInt32(ViewState["RoleID"]);

            SecRole role = null;

            Page.Validate("Role");
            if (!Page.IsValid)
            {
                return;
            }


            clientID = Core.SessionHelper.getClientId();

            if (roleID == 0)
            {
                role          = new SecRole();
                role.ClientID = clientID;
                role.Status   = true;
            }
            else
            {
                role = SecRoleManager.GetByRoleId(roleID);
            }

            if (role != null)
            {
                role.RoleDescription = txtRoleDescription.Text;

                role.RoleName = txtRoleName.Text;

                try {
                    using (TransactionScope scope = new TransactionScope()) {
                        role = SecRoleManager.Save(role);

                        SecRoleModuleManager.deleteRoleModules(clientID, roleID);

                        saveRoleModules(clientID, roleID);

                        saveRoleActions(clientID, roleID);

                        // complete transaction
                        scope.Complete();
                    }

                    // return user to grid
                    showGridPanel();

                    doBind();
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }
            }
        }
Ejemplo n.º 7
0
        private void bindRoleModules(int roleID)
        {
            // get all modules client can edit
            roleModules = SecRoleModuleManager.getRoleModule(clientID, roleID);

            // get those main menu items
            List <SecRoleModuleManager.secRoleModuleGet> parentModules = (from x in roleModules where (x.ParentId == null || x.ParentId == 0) orderby x.ModuleName select x).ToList();

            // show them on grid
            gvModules.DataSource = parentModules;
            gvModules.DataBind();
        }
Ejemplo n.º 8
0
        protected void impersonateClient(Client client)
        {
            List <SecRoleModuleManager.secRoleModuleGet> resRolePermission = new List <SecRoleModuleManager.secRoleModuleGet>();

            string userData = null;

            CRM.Data.Entities.SecUser user = null;

            user = client.SecUser;

            Session["UserId"]   = client.SecUser.UserId;
            Session["UserName"] = client.SecUser.UserName;
            Session["RoleId"]   = client.SecUser.SecRole.RoleId.ToString();

            // 201307-29
            Session["ClientId"]       = client.SecUser.ClientID;
            Session["ClientShowTask"] = (client.isShowTasks ?? true);

            userData = string.Format("{0}|{1}|{2} {3}|{4}", user.SecRole.RoleName, user.SecRole.RoleId, user.FirstName, user.LastName, user.Email);

            var ticket = new FormsAuthenticationTicket
                         (
                1,
                client.SecUser.UserId.ToString(),
                DateTime.Now,
                DateTime.Now.AddMinutes(120),
                true,
                userData,                       //(client.SecUser.SecRole.RoleName + "|" + client.SecUser.SecRole.RoleId.ToString()),
                FormsAuthentication.FormsCookiePath
                         );

            string encryptedTicket = FormsAuthentication.Encrypt(ticket);

            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket));
            Session["rolePermission"] = resRolePermission = SecRoleModuleManager.getRolePermission(client.SecUser.SecRole.RoleId).ToList();



            var url = FormsAuthentication.DefaultUrl;

            Response.Redirect(url);
        }
Ejemplo n.º 9
0
        private void buildMenu()
        {
            int clientID = Core.SessionHelper.getClientId();

            Infragistics.Web.UI.NavigationControls.ExplorerBarGroup menuGroup     = null;
            Infragistics.Web.UI.NavigationControls.ExplorerBarItem  menuItem      = null;
            Infragistics.Web.UI.NavigationControls.ExplorerBarGroup subMenuGroup  = null;
            List <SecRoleModuleManager.secRoleModuleGet>            resRoleModule = null;

            lblUserWelcome.Text = "";
            if (Session["h1"] != null && Session["h2"] != null && Session["h3"] != null && Session["h4"] != null && Session["h5"] != null)
            {
                h1 = Session["h1"].ToString();
                h2 = Session["h2"].ToString();
                h3 = Session["h3"].ToString();
                h4 = Session["h4"].ToString();
                h5 = Session["h5"].ToString();
            }
            string[] userRoleName = (((FormsIdentity)HttpContext.Current.User.Identity).Ticket).UserData.Split('|');

            currentUserRoleId = Convert.ToInt32(userRoleName[1]);

            currentUserId = Convert.ToInt32(Session["UserId"]);

            //if (currentUserId <= 0 || userRoleName[0].ToString().Trim().Replace(" ", "").ToUpper() == "FORALL")
            //LogoutUser();

            //lblUserWelcome.Text = "Welcome (" + userRoleName[0].ToString() + ")";
            //lblUserWelcome.Text = string.Format("Welcome ({0})", Session["UserName"] ?? "");

            // fill socialbox
            lblUserWelcome.Text = string.Format("{0}", Session["UserName"] ?? "");

            // first/last name
            lblUserName.Text = userRoleName[2];

            if (userRoleName.Length > 3)
            {
                lblUserEmail.Text = userRoleName[3] ?? "n/a";
            }


            resRoleModule = new List <SecRoleModuleManager.secRoleModuleGet>();

            if (currentUserRoleId == (int)UserRole.Administrator || currentUserRoleId == (int)UserRole.Client)
            {
                resRoleModule = SecRoleModuleManager.getRoleModuleMenu(currentUserRoleId);
            }
            else
            {
                resRoleModule = SecRoleModuleManager.getRoleModuleMenu(clientID, currentUserRoleId);
            }

            List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleParent =
                resRoleModule.Where(x => (x.ParentId == 0 || x.ParentId == null)).OrderBy(x => x.SortOrder).ToList();
            List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleChild = new List <SecRoleModuleManager.secRoleModuleGet>();

            List <Infragistics.Web.UI.NavigationControls.ExplorerBarGroup> igCurrentMenuGroups = navBar.Groups.Cast <Infragistics.Web.UI.NavigationControls.ExplorerBarGroup>().ToList();

            List <Infragistics.Web.UI.NavigationControls.ExplorerBarGroup> menuGroups = new List <Infragistics.Web.UI.NavigationControls.ExplorerBarGroup>();

            // remove any existing groups in declarative text
            navBar.Groups.Clear();

            foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleParent in resRoleModuleParent)
            {
                if (objRoleModuleParent.Url.Trim() == "")
                {
                    if (objRoleModuleParent.ModuleId > 0)
                    {
                        List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionParent = resRoleModule.Where(x => (x.ModuleId == objRoleModuleParent.ModuleId) && (x.ViewPermssion == true)).OrderBy(x => x.SortOrder).ToList();
                        List <SecRoleModuleManager.secRoleModuleGet> checkforchild             = new List <SecRoleModuleManager.secRoleModuleGet>();
                        checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                        if (checkforchild.Count > 0 || checkviewPermissionParent.Count > 0)
                        {
                            //strMenu.Append("<li><a href='#'>" + objRoleModuleParent.ModuleName + "</a>");
                            menuGroup       = new Infragistics.Web.UI.NavigationControls.ExplorerBarGroup(objRoleModuleParent.ModuleName);
                            menuGroup.Value = objRoleModuleParent.ModuleId.ToString();
                            menuGroups.Add(menuGroup);
                            //navBar.Groups.Add(menuGroup);
                        }
                    }
                }
                else
                {
                    List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionParent = resRoleModule.Where(x => (x.ModuleId == objRoleModuleParent.ModuleId) && (x.ViewPermssion == true)).ToList();
                    List <SecRoleModuleManager.secRoleModuleGet> checkforchild             = new List <SecRoleModuleManager.secRoleModuleGet>();
                    checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                    if (checkforchild.Count > 0 || checkviewPermissionParent.Count > 0)
                    {
                        //strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleParent.Url + "'>" + objRoleModuleParent.ModuleName + "</a>");
                        menuGroup       = new Infragistics.Web.UI.NavigationControls.ExplorerBarGroup(objRoleModuleParent.ModuleName);
                        menuGroup.Value = objRoleModuleParent.ModuleId.ToString();
                        // enable this to add URL navigation to group
                        //menuGroup.NavigateUrl = "~/Protected/Admin/" + objRoleModuleParent.Url;

                        menuGroups.Add(menuGroup);
                    }
                }



                // get all menu options for menu group
                resRoleModuleChild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId))).ToList();

                if (resRoleModuleChild.Count > 0)
                {
                    //strMenu.Append("<ul>");
                    foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleChild in resRoleModuleChild)
                    {
                        List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleChildChildren = new List <SecRoleModuleManager.secRoleModuleGet>();
                        resRoleModuleChildChildren = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();

                        menuItem = new Infragistics.Web.UI.NavigationControls.ExplorerBarItem();
                        menuGroup.Items.Add(menuItem);
                        menuItem.Text  = objRoleModuleChild.ModuleName;
                        menuItem.Value = objRoleModuleChild.ModuleId.ToString();

                        menuItem.NavigateUrl = string.Format("~/Protected/Admin/{0}?p={1}&c={2}", objRoleModuleChild.Url, menuGroup.Value, menuItem.Value);

                        // 2014-04-16
                        //if (menuItem.NavigateUrl.Contains("Reports"))
                        //	menuItem.Target = "_blank";

                        //subMenuGroup = new Infragistics.Web.UI.NavigationControls.ExplorerBarGroup(objRoleModuleChild.ModuleName);
                        //menuGroup.Items.Add(subMenuGroup);

                        if (objRoleModuleChild.Url.Trim() == "")
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                //strMenu.Append("<li><a href='#'>" + objRoleModuleChild.ModuleName + "</a>");
                            }

                            //strMenu.Append("<ul>");
                            foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleChildChildren in resRoleModuleChildChildren)
                            {
                                if (objRoleModuleChildChildren.Url.Trim() == "")
                                {
                                    //strMenu.Append("<li><a href='#'>" + objRoleModuleChildChildren.ModuleName + "</a>");
                                    //subMenuGroup.Items.Add(new Infragistics.Web.UI.NavigationControls.ExplorerBarItem(objRoleModuleChildChildren.ModuleName));
                                }
                                else
                                {
                                    //strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleChildChildren.Url + "'>" + objRoleModuleChildChildren.ModuleName + "</a></li>");
                                    //subMenuGroup.Items.Add(new Infragistics.Web.UI.NavigationControls.ExplorerBarItem(objRoleModuleChildChildren.ModuleName));
                                }
                            }
                        }
                        else if (objRoleModuleChild.Url.Trim() == "AllUserLeadsReport.aspx")
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                //strMenu.Append("<li><a href='../../Protected/Reports/" + objRoleModuleChild.Url + "'>" + objRoleModuleChild.ModuleName + "</a></li>");
                            }
                        }
                        else
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                //strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleChild.Url + "'>" + objRoleModuleChild.ModuleName + "</a></li>");
                            }
                        }
                    }

                    //strMenu.Append("</ul>");
                }
                //strMenu.Append("</li>");
            }

            foreach (Infragistics.Web.UI.NavigationControls.ExplorerBarGroup group in menuGroups)
            {
                navBar.Groups.Add(group);
            }

            foreach (Infragistics.Web.UI.NavigationControls.ExplorerBarGroup group in igCurrentMenuGroups)
            {
                navBar.Groups.Add(group);
            }
        }
Ejemplo n.º 10
0
        public void DoAuthenticate(CRM.Data.Entities.SecUser user)
        {
            string     url         = null;
            string     userData    = null;
            List <int> roleActions = null;

            Session["UserId"]   = user.UserId;
            Session["UserName"] = user.UserName;
            Session["RoleId"]   = user.SecRole.RoleId.ToString();

            // 201307-29
            Session["ClientId"] = user.ClientID;
            if (user.Client.Count > 0)
            {
                Session["ClientShowTask"] = user.Client == null ? true : (user.Client.FirstOrDefault().isShowTasks ?? true);
            }
            else
            {
                Session["ClientShowTask"] = true;
            }

            userData = string.Format("{0}|{1}|{2} {3}|{4}", user.SecRole.RoleName, user.SecRole.RoleId, user.FirstName, user.LastName, user.Email);

            var ticket = new FormsAuthenticationTicket
                         (
                1,
                user.UserId.ToString(),
                DateTime.Now,
                DateTime.Now.AddMinutes(120),
                true,
                userData,       //(user.SecRole.RoleName + "|" + user.SecRole.RoleId.ToString()),
                FormsAuthentication.FormsCookiePath
                         );

            string encryptedTicket = FormsAuthentication.Encrypt(ticket);

            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket));
            Session["rolePermission"] = resRolePermission = SecRoleModuleManager.getRolePermission(user.SecRole.RoleId).ToList();

            // get role actions
            if (user.RoleId != (int)UserRole.Administrator)
            {
                using (ActionManager repository = new ActionManager())
                {
                    roleActions            = repository.GetActions((int)user.ClientID, (int)user.RoleId);
                    Session["roleActions"] = roleActions;
                }
            }

            //if (user.SecRole.RoleId == (int)UserRole.Adjuster)
            //	url = "~/Protected/Intake/form.aspx";
            //else
            if (Request.QueryString["url"] != null)
            {
                url = Request.QueryString["url"].ToString();
            }
            else
            {
                url = FormsAuthentication.DefaultUrl;
                Session["Count"] = null;


                formatException();
                setRulexception();

                setGlobalSession();



                Thread thread = new Thread(delegate()
                {
                    workerObject.DoWork();
                });
                //ThreadPool.QueueUserWorkItem(new WaitCallback(workerObject.DoWork), leadView, testse);

                // workerThread = new Thread(workerObject.DoWork);

                thread.Start();
            }

            Response.Redirect(url);
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblUserWelcome.Text = "";
            if (Session["h1"] != null && Session["h2"] != null && Session["h3"] != null && Session["h4"] != null && Session["h5"] != null)
            {
                h1 = Session["h1"].ToString();
                h2 = Session["h2"].ToString();
                h3 = Session["h3"].ToString();
                h4 = Session["h4"].ToString();
                h5 = Session["h5"].ToString();
            }
            string[] userRoleName = (((FormsIdentity)HttpContext.Current.User.Identity).Ticket).UserData.Split('|');
            currentUserRoleId = Convert.ToInt32(userRoleName[1]);
            currentUserId     = Convert.ToInt32(Session["UserId"]);
            if (currentUserId <= 0 || userRoleName[0].ToString().Trim().Replace(" ", "").ToUpper() == "FORALL")
            {
                LogoutUser();
            }

            lblUserWelcome.Text = "Welcome (" + userRoleName[0].ToString() + ")";

            List <SecRoleModuleManager.secRoleModuleGet> resRoleModule = new List <SecRoleModuleManager.secRoleModuleGet>();

            resRoleModule = SecRoleModuleManager.getRoleModuleMenu(currentUserRoleId);
            List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleParent = resRoleModule.Where(x => (x.ParentId == 0 || x.ParentId == null)).ToList();
            List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleChild  = new List <SecRoleModuleManager.secRoleModuleGet>();

            StringBuilder strMenu = new StringBuilder();

            strMenu.Append("<div id='smoothmenu1' class='ddsmoothmenu'>");
            strMenu.Append("<ul style='padding-left:40px;'>");
            if (resRoleModuleParent.Count > 0)
            {
                if (resRoleModuleParent[0].RoleID == 1)
                {
                    strMenu.Append("<li><a href='../../Protected/Admin/AllUsersLeads.aspx'>Home</a></li>");
                }
                else
                {
                    strMenu.Append("<li><a href='../../Protected/Admin/UsersLeads.aspx'>Home</a></li>");
                }
            }
            foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleParent in resRoleModuleParent)
            {
                if (objRoleModuleParent.Url.Trim() == "")
                {
                    if (objRoleModuleParent.ModuleId > 0)
                    {
                        List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionParent = resRoleModule.Where(x => (x.ModuleId == objRoleModuleParent.ModuleId) && (x.ViewPermssion == true)).ToList();
                        List <SecRoleModuleManager.secRoleModuleGet> checkforchild             = new List <SecRoleModuleManager.secRoleModuleGet>();
                        checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                        if (checkforchild.Count > 0 || checkviewPermissionParent.Count > 0)
                        {
                            strMenu.Append("<li><a href='#'>" + objRoleModuleParent.ModuleName + "</a>");
                        }
                    }
                }
                else
                {
                    List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionParent = resRoleModule.Where(x => (x.ModuleId == objRoleModuleParent.ModuleId) && (x.ViewPermssion == true)).ToList();
                    List <SecRoleModuleManager.secRoleModuleGet> checkforchild             = new List <SecRoleModuleManager.secRoleModuleGet>();
                    checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                    if (checkforchild.Count > 0 || checkviewPermissionParent.Count > 0)
                    {
                        strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleParent.Url + "'>" + objRoleModuleParent.ModuleName + "</a>");
                    }
                }

                resRoleModuleChild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId))).ToList();
                if (resRoleModuleChild.Count > 0)
                {
                    strMenu.Append("<ul>");
                    foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleChild in resRoleModuleChild)
                    {
                        List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleChildChildren = new List <SecRoleModuleManager.secRoleModuleGet>();
                        resRoleModuleChildChildren = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();

                        if (objRoleModuleChild.Url.Trim() == "")
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                strMenu.Append("<li><a href='#'>" + objRoleModuleChild.ModuleName + "</a>");
                            }

                            strMenu.Append("<ul>");
                            foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleChildChildren in resRoleModuleChildChildren)
                            {
                                if (objRoleModuleChildChildren.Url.Trim() == "")
                                {
                                    strMenu.Append("<li><a href='#'>" + objRoleModuleChildChildren.ModuleName + "</a>");
                                }
                                else
                                {
                                    strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleChildChildren.Url + "'>" + objRoleModuleChildChildren.ModuleName + "</a></li>");
                                }
                            }
                            strMenu.Append("</ul>");
                            strMenu.Append("</li>");
                        }
                        else if (objRoleModuleChild.Url.Trim() == "AllUserLeadsReport.aspx")
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                strMenu.Append("<li><a href='../../Protected/Reports/" + objRoleModuleChild.Url + "'>" + objRoleModuleChild.ModuleName + "</a></li>");
                            }
                        }
                        else
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleChild.Url + "'>" + objRoleModuleChild.ModuleName + "</a></li>");
                            }
                        }
                    }

                    strMenu.Append("</ul>");
                }
                strMenu.Append("</li>");
            }
            strMenu.Append("</ul>");
            strMenu.Append("<br style='clear: left' />");
            strMenu.Append("</div>");
            dvMenu.InnerHtml = strMenu.ToString();
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "menukey", "cssdropdown.startchrome('chromemenu2');", true);
            setUserName();
        }
Ejemplo n.º 12
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text    = string.Empty;
            lblSave.Text     = string.Empty;
            lblSave.Visible  = false;
            lblError.Visible = false;
            try {
                using (TransactionScope scope = new TransactionScope()) {
                    SecRoleModuleManager.UpdateSecRoleModuleStatus(Convert.ToInt32(ddlRole.SelectedValue));

                    foreach (GridViewRow row in grdModule.Rows)
                    {
                        int         check          = 0;
                        int         checkParent    = 0;
                        GridView    gv             = (GridView)row.FindControl("gvSubModule");
                        HiddenField hfRoleModuleId = (HiddenField)row.FindControl("hfRoleModuleId");
                        HiddenField hfModuleId     = (HiddenField)row.FindControl("hfModuleId");

                        if (hfRoleModuleId.Value == string.Empty)
                        {
                            hfRoleModuleId.Value = "0";
                        }

                        CheckBox chkAllAdd  = (CheckBox)row.FindControl("chkAllAdd");
                        CheckBox chkAllEdit = (CheckBox)row.FindControl("chkAllEdit");
                        CheckBox chkAllDel  = (CheckBox)row.FindControl("chkAllDel");
                        CheckBox chkAllView = (CheckBox)row.FindControl("chkAllView");

                        SecRoleModule roleModuleMainGrid = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                        if (chkAllView.Checked || chkAllAdd.Checked || chkAllEdit.Checked || chkAllEdit.Checked)
                        {
                            var secRoleModule = new CRM.Data.Entities.SecRoleModule {
                                ModuleID         = Convert.ToInt32(hfModuleId.Value),
                                RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                AddPermssion     = chkAllAdd.Checked == true ? true : false,
                                EditPermission   = chkAllEdit.Checked == true ? true : false,
                                DeletePermission = chkAllDel.Checked == true ? true : false,
                                ViewPermission   = chkAllView.Checked == true ? true : false,
                                Status           = 1,
                                CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                CreatedOn        = DateTime.Now,
                                UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                UpdatedOn        = DateTime.Now,
                                CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                            };
                            SecRoleModuleManager.SaveRoleModule(secRoleModule);
                            checkParent = 1;
                        }


                        foreach (GridViewRow subGridRow in gv.Rows)
                        {
                            CheckBox      chkAdd          = (CheckBox)subGridRow.FindControl("chkAdd");
                            CheckBox      chkEdit         = (CheckBox)subGridRow.FindControl("chkEdit");
                            CheckBox      chkDelete       = (CheckBox)subGridRow.FindControl("chkDel");
                            CheckBox      chkView         = (CheckBox)subGridRow.FindControl("chkView");
                            HiddenField   hfModuleIdChild = (HiddenField)subGridRow.FindControl("hfModuleIdChild");
                            SecRoleModule roleModule      = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                            if (chkAdd.Checked || chkEdit.Checked || chkDelete.Checked || chkView.Checked)
                            {
                                var secRoleModuleChild = new CRM.Data.Entities.SecRoleModule {
                                    ModuleID         = Convert.ToInt32(hfModuleIdChild.Value),
                                    RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                    AddPermssion     = chkAdd.Checked == true ? true : false,
                                    EditPermission   = chkEdit.Checked == true ? true : false,
                                    DeletePermission = chkDelete.Checked == true ? true : false,
                                    ViewPermission   = chkView.Checked == true ? true : false,
                                    Status           = 1,
                                    CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                    CreatedOn        = DateTime.Now,
                                    UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                    UpdatedOn        = DateTime.Now,
                                    CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                                };
                                SecRoleModuleManager.SaveRoleModule(secRoleModuleChild);
                                check       = 1;
                                checkParent = 0;
                            }

                            GridView gvchild = (GridView)subGridRow.FindControl("gvSubModule1");
                            if (gvchild.Rows.Count > 0)
                            {
                                foreach (GridViewRow child in gvchild.Rows)
                                {
                                    CheckBox      chkAdd1          = (CheckBox)child.FindControl("chkAdd");
                                    CheckBox      chkEdit1         = (CheckBox)child.FindControl("chkEdit");
                                    CheckBox      chkDelete1       = (CheckBox)child.FindControl("chkDel");
                                    CheckBox      chkView1         = (CheckBox)child.FindControl("chkView");
                                    HiddenField   hfModuleIdChild1 = (HiddenField)child.FindControl("hfModuleIdChild1");
                                    SecRoleModule roleModule1      = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                                    if (chkAdd1.Checked || chkEdit1.Checked || chkDelete1.Checked || chkView1.Checked)
                                    {
                                        var secRoleModuleChild = new CRM.Data.Entities.SecRoleModule {
                                            ModuleID         = Convert.ToInt32(hfModuleIdChild1.Value),
                                            RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                            AddPermssion     = chkAdd.Checked == true ? true : false,
                                            EditPermission   = chkEdit.Checked == true ? true : false,
                                            DeletePermission = chkDelete.Checked == true ? true : false,
                                            ViewPermission   = chkView.Checked == true ? true : false,
                                            Status           = 1,
                                            CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                            CreatedOn        = DateTime.Now,
                                            UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                            UpdatedOn        = DateTime.Now,
                                            CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                                        };
                                        SecRoleModuleManager.SaveRoleModule(secRoleModuleChild);
                                        check       = 1;
                                        checkParent = 0;
                                    }
                                }
                            }
                        }
                    }

                    CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(Convert.ToInt32(HttpContext.Current.User.Identity.Name));
                    if (user.SecRole.RoleId == Convert.ToInt32(ddlRole.SelectedValue))
                    {
                        Session["rolePermission"] = refreshRolePermission = SecRoleModuleManager.getRolePermission(user.SecRole.RoleId).ToList();
                    }
                    bindGrid(Convert.ToInt32(ddlRole.SelectedValue));
                    lblSave.Text    = "Record Saved Sucessfully.";
                    lblSave.Visible = true;
                    scope.Complete();
                }
            }
            catch (Exception ex) {
                lblError.Text    = "Record Not Saved Sucessfully.";
                lblError.Visible = true;
            }
        }
Ejemplo n.º 13
0
        static public void buildMenu(HtmlGenericControl dvMenu, List <SecRoleModuleManager.secRoleModuleGet> menuItems)
        {
            int           currentUserRoleId = 0;
            int           currentUserId     = 0;
            StringBuilder strMenu           = new StringBuilder();

            List <SecRoleModuleManager.secRoleModuleGet> resRoleModule = new List <SecRoleModuleManager.secRoleModuleGet>();

            //List<SecRoleModuleManager.secRoleModuleGet> resRoleModule = menuItems;

            resRoleModule = SecRoleModuleManager.getRoleModuleMenu(currentUserRoleId);
            List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleParent = menuItems.Where(x => (x.ParentId == 0 || x.ParentId == null)).ToList();
            List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleChild  = new List <SecRoleModuleManager.secRoleModuleGet>();


            strMenu.Append("<div id='smoothmenu2' class='ddsmoothmenu'>");
            strMenu.Append("<ul style='padding-left:40px;'>");

            foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleParent in resRoleModuleParent)
            {
                if (objRoleModuleParent.Url.Trim() == "")
                {
                    if (objRoleModuleParent.ModuleId > 0)
                    {
                        List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionParent = resRoleModule.Where(x => (x.ModuleId == objRoleModuleParent.ModuleId) && (x.ViewPermssion == true)).ToList();
                        List <SecRoleModuleManager.secRoleModuleGet> checkforchild             = new List <SecRoleModuleManager.secRoleModuleGet>();
                        checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                        if (checkforchild.Count > 0 || checkviewPermissionParent.Count > 0)
                        {
                            strMenu.Append("<li><a href='#'>" + objRoleModuleParent.ModuleName + "</a>");
                        }
                    }
                }
                else
                {
                    List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionParent = resRoleModule.Where(x => (x.ModuleId == objRoleModuleParent.ModuleId) && (x.ViewPermssion == true)).ToList();
                    List <SecRoleModuleManager.secRoleModuleGet> checkforchild             = new List <SecRoleModuleManager.secRoleModuleGet>();
                    checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                    if (checkforchild.Count > 0 || checkviewPermissionParent.Count > 0)
                    {
                        strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleParent.Url + "'>" + objRoleModuleParent.ModuleName + "</a>");
                    }
                }

                resRoleModuleChild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleParent.ModuleId))).ToList();
                if (resRoleModuleChild.Count > 0)
                {
                    strMenu.Append("<ul>");
                    foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleChild in resRoleModuleChild)
                    {
                        List <SecRoleModuleManager.secRoleModuleGet> resRoleModuleChildChildren = new List <SecRoleModuleManager.secRoleModuleGet>();
                        resRoleModuleChildChildren = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();

                        if (objRoleModuleChild.Url.Trim() == "")
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                strMenu.Append("<li><a href='#'>" + objRoleModuleChild.ModuleName + "</a>");
                            }

                            strMenu.Append("<ul>");
                            foreach (SecRoleModuleManager.secRoleModuleGet objRoleModuleChildChildren in resRoleModuleChildChildren)
                            {
                                if (objRoleModuleChildChildren.Url.Trim() == "")
                                {
                                    strMenu.Append("<li><a href='#'>" + objRoleModuleChildChildren.ModuleName + "</a>");
                                }
                                else
                                {
                                    strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleChildChildren.Url + "'>" + objRoleModuleChildChildren.ModuleName + "</a></li>");
                                }
                            }
                            strMenu.Append("</ul>");
                            strMenu.Append("</li>");
                        }
                        else if (objRoleModuleChild.Url.Trim() == "AllUserLeadsReport.aspx")
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                strMenu.Append("<li><a href='../../Protected/Reports/" + objRoleModuleChild.Url + "'>" + objRoleModuleChild.ModuleName + "</a></li>");
                            }
                        }
                        else
                        {
                            List <SecRoleModuleManager.secRoleModuleGet> checkviewPermissionChild = resRoleModule.Where(x => (x.ModuleId == objRoleModuleChild.ModuleId) && (x.ViewPermssion == true)).ToList();
                            List <SecRoleModuleManager.secRoleModuleGet> checkforchild            = new List <SecRoleModuleManager.secRoleModuleGet>();
                            checkforchild = resRoleModule.Where(x => (x.ParentId == Convert.ToInt32(objRoleModuleChild.ModuleId)) && (x.ViewPermssion == true || x.ViewPermssion == null)).ToList();
                            if (checkforchild.Count > 0 || checkviewPermissionChild.Count > 0)
                            {
                                strMenu.Append("<li><a href='../../Protected/Admin/" + objRoleModuleChild.Url + "'>" + objRoleModuleChild.ModuleName + "</a></li>");
                            }
                        }
                    }

                    strMenu.Append("</ul>");
                }
                strMenu.Append("</li>");
            }
            strMenu.Append("</ul>");
            strMenu.Append("<br style='clear: left' />");
            strMenu.Append("</div>");
            dvMenu.InnerHtml = strMenu.ToString();
            //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "menukey", "cssdropdown.startchrome('chromemenu2');", true);
        }