public ActionResult ListAdd(int id) { Expression <Func <InStorage, bool> > where = i => i.Id == id; var s = instorage.GetByWhere(where).SingleOrDefault(); //供应商 var gys = GonYinShang.GetAll(); gys.Insert(0, new Supplier() { Id = 9999, SupplierName = "请选择供应商" }); ViewBag.SupplierId = new SelectList(gys, "Id", "SupplierName", s.SupplierId); //退货类型 var type = returnOrderType.GetAll(); type.Insert(0, new ReturnOrderType() { Id = 9999, ReturnTypeName = "请选择退货类型" }); ViewBag.ReturnTypeId = new SelectList(type, "Id", "ReturnTypeName"); //产品 var product_1 = product.GetAll(); product_1.Insert(0, new Product() { Id = 9999, ProductName = "请选择产品" }); ViewBag.Product = new SelectList(product_1, "Id", "ProductName"); return(View(s)); }
public ActionResult QueryMinXi(int id) { Expression <Func <InStorage, bool> > where = i => i.Id == id; var s = inStorage.GetByWhere(where).SingleOrDefault(); var d = inStorageDetail.GetByWhere(i => i.InStorageId == s.InSNum && i.IsReturnOrder == 0); var t = inStorageType.GetByWhere(i => i.Id == s.InSTypeId).SingleOrDefault(); var g = GonYinShang.GetByWhere(i => i.Id == s.SupplierId).SingleOrDefault(); //主表显示 var info = new { id = s.Id, rukudanhao = s.InSNum, rukuleixin = t.InSTypeName, zt = s.Status, gonyinshangId = g.SupplierNum, gonyinshangName = g.SupplierName, lianxiren = g.Contacts, chuanjianren = s.AuditUser, chuanjianTime = s.AuditTime.ToString("yyyy-MM-dd"), phone = g.Phone, beizhu = s.Remark }; //明细 var dd = d.Select(i => new { Id = i.Id, DetailNum = i.DetailNum, InStorageId = i.InStorageId, ProductNum = i.ProductNum, ProductName = i.ProductName, Size = i.Size, UnitPrice = i.UnitPrice, Quantity = i.Quantity, SumMoney = i.SumMoney, Location = i.Location }); var result = new { InstorageInfo = info, XiangXiInfo = dd }; return(Json(result, JsonRequestBehavior.AllowGet)); }
//修改入库单 public ActionResult UpdtInfo(List <InStorageDetail> detail, int inSTypeId, int supplierId, string Remark, string InSNum) { //先删除明细 bool val_1 = true; var inStorageDetails = new InStorageDetailManager(); var mx = inStorageDetails.GetByWhere(i => i.InStorageId == InSNum); foreach (var item in mx) { val_1 = inStorageDetails.Delete(item); } //获取明细表最大编号 string detailNumBig = inStorageDetail.GetByWhere(item => true).OrderByDescending(item => item.DetailNum).Take(1).Select(item => item.DetailNum).FirstOrDefault(); string detailNum = ""; if (detailNumBig == null) { detailNumBig = "000001"; } else { detailNum = "00000" + (int.Parse(detailNumBig) + 1); int num1 = int.Parse(detailNumBig); if (num1 >= 9) { detailNumBig = "0000" + (int.Parse(detailNumBig) + 1); } else if (num1 >= 99) { detailNumBig = "000" + (int.Parse(detailNumBig) + 1); } } string msg = ""; bool val = true; foreach (var item in detail) { item.DetailNum = detailNum; item.InStorageId = InSNum; item.CreateTime = DateTime.Now; val = inStorageDetail.Add(item); } if (val) { var num = inStorageDetail.GetByWhere(item => item.InStorageId == InSNum).Sum(item => item.Quantity); var sumMoney = Convert.ToDouble(inStorageDetail.GetByWhere(item => item.InStorageId == InSNum).Sum(item => item.SumMoney)); var inStorage_1 = new InStorageManager(); var s = inStorage_1.GetByWhere(i => i.InSNum == InSNum).SingleOrDefault(); s.DetailNum = detailNum; s.InSTypeId = inSTypeId; s.SupplierId = supplierId; s.Remark = Remark; s.Num = Convert.ToInt32(num); s.SumMoney = Convert.ToDouble(sumMoney); bool vall = inStorage.Update(s); if (vall) { msg = "修改成功"; } else { msg = "修改失败"; } msg = "修改成功"; } else { msg = "修改失败"; } return(Json(msg, JsonRequestBehavior.AllowGet)); }