Beispiel #1
0
        /// <summary>
        /// 得到  wx_shop 数据实体
        /// </summary>
        /// <param name="dr">dr</param>
        /// <returns>wx_shop 数据实体</returns>
        public wx_ShopEntity Populate_wx_ShopEntity_FromDr(IDataReader dr)
        {
            wx_ShopEntity Obj = new wx_ShopEntity();

            Obj.ShopId      = ((dr["ShopId"]) == DBNull.Value)?0:Convert.ToInt32(dr["ShopId"]);
            Obj.ShopName    = dr["ShopName"].ToString();
            Obj.Description = dr["Description"].ToString();
            Obj.Images      = dr["Images"].ToString();
            Obj.Status      = ((dr["Status"]) == DBNull.Value)?0:Convert.ToInt32(dr["Status"]);
            Obj.AddTime     = ((dr["AddTime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(dr["AddTime"]);
            Obj.UpdateTime  = ((dr["UpdateTime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(dr["UpdateTime"]);

            return(Obj);
        }
Beispiel #2
0
        /// <summary>
        /// 根据ID,返回一个wx_Shop对象
        /// </summary>
        /// <param name="shopId">shopId</param>
        /// <returns>wx_Shop对象</returns>
        public wx_ShopEntity Get_wx_ShopEntity(int shopId)
        {
            wx_ShopEntity _obj = null;

            SqlParameter[] _param =
            {
                new SqlParameter("@ShopId", SqlDbType.Int)
            };
            _param[0].Value = shopId;
            string sqlStr = "select * from wx_Shop with(nolock) where ShopId=@ShopId";

            using (SqlDataReader dr = SqlHelper.ExecuteReader(WebConfig.WfxRW, CommandType.Text, sqlStr, _param))
            {
                while (dr.Read())
                {
                    _obj = Populate_wx_ShopEntity_FromDr(dr);
                }
            }
            return(_obj);
        }
Beispiel #3
0
        /// <summary>
        /// 得到  wx_shop 数据实体
        /// </summary>
        /// <param name="row">row</param>
        /// <returns>wx_shop 数据实体</returns>
        public wx_ShopEntity Populate_wx_ShopEntity_FromDr(DataRow row)
        {
            wx_ShopEntity Obj = new wx_ShopEntity();

            if (row != null)
            {
                Obj.ShopId      = ((row["ShopId"]) == DBNull.Value)?0:Convert.ToInt32(row["ShopId"]);
                Obj.ShopName    = row["ShopName"].ToString();
                Obj.Description = row["Description"].ToString();
                Obj.Images      = row["Images"].ToString();
                Obj.Status      = ((row["Status"]) == DBNull.Value)?0:Convert.ToInt32(row["Status"]);
                Obj.AddTime     = ((row["AddTime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(row["AddTime"]);
                Obj.UpdateTime  = ((row["UpdateTime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(row["UpdateTime"]);
            }
            else
            {
                return(null);
            }
            return(Obj);
        }
Beispiel #4
0
        /// <summary>
        /// 向数据库中插入一条新记录。带事务
        /// </summary>
        /// <param name="sp">事务对象</param>
        /// <param name="_wx_ShopModel">wx_Shop实体</param>
        /// <returns>新插入记录的编号</returns>
        public int Insert(SqlTransaction sp, wx_ShopEntity _wx_ShopModel)
        {
            string sqlStr = "insert into wx_Shop([ShopName],[Description],[Images],[Status],[AddTime],[UpdateTime]) values(@ShopName,@Description,@Images,@Status,@AddTime,@UpdateTime) select @@identity";
            int    res;

            SqlParameter[] _param =
            {
                new SqlParameter("@ShopName",    SqlDbType.VarChar),
                new SqlParameter("@Description", SqlDbType.VarChar),
                new SqlParameter("@Images",      SqlDbType.VarChar),
                new SqlParameter("@Status",      SqlDbType.Int),
                new SqlParameter("@AddTime",     SqlDbType.DateTime),
                new SqlParameter("@UpdateTime",  SqlDbType.DateTime)
            };
            _param[0].Value = _wx_ShopModel.ShopName;
            _param[1].Value = _wx_ShopModel.Description;
            _param[2].Value = _wx_ShopModel.Images;
            _param[3].Value = _wx_ShopModel.Status;
            _param[4].Value = _wx_ShopModel.AddTime;
            _param[5].Value = _wx_ShopModel.UpdateTime;
            res             = Convert.ToInt32(SqlHelper.ExecuteScalar(sp, CommandType.Text, sqlStr, _param));
            return(res);
        }
Beispiel #5
0
        /// <summary>
        /// 向数据表wx_Shop更新一条记录。带事务
        /// </summary>
        /// <param name="sp">事务对象</param>
        /// <param name="_wx_ShopModel">_wx_ShopModel</param>
        /// <returns>影响的行数</returns>
        public int Update(SqlTransaction sp, wx_ShopEntity _wx_ShopModel)
        {
            string sqlStr = "update wx_Shop set [ShopName]=@ShopName,[Description]=@Description,[Images]=@Images,[Status]=@Status,[AddTime]=@AddTime,[UpdateTime]=@UpdateTime where ShopId=@ShopId";

            SqlParameter[] _param =
            {
                new SqlParameter("@ShopId",      SqlDbType.Int),
                new SqlParameter("@ShopName",    SqlDbType.VarChar),
                new SqlParameter("@Description", SqlDbType.VarChar),
                new SqlParameter("@Images",      SqlDbType.VarChar),
                new SqlParameter("@Status",      SqlDbType.Int),
                new SqlParameter("@AddTime",     SqlDbType.DateTime),
                new SqlParameter("@UpdateTime",  SqlDbType.DateTime)
            };
            _param[0].Value = _wx_ShopModel.ShopId;
            _param[1].Value = _wx_ShopModel.ShopName;
            _param[2].Value = _wx_ShopModel.Description;
            _param[3].Value = _wx_ShopModel.Images;
            _param[4].Value = _wx_ShopModel.Status;
            _param[5].Value = _wx_ShopModel.AddTime;
            _param[6].Value = _wx_ShopModel.UpdateTime;
            return(SqlHelper.ExecuteNonQuery(sp, CommandType.Text, sqlStr, _param));
        }
Beispiel #6
0
 public void Update(wx_ShopEntity wx_ShopEntity)
 {
     wx_Shopdal.Update(wx_ShopEntity);
 }
Beispiel #7
0
 public int Insert(wx_ShopEntity wx_ShopEntity)
 {
     return(wx_Shopdal.Insert(wx_ShopEntity));
 }