public int Save(WHPart model) { WHPart dbEntry = _context.WHParts.Where(p => p.PartNum == model.PartNum && p.PartID == model.PartID).FirstOrDefault(); if (dbEntry == null) { model.Enable = true; _context.WHParts.Add(model); } else { dbEntry.PartNum = model.PartNum; dbEntry.PartName = model.PartName; dbEntry.Specification = model.Specification; dbEntry.SafeQuantity = model.SafeQuantity; dbEntry.Materials = model.Materials; dbEntry.StockTypes = model.StockTypes; dbEntry.PurchaseType = model.PurchaseType; dbEntry.MoldNumber = model.MoldNumber; dbEntry.Enable = model.Enable; dbEntry.PlanQty = model.PlanQty; } _context.SaveChanges(); return(1); }
/// <summary> /// 外发任务 物料编号 生成外发采购物料时引用 /// </summary> /// <param name="_taskID"></param> /// <returns></returns> public string GetwfTaskPartNum(int _taskID) { WHPart _wfwhPart = GetwfTaskPart(_taskID); Entity.Task _task = _context.Tasks.Where(t => t.TaskID == _taskID).FirstOrDefault(); var _sObj = _context.Sequences.Where(s => s.Name == "WFPartNum").FirstOrDefault(); if (_sObj != null) { if (_wfwhPart != null) { return(_wfwhPart.PartNum); } else { List <WHPart> _wfparts = GetwfWHPartByMoldNum(_task.MoldNumber).OrderBy(p => p.CreDate).ToList(); int num; if (_wfparts.Count > 0) { string _partNums = _wfparts.Select(p => p.PartNum).Max(); var _partNumArry = _partNums.Split('-'); num = Convert.ToInt32(_partNumArry[1].Substring(1, _partNumArry[1].Length - 1)) + 1; } else { num = 1; } string _fLetter = _sObj.NameConvension.Substring(0, 1); //Z string _ZeroList = _sObj.NameConvension.Substring(1, _sObj.NameConvension.Length - 1); //000 string _strNum = string.Format("{0:" + _ZeroList + "}", num); //001 return(_task.MoldNumber + "-" + _fLetter + _strNum); //xxxxxx-Z001 } } return(null); }
public int Delete(WHPart model) { WHPart _part = _context.WHParts.Where(p => p.PartNum == model.PartNum && p.PartID == model.PartID && p.Enable == true).FirstOrDefault(); if (_part != null) { _part.Enable = false; _context.SaveChanges(); return(1); } return(-99); }
/// <summary> /// 根据任务获取该任务 外发零件 PartName唯一 /// </summary> /// <param name="_taskID"></param> /// <returns></returns> public WHPart GetwfTaskPart(int _taskID) { Entity.Task _task = _context.Tasks.Where(t => t.TaskID == _taskID).FirstOrDefault(); string _wfPartname = _task.TaskName + "_" + _task.ProcessName + "(V" + string.Format("{0:00}", _task.Version) + ")"; WHPart _whpart = _context.WHParts.Where(p => p.PartName == _wfPartname && p.Enable == true).FirstOrDefault(); if (_whpart != null) { return(_whpart); } return(null); }
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 WarehouseStockGridViewModel(List <WHStock> StockItems, IUserRepository UserRepo, IPurchaseItemRepository PurchaseItemRepo, IPurchaseTypeRepository PurchaseTypeRepo, IStockTypeRepository StockTypeRepo, IWarehouseRepository WarehouseRepo, IWarehousePositionRepository WarehousePositionRepo, IWHPartRepository WHPartRepository) { string UserName, PurchaseUserName, WarehouseUserName, PurchaseType, StockType, Warehouse, WarehousePosition; foreach (var _item in StockItems) { //PurchaseItem _purchaseItem = PurchaseItemRepo.QueryByID(_item.PurchaseItemID); try { //UserName = UserRepo.GetUserByID(_item.RequestUserID).FullName; UserName = ""; } catch { UserName = ""; } try { //PurchaseUserName = UserRepo.GetUserByID(_purchaseItem.PurchaseUserID).FullName; PurchaseUserName = ""; } catch { PurchaseUserName = ""; } try { //WarehouseUserName = UserRepo.GetUserByID(_item.WarehouseUserID).FullName; WarehouseUserName = ""; } catch { WarehouseUserName = ""; } try { PurchaseType = PurchaseTypeRepo.QueryByID(_item.PurchaseType).Name; } catch { PurchaseType = ""; } try { var _PartNumStrs = _item.PartNum.Split('-'); StockType = StockTypeRepo.StockTypes.Where(s => s.Code == _PartNumStrs[0]).FirstOrDefault().Name;//StockTypeRepo.QueryByID(_item.StockType).Name; } catch { StockType = ""; } try { Warehouse = WarehouseRepo.QueryByID(_item.WarehouseID).Name; } catch { Warehouse = ""; } try { WarehousePosition = WarehousePositionRepo.QueryByID(_item.WarehousePositionID).Name; } catch { WarehousePosition = ""; } WHPart _part1 = WHPartRepository.GetPart(_item.PartNum, _item.PartID) ?? new WHPart(); rows.Add(new WarehouseStockGridRowModel(_item, _part1, //UserName, //PurchaseUserName, //WarehouseUserName, PurchaseType, StockType, Warehouse, WarehousePosition)); } }
public WHPart GetPart(string _partNum, int PartID = 0) { WHPart _part = _context.WHParts.Where(p => p.PartNum == _partNum && p.PartID == PartID && p.Enable == true).FirstOrDefault(); return(_part); }