/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SchSystem.Model.SchUserRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SchUserRole set ");
            strSql.Append("RoleName=@RoleName,");
            strSql.Append("Stat=@Stat,");
            strSql.Append("LastRecTime=@LastRecTime,");
            strSql.Append("LastRecUser=@LastRecUser");
            strSql.Append(" where RoleId=@RoleId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleName",    SqlDbType.VarChar,   50),
                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.RoleName;
            parameters[1].Value = model.Stat;
            parameters[2].Value = model.LastRecTime;
            parameters[3].Value = model.LastRecUser;
            parameters[4].Value = model.RoleId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SchSystem.Model.SchUserRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SchUserRole set ");
            strSql.Append("RoleID=@RoleID,");
            strSql.Append("UserName=@UserName,");
            strSql.Append("RecTime=@RecTime,");
            strSql.Append("RecUser=@RecUser,");
            strSql.Append("LastRecTime=@LastRecTime,");
            strSql.Append("LastRecUser=@LastRecUser,");
            strSql.Append("SchId=@SchId");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleID",      SqlDbType.Int,             4),
                new SqlParameter("@UserName",    SqlDbType.VarChar,        20),
                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("@AutoId",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RoleID;
            parameters[1].Value = model.UserName;
            parameters[2].Value = model.RecTime;
            parameters[3].Value = model.RecUser;
            parameters[4].Value = model.LastRecTime;
            parameters[5].Value = model.LastRecUser;
            parameters[6].Value = model.SchId;
            parameters[7].Value = model.AutoId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.SchUserRole DataRowToModel(DataRow row)
 {
     SchSystem.Model.SchUserRole model = new SchSystem.Model.SchUserRole();
     if (row != null)
     {
         if (row["AutoId"] != null && row["AutoId"].ToString() != "")
         {
             model.AutoId = int.Parse(row["AutoId"].ToString());
         }
         if (row["RoleID"] != null && row["RoleID"].ToString() != "")
         {
             model.RoleID = int.Parse(row["RoleID"].ToString());
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].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());
         }
     }
     return(model);
 }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.SchUserRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SchUserRole(");
            strSql.Append("RoleID,UserName,RecTime,RecUser,LastRecTime,LastRecUser,SchId)");
            strSql.Append(" values (");
            strSql.Append("@RoleID,@UserName,@RecTime,@RecUser,@LastRecTime,@LastRecUser,@SchId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleID",      SqlDbType.Int,             4),
                new SqlParameter("@UserName",    SqlDbType.VarChar,        20),
                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)
            };
            parameters[0].Value = model.RoleID;
            parameters[1].Value = model.UserName;
            parameters[2].Value = model.RecTime;
            parameters[3].Value = model.RecUser;
            parameters[4].Value = model.LastRecTime;
            parameters[5].Value = model.LastRecUser;
            parameters[6].Value = model.SchId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.SchUserRole GetModel(int AutoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AutoId,RoleID,UserName,RecTime,RecUser,LastRecTime,LastRecUser,SchId from SchUserRole ");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId", SqlDbType.Int, 4)
            };
            parameters[0].Value = AutoId;

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

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