private Panel BuildEditControl(GridControlEditMode mode)
        {
            List <Control> controls = new List <Control>();

            if (this.SelectedItem == null &&
                mode == GridControlEditMode.Edit)
            {
                return(new Panel());
            }

            WebUtilities.Controls.Table table = new WebUtilities.Controls.Table();

            foreach (string field in this.Fields)
            {
                WebUtilities.Controls.TableRow tableRow =
                    new WebUtilities.Controls.TableRow();

                WebUtilities.Controls.TableCell tableCellFieldName =
                    new WebUtilities.Controls.TableCell();
                WebUtilities.Controls.TableCell tableCellFieldValue =
                    new WebUtilities.Controls.TableCell();

                Label lblFieldName = new Label();
                lblFieldName.Name = field;

                //object value = this.SelectedItem.GetValue(field);

                Control control = null;

                control = BuildControl(field, mode == GridControlEditMode.Edit);

                control.ID = this.ID + "_" + field;

                controls.Add(control);

                tableCellFieldName.Controls.Add(lblFieldName);
                tableCellFieldValue.Controls.Add(control);

                tableRow.Cells.Add(tableCellFieldName);
                tableRow.Cells.Add(tableCellFieldValue);

                table.Rows.Add(tableRow);
            }

            // Run through all additional fields.
            foreach (AdditionalField <T> field in this.AdditionalFields)
            {
                if (!field.ShowInEdit)
                {
                    continue;
                }

                if (field.Condition != null && field.Condition(this.SelectedItem) == false)
                {
                    continue;
                }

                WebUtilities.Controls.TableRow tableRow = new WebUtilities.Controls.TableRow();

                WebUtilities.Controls.TableCell tableCellFieldName =
                    new WebUtilities.Controls.TableCell();
                WebUtilities.Controls.TableCell tableCellFieldValue =
                    new WebUtilities.Controls.TableCell();

                Label lblFieldName = new Label();
                lblFieldName.Name = field.Name;

                Control value = field.Render.Invoke(
                    mode == GridControlEditMode.Edit ?
                    this.SelectedItem :
                    null
                    );

                if (value == null)
                {
                    continue;
                }

                controls.Add(value);

                tableCellFieldName.Controls.Add(lblFieldName);
                tableCellFieldValue.Controls.Add(value);

                tableRow.Cells.Add(tableCellFieldName);
                tableRow.Cells.Add(tableCellFieldValue);

                table.Rows.Add(tableRow);
            }

            WebUtilities.Controls.TableRow tableRowButtons =
                new WebUtilities.Controls.TableRow();

            WebUtilities.Controls.TableCell tableCellButtons =
                new WebUtilities.Controls.TableCell();
            tableCellButtons.ColumnSpan      = 2;
            tableCellButtons.HorizontalAlign = HorizontalAlign.Right;

            Button defaultButton = null;

            if (mode == GridControlEditMode.Add)
            {
                Button btnAddConfirm = new Button();
                btnAddConfirm.ID     = this.ID + "BoxAdd";
                btnAddConfirm.Name   = "Add";
                btnAddConfirm.Click += btnAddConfirm_Click;

                defaultButton = btnAddConfirm;

                tableCellButtons.Controls.Add(btnAddConfirm);
            }
            else
            {
                Button btnSave = new Button();
                btnSave.ID     = this.ID + "BoxSave";
                btnSave.Name   = "Save";
                btnSave.Click += btnSave_Click;

                defaultButton = btnSave;

                tableCellButtons.Controls.Add(btnSave);
            }

            Button btnCancel = new Button();

            btnCancel.Name = "Cancel";

            tableCellButtons.Controls.Add(btnCancel);

            tableRowButtons.Cells.Add(tableCellButtons);

            table.Rows.Add(tableRowButtons);

            dragBox       = new Box();
            dragBox.ID    = this.ID + mode.ToString();
            dragBox.Title = mode.ToString() + (this.Items.Count > 0 ? this.Items[0].GetType().Name : "");
            dragBox.TitleLanguageLabel = true;
            dragBox.Dragable           = true;
            dragBox.Visible            = true;

            dragBox.Controls.Add(table);

            Panel panel = new Panel();

            panel.Controls.Add(dragBox);

            foreach (Control control in controls)
            {
                if (control.GetType() == typeof(TextBox))
                {
                    TextBox textBox = (TextBox)control;

                    textBox.Button = defaultButton.ID;
                }
            }

            return(panel);
        }
        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);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        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);
                }
            }
        }
예제 #5
0
        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);
                }
            }
        }