Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DataService.Model.UserGroup model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserGroup set ");
            strSql.Append("UserID=@UserID,");
            strSql.Append("GroupName=@GroupName,");
            strSql.Append("Users=@Users,");
            strSql.Append("AddTime=@AddTime");
            strSql.Append(" where GroupID=@GroupID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID",    SqlDbType.Int,         4),
                new SqlParameter("@GroupName", SqlDbType.NVarChar,  500),
                new SqlParameter("@Users",     SqlDbType.NVarChar,  500),
                new SqlParameter("@AddTime",   SqlDbType.DateTime),
                new SqlParameter("@GroupID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserID;
            parameters[1].Value = model.GroupName;
            parameters[2].Value = model.Users;
            parameters[3].Value = model.AddTime;
            parameters[4].Value = model.GroupID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DataService.Model.UserGroup DataRowToModel(DataRow row)
 {
     DataService.Model.UserGroup model = new DataService.Model.UserGroup();
     if (row != null)
     {
         if (row["GroupID"] != null && row["GroupID"].ToString() != "")
         {
             model.GroupID = int.Parse(row["GroupID"].ToString());
         }
         if (row["UserID"] != null && row["UserID"].ToString() != "")
         {
             model.UserID = int.Parse(row["UserID"].ToString());
         }
         if (row["GroupName"] != null)
         {
             model.GroupName = row["GroupName"].ToString();
         }
         if (row["Users"] != null)
         {
             model.Users = row["Users"].ToString();
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = DateTime.Parse(row["AddTime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DataService.Model.UserGroup model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserGroup(");
            strSql.Append("GroupID,UserID,GroupName,Users,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@GroupID,@UserID,@GroupName,@Users,@AddTime)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupID",   SqlDbType.Int,        4),
                new SqlParameter("@UserID",    SqlDbType.Int,        4),
                new SqlParameter("@GroupName", SqlDbType.NVarChar, 500),
                new SqlParameter("@Users",     SqlDbType.NVarChar, 500),
                new SqlParameter("@AddTime",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.GroupID;
            parameters[1].Value = model.UserID;
            parameters[2].Value = model.GroupName;
            parameters[3].Value = model.Users;
            parameters[4].Value = model.AddTime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DataService.Model.UserGroup GetModel(int GroupID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 GroupID,UserID,GroupName,Users,AddTime from UserGroup ");
            strSql.Append(" where GroupID=@GroupID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupID", SqlDbType.Int, 4)
            };
            parameters[0].Value = GroupID;

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

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