Esempio n. 1
0
        public string CreateACLActionTable()
        {
            string message = "";

            if (Session["UserID"] != null)
            {

                StringBuilder sb = new StringBuilder();
                ACLRoleBL aclRoleBL = new ACLRoleBL();

                int qroleid = Convert.ToInt32(Session["EditRoleID"]);

                // string name = aclRoleBL.SearchRoleNameByID(qroleid);
                // string des = aclRoleBL.SearchRoleDesByID(qroleid);

                //HiddenField1.Value = name + ":" + des;

                //TextBox txtRoleName = (TextBox)aclAction.FindControl("RoleNameTextBox");
                //TextBox txtDes = (TextBox)aclAction.FindControl("DescriptionTextBox");

                //txtRoleName.Text = name;
                //DescriptionTextBox.Text = des;

                //sb.Append("<table><tr><td>");
                //sb.Append("Role Name");
                //sb.Append("</td><td>");
                //sb.Append("<input id='NameTextBox' type='text' onclick='rolename(this);' value='").Append(name).Append("' />");

                //sb.Append("</td></tr>");
                //sb.Append("<tr><td>");
                //sb.Append("Description");
                //sb.Append("</td><td>");
                //sb.Append("<input id='DesTextBox' type='text' onclick='roledes(this);' value='").Append(des).Append("' />");
                //sb.Append("</td></tr></table>");

                sb.Append("<table><tr><td><b>Modules</b></td>");

                IEnumerable<ACLFunction> functionList;
                IEnumerable<CompanyModule> moduleList;

                functionList = aclRoleBL.GetFunctionList();
                moduleList = aclRoleBL.GetModuleListByCompanyID();
                int listCount = functionList.Count();
                int moduleCount = moduleList.Count();
                string check = "checked";
                string functionName;
                string moduleName;
                int moduleId;
                int functionId;
                string accessid;
                int a;

                for (a = 0; a < listCount; a++)
                {
                    functionName = functionList.ElementAt(a).FunctionName;
                    functionId = functionList.ElementAt(a).FunctionID;

                    sb.Append("<td><b>").Append(functionName).Append("</b></td>");

                }

                sb.Append("</tr>");

                //string acess = "";
                string allchk = "";

                for (int j = 0; j < moduleCount; j++)
                {
                    moduleId = moduleList.ElementAt(j).ModuleID;
                    moduleName = aclRoleBL.GetModuleNameByID(moduleId);

                    sb.Append("<tr>");
                    sb.Append("<td>").Append(moduleName).Append("</td>");

                    for (int i = 0; i < listCount; i++)
                    {
                        functionName = functionList.ElementAt(i).FunctionName;
                        functionId = functionList.ElementAt(i).FunctionID;
                        string dropdownid = moduleId + ":" + functionId;
                        check = "checked";

                        accessid = aclRoleBL.SearchACLActionAccessID(qroleid, moduleId, functionId);

                        //acess += accessid ;
                        //Label6.Text = "access id id " + acess  ;

                        if (qroleid > 0 && accessid != "-1")
                        {

                            if (accessid == "1") { check = "checked"; allchk += moduleId + ":" + functionId + "#"; }
                            else if (accessid == "0") { check = ""; }
                            else if (accessid == "n/a") { check = ""; }
                        }
                        else if (qroleid == 0)
                        {
                            check = "checked";
                            allchk = "new";
                        }

                        sb.Append("<td>");
                        sb.Append("<input id='").Append(dropdownid).Append("' type='checkbox'").Append(check).Append(" onclick='clickMethod(this);' value='").Append(dropdownid).Append("' />");

                    }

                    sb.Append("</td></tr>");

                }

                //sb.Append("<tr><td>");
                //sb.Append("<input runat=server type=button value='Save' onClick='HandleIT(); return false;' />");
                //sb.Append("</td></tr>");
                sb.Append("</table>");
                return sb.ToString();
            }

            else
            {

                Response.Redirect("~/UserLogin.aspx");
                return message;
            }
        }