Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(AreaModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Base_Area(");
            strSql.Append("area_id,area_name,area_pid,area_level,orderby)");
            strSql.Append(" values (");
            strSql.Append("@area_id,@area_name,@area_pid,@area_level,@orderby)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@area_id",    SqlDbType.VarChar,  50),
                new SqlParameter("@area_name",  SqlDbType.VarChar, 200),
                new SqlParameter("@area_pid",   SqlDbType.VarChar,  50),
                new SqlParameter("@area_level", SqlDbType.Int,       4),
                new SqlParameter("@orderby",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.area_id;
            parameters[1].Value = model.area_name;
            parameters[2].Value = model.area_pid;
            parameters[3].Value = model.area_level;
            parameters[4].Value = model.orderby;

            int rows = adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AreaModel DataRowToModel(DataRow row)
        {
            AreaModel model = new AreaModel();

            if (row != null)
            {
                if (row["area_id"] != null)
                {
                    model.area_id = row["area_id"].ToString();
                }
                if (row["area_name"] != null)
                {
                    model.area_name = row["area_name"].ToString();
                }
                if (row["area_pid"] != null)
                {
                    model.area_pid = row["area_pid"].ToString();
                }
                if (row["area_level"] != null && row["area_level"].ToString() != "")
                {
                    model.area_level = int.Parse(row["area_level"].ToString());
                }
                if (row["orderby"] != null && row["orderby"].ToString() != "")
                {
                    model.orderby = int.Parse(row["orderby"].ToString());
                }
            }
            return(model);
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AreaModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Base_Area set ");
            strSql.Append("area_id=@area_id,");
            strSql.Append("area_name=@area_name,");
            strSql.Append("area_pid=@area_pid,");
            strSql.Append("area_level=@area_level,");
            strSql.Append("orderby=@orderby");
            strSql.Append(" where area_id=@area_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@area_id",    SqlDbType.VarChar,  50),
                new SqlParameter("@area_name",  SqlDbType.VarChar, 200),
                new SqlParameter("@area_pid",   SqlDbType.VarChar,  50),
                new SqlParameter("@area_level", SqlDbType.Int,       4),
                new SqlParameter("@orderby",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.area_id;
            parameters[1].Value = model.area_name;
            parameters[2].Value = model.area_pid;
            parameters[3].Value = model.area_level;
            parameters[4].Value = model.orderby;

            int rows = adoHelper.ExecuteSqlNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AreaModel GetModel(string area_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 area_id,area_name,area_pid,area_level,orderby from T_Base_Area ");
            strSql.Append(" where area_id=@area_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@area_id", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = area_id;

            AreaModel model = new AreaModel();
            DataSet   ds    = adoHelper.ExecuteSqlDataset(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(AreaModel model)
 {
     return(dal.Update(model));
 }
Esempio n. 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(AreaModel model)
 {
     return(dal.Add(model));
 }