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

            strSql.Append("update pre_common_district set ");
            strSql.Append("name=@name,");
            strSql.Append("level=@level,");
            strSql.Append("upid=@upid");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",  SqlDbType.NVarChar, 255),
                new SqlParameter("@level", SqlDbType.Int,        4),
                new SqlParameter("@upid",  SqlDbType.Int,        4),
                new SqlParameter("@id",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.level;
            parameters[2].Value = model.upid;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(XCWeiXin.Model.pre_common_district model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into pre_common_district(");
            strSql.Append("id,name,level,upid)");
            strSql.Append(" values (");
            strSql.Append("@id,@name,@level,@upid)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",    SqlDbType.Int,        4),
                new SqlParameter("@name",  SqlDbType.NVarChar, 255),
                new SqlParameter("@level", SqlDbType.Int,        4),
                new SqlParameter("@upid",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.name;
            parameters[2].Value = model.level;
            parameters[3].Value = model.upid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XCWeiXin.Model.pre_common_district DataRowToModel(DataRow row)
 {
     XCWeiXin.Model.pre_common_district model = new XCWeiXin.Model.pre_common_district();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["level"] != null && row["level"].ToString() != "")
         {
             model.level = int.Parse(row["level"].ToString());
         }
         if (row["upid"] != null && row["upid"].ToString() != "")
         {
             model.upid = int.Parse(row["upid"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCWeiXin.Model.pre_common_district GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,name,level,upid from pre_common_district ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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