//商品日志 public static void GetProductRecord(ProductType obj, string recordType, string Content,UserType CurrentUser,ISession NSession) { GetProductRecord(obj.Id, obj.OldSKU, obj.SKU, recordType, Content, CurrentUser, NSession); }
public ViewResult Received(int id) { NoStockType obj = GetById(id); ProductType product= new ProductType(); product.OldSKU = obj.OldSKU; product.SKU = obj.SKU; product.ProductName = obj.Name; product.Standard = obj.Standard; ViewData["nid"] = id; return View(product); }
public ActionResult Edit(ProductType obj) { try { string str = ""; obj.Enabled = 1; ProductType obj2 = GetById(obj.Id); List<ProductComposeType> list1 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProductComposeType>>(obj.rows); List<ProductComposeType> pis = NSession.CreateQuery("from ProductComposeType where SKU='" + obj.SKU + "'").List<ProductComposeType>().ToList<ProductComposeType>(); if (list1.Count != pis.Count) { str += "组合产品由<br>"; foreach (var item in pis) { str += Zu(item); } str += "修改为<br> "; foreach (var item in list1) { str += Zu(item); } str += "<br>"; } else { foreach (var item in pis) { int check = 0; foreach (var it in list1) { if (it.SrcSKU == item.SrcSKU && it.SrcQty == item.SrcQty) { check = 1; } } if (check != 1) { str += "组合产品由<br>"; foreach (var zu in pis) { str += Zu(zu); } str += "修改为<br> "; foreach (var zu in list1) { str += Zu(zu); } str += "<br>"; } } } NSession.Delete("from ProductComposeType where SKU='" + obj.SKU + "'"); NSession.Flush(); NSession.Clear(); foreach (ProductComposeType productCompose in list1) { productCompose.SKU = obj.SKU; productCompose.PId = obj.Id; NSession.Save(productCompose); NSession.Flush(); NSession.Clear(); obj.IsZu = 1; } str += Utilities.GetObjEditString(obj2, obj) + "<br>"; List<ProductIsInfractionType> list2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProductIsInfractionType>>(obj.rows2); foreach (ProductIsInfractionType item in list2) { IList<ProductIsInfractionType> qin = NSession.CreateQuery("from ProductIsInfractionType where SKU='" + obj.SKU + "' and Platform='" + item.Platform + "'").List<ProductIsInfractionType>(); if (qin.Count != 0) { foreach (var s in qin) { if (item.Isinfraction != s.Isinfraction) { str += item.Platform + "是否侵权由" + s.Isinfraction + "修改为" + item.Isinfraction + "<br>"; } } } } NSession.Delete("from ProductIsInfractionType where SKU='" + obj.SKU + "'"); NSession.Flush(); NSession.Clear(); foreach (ProductIsInfractionType item in list2) { item.OldSKU = obj.OldSKU; item.SKU = obj.SKU; NSession.Save(item); NSession.Flush(); NSession.Clear(); } NSession.Update(obj); NSession.Flush(); NSession.Clear(); //修改库存中的数据 IList<WarehouseStockType> list = NSession.CreateQuery(" from WarehouseStockType where PId=" + obj.Id).List<WarehouseStockType>(); // //在仓库中添加产品库存 // if (list.Count > 0) { foreach (var item in list) { item.Pic = obj.SPicUrl; item.SKU = obj.SKU; item.Title = obj.ProductName; item.UpdateOn = DateTime.Now; NSession.Update(item); NSession.Flush(); } } else { AddToWarehouse(obj); } LoggerUtil.GetProductRecord(obj, "商品修改", str, CurrentUser, NSession); } catch (Exception ee) { return Json(new { IsSuccess = false, ErrorMsg = "出错了" }); } return Json(new { IsSuccess = true }); }
private void AddToWarehouse(ProductType obj) { IList<WarehouseType> list = NSession.CreateQuery(" from WarehouseType").List<WarehouseType>(); // //在仓库中添加产品库存 // foreach (var item in list) { WarehouseStockType stock = new WarehouseStockType(); stock.Pic = obj.SPicUrl; stock.WId = item.Id; stock.Warehouse = item.WName; stock.PId = obj.Id; stock.SKU = obj.SKU; stock.Title = obj.ProductName; stock.Qty = 0; stock.UpdateOn = DateTime.Now; NSession.SaveOrUpdate(stock); NSession.Flush(); } }
public JsonResult Create(ProductType obj) { try { string filePath = Server.MapPath("~"); obj.CreateOn = DateTime.Now; string pic = obj.PicUrl; if (!string.IsNullOrEmpty(pic)) { obj.PicUrl = Utilities.BPicPath + obj.SKU + ".jpg"; obj.SPicUrl = Utilities.SPicPath + obj.SKU + ".png"; Utilities.DrawImageRectRect(pic, filePath + obj.PicUrl, 310, 310); Utilities.DrawImageRectRect(pic, filePath + obj.SPicUrl, 64, 64); } List<ProductComposeType> list1 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProductComposeType>>(obj.rows); if (list1.Count > 0) obj.IsZu = 1; obj.Enabled = 1; NSession.SaveOrUpdate(obj); NSession.Flush(); foreach (ProductComposeType productCompose in list1) { productCompose.SKU = obj.SKU; productCompose.PId = obj.Id; NSession.Save(productCompose); NSession.Flush(); } List<ProductIsInfractionType> list2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProductIsInfractionType>>(obj.rows2); foreach (ProductIsInfractionType item in list2) { item.OldSKU = obj.OldSKU; item.SKU = obj.SKU; NSession.Save(item); NSession.Flush(); } AddToWarehouse(obj); LoggerUtil.GetProductRecord(obj, "商品创建", "创建一件商品", CurrentUser, NSession); } catch (Exception ee) { return Json(new { IsSuccess = false, ErrorMsg = "出错了" }); } return Json(new { IsSuccess = true }); }
public ActionResult ImportProduct(string fileName) { try { List<ResultInfo> results = new List<ResultInfo>(); DataTable dt = OrderHelper.GetDataTable(fileName); IList<WarehouseType> list = NSession.CreateQuery(" from WarehouseType").List<WarehouseType>(); for (int i = 0; i < dt.Rows.Count; i++) { ProductType p = new ProductType { CreateOn = DateTime.Now }; p.SKU = dt.Rows[i]["子SKU"].ToString().Trim(); if (IsExist(p.SKU)) { continue; } p.Status = dt.Rows[i]["销售状态"].ToString(); p.ProductName = dt.Rows[i]["名称"].ToString(); p.Category = dt.Rows[i]["分类"].ToString(); p.Standard = dt.Rows[i]["规格"].ToString(); p.Price = Convert.ToDouble(dt.Rows[i]["价格"]); p.Weight = Convert.ToInt16(dt.Rows[i]["重量"]); p.Long = Convert.ToInt16(dt.Rows[i]["长"]); p.Wide = Convert.ToInt16(dt.Rows[i]["宽"]); p.High = Convert.ToInt16(dt.Rows[i]["高"]); p.Location = dt.Rows[i]["库位号"].ToString(); p.OldSKU = dt.Rows[i]["SKU"].ToString(); p.HasBattery = Convert.ToInt32(dt.Rows[i]["电池"].ToString()); p.IsElectronic = Convert.ToInt32(dt.Rows[i]["电子"].ToString()); p.IsScan = Convert.ToInt32(dt.Rows[i]["配货扫描"].ToString()); p.DayByStock = Convert.ToInt32(dt.Rows[i]["备货天数"].ToString()); p.ProductAttribute = dt.Rows[i]["产品属性"].ToString(); p.Enabled = 1; if (!HasExsit(p.SKU)) { NSession.SaveOrUpdate(p); NSession.Flush(); results.Add(OrderHelper.GetResult(p.SKU, "", "导入成功")); //在仓库中添加产品库存 foreach (var item in list) { WarehouseStockType stock = new WarehouseStockType(); stock.Pic = p.SPicUrl; stock.WId = item.Id; stock.Warehouse = item.WName; stock.PId = p.Id; stock.SKU = p.SKU; stock.Title = p.ProductName; stock.Qty = 0; stock.UpdateOn = DateTime.Now; NSession.SaveOrUpdate(stock); NSession.Flush(); } } else { results.Add(OrderHelper.GetResult(p.SKU, "该产品已存在", "导入失败")); } } Session["Results"] = results; return Json(new { IsSuccess = true, Info = true }); } catch (Exception ex) { return Json(new { IsSuccess = false, ErrorMsg = ex.Message, Info = true }); } }