Exemple #1
0
        public bool SavePower(int id, string list, int creator)
        {
            JavaScriptSerializer js      = new JavaScriptSerializer();
            List <PageTreeDto>   ListDto = js.Deserialize <List <PageTreeDto> >(list);

            MultiSQLExecuteParam param = new MultiSQLExecuteParam();

            //删除权限数据
            param.beforeSql = @"DELETE FROM tbPower WHERE roleId = @id";
            param.beforeParam.Add("id", id);

            param.listSql = @"INSERT tbPower
                        (	roleId,
	                        pageId,
	                        createDate,
	                        creator)
                        VALUES
                        (	@roleId,
	                        @pageId,
	                        GETDATE(),
	                        @creator)"    ;
            int opCount = 0;

            foreach (PageTreeDto item in ListDto)
            {
                //判断是否为checked 由于当前设计看不到上层即看不到下层页面 如果上层未选择则视为下层也不选中
                if (item.state.@checked == true)
                {
                    //保存该条
                    item.roleId  = id;
                    item.creator = creator;
                    param.objList.Add(item);
                    opCount++;

                    //循环Nodes
                    foreach (var subitem in item.nodes)
                    {
                        if (subitem.state.@checked == true)
                        {
                            //保存该条
                            subitem.roleId  = id;
                            subitem.creator = creator;
                            param.objList.Add(subitem);
                            opCount++;
                            //循环Nodes
                            foreach (var thrditem in subitem.nodes)
                            {
                                if (thrditem.state.@checked == true)
                                {
                                    //保存该条
                                    thrditem.roleId  = id;
                                    thrditem.creator = creator;
                                    param.objList.Add(thrditem);
                                    opCount++;
                                }
                            }
                        }
                    }
                }
            }

            if (opCount == DBAgent.MultipleSQLExecuteReturnRows(param))
            {
                return(true);
            }

            return(false);
        }