//查询明细 public ActionResult QueryMinXi(int id) { Expression <Func <CheckStock, bool> > where = i => i.Id == id; var s = checkStock.GetByWhere(where).SingleOrDefault(); var d = checkStockDetail.GetByWhere(i => i.CheckId == s.CheckNum); var t = checkStockType.GetByWhere(i => i.Id == s.CheckTypeId).SingleOrDefault(); //主表显示 var info = new { id = s.Id, CheckNum = s.CheckNum, CheckTypeId = t.MoveTypeName, Status = s.Status, AuditUser = s.AuditUser, AuditTime = s.AuditTime.ToString("yyyy-MM-dd"), Remark = s.Remark }; //明细 var dd = d.Select(i => new { Id = i.Id, DetailNum = i.DetailNum, CheckId = i.CheckId, ProductNum = i.ProductNum, ProductName = i.ProductName, Size = i.Size, Type = i.Type, Measure = i.Measure, UnitPrice = i.UnitPrice, Sum = i.Sum }); var result = new { CheckStockInfo = info, XiangXiInfo = dd }; return(Json(result, JsonRequestBehavior.AllowGet)); }
//修改盘点单 public ActionResult UpdtInfo(List <CheckStockDetail> detail, int CheckTypeId, string Remark, string checkNum) { //先删除明细 bool val_1 = true; var checkStockDetails = new CheckStockDetailManager(); var mx = checkStockDetails.GetByWhere(i => i.CheckId == checkNum); foreach (var item in mx) { val_1 = checkStockDetails.Delete(item); } //获取明细表最大编号 string detailNumBig = checkStockDetail.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.CreateTime = DateTime.Now; item.CheckId = checkNum; val = checkStockDetail.Add(item); } if (val) { var checkStock_1 = new CheckStockManager(); var s = checkStock_1.GetByWhere(i => i.CheckNum == checkNum).SingleOrDefault(); s.DetailNum = detailNum; s.CheckTypeId = CheckTypeId; s.Remark = Remark; bool vall = checkStock.Update(s); if (vall) { msg = "修改成功"; } else { msg = "修改失败"; } msg = "修改成功"; } else { msg = "修改失败"; } return(Json(msg, JsonRequestBehavior.AllowGet)); }