private void Draw() { try { OriginalPo = SequenceQuery.GetOriginalPo(Schedule); LoaderPanel.Controls.Clear(); SizeCtrl Sviewer = new SizeCtrl(null, true); LoaderPanel.Controls.Add(Sviewer); foreach (var s in OriginalPo.OriginalPOsequences) { Sviewer = new SizeCtrl(s, false); LoaderPanel.Controls.Add(Sviewer); } } catch { } int hedaderHeigth = 100; if (!header) { hedaderHeigth = 0; } if (OriginalPo.OriginalPOsequences != null) { this.Height = OriginalPo.OriginalPOsequences.Count * 23 + hedaderHeigth; } this.Width = 1000; }
private void UpdateOgiginalSequence() { try { SelectedOriginalPo = SequenceQuery.GetOriginalPo(SelectedSchedule); DS_Sequence.DataSource = SequenceQuery.GetOriginalSequence(SelectedSchedule); } catch { } }
public bool AddNewOriginalPo(OriginalPO _originalPo) { try { using (SequenceContext = new SequenceContext(database)) { SequenceContext.OriginalPOes.Add(_originalPo); SequenceContext.SaveChanges(); return(true); } } catch { return(false); } }
public BeamCutPo CloneOriginalPo(OriginalPO originalPo, ShoeComponent shoeComponent) { try { SequenceQuery sequenceQuery = new SequenceQuery(database); ScheduleQuery scheduleQuery = new ScheduleQuery(database); ComponentQuery componentQuery = new ComponentQuery(database); // New BeamCutPo var beamCutPo = AddNewBeamCutPo(originalPo, shoeComponent); if (beamCutPo == null) { Console.WriteLine("Can not add new beam cut po"); return(null); } // make return value beamCutPo.BeamCutSeqs = new List <BeamCutSeq>(); foreach (var seq in originalPo.OriginalPOsequences) { var currentSeq = sequenceQuery.GetOriginalSequence(seq.id); //New BeamCutSeq var beamSeq = AddNewBeamSeq(currentSeq, shoeComponent.Id, beamCutPo.id); if (beamSeq == null) { continue; } // make return value beamSeq.BeamCutSizes = new List <BeamCutSize>(); foreach (var size in currentSeq.OriginalSizes) { var beamSize = AddNewBeamSize(size, beamSeq.id, ShareFuncs.GetInt(beamSeq.SequenceNo), shoeComponent.Id, beamCutPo.id); if (beamSize == null) { continue; } // make return value beamSeq.BeamCutSizes.Add(beamSize); } // make return value beamCutPo.BeamCutSeqs.Add(beamSeq); } // make return value return(beamCutPo); } catch { return(null); } }
public OriginalPO GetOriginalPo(OriginalPO _originalPo) { try { using (SequenceContext = new SequenceContext(database)) { return(SequenceContext.OriginalPOes .Where(i => i.PoNumber == _originalPo.PoNumber && i.ModelName == _originalPo.ModelName && i.Article == _originalPo.Article && i.Quantity == _originalPo.Quantity ).First()); } } catch { return(null); } }
public bool UpdateOriginalPo(OriginalPO _originalPo) { try { using (SequenceContext = new SequenceContext(database)) { var po = SequenceContext.OriginalPOes.Find(_originalPo.id); po.ProductionLine_Id = _originalPo.ProductionLine_Id; po.Article = _originalPo.Article; SequenceContext.Entry(po).State = EntityState.Modified; SequenceContext.SaveChanges(); return(true); } } catch { return(false); } }
public BDeviceOrder GetBDeviceOrder(OriginalPO po, int machineId) { try { using (BeamCutContext = new BeamCutContext(database)) { return(BeamCutContext.BDeviceOrders .Where(i => i.BeamCutDevice_Id == machineId && i.PoNumber == po.PoNumber && i.ProductionLine_Id == po.ProductionLine_Id && i.PoQty == po.Quantity) .First()); } } catch { return(null); } }
public SequenceCtrl(Schedule _schedule, bool _displayHeader) { InitializeComponent(); header = _displayHeader; Schedule = new Schedule(); if (Schedule != null) { Schedule = ScheduleQuery.GetSchedule(_schedule.id); ds_schedule.DataSource = Schedule; var ProductionLine = BuildingQuery.GetProductionLine(ShareFuncs.GetInt(Schedule.ProductionLine_Id)); txProductionLine.Text = ProductionLine.LineName; txtUpdateTime.Text = Schedule.ScheduleClass.LastModified.ToString("hh::mm: tt, dd/MM/yyyy"); } OriginalPo = new OriginalPO(); Draw(); }
/// <summary> /// Read Po from excel file /// </summary> /// <param name="_row"></param> /// <returns></returns> public OriginalPO Handle_getOriginalPO(int _row) { var new_po = new OriginalPO(); try { string po = OleDb_readCellValue(_row, ExcelColumnDef.PoCol); string extend = OleDb_readCellValue(_row, ExcelColumnDef.ExtendCol); new_po.Line = OleDb_readCellValue(_row, ExcelColumnDef.ProductionLineCol); new_po.PoNumber = po + extend; if (ExcelColumnDef.EnableArtilce) { new_po.Article = OleDb_readCellValue(_row, ExcelColumnDef.ArticleCol); } if (ExcelColumnDef.EnableModelCol) { new_po.Model = OleDb_readCellValue(_row, ExcelColumnDef.ModelNumberCol); } if (ExcelColumnDef.EnableModelName) { new_po.ModelName = OleDb_readCellValue(_row, ExcelColumnDef.ModelNameCol); } if (ExcelColumnDef.EnableCuttingDate) { new_po.CuttingDate = OleDb_readCellValue(_row, ExcelColumnDef.CuttingDateCol); } if (ExcelColumnDef.EnableStitchingDate) { new_po.StitchingDate = OleDb_readCellValue(_row, ExcelColumnDef.StitchingDateCol); } } catch { } return(new_po); }
public Schedule GetSchedule(OriginalPO _originalPo) { try { using (ScheduleContext = new ScheduleContext(database)) { return(ScheduleContext.Schedules .Where(i => i.PoNumber == _originalPo.PoNumber //&& i.ModelName.ToUpper().Trim() == _originalPo.ModelName.ToUpper().Trim() && i.ProductionLine_Id == _originalPo.ProductionLine_Id && i.Quantity == _originalPo.Quantity) //&& i.Article.ToUpper().Trim() == _originalPo.Article.ToUpper().Trim()) .First()); } } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }
public BeamCutPo AddNewBeamCutPo(OriginalPO originalPo, ShoeComponent shoeComponent) { try { using (BeamCutContext = new BeamCutContext(database)) { var result = BeamCutContext.BeamCutPos.Add(new BeamCutPo { OriginalPo_Id = originalPo.id, PoNumber = originalPo.PoNumber, PoQuantity = ShareFuncs.GetInt(originalPo.Quantity), ProductionLine_Id = ShareFuncs.GetInt(originalPo.ProductionLine_Id), Finish = false, CuttingQuantity = 0, ComponentRef = shoeComponent.Reference, Component_Id = shoeComponent.Id }); BeamCutContext.SaveChanges(); return(result); } } catch { return(null); } }
private void UpdateSelectedSchedule() { SelectedOriginalPo = new OriginalPO(); SelectedSchedule = new Schedule(); SelectedSequence = new OriginalPOsequence(); SelectedScheduleLine = string.Empty; txtProductionLine.Text = string.Empty; if (lbSchedule.SelectedItem == null) { return; } SelectedSchedule = ScheduleQuery.GetSchedule((lbSchedule.SelectedItem as Schedule).id); SelectedProductionLine = BuildingQuery.GetProductionLine(ShareFuncs.GetInt(SelectedSchedule.ProductionLine_Id)); txtProductionLine.Text = SelectedScheduleLine = SelectedProductionLine.LineName; UpdateModelComponent(); UpdateOgiginalSequence(); }
/// <returns> /// 0 not found => add new /// 1 diff article >> update /// 2 diff productionline >> update line Id /// 3 same po same article same modelname same qty >> skip /// </returns> public int CheckOriginalPo(OriginalPO _originalPo) { try { using (SequenceContext = new SequenceContext(database)) { var po1 = SequenceContext.OriginalPOes .Where(i => i.PoNumber == _originalPo.PoNumber && i.ModelName == _originalPo.ModelName && i.Article == _originalPo.Article && i.Quantity == _originalPo.Quantity && i.ProductionLine_Id == _originalPo.ProductionLine_Id); if (po1.Count() > 0) { return(3); } var po2 = SequenceContext.OriginalPOes .Where(i => i.PoNumber == _originalPo.PoNumber && i.ModelName == _originalPo.ModelName && i.Article == _originalPo.Article && i.Quantity == _originalPo.Quantity && i.ProductionLine_Id != _originalPo.ProductionLine_Id); if (po2.Count() > 0) { var po22 = po2.First(); po22.ProductionLine_Id = _originalPo.ProductionLine_Id; if (UpdateOriginalPo(po22)) { return(2); } else { return(4); } } var po3 = SequenceContext.OriginalPOes .Where(i => i.PoNumber == _originalPo.PoNumber && i.ModelName == _originalPo.ModelName && i.Article != _originalPo.Article && i.Quantity == _originalPo.Quantity && i.ProductionLine_Id == _originalPo.ProductionLine_Id); if (po3.Count() > 0) { var po33 = po3.First(); po33.Article = _originalPo.Article; if (UpdateOriginalPo(po33)) { return(1); } else { return(5); } } return(0); } } catch { return(0); } }
public SequenceCtrl() { InitializeComponent(); OriginalPo = new OriginalPO(); }