public ActionResult Add(SalesShipmentsDataModel model) { if (ModelState.IsValid) { SalesShipmentsData SalesShipments = model.MapTo <SalesShipmentsDataModel, SalesShipmentsData>(); int salesShipmentsDataID = _salesShipmentsDataService.Insert(SalesShipments); var inventoryDataRes = _inventoryDataService.GetById(model.InventoryDataID); InventoryData inventoryData = new InventoryData() { ID = model.InventoryDataID, WarehouseID = model.WarehouseID, WarehouseName = model.WarehouseName, GoodsID = model.GoodsID, GoodsName = model.GoodsName, Unit = model.Unit, Specification = model.Specification, GoodsType = model.GoodsType, Brand = model.Brand, InventoryQuantity = model.OldQuantity - model.Quantity, CostPrice = inventoryDataRes.CostPrice, InventorySum = inventoryDataRes.InventorySum - model.Sum, PurchaseDate = DateTime.Now, ShipmentsDate = DateTime.Now, LastInventoryDate = DateTime.Now, FinalSaleDate = DateTime.Now }; _inventoryDataService.Update(inventoryData); if (model.ArrearsAmount != 0 && model.ArrearsAmount != null) { //添加欠款信息 ArrearsInset(model, salesShipmentsDataID); } SuccessNotification("添加成功"); return(RedirectToAction("Index")); } model.ClientDataList = GetClientDataList(); model.WarehouseList = GetWarehouseList(); model.SpecificationList = GetSpecificationList(); model.GoodsTypeList = GetGoodsTypeList(); return(View(model)); }
public ActionResult Edit(PurchaseDataModel model) { if (ModelState.IsValid) { PurchaseData purchase = model.MapTo <PurchaseDataModel, PurchaseData>(); InventoryData inventoryData = new InventoryData() { WarehouseID = model.WarehouseID, WarehouseName = model.WarehouseName, GoodsID = model.GoodsID, GoodsName = model.GoodsName, Unit = model.Unit, Specification = model.Specification, GoodsType = model.GoodsType, Brand = model.Brand, InventoryQuantity = model.Quantity, CostPrice = ((model.Quantity != 0) ? (model.Sum / Convert.ToDecimal(model.Quantity)) : 0), InventorySum = model.Sum, SupplierID = model.SupplierID, SupplierName = model.SupplierName, SupplierAddress = model.SupplierAddress, PurchaseDate = DateTime.Now, ShipmentsDate = DateTime.Now, LastInventoryDate = DateTime.Now, FinalSaleDate = DateTime.Now, Active = "1", ShipmentsQuantity = 0, RemainingQuantity = model.Quantity, ID = model.InventoryDataID }; //修改货物库存表返回ID _inventoryDataService.Update(inventoryData); purchase.Active = "1"; _purchaseDataService.Update(purchase); SuccessNotification("修改成功" + model.GoodsName); return(RedirectToAction("Index")); } model.GoodsList = GetGoodsList(); model.SupplierList = GetSupplierList(); model.WarehouseList = GetWarehouseList(); model.SpecificationList = GetSpecificationList(); model.GoodsTypeList = GetGoodsTypeList(); return(View(model)); }