Exemplo n.º 1
0
        /// <summary>
        /// 得到  productsku 数据实体
        /// </summary>
        /// <param name="dr">dr</param>
        /// <returns>productsku 数据实体</returns>
        public ProductSKUEntity Populate_ProductSKUEntity_FromDr(IDataReader dr)
        {
            ProductSKUEntity Obj = new ProductSKUEntity();

            Obj.Id          = ((dr["Id"]) == DBNull.Value)?0:Convert.ToInt32(dr["Id"]);
            Obj.ProductId   = ((dr["ProductId"]) == DBNull.Value)?0:Convert.ToInt32(dr["ProductId"]);
            Obj.AttrValue   = dr["AttrValue"].ToString();
            Obj.Stock       = ((dr["Stock"]) == DBNull.Value)?0:Convert.ToInt32(dr["Stock"]);
            Obj.ProductCode = dr["ProductCode"].ToString();
            Obj.Images      = dr["Images"].ToString();

            return(Obj);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到  productsku 数据实体
        /// </summary>
        /// <param name="row">row</param>
        /// <returns>productsku 数据实体</returns>
        public ProductSKUEntity Populate_ProductSKUEntity_FromDr(DataRow row)
        {
            ProductSKUEntity Obj = new ProductSKUEntity();

            if (row != null)
            {
                Obj.Id          = ((row["Id"]) == DBNull.Value)?0:Convert.ToInt32(row["Id"]);
                Obj.ProductId   = ((row["ProductId"]) == DBNull.Value)?0:Convert.ToInt32(row["ProductId"]);
                Obj.AttrValue   = row["AttrValue"].ToString();
                Obj.Stock       = ((row["Stock"]) == DBNull.Value)?0:Convert.ToInt32(row["Stock"]);
                Obj.ProductCode = row["ProductCode"].ToString();
                Obj.Images      = row["Images"].ToString();
            }
            else
            {
                return(null);
            }
            return(Obj);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据ID,返回一个ProductSKU对象
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>ProductSKU对象</returns>
        public ProductSKUEntity Get_ProductSKUEntity(int id)
        {
            ProductSKUEntity _obj = null;

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

            using (SqlDataReader dr = SqlHelper.ExecuteReader(WebConfig.WfxRW, CommandType.Text, sqlStr, _param))
            {
                while (dr.Read())
                {
                    _obj = Populate_ProductSKUEntity_FromDr(dr);
                }
            }
            return(_obj);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 向数据库中插入一条新记录。带事务
        /// </summary>
        /// <param name="sp">事务对象</param>
        /// <param name="_ProductSKUModel">ProductSKU实体</param>
        /// <returns>新插入记录的编号</returns>
        public int Insert(SqlTransaction sp, ProductSKUEntity _ProductSKUModel)
        {
            string sqlStr = "insert into ProductSKU([ProductId],[AttrValue],[Stock],[ProductCode],[Images]) values(@ProductId,@AttrValue,@Stock,@ProductCode,@Images) select @@identity";
            int    res;

            SqlParameter[] _param =
            {
                new SqlParameter("@ProductId",   SqlDbType.Int),
                new SqlParameter("@AttrValue",   SqlDbType.VarChar),
                new SqlParameter("@Stock",       SqlDbType.Int),
                new SqlParameter("@ProductCode", SqlDbType.VarChar),
                new SqlParameter("@Images",      SqlDbType.VarChar)
            };
            _param[0].Value = _ProductSKUModel.ProductId;
            _param[1].Value = _ProductSKUModel.AttrValue;
            _param[2].Value = _ProductSKUModel.Stock;
            _param[3].Value = _ProductSKUModel.ProductCode;
            _param[4].Value = _ProductSKUModel.Images;
            res             = Convert.ToInt32(SqlHelper.ExecuteScalar(sp, CommandType.Text, sqlStr, _param));
            return(res);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 向数据表ProductSKU更新一条记录。带事务
        /// </summary>
        /// <param name="sp">事务对象</param>
        /// <param name="_ProductSKUModel">_ProductSKUModel</param>
        /// <returns>影响的行数</returns>
        public int Update(SqlTransaction sp, ProductSKUEntity _ProductSKUModel)
        {
            string sqlStr = "update ProductSKU set [ProductId]=@ProductId,[AttrValue]=@AttrValue,[Stock]=@Stock,[ProductCode]=@ProductCode,[Images]=@Images where Id=@Id";

            SqlParameter[] _param =
            {
                new SqlParameter("@Id",          SqlDbType.Int),
                new SqlParameter("@ProductId",   SqlDbType.Int),
                new SqlParameter("@AttrValue",   SqlDbType.VarChar),
                new SqlParameter("@Stock",       SqlDbType.Int),
                new SqlParameter("@ProductCode", SqlDbType.VarChar),
                new SqlParameter("@Images",      SqlDbType.VarChar)
            };
            _param[0].Value = _ProductSKUModel.Id;
            _param[1].Value = _ProductSKUModel.ProductId;
            _param[2].Value = _ProductSKUModel.AttrValue;
            _param[3].Value = _ProductSKUModel.Stock;
            _param[4].Value = _ProductSKUModel.ProductCode;
            _param[5].Value = _ProductSKUModel.Images;
            return(SqlHelper.ExecuteNonQuery(sp, CommandType.Text, sqlStr, _param));
        }
Exemplo n.º 6
0
 public void Update(ProductSKUEntity productSKUEntity)
 {
     productSKUdal.Update(productSKUEntity);
 }
Exemplo n.º 7
0
 public int Insert(ProductSKUEntity productSKUEntity)
 {
     return(productSKUdal.Insert(productSKUEntity));
 }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["cmd"]))
        {
            if (Request["cmd"] == "GetAttrValueSKUListByProcuctId")
            {
                object obj = Request["productid"];
                if (obj == null)
                {
                    return;
                }
                int productid = 0;
                int.TryParse(obj.ToString(), out productid);
                IList <Weifenxiao.Entity.AttrValueSKUEntity> list = Weifenxiao.BLL.AttrValueSKUBLL.GetInstance().GetAttrValueSKUListByProcuctId(productid);

                // string resJson = "[{\"Id\":5,\"ProductId\":473,\"AttrSkuId\":1,\"AttrSkuVal\":\"黑色\"},{\"Id\":6,\"ProductId\":473,\"AttrSkuId\":1,\"AttrSkuVal\":\"白色\"},{\"Id\":7,\"ProductId\":473,\"AttrSkuId\":1,\"AttrSkuVal\":\"紫色\"},{\"Id\":8,\"ProductId\":473,\"AttrSkuId\":2,\"AttrSkuVal\":\"M\"},{\"Id\":9,\"ProductId\":473,\"AttrSkuId\":2,\"AttrSkuVal\":\"L\"}]";
                string resJson = Jnwf.Utils.Json.JsonHelper.SerializeJson(list);
                Response.Write(resJson);
                Response.End();
            }
            else if (Request["cmd"] == "InsetProductSKU")  //批量插入
            {
                string json_productsku = Request["data"];
                json_productsku = System.Web.HttpUtility.UrlDecode(json_productsku);
                ProductSKUEntity a = new ProductSKUEntity();

                List <ProductSKUEntity> list_productsku = Jnwf.Utils.Json.JsonHelper.DeserializeJsonReturnList <ProductSKUEntity>(json_productsku);
                int res = Weifenxiao.BLL.ProductSKUBLL.GetInstance().Insert(list_productsku);
                Response.Write(res);
                Response.End();
            }
            else if (Request["cmd"] == "UpdateProductSKU")  //批量更新
            {
                string json_productsku = Request["data"];
                json_productsku = System.Web.HttpUtility.UrlDecode(json_productsku);
                ProductSKUEntity a = new ProductSKUEntity();

                List <ProductSKUEntity> list_productsku = Jnwf.Utils.Json.JsonHelper.DeserializeJsonReturnList <ProductSKUEntity>(json_productsku);
                int res = Weifenxiao.BLL.ProductSKUBLL.GetInstance().Update(list_productsku);
                Response.Write(res);
                Response.End();
            }
            else if (Request["cmd"] == "GetProductSKUList")  //
            {
                object obj = Request["productid"];
                if (obj == null)
                {
                    return;
                }
                int productid = 0;
                int.TryParse(obj.ToString(), out productid);
                IList <ProductSKUEntity> skulist = Weifenxiao.BLL.ProductSKUBLL.GetInstance().GetProductSKUList(productid);
                string resJson = Jnwf.Utils.Json.JsonHelper.SerializeJson(skulist);
                Response.Write(resJson);
                Response.End();
            }
            else if (Request["cmd"] == "GetAttrSKUList")
            {
                IList <Weifenxiao.Entity.AttrSKUEntity> list = Weifenxiao.BLL.AttrSKUBLL.GetInstance().GetAttrSKUList();

                string resJson = Jnwf.Utils.Json.JsonHelper.SerializeJson(list);
                Response.Write(resJson);
                Response.End();
            }
        }
    }