Пример #1
0
        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));
        }
Пример #2
0
        public ActionResult Edit(SalesShipmentsDataModel model)
        {
            if (ModelState.IsValid)
            {
                SalesShipmentsData salesShipments = model.MapTo <SalesShipmentsDataModel, SalesShipmentsData>();
                _salesShipmentsDataService.Update(salesShipments);


                var           inventoryDataID = _inventoryDataService.GetById(model.InventoryDataID);
                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 = inventoryDataID.InventoryQuantity + (model.Quantity - model.OldQuantity),
                    CostPrice         = ((model.Quantity != 0) ? (model.Sum / Convert.ToDecimal(model.Quantity)) : 0),
                    InventorySum      = model.Sum,

                    PurchaseDate      = DateTime.Now,
                    ShipmentsDate     = DateTime.Now,
                    LastInventoryDate = DateTime.Now,
                    FinalSaleDate     = DateTime.Now
                };
                _inventoryDataService.Update(inventoryData);
                SuccessNotification("修改成功");
                return(RedirectToAction("Index"));
            }

            model.ClientDataList    = GetClientDataList();
            model.WarehouseList     = GetWarehouseList();
            model.SpecificationList = GetSpecificationList();
            model.GoodsTypeList     = GetGoodsTypeList();
            return(View(model));
        }