public static string uprole(string schid, string roleid, string rolename, string rolestr, string rolextstr)
        {
            if (!Com.Public.isVa(schid, ""))
            {
                return("无跨界权限;");
            }
            string ret = "success";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                try
                {
                    SchSystem.BLL.SchRoleSoure   bll   = new SchSystem.BLL.SchRoleSoure();
                    SchSystem.Model.SchRoleSoure model = new SchSystem.Model.SchRoleSoure();
                    model.RoleId   = int.Parse(roleid);
                    model.RoleName = Com.Public.SqlEncStr(rolename);
                    model.RoleStr  = rolestr;
                    //model.RoleExtStr = rolextstr;
                    model.Stat        = 1;
                    model.LastRecTime = DateTime.Now;
                    model.LastRecUser = Com.SoureSession.Soureuserid;
                    bll.Update(model);
                }
                catch (Exception ex)
                {
                    ret = ex.Message;
                }
            }
            return(ret);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateStat(SchSystem.Model.SchRoleSoure model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SchRoleSoure set ");
            strSql.Append("Stat=@Stat,");
            strSql.Append("LastRecTime=@LastRecTime,");
            strSql.Append("LastRecUser=@LastRecUser");
            strSql.Append(" where RoleId=@RoleId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Stat",        SqlDbType.TinyInt,    1),
                new SqlParameter("@LastRecTime", SqlDbType.DateTime),
                new SqlParameter("@LastRecUser", SqlDbType.VarChar,   20),
                new SqlParameter("@RoleId",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Stat;
            parameters[1].Value = model.LastRecTime;
            parameters[2].Value = model.LastRecUser;
            parameters[3].Value = model.RoleId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.SchRoleSoure DataRowToModel(DataRow row)
 {
     SchSystem.Model.SchRoleSoure model = new SchSystem.Model.SchRoleSoure();
     if (row != null)
     {
         if (row["RoleId"] != null && row["RoleId"].ToString() != "")
         {
             model.RoleId = int.Parse(row["RoleId"].ToString());
         }
         if (row["RoleName"] != null)
         {
             model.RoleName = row["RoleName"].ToString();
         }
         if (row["RoleStr"] != null)
         {
             model.RoleStr = row["RoleStr"].ToString();
         }
         if (row["RoleStrExt"] != null)
         {
             model.RoleStrExt = row["RoleStrExt"].ToString();
         }
         if (row["Stat"] != null && row["Stat"].ToString() != "")
         {
             model.Stat = int.Parse(row["Stat"].ToString());
         }
         if (row["RecTime"] != null && row["RecTime"].ToString() != "")
         {
             model.RecTime = DateTime.Parse(row["RecTime"].ToString());
         }
         if (row["RecUser"] != null)
         {
             model.RecUser = row["RecUser"].ToString();
         }
         if (row["LastRecTime"] != null && row["LastRecTime"].ToString() != "")
         {
             model.LastRecTime = DateTime.Parse(row["LastRecTime"].ToString());
         }
         if (row["LastRecUser"] != null)
         {
             model.LastRecUser = row["LastRecUser"].ToString();
         }
         if (row["SchId"] != null && row["SchId"].ToString() != "")
         {
             model.SchId = int.Parse(row["SchId"].ToString());
         }
         if (row["SysType"] != null && row["SysType"].ToString() != "")
         {
             model.SysType = int.Parse(row["SysType"].ToString());
         }
     }
     return(model);
 }
        public static string roledel(string schid, string roleid)
        {
            if (!Com.Public.isVa(schid, ""))
            {
                return("无跨界权限;");
            }
            string ret = "success";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                try
                {
                    SchSystem.BLL.SchUserRoleSoure surBll = new SchSystem.BLL.SchUserRoleSoure();
                    bool surBool = surBll.ExistsRoleData(schid, roleid);
                    if (surBool)
                    {
                        ret = "success01";
                    }
                    else
                    {
                        SchSystem.BLL.SchRoleSoure   bll   = new SchSystem.BLL.SchRoleSoure();
                        SchSystem.Model.SchRoleSoure model = new SchSystem.Model.SchRoleSoure();
                        model.RoleId      = int.Parse(roleid);
                        model.Stat        = 2;
                        model.LastRecTime = DateTime.Now;
                        model.LastRecUser = Com.Session.userid;
                        if (bll.UpdateStat(model))
                        {
                            ret = "success";
                        }
                        else
                        {
                            ret = "操作失败";
                        }
                    }
                }
                catch (Exception ex)
                {
                    ret = ex.Message;
                }
            }
            return(ret);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.SchRoleSoure model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SchRoleSoure(");
            strSql.Append("RoleName,RoleStr,RoleStrExt,Stat,RecTime,RecUser,LastRecTime,LastRecUser,SchId,SysType)");
            strSql.Append(" values (");
            strSql.Append("@RoleName,@RoleStr,@RoleStrExt,@Stat,@RecTime,@RecUser,@LastRecTime,@LastRecUser,@SchId,@SysType)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleName",    SqlDbType.VarChar,          50),
                new SqlParameter("@RoleStr",     SqlDbType.VarChar,        4000),
                new SqlParameter("@RoleStrExt",  SqlDbType.VarChar,          50),
                new SqlParameter("@Stat",        SqlDbType.TinyInt,           1),
                new SqlParameter("@RecTime",     SqlDbType.SmallDateTime),
                new SqlParameter("@RecUser",     SqlDbType.VarChar,          50),
                new SqlParameter("@LastRecTime", SqlDbType.DateTime),
                new SqlParameter("@LastRecUser", SqlDbType.VarChar,          20),
                new SqlParameter("@SchId",       SqlDbType.Int,               4),
                new SqlParameter("@SysType",     SqlDbType.TinyInt, 1)
            };
            parameters[0].Value = model.RoleName;
            parameters[1].Value = model.RoleStr;
            parameters[2].Value = model.RoleStrExt;
            parameters[3].Value = model.Stat;
            parameters[4].Value = model.RecTime;
            parameters[5].Value = model.RecUser;
            parameters[6].Value = model.LastRecTime;
            parameters[7].Value = model.LastRecUser;
            parameters[8].Value = model.SchId;
            parameters[9].Value = model.SysType;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        public static string addrole(string schid, string rolename, string rolestr, string roleextstr)
        {
            if (!Com.Public.isVa(schid, ""))
            {
                return("无跨界权限;");
            }
            string ret = "";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                try
                {
                    SchSystem.BLL.SchRoleSoure   bll   = new SchSystem.BLL.SchRoleSoure();
                    SchSystem.Model.SchRoleSoure model = new SchSystem.Model.SchRoleSoure();
                    model.RecTime  = DateTime.Now;
                    model.RecUser  = Com.Session.userid;
                    model.SchId    = int.Parse(schid);
                    model.SysType  = 0;
                    model.RoleName = Com.Public.SqlEncStr(rolename);
                    model.RoleStr  = rolestr;
                    //model.RoleExtStr = roleextstr;
                    model.RoleStrExt  = roleextstr;
                    model.Stat        = 1;
                    model.LastRecTime = DateTime.Now;
                    model.LastRecUser = Com.Session.userid;
                    int id = bll.Add(model);
                    ret = id.ToString();
                }
                catch (Exception ex)
                {
                    ret = ex.Message;
                }
            }
            return(ret);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.SchRoleSoure GetModel(int RoleId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RoleId,RoleName,RoleStr,RoleStrExt,Stat,RecTime,RecUser,LastRecTime,LastRecUser,SchId,SysType from SchRoleSoure ");
            strSql.Append(" where RoleId=@RoleId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleId", SqlDbType.Int, 4)
            };
            parameters[0].Value = RoleId;

            SchSystem.Model.SchRoleSoure model = new SchSystem.Model.SchRoleSoure();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }