Ejemplo n.º 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        MojoCube.Web.Role.List list = new MojoCube.Web.Role.List();

        int roleId = int.Parse(ViewState["pk_Name"].ToString());

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            list.pk_Role = 0;

            int menuId = int.Parse(((Label)GridView1.Rows[i].FindControl("lblID")).Text);

            list.GetData(roleId, menuId);

            if (list.pk_Role > 0)
            {
                list.IsUse   = ((CheckBox)GridView1.Rows[i].FindControl("cbUse")).Checked;
                list.IsAdmin = ((CheckBox)GridView1.Rows[i].FindControl("cbAdmin")).Checked;
                list.UpdateData(list.pk_Role);
            }
            else
            {
                list.fk_RoleName = roleId;
                list.fk_Menu     = menuId;
                list.IsUse       = ((CheckBox)GridView1.Rows[i].FindControl("cbUse")).Checked;
                list.IsAdmin     = ((CheckBox)GridView1.Rows[i].FindControl("cbAdmin")).Checked;
                list.PowerList   = "";
                list.fk_Company  = 0;
                list.InsertData();
            }
        }

        AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("success", "数据保存成功");
    }
Ejemplo n.º 2
0
    private void GridBind()
    {
        MojoCube.Web.Sql treeGrid = new MojoCube.Web.Sql();
        treeGrid.TableName   = "Sys_Menu";
        treeGrid.OrderByKey  = "SortID";
        treeGrid.OrderByType = "asc,pk_Menu asc";
        treeGrid.Where       = null;
        treeGrid.pk_ID       = "pk_Menu";
        treeGrid.ParentID    = "ParentID";
        treeGrid.TreeGridBind(GridView1);

        MojoCube.Web.Role.List list = new MojoCube.Web.Role.List();

        int roleId = int.Parse(ViewState["pk_Name"].ToString());

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            list.pk_Role = 0;

            int menuId = int.Parse(((Label)GridView1.Rows[i].FindControl("lblID")).Text);

            list.GetData(roleId, menuId);

            if (list.pk_Role > 0)
            {
                if (list.IsUse)
                {
                    ((CheckBox)GridView1.Rows[i].FindControl("cbUse")).Checked = true;
                }
                if (list.IsAdmin)
                {
                    ((CheckBox)GridView1.Rows[i].FindControl("cbAdmin")).Checked = true;
                }
            }
        }
    }