private void BindUserWorkgroups(Guid idUser) { // Get all workgroups of the client. List <object[]> workgroups = Global.Core.Workgroups.GetValues( new string[] { "Id", "Name" }, new string[] { }, new object[] { } ); // Create a new table for the workgroups. Table table = new Table(); table.Style.Add("width", "100%"); table.Style.Add("border", "2px;"); // Run through all workgroups of the client. foreach (object[] workgroup in workgroups) { // Create a new table row for the workgroup. TableRow tableRow = new TableRow(); TableCell tableCellCheckbox = new TableCell(); TableCell tableCellName = new TableCell(); tableCellCheckbox.Style.Add("padding", "5px"); tableCellName.Style.Add("width", "100%"); WebUtilities.Controls.CheckBox chkWorkgroup = new WebUtilities.Controls.CheckBox(); chkWorkgroup.ID = "chkUserWorkgroup" + workgroup[0]; chkWorkgroup.Checked = Global.Core.UserWorkgroups.GetCount( new string[] { "IdUser", "IdWorkgroup" }, new object[] { idUser, workgroup[0] } ) > 0; tableCellCheckbox.Controls.Add(chkWorkgroup); tableCellName.Text = (string)workgroup[1]; tableRow.Cells.Add(tableCellCheckbox); tableRow.Cells.Add(tableCellName); table.Rows.Add(tableRow); } if (workgroups.Count == 0) { pnlUserWorkgroups.Controls.Add(new LiteralControl(Global.LanguageManager.GetText("NoWorkGroups"))); } else { pnlUserWorkgroups.Controls.Add(table); } }
private void GenereateUserGroups(string selectedRole) { pnlModuleDetails.Controls.Clear(); if (selectedRole != null) { if (Global.PermissionCore.Sections.Items != null) { var results = Global.Core.Roles.Get().OrderBy(s => s.Name); var roles = results.Where(x => x.Name == selectedRole); // var results = listData.Where((item, index) => listFilter[index] == 1); if (roles != null) { object idRoleUser = Global.Core.UserRoles.GetValue("IdRole", "IdUser", Global.IdUser.Value); if (idRoleUser == null) { idRoleUser = new Guid(); } foreach (Role role in roles) { if (role.Hidden && role.Id != (Guid)idRoleUser) { continue; } WebUtilities.Controls.Table tblSection = new WebUtilities.Controls.Table(); tblSection.ID = "tblRole";//"tbl" + role.Name; tblSection.CssClass = "Userroletable"; tblSection.CellPadding = 0; tblSection.CellSpacing = 0; //TableHeaderRow hrow = new TableHeaderRow(); //TableCell hCell1 = new TableCell(); //hCell1.ID = "hCell_" + role.Name; //hCell1.Width = new Unit(150, UnitType.Pixel); //hCell1.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor8"; //hCell1.Text = PrepareRoleName(role.Name.ToLower()); //hrow.Cells.Add(hCell1); //tblSection.Rows.Add(hrow); foreach (PermissionCore.Classes.Section sec in Global.PermissionCore.Sections.Items) { TableRow trSec = new WebUtilities.Controls.TableRow(); TableCell secEmpty = new TableCell(); secEmpty.ID = "secEmpty_" + role.Name + sec.Name; secEmpty.Width = new Unit(150, UnitType.Pixel); secEmpty.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor8 TableCellPercentage"; secEmpty.Text = PrepareRoleName(Global.LanguageManager.GetText(sec.Name).ToLower()); trSec.Cells.Add(secEmpty); int cnt = 0; foreach (PermissionCore.Classes.Permission permission in sec.Permissions) { if (!Global.User.HasPermission(permission.Id) && Global.User.HasPermission(1001) == false) { continue; } if (!(permission.Id == 1001) && !(permission.Id == 1000)) { TableCell tc = new TableCell { ID = "tc" + permission.Name.ToLower() + "_" + role.Name, Text = PrepareRoleName(Global.LanguageManager.GetText(permission.Name).ToLower()), Width = new Unit(150, UnitType.Pixel), CssClass = cnt % 2 == 0 ? "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor5" : "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor9" }; trSec.Cells.Add(tc); cnt++; } tblSection.Rows.Add(trSec); } // var roles = Global.Core.Roles.Get().OrderBy(s => s.Name); //RolePermission rolePermission = Global.Core.RolePermissions.GetSingle("IdRole", role.Id); //TableRow tr = new WebUtilities.Controls.TableRow(); //TableCell td1 = new TableCell //{ // ID = "td_" + sec.Name + "_" + role.Name, // Width = new Unit(150, UnitType.Pixel), // Text = PrepareRoleName(sec.Name) //}; //td1.Font.Bold = true; //td1.CssClass = // "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor8"; //tr.Cells.Add(td1); TableRow tr = new WebUtilities.Controls.TableRow(); TableCell tdSec = new TableCell(); tdSec.ID = "tdSec_" + sec.Name + role.Name; tdSec.Width = new Unit(150, UnitType.Pixel); tdSec.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor7 TableCellPercentage"; tr.Cells.Add(tdSec); int count = 0; foreach (PermissionCore.Classes.Permission detailPermission in sec.Permissions) { if (!Global.User.HasPermission(detailPermission.Id) && Global.User.HasPermission(1001) == false) { continue; } if (!(detailPermission.Id == 1001) && !(detailPermission.Id == 1000)) { TableCell cell = new TableCell { ID = "td" + detailPermission.Name + role.Id, Width = new Unit(150, UnitType.Pixel), Text = PrepareRoleName(role.Name.ToLower()), CssClass = count % 2 == 0 ? "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor9" : "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor5" }; WebUtilities.Controls.CheckBox checkBox = new WebUtilities.Controls.CheckBox { ID = "chk_" + role.Id + "_" + detailPermission.Id }; RolePermission dbPermission = Global.Core.RolePermissions.GetSingle(new string[] { "IdRole", "Permission" }, new object[] { role.Id, detailPermission.Id }); checkBox.Checked = dbPermission != null; cell.Controls.Add(checkBox); tr.Cells.Add(cell); count++; } } tblSection.Rows.Add(tr); pnlModuleDetails.Controls.Add(tblSection); } } } } } }
private void GenerateUserRoleDetails(Guid roleId) { if (Global.PermissionCore.Sections.Items != null) { foreach (PermissionCore.Classes.Section sec in Global.PermissionCore.Sections.Items) { WebUtilities.Controls.Table tblSection = new WebUtilities.Controls.Table { ID = "tbl" + sec.Name, CssClass = "Userroletable", CellPadding = 0, CellSpacing = 0 }; TableHeaderRow hrow = new TableHeaderRow(); TableCell hCell1 = new TableCell(); hCell1.ID = "hCellgroupassigned"; hCell1.Width = new Unit(150, UnitType.Pixel); hCell1.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor1"; hrow.Cells.Add(hCell1); int cnt = 0; foreach (PermissionCore.Classes.Permission permission in sec.Permissions) { TableCell tc = new TableCell { ID = "tc" + permission.Name.ToLower(), Text = permission.Name.ToLower(), Width = new Unit(150, UnitType.Pixel), CssClass = cnt % 2 == 0 ? "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor5" : "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor1" }; hrow.Cells.Add(tc); cnt++; } tblSection.Rows.Add(hrow); var role = Global.Core.Roles.GetSingle(roleId); if (role != null) { TableRow tr = new WebUtilities.Controls.TableRow(); TableCell td1 = new TableCell { ID = "td_" + role.Name, Width = new Unit(150, UnitType.Pixel), Text = role.Name.ToLower() }; td1.Font.Bold = true; td1.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor5"; tr.Cells.Add(td1); int count = 0; foreach (PermissionCore.Classes.Permission detailPermission in sec.Permissions) { TableCell cell = new TableCell { ID = "td" + detailPermission.Name, Width = new Unit(150, UnitType.Pixel), Text = role.Name.ToLower(), CssClass = count % 2 == 0 ? "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor1" : "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor5" }; WebUtilities.Controls.CheckBox checkBox = new WebUtilities.Controls.CheckBox { ID = "chk_" + role.Id + "_" + detailPermission.Id }; RolePermission dbPermission = Global.Core.RolePermissions.GetSingle(new string[] { "IdRole", "Permission" }, new object[] { role.Id, detailPermission.Id }); checkBox.Checked = dbPermission != null; cell.Controls.Add(checkBox); tr.Cells.Add(cell); count++; } tblSection.Rows.Add(tr); } pnlModuleDetails.Controls.Add(tblSection); } } }
private void GenerateUserRoleDetails() { if (Global.PermissionCore.Sections.Items != null) { foreach (PermissionCore.Classes.Section sec in Global.PermissionCore.Sections.Items) { WebUtilities.Controls.Table tblSection = new WebUtilities.Controls.Table(); tblSection.ID = "tbl" + sec.Name; tblSection.CssClass = "Userroletable"; tblSection.CellPadding = 0; tblSection.CellSpacing = 0; TableHeaderRow hrow = new TableHeaderRow(); TableCell hCell1 = new TableCell(); hCell1.ID = "hCell_" + sec.Name; hCell1.Width = new Unit(150, UnitType.Pixel); hCell1.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor9 TableCellPercentage"; hCell1.Text = PrepareRoleName(Global.LanguageManager.GetText(sec.Name)); hrow.Cells.Add(hCell1); int cnt = 0; foreach (PermissionCore.Classes.Permission permission in sec.Permissions) { if (!Global.User.HasPermission(permission.Id) && Global.User.HasPermission(1001) == false) { continue; } if (!(permission.Id == 1001) && !(permission.Id == 1000)) { TableCell tc = new TableCell { ID = "tc" + permission.Name.ToLower(), Text = PrepareRoleName(Global.LanguageManager.GetText(permission.Name).ToLower()), Width = new Unit(150, UnitType.Pixel), CssClass = cnt % 2 == 0 ? "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor5" : "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor9" }; hrow.Cells.Add(tc); cnt++; } } tblSection.Rows.Add(hrow); var roles = Global.Core.Roles.Get().OrderBy(s => s.Name); if (roles != null) { foreach (Role role in roles) { RolePermission rolePermission = Global.Core.RolePermissions.GetSingle("IdRole", role.Id); TableRow tr = new WebUtilities.Controls.TableRow(); TableCell td1 = new TableCell { ID = "td_" + sec.Name + "_" + role.Name, Width = new Unit(150, UnitType.Pixel), Text = PrepareRoleName(role.Name.ToLower()) }; td1.Font.Bold = true; td1.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor8"; tr.Cells.Add(td1); int count = 0; foreach (PermissionCore.Classes.Permission detailPermission in sec.Permissions) { if (!Global.User.HasPermission(detailPermission.Id) && Global.User.HasPermission(1001) == false) { continue; } if (!(detailPermission.Id == 1001) && !(detailPermission.Id == 1000)) { TableCell cell = new TableCell { ID = "td" + detailPermission.Name + role.Id, Width = new Unit(150, UnitType.Pixel), Text = PrepareRoleName(role.Name.ToLower()), CssClass = count % 2 == 0 ? "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor9" : "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor5" }; WebUtilities.Controls.CheckBox checkBox = new WebUtilities.Controls.CheckBox { ID = "chk_" + role.Id + "_" + detailPermission.Id }; RolePermission dbPermission = Global.Core.RolePermissions.GetSingle(new string[] { "IdRole", "Permission" }, new object[] { role.Id, detailPermission.Id }); checkBox.Checked = dbPermission != null; cell.Controls.Add(checkBox); tr.Cells.Add(cell); count++; } } tblSection.Rows.Add(tr); } } pnlModuleDetails.Controls.Add(tblSection); } } }
private void GenerateModules() { if (Global.PermissionCore.Sections.Items != null) { foreach (PermissionCore.Classes.Section sec in Global.PermissionCore.Sections.Items) { WebUtilities.Controls.Table tblSection = new WebUtilities.Controls.Table(); tblSection.ID = "tbl" + sec.Name; tblSection.CssClass = "Userroletable"; tblSection.CellPadding = 0; tblSection.CellSpacing = 0; tblSection.Width = new Unit(100, UnitType.Percentage); TableHeaderRow hrow = new TableHeaderRow(); TableCell hCell1 = new TableCell(); hCell1.ID = "hCell" + sec.Name; hCell1.Width = new Unit(100, UnitType.Pixel); hCell1.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor8 TableCellPercentage"; hCell1.Text = Global.LanguageManager.GetText(sec.Name).ToLower(); hrow.Cells.Add(hCell1); int cnt = 0; foreach (PermissionCore.Classes.Permission permission in sec.Permissions) { if (!Global.User.HasPermission(permission.Id) && Global.User.HasPermission(1001) == false) { continue; } if (!(permission.Id == 1001) && !(permission.Id == 1000)) { TableCell tc = new TableCell(); tc.ID = "tc" + permission.Name.ToLower(); tc.Text = PrepareRoleName(Global.LanguageManager.GetText(permission.Name).ToLower()); tc.Width = new Unit(150, UnitType.Pixel); tc.CssClass = cnt % 2 == 0 ? "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor5" : "TableCellHeadline TableCellHeadlineCategory BorderColor9 BackgroundColor9"; hrow.Cells.Add(tc); cnt++; } } tblSection.Rows.Add(hrow); TableRow tr = new WebUtilities.Controls.TableRow(); TableCell td1 = new TableCell { ID = "td_" + sec.Name, Width = new Unit(150, UnitType.Pixel) }; td1.CssClass = "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor7"; tr.Cells.Add(td1); int count = 0; foreach (PermissionCore.Classes.Permission detailPermission in sec.Permissions) { if (!Global.User.HasPermission(detailPermission.Id) && Global.User.HasPermission(1001) == false) { continue; } if (!(detailPermission.Id == 1001) && !(detailPermission.Id == 1000)) { TableCell cell = new TableCell(); cell.ID = "td" + detailPermission.Name; cell.Width = new Unit(150, UnitType.Pixel); cell.CssClass = count % 2 == 0 ? "TableCellHeadline TableCellHeadlineCategory BorderColor7 BackgroundColor9" : "TableCellHeadline TableCellHeadlineCategory BorderColor9 BackgroundColor5"; WebUtilities.Controls.CheckBox checkBox = new WebUtilities.Controls.CheckBox(); checkBox.ID = "chk_" + detailPermission.Id; cell.Controls.Add(checkBox); tr.Cells.Add(cell); count++; } } tblSection.Rows.Add(tr); pnlModuleDetails.Controls.Add(tblSection); } } }