public VWProductDetailEntity GetProductDetailByPId(int productid) { string sql = @"SELECT a.*,b.AdTitle AS ProductAdTitle,b.Name AS ProductName FROM Product b WITH(NOLOCK) LEFT join dbo.[ProductDetail] a WITH(NOLOCK) on a.ProductId=b.Id WHERE b.[Id]=@ProductId" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@ProductId", DbType.Int32, productid); VWProductDetailEntity entity = new VWProductDetailEntity(); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.ProductId = StringUtils.GetDbInt(reader["ProductId"]); entity.ProductName = StringUtils.GetDbString(reader["ProductName"]); entity.ProductAdTitle = StringUtils.GetDbString(reader["ProductAdTitle"]); entity.Price = StringUtils.GetDbDecimal(reader["Price"]); entity.TradePrice = StringUtils.GetDbDecimal(reader["TradePrice"]); entity.StockNum = StringUtils.GetDbInt(reader["StockNum"]); entity.SaleNum = StringUtils.GetDbInt(reader["SaleNum"]); entity.ProductType = StringUtils.GetDbInt(reader["ProductType"]); entity.Status = StringUtils.GetDbInt(reader["Status"]); entity.IsBP = StringUtils.GetDbInt(reader["IsBP"]); entity.TimeStampCode = StringUtils.GetDbString(reader["TimeStampCode"]); } } return(entity); }
public string GetProductStockNum() { string result = ""; int _pdid = FormString.IntSafeQ("pdid");//上级品牌Id,0代表第一级 if (_pdid > 0) { VWProductDetailEntity entity = ProductDetailBLL.Instance.GetProductDetail(_pdid); if (entity != null && entity.Id > 0) { result = entity.StockNum.ToString(); } } return(result); }
/// <summary> /// 发布常规或者特价产品 /// </summary> /// <returns></returns> public ActionResult ReleaseProduct() { int _pdid = QueryString.IntSafeQ("pdid"); int _pid = QueryString.IntSafeQ("pid"); VWProductDetailEntity detailEntity = new VWProductDetailEntity(); if (_pdid > 0) { detailEntity = ProductDetailBLL.Instance.GetProductDetail(_pdid); ViewBag.ProductId = detailEntity.ProductId; } else if (_pid > 0) { ViewBag.ProductId = _pid; detailEntity = ProductDetailBLL.Instance.GetProductDetailByPId(_pid); } ViewBag.DetailEntity = detailEntity; return(View()); }