示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SchSystem.Model.SchUserCope model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SchUserCope set ");
            strSql.Append("SchIds=@SchIds,");
            strSql.Append("GradeIds=@GradeIds,");
            strSql.Append("ClassIds=@ClassIds,");
            strSql.Append("UserId=@UserId");
            strSql.Append(" where TabId=@TabId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SchIds",   SqlDbType.VarChar,  100),
                new SqlParameter("@GradeIds", SqlDbType.VarChar,  500),
                new SqlParameter("@ClassIds", SqlDbType.VarChar, 2000),
                new SqlParameter("@UserId",   SqlDbType.Int,        4),
                new SqlParameter("@TabId",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SchIds;
            parameters[1].Value = model.GradeIds;
            parameters[2].Value = model.ClassIds;
            parameters[3].Value = model.UserId;
            parameters[4].Value = model.TabId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.SchUserCope DataRowToModel(DataRow row)
 {
     SchSystem.Model.SchUserCope model = new SchSystem.Model.SchUserCope();
     if (row != null)
     {
         if (row["TabId"] != null && row["TabId"].ToString() != "")
         {
             model.TabId = int.Parse(row["TabId"].ToString());
         }
         if (row["SchIds"] != null)
         {
             model.SchIds = row["SchIds"].ToString();
         }
         if (row["GradeIds"] != null)
         {
             model.GradeIds = row["GradeIds"].ToString();
         }
         if (row["ClassIds"] != null)
         {
             model.ClassIds = row["ClassIds"].ToString();
         }
         if (row["UserId"] != null && row["UserId"].ToString() != "")
         {
             model.UserId = int.Parse(row["UserId"].ToString());
         }
     }
     return(model);
 }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.SchUserCope model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SchUserCope(");
            strSql.Append("SchIds,GradeIds,ClassIds,UserId)");
            strSql.Append(" values (");
            strSql.Append("@SchIds,@GradeIds,@ClassIds,@UserId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SchIds",   SqlDbType.VarChar,  100),
                new SqlParameter("@GradeIds", SqlDbType.VarChar,  500),
                new SqlParameter("@ClassIds", SqlDbType.VarChar, 2000),
                new SqlParameter("@UserId",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SchIds;
            parameters[1].Value = model.GradeIds;
            parameters[2].Value = model.ClassIds;
            parameters[3].Value = model.UserId;

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

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

            strSql.Append("select  top 1 TabId,SchIds,GradeIds,ClassIds,UserId from SchUserCope ");
            strSql.Append(" where TabId=@TabId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TabId", SqlDbType.Int, 4)
            };
            parameters[0].Value = TabId;

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

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