public StockMeasure AddNewStockMeasure(Schedule _schedule) { try { StockMeasure stockMeasure = new StockMeasure { PoNumber = _schedule.PoNumber, ModelNumber = _schedule.Model, ModelName = _schedule.ModelName, Article = _schedule.Article, PoQuantity = _schedule.Quantity, PreparingTime = DateTime.Now, ProductionLine_Id = _schedule.ProductionLine_Id, ScheduleClass_Id = _schedule.ScheduleClass_Id }; using (StockContext = new StockContext(database)) { StockContext.StockMeasures.Add(stockMeasure); StockContext.SaveChanges(); return(stockMeasure); } } catch { return(null); } }
public bool AddNewStockPreaparing(OriginalPOsequence _sequence, Schedule _schedule) { try { StockMeasure stockMeasure = GetStockMeasure(_schedule); if (stockMeasure == null) { return(false); } using (StockContext = new StockContext(database)) { StockContext.StockPreparing.Add(new StockPreparing { SequenceNo = _sequence.SequenceNo, SequenceQty = _sequence.Quantity, StockMeasure_Id = stockMeasure.id, UpdateTime = DateTime.Now }); StockContext.SaveChanges(); return(true); } } catch { return(false); } }
public StockMeasure AddNewStockMeasureByPrepare(Schedule _schedule, int _totalSequence) { try { StockMeasure stockMeasure = new StockMeasure { PoNumber = _schedule.PoNumber, ModelNumber = _schedule.Model, ModelName = _schedule.ModelName, Article = _schedule.Article, PoQuantity = _schedule.Quantity, TotalSequence = _totalSequence, PreparingTime = DateTime.Now, ProductionLine_Id = _schedule.ProductionLine_Id, PrepareCode = (int)SysActionCode.STOCK_START_PREAPARING, ScheduleClass_Id = _schedule.ScheduleClass_Id, }; using (StockContext = new StockContext(database)) { StockContext.StockMeasures.Add(stockMeasure); StockContext.SaveChanges(); return(stockMeasure); } } catch { return(null); } }
public bool UpdateStockMeasure(StockMeasure _stockMeasure) { try { using (StockContext = new StockContext(database)) { StockContext.Entry(_stockMeasure).State = EntityState.Modified; StockContext.SaveChanges(); return(true); } } catch { return(false); } }
public StockMeasure AddNewStockMeasure(StockMeasure _stockMeasure) { try { using (StockContext = new StockContext(database)) { var result = StockContext.StockMeasures.Add(_stockMeasure); StockContext.SaveChanges(); return(result); } } catch { return(null); } }
public bool DeleteStockMeasure(Schedule _schedule) { try { StockMeasure stockMeasure = GetStockMeasure(_schedule); if (stockMeasure == null) { return(false); } using (StockContext = new StockContext(database)) { StockContext.Entry(stockMeasure).State = EntityState.Deleted; StockContext.SaveChanges(); return(true); } } catch { return(false); } }
// start cutting construction public RespCutting(IDbName database, int deviceId, int workerId, int clonePoId, int seq1Id, int seq2Id, int binterfaceId) { BeamCutQuery = new BeamCutQuery(database); StockQuery = new StockQuery(database); EmployeeQuery = new EmployeeQuery(database); SequenceQuery = new SequenceQuery(database); ScheduleQuery = new ScheduleQuery(database); ComponentQuery = new ComponentQuery(database); try { var worker = EmployeeQuery.GetEmployee(workerId); if (worker == null) { Exception = new RespException(true, "Invalid worker Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var bdevice = BeamCutQuery.GetBeamCutDevice(deviceId); if (bdevice == null) { Exception = new RespException(true, "Invalid device Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var clonePo = BeamCutQuery.GetBeamCutPo(clonePoId); if (clonePo == null) { Exception = new RespException(true, "Invalid clone Po Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var originalPo = SequenceQuery.GetOriginalPo(clonePo.OriginalPo_Id); if (originalPo == null) { Exception = new RespException(true, "Can not find original po", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var component = ComponentQuery.GetShoeComponent(clonePo.Component_Id); if (component == null) { Exception = new RespException(true, "Can not find component", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var schedule = ScheduleQuery.GetSchedule(originalPo); if (schedule == null) { Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var order = BeamCutQuery.GetBDeviceOrder(originalPo, deviceId); var startSeq = BeamCutQuery.GetBeamCutSeq(seq1Id); var stopSeq = BeamCutQuery.GetBeamCutSeq(seq2Id); if (startSeq == null || stopSeq == null) { Exception = new RespException(true, "Invalid clone Seq Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } int[] qty = BeamCutQuery.GetTotalSelectSequenceQty(startSeq, stopSeq); if (qty == null) { qty = new int[] { 0, 0 } } ; int bId = binterfaceId; BeamCutInterface binterface = BeamCutQuery.GetBeamInterfaceById(binterfaceId); int scheduleId = 0; if (schedule != null) { scheduleId = schedule.id; } if (binterface == null) { binterface = new BeamCutInterface { Employee_Id = workerId, BeamCutDevice_Id = deviceId, BeamCutPo_Id = clonePoId, OriginalPo_Id = clonePo.OriginalPo_Id, BeamCutStartSeq_Id = seq1Id, BeamCutStopSeq_Id = seq2Id, TotalSelectedQty = qty[0], TotalSelectCutQty = qty[1], Schedule_Id = scheduleId, StartSeqNo = startSeq.SequenceNo, StopSeqNo = stopSeq.SequenceNo, StartCutTime = DateTime.Now, CuttingQty = 0, BeamCutCounter = 0, BDeviceOrder_Id = order != null ? order.id : 0, }; var beamInterface = BeamCutQuery.AddNewBeamCutInterface(binterface); if (beamInterface == null) { Exception = new RespException(true, "Add new BInterface error", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } bId = beamInterface.id; } StockMeasure stockMeasure = StockQuery.GetStockMeasure(schedule); if (stockMeasure == null) { var stock = StockQuery.AddNewStockMeasure(schedule); } Exception = new RespException(false, "Start cutting: OK", EKB_SYS_REQUEST.BEAM_START_CUTTING); InterfaceId = bId; } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_START_CUTTING); } }