public int Save(WHStock model) { WHStock _stock = (_context.WHStocks.Where(s => s.PartID == model.PartID && s.PartNum == model.PartNum && s.WarehouseID == model.WarehouseID && s.WarehousePositionID == model.WarehousePositionID).FirstOrDefault() ?? new WHStock()); if (_stock.ID == 0) { _stock.PartNum = model.PartNum; _stock.WarehouseID = model.WarehouseID; _stock.WarehousePositionID = model.WarehousePositionID; //_stock.Qty = model.Qty; _stock.PurchaseType = model.PurchaseType; _stock.StockType = model.StockType; _stock.PartID = model.PartID; _stock.TaskID = model.TaskID; //_stock.InStockQty = model.InStockQty; //_stock.OutStockQty = model.OutStockQty; _stock.FInStockDate = model.FInStockDate; _stock.LInStockDate = model.LInStockDate; _stock.MoldNumber = model.MoldNumber; _stock.Enable = true; _stock.Memo = model.Memo; _context.WHStocks.Add(_stock); } else { _stock.Memo = model.Memo; _stock.LInStockDate = model.LInStockDate; } _context.SaveChanges(); return(_stock.ID); }
public WHRequestItemGridViewModel(IEnumerable <WarehouseRequestItem> Items, IWHStockRepository WHStockRepo) { foreach (WarehouseRequestItem _item in Items) { WHStock _stockItem = WHStockRepo.GetStockByPartNum(_item.PartNumber, _item.PartID); rows.Add(new WHRequestItemGridRowModel(_item, _stockItem)); } }
public decimal GetStockQtyByPart(string PartNum, int PartID = 0) { WHStock _stock = _context.WHStocks.Where(s => s.PartNum == PartNum && s.PartID == PartID).FirstOrDefault(); if (_stock != null) { return(_stock.Qty); } return(0); }
public WarehousePositionEditModel(WHStock StockItem, string name, string WarehouseName, string WarehousePositionName) { StockID = StockItem.ID; Name = name; PartNum = StockItem.PartNum; //MaterialNumber = StockItem.MaterialNumber; WarehouseID = StockItem.WarehouseID; WarehousePositionID = StockItem.WarehousePositionID; Warehouse = WarehouseName; Position = WarehousePositionName; }
public WHPOContentGridViewModel(IEnumerable <PurchaseItem> PurchaseItems , IWarehouseRepository _warehouseRepo , IWarehousePositionRepository _warehousePositonRepo , IWHStockRepository _whstockRepo) { rows = new List <WHPOContentGridRowModel>(); Page = 1; Total = PurchaseItems.Count(); foreach (PurchaseItem _item in PurchaseItems) { string warehoseListStr = string.Empty; string whpositionListStr = string.Empty; WHStock _stock = (_whstockRepo.WHStocks.Where(s => s.PartNum == _item.PartNumber && s.PartID == _item.PartID && s.Enable == true).FirstOrDefault() ?? new WHStock()); if (_stock.ID == 0) { warehoseListStr = "<select id='wh" + _item.PurchaseItemID.ToString() + "' class='form-control'>"; whpositionListStr = "<select id='whposi" + _item.PurchaseItemID.ToString() + "' class='form-control'>"; foreach (var w in _warehouseRepo.Warehouses.ToList()) { if (_stock.WarehouseID == w.WarehouseID) { warehoseListStr = warehoseListStr + "<option value='" + w.WarehouseID.ToString() + "' selected>" + w.Name + "</option>"; } else { warehoseListStr = warehoseListStr + "<option value='" + w.WarehouseID.ToString() + "'>" + w.Name + "</option>"; } } warehoseListStr = warehoseListStr + "</select>"; List <WarehousePosition> _whpositionList = _warehousePositonRepo.QueryByWarehouse(_warehouseRepo.Warehouses.FirstOrDefault().WarehouseID).ToList(); foreach (var p in _whpositionList) { if (_stock.WarehousePositionID == p.WarehousePositionID) { whpositionListStr = whpositionListStr + "<option value='" + p.WarehousePositionID.ToString() + "' selected>" + p.Name + "</option>"; } else { whpositionListStr = whpositionListStr + "<option value='" + p.WarehousePositionID.ToString() + "'>" + p.Name + "</option>"; } } } else { warehoseListStr = "<input id='wh" + _item.PurchaseItemID.ToString() + "' value='" + _stock.WarehouseID.ToString() + "' hidden/> " + _warehouseRepo.QueryByID(_stock.WarehouseID).Name; whpositionListStr = "<input id='whposi" + _item.PurchaseItemID.ToString() + "' value='" + _stock.WarehousePositionID.ToString() + "' hidden/> " + _warehousePositonRepo.QueryByID(_stock.WarehousePositionID).Name; } whpositionListStr = whpositionListStr + "</select>"; rows.Add(new WHPOContentGridRowModel(_item, warehoseListStr, whpositionListStr, _stock)); } }
/// <summary> /// 退货 /// </summary> /// <param name="stockID"></param> /// <param name="_qty"></param> /// <returns></returns> public int StockReturn(int stockID, decimal _qty) { WHStock _stock = _context.WHStocks.Where(s => s.ID == stockID).FirstOrDefault(); if (_stock != null) { _stock.Qty = _stock.Qty - _qty; _stock.InStockQty = _stock.InStockQty - _qty; _context.SaveChanges(); return(1); } return(-99); }
/// <summary> /// 库位调整 /// </summary> /// <param name="model"></param> /// <returns></returns> public int ChangeWHPosition(WHStock model) { WHStock _stock = _context.WHStocks.Where(s => s.ID == model.ID).FirstOrDefault(); if (_stock != null) { _stock.WarehouseID = model.WarehouseID; _stock.WarehousePositionID = model.WarehousePositionID; _context.SaveChanges(); return(0); } return(-99); }
public WarehouseStockGridRowModel(WHStock Stock, WHPart _Part, //string RequestUser, //string PurchaseUser, //string State, string PurchaseType, string StockType, string Warehouse, string WarehousePosition) { //if (PurchaseItem == null) //{ // PurchaseItem = new PurchaseItem(); //} cell = new string[14]; cell[0] = Stock.ID.ToString(); cell[1] = _Part.PartName; cell[2] = _Part.PartNum; cell[3] = _Part.Specification; cell[4] = _Part.Materials; if ((_Part.SafeQuantity > 0) && (Stock.Qty < _Part.SafeQuantity)) { cell[5] = "<font color='#ff0000'>" + Stock.Qty.ToString() + "</font>"; } else { cell[5] = Stock.Qty.ToString(); } cell[6] = _Part.SafeQuantity.ToString(); //cell[7] = PurchaseItem==null?"":PurchaseItem.SupplierName; cell[7] = PurchaseType; cell[8] = StockType; //cell[10] = PurchaseItem == null ? "-" : PurchaseItem.PlanTime.ToString("yy/MM/dd"); //cell[11] = PurchaseItem == null ? "-" : PurchaseItem.RequireTime.ToString("yy/MM/dd"); //cell[12] = PurchaseItem == null ? "-" : PurchaseItem.DeliveryTime.ToString("yy/MM/dd"); //cell[13] = PurchaseItem == null ? "-" : PurchaseItem.CreateTime.ToString("yy/MM/dd"); //cell[14] = Stock.InStockTime.ToString("yy/MM/dd"); //cell[15] = PurchaseUser; //cell[16] = State; cell[9] = Stock.InStockQty.ToString(); cell[10] = Stock.OutStockQty.ToString(); //cell[19] = Stock.PlanQty.ToString(); cell[11] = Warehouse; cell[12] = WarehousePosition; cell[13] = Stock.PartID.ToString(); }
public ReturnItemGridViewModel(List <ReturnItem> ReturnItems, IPurchaseItemRepository POItemRepository, IWHStockRepository StockRepository, int RequestState) { rows = new List <ReturnItemGridRowModel>(); foreach (ReturnItem _item in ReturnItems) { WHStock _stock = StockRepository.QueryByID(_item.WarehouseItemID); PurchaseItem _poItem = POItemRepository.QueryByID(_item.PurchaseItemID); rows.Add(new ReturnItemGridRowModel(_item, _poItem, _stock, RequestState)); } Page = 1; Total = ReturnItems.Count(); Records = ReturnItems.Count(); }
/// <summary> /// Stock item quantity modification /// </summary> /// <param name="WarehouseStockID"></param> /// <param name="Quantity"></param> /// <param name="WarehouseID"></param> /// <param name="Type"> Update Operation Type /// 1:入库 /// 2:出库 /// </param> /// <returns></returns> public int UpdateQuantity(int WarehouseStockID, int Quantity, int WarehouseID = 1) { WHStock _dbEntry = _context.WHStocks.Find(WarehouseStockID); if (_dbEntry != null) { _dbEntry.InStockQty = _dbEntry.InStockQty + Quantity; if (Quantity < 0) { _dbEntry.OutStockQty = _dbEntry.OutStockQty + (-Quantity); } _dbEntry.Qty = _dbEntry.Qty + Quantity; } _dbEntry.LInStockDate = DateTime.Now; _context.SaveChanges(); return(_dbEntry.ID); }
public WHRequestItemGridRowModel(WarehouseRequestItem Item, WHStock _stockItem) { cell = new string[14]; cell[0] = Item.WarehouseRequestItemID.ToString(); cell[1] = Item.PartName; cell[2] = Item.PartNumber; cell[3] = Item.Specification; cell[4] = _stockItem.Qty.ToString(); cell[5] = Item.Quantity.ToString(); cell[6] = Item.ReceivedQuantity.ToString(); cell[7] = Item.ShortQty.ToString(); cell[8] = ""; cell[9] = ""; cell[10] = ""; cell[11] = ""; cell[12] = Item.PartID.ToString(); cell[13] = _stockItem.ID.ToString(); }
public ReturnItemGridRowModel(ReturnItem Item, PurchaseItem POItem, WHStock Stock, int RequestState) { cell = new string[12]; cell[0] = Item.ReturnItemID.ToString(); cell[1] = Item.PurchaseItemID.ToString(); cell[2] = Item.WarehouseItemID.ToString(); cell[3] = Item.Name; cell[4] = Item.MaterialNumber; cell[5] = Item.Specification; cell[6] = POItem.Quantity.ToString(); cell[7] = POItem.InStockQty.ToString(); if (RequestState != 0) { cell[8] = Stock.Qty.ToString(); } else { cell[8] = (Stock.Qty + Item.Quantity).ToString(); } if (Item.Quantity == 0) { if (Stock.Qty > POItem.InStockQty) { cell[9] = POItem.InStockQty.ToString(); } else { cell[9] = Stock.Qty.ToString(); } } else { cell[9] = Item.Quantity.ToString(); } cell[10] = Item.Memo; cell[11] = Item.Enabled.ToString(); }
public int StockIncrease(int stockID, decimal _qty) { //WHStock _stock = _context.WHStocks.Where(s =>s.PartID == model.PartID && s.PartNum == model.PartNum && s.WarehouseID == model.WarehouseID && s.WarehousePositionID == model.WarehousePositionID && s.PurchaseType == model.PurchaseType).FirstOrDefault(); WHStock _stock = _context.WHStocks.Where(s => s.ID == stockID).FirstOrDefault(); if (_stock != null) { _stock.Qty = _stock.Qty + _qty; if (_qty > 0)//入 { _stock.InStockQty = _stock.InStockQty + _qty; } else//出 { _stock.OutStockQty = _stock.OutStockQty + (-_qty); } _context.SaveChanges(); return(1); } return(-99); }
public WHStock GetStockByPartNum(string partNum, int partID) { WHStock _stockItem = (_context.WHStocks.Where(s => s.PartNum == partNum && s.PartID == partID && s.Enable == true).FirstOrDefault() ?? new WHStock()); return(_stockItem); }
public WHPOContentGridRowModel(PurchaseItem PurchaseItem, string warehoseListStr, string whpositionListStr, WHStock _whstock) { cell = new string[12]; cell[0] = PurchaseItem.PurchaseItemID.ToString(); cell[1] = PurchaseItem.Name; cell[2] = PurchaseItem.PartNumber; cell[3] = PurchaseItem.Specification; cell[4] = PurchaseItem.Quantity.ToString(); cell[5] = PurchaseItem.InStockQty.ToString(); cell[6] = "0"; cell[7] = warehoseListStr;//"<select class='form-control'><option>wh1</option></select>"; cell[8] = whpositionListStr; cell[9] = PurchaseItem.PlanTime == new DateTime(1900, 1, 1) ? "" : PurchaseItem.PlanTime.ToString("yyyy-MM-dd"); cell[10] = _whstock.Memo; cell[11] = _whstock.ID.ToString(); }