public ActionResult Create(ProfitLossBillMaster profitLossBillMaster) { bool bResult = ProfitLossBillMasterService.Add(profitLossBillMaster, this.User.Identity.Name.ToString()); string msg = bResult ? "新增成功" : "新增失败"; return(Json(JsonMessageHelper.getJsonMessage(bResult, msg, null), "text", JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(ProfitLossBillMaster profitLossBillMaster) { string strResult = string.Empty; bool bResult = ProfitLossBillMasterService.Save(profitLossBillMaster, out strResult); string msg = bResult ? "修改成功" : "修改失败"; return(Json(JsonMessageHelper.getJsonMessage(bResult, msg, strResult), "text", JsonRequestBehavior.AllowGet)); }
/// <summary> /// 盘点确认 /// </summary> /// <param name="billNo">单据号</param> /// <returns></returns> public bool confirmCheck(string billNo, string userName, out string errorInfo) { bool result = false; errorInfo = string.Empty; var checkbm = CheckBillMasterRepository.GetQueryable().FirstOrDefault(i => i.BillNo == billNo); var checkDetail = CheckBillDetailRepository.GetQueryable().Where(c => c.BillNo == checkbm.BillNo && c.ProductCode == c.RealProductCode && c.Quantity != c.RealQuantity && c.Status == "2"); using (var scope = new TransactionScope()) { try { if (checkDetail.Count() > 0) { string billno = GenProfitLossBillNo(userName).ToString(); //添加损益主表 var pbm = new ProfitLossBillMaster(); var employee = EmployeeRepository.GetQueryable().FirstOrDefault(i => i.UserName == userName); if (employee != null) { pbm.BillNo = billno; pbm.BillDate = DateTime.Now; pbm.BillTypeCode = "5002"; pbm.WarehouseCode = checkbm.WarehouseCode; pbm.OperatePersonID = employee.ID; pbm.Status = "1"; pbm.IsActive = "1"; pbm.UpdateTime = DateTime.Now; ProfitLossBillMasterRepository.Add(pbm); ProfitLossBillMasterRepository.SaveChanges(); } //添加损益细表 foreach (var item in checkDetail.ToArray()) { decimal differQuantity = item.RealQuantity - item.Quantity; //损益数量 if (Locker.LockNoEmptyStorage(item.Storage, item.Product) != null) //锁库存 { var pbd = new ProfitLossBillDetail(); pbd.BillNo = billno; pbd.CellCode = item.CellCode; pbd.StorageCode = item.StorageCode; pbd.ProductCode = item.ProductCode; pbd.UnitCode = item.UnitCode; pbd.Price = item.Product != null ? item.Product.CostPrice : 0; pbd.Quantity = differQuantity; if (differQuantity > 0) { item.Storage.InFrozenQuantity += differQuantity; } else { item.Storage.OutFrozenQuantity += Math.Abs(differQuantity); } ProfitLossBillDetailRepository.Add(pbd); item.Storage.LockTag = string.Empty; ProfitLossBillDetailRepository.SaveChanges(); } scope.Complete(); } } var checkBillDetail = CheckBillDetailRepository.GetQueryable().Where(c => c.BillNo == checkbm.BillNo);//解锁盘点锁定 foreach (var item in checkBillDetail.ToArray()) { item.Storage.IsLock = "0"; } if (checkbm != null && checkbm.Status == "4") { checkbm.Status = "5"; checkbm.VerifyDate = DateTime.Now; checkbm.UpdateTime = DateTime.Now; CheckBillMasterRepository.SaveChanges(); result = true; } } catch (Exception e) { errorInfo = "确认盘点损益失败!原因:" + e.Message; } scope.Complete(); } return(result); }