コード例 #1
0
 /// <summary>
 /// 批量增加菜单
 /// </summary>
 /// <param name="RoleID"></param>
 /// <param name="ModuleID"></param>
 /// <param name="FunctionID"></param>
 /// <returns></returns>
 public static bool AddRoleFunInfo(string RoleID, string ModuleID)
 {
     if (string.IsNullOrEmpty(RoleID) && string.IsNullOrEmpty(ModuleID))
     {
         return(false);
     }
     string[] sql = null;
     try
     {
         ArrayList lstDelete = new ArrayList();
         int       sql_index = 0;
         string[]  roleid    = RoleID.Split(',');
         string[]  moduleId  = ModuleID.Split(',');
         sql = new string[moduleId.Length];
         if (roleid.Length >= 1)
         {
             sql = new string[moduleId.Length * roleid.Length];
         }
         for (int index_role = 0; index_role < roleid.Length; index_role++)
         {
             for (int index_moduleId = 0; index_moduleId < moduleId.Length; index_moduleId++)
             {
                 if (!string.IsNullOrEmpty(moduleId[index_moduleId]))
                 {
                     RoleFunModel Model = new RoleFunModel();
                     Model.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;//待修改
                     Model.RoleID    = Convert.ToInt32(roleid[index_role]);
                     Model.ModuleID  = Convert.ToInt32(moduleId[index_moduleId]);
                     DelRoleFunInfo(Model);
                     System.Text.StringBuilder cmdsql = new System.Text.StringBuilder();
                     cmdsql.AppendLine(" Insert into  officedba.RoleFunction ");
                     cmdsql.AppendLine(" (CompanyCD,RoleID,ModuleID, ");
                     cmdsql.AppendLine("  ModifiedDate,ModifiedUserID) ");
                     cmdsql.AppendLine(" Values(@CompanyCD ");
                     cmdsql.AppendLine("  , @roleid,@moduleId");
                     cmdsql.AppendLine(" ,getdate(),");
                     cmdsql.AppendLine(" '" + ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID + "' ) ");
                     sql[sql_index] = cmdsql.ToString();
                     sql_index++;
                     SqlCommand sqlcomm = new SqlCommand();
                     sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", Model.CompanyCD));
                     sqlcomm.Parameters.Add(SqlHelper.GetParameter("@roleid", roleid[index_role].ToString()));
                     sqlcomm.Parameters.Add(SqlHelper.GetParameter("@moduleId", moduleId[index_moduleId].ToString()));
                     sqlcomm.CommandText = cmdsql.ToString();
                     lstDelete.Add(sqlcomm);
                 }
             }
         }
         return(SqlHelper.ExecuteTransWithArrayList(lstDelete));
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
        public static int DelRoleFunInfo(RoleFunModel Model)
        {
            string sql = "Delete from officedba.RoleFunction where CompanyCD=@CompanyCD  and RoleID=@RoleID " +
                         "and ModuleID like @ModuleID ";

            SqlParameter[] parms = new SqlParameter[3];
            parms[0] = SqlHelper.GetParameter("@CompanyCD", Model.CompanyCD);
            parms[1] = SqlHelper.GetParameter("@RoleID", Model.RoleID);
            parms[2] = SqlHelper.GetParameter("@ModuleID", "%" + Model.ModuleID.ToString().Substring(0, 1) + "%");
            return(SqlHelper.ExecuteTransSql(sql, parms));
        }
コード例 #3
0
        /// <summary>
        /// 删除角色功能
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public static int DelRoleFun(RoleFunModel Model)
        {
            string sql = "Delete from officedba.RoleFunction where CompanyCD=@CompanyCD  and RoleID=@RoleID " +
                         "and ModuleID=@ModuleID and FunctionID=@FunctionID ";

            SqlParameter[] parms = new SqlParameter[4];
            parms[0] = SqlHelper.GetParameter("@CompanyCD", Model.CompanyCD);
            parms[1] = SqlHelper.GetParameter("@RoleID", Model.RoleID);
            parms[2] = SqlHelper.GetParameter("@ModuleID", Model.ModuleID);
            parms[3] = SqlHelper.GetParameter("@FunctionID", Model.FunctionID);
            return(SqlHelper.ExecuteTransSql(sql, parms));
        }
コード例 #4
0
 public static int DelRoleFunInfo(RoleFunModel Model)
 {
     if (Model == null)
     {
         return(0);
     }
     try
     {
         return(RoleFunctionDBHelper.DelRoleFunInfo(Model));
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
コード例 #5
0
 /// <summary>
 /// 批量增加角色菜单功能
 /// </summary>
 public static bool AddRoleFun(string RoleID, string ModuleID, string FunctionID, string FunctionType)
 {
     if (string.IsNullOrEmpty(RoleID) && string.IsNullOrEmpty(ModuleID) &&
         string.IsNullOrEmpty(FunctionID))
     {
         return(false);
     }
     string[] sql = null;
     try
     {
         string    str1      = null;
         string    str2      = null;
         int       sql_index = 0;
         string[]  funId     = FunctionID.Split(',');
         string[]  roleid    = RoleID.Split(',');
         string[]  moduleId  = ModuleID.Split(',');
         ArrayList lstDelete = new ArrayList();
         sql = new string[funId.Length];
         if (roleid.Length >= 1)
         {
             sql = new string[funId.Length * roleid.Length];
         }
         for (int index_role = 0; index_role < roleid.Length; index_role++)
         {
             for (int index_moduleId = 0; index_moduleId < moduleId.Length; index_moduleId++)
             {
                 if (ModuleFunBus.IsExistByModuleId(moduleId[index_moduleId].ToString()))
                 {
                     DataTable dt = ModuleFunBus.GetModuleFunInfo(moduleId[index_moduleId].ToString(), FunctionType);
                     foreach (DataRow Row in dt.Rows)
                     {
                         for (int i = 0; i < funId.Length; i++)
                         {
                             str1 = funId[i].Split('|')[0].ToString();
                             str2 = funId[i].Split('|')[1].ToString();
                             if (str1 == Row["FunctionID"].ToString() && (str2 == Row["ID"].ToString()))
                             {
                                 RoleFunModel Model = new RoleFunModel();
                                 Model.CompanyCD  = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;   //待修改
                                 Model.FunctionID = Convert.ToInt32(Row["FunctionID"]);
                                 Model.RoleID     = Convert.ToInt32(roleid[index_role]);
                                 Model.ModuleID   = Convert.ToInt32(moduleId[index_moduleId]);
                                 DelRoleFun(Model);
                                 System.Text.StringBuilder cmdsql = new System.Text.StringBuilder();
                                 cmdsql.AppendLine(" Insert into  officedba.RoleFunction ");
                                 cmdsql.AppendLine(" (CompanyCD,RoleID,ModuleID,FunctionID ");
                                 cmdsql.AppendLine("  ,ModifiedDate,ModifiedUserID) ");
                                 cmdsql.AppendLine(" Values(@CompanyCD ");
                                 cmdsql.AppendLine("  , @roleid,@moduleId,@FunctionID");
                                 cmdsql.AppendLine(" ,getdate(),");
                                 cmdsql.AppendLine(" '" + ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID + "' ) ");
                                 sql[sql_index] = cmdsql.ToString();
                                 sql_index++;
                                 SqlCommand sqlcomm = new SqlCommand();
                                 sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", Model.CompanyCD));
                                 sqlcomm.Parameters.Add(SqlHelper.GetParameter("@roleid", roleid[index_role].ToString()));
                                 sqlcomm.Parameters.Add(SqlHelper.GetParameter("@moduleId", moduleId[index_moduleId].ToString()));
                                 sqlcomm.Parameters.Add(SqlHelper.GetParameter("@FunctionID", Row["FunctionID"].ToString()));
                                 sqlcomm.CommandText = cmdsql.ToString();
                                 lstDelete.Add(sqlcomm);
                                 if (Row["FunctionID"] != null)
                                 {
                                     SqlCommand cmd = new SqlCommand();
                                     cmd.CommandText = "delete from officedba.RoleFunction where ModuleID=@ModuleID and FunctionID is null and RoleID=@RoleID";
                                     cmd.Parameters.Add(SqlHelper.GetParameter("@ModuleID", moduleId[index_moduleId].ToString()));
                                     cmd.Parameters.Add(SqlHelper.GetParameter("@RoleID", roleid[index_role].ToString()));
                                     lstDelete.Add(cmd);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         return(SqlHelper.ExecuteTransWithArrayList(lstDelete));
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }