public ICollection <BDeviceOrder> AddNewOrder(BDeviceOrder BDeviceOrder) { try { var orders = GetBDeviceOrders(ShareFuncs.GetInt(BDeviceOrder.BeamCutDevice_Id)); int place = 0; if (orders != null) { var temp = orders.OrderByDescending(i => i.Place); if (temp.Count() > 0) { place = ShareFuncs.GetInt(temp.First().Place) + 1; } else { place = 0; } } else { place = 0; } BDeviceOrder.Place = place; using (BeamCutContext = new BeamCutContext(database)) { BeamCutContext.BDeviceOrders.Add(BDeviceOrder); BeamCutContext.SaveChanges(); } return(GetBDeviceOrders(ShareFuncs.GetInt(BDeviceOrder.BeamCutDevice_Id))); } catch { return(null); } }
private void btnAddOrder_Click(object sender, EventArgs e) { try { var currentSchedule = DS_Schedule.Current as Schedule; var currentDevice = DS_BDevice.Current as BeamCutDevice; var currentLine = DS_Line.Current as ProductionLine; if (MessageBox.Show($"Do you really want to add PO: {currentSchedule.PoNumber} to device: {currentDevice.Name}", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } BDeviceOrder BDeviceOrder = new BDeviceOrder { AddPeople_Id = CurrentUser.id, BeamCutDevice_Id = currentDevice.id, PoNumber = currentSchedule.PoNumber, PoQty = currentSchedule.Quantity, ProductionLine_Id = currentLine.id, Schedule_Id = currentSchedule.id, OrderDate = DateTime.Now, }; var orders = BeamCutQuery.AddNewOrder(BDeviceOrder); if (orders != null) { MachineProgressViewer.UpdateOrderViewer(orders); } } catch (Exception ex) { } }
public void UpdateOrderDetail(BDeviceOrder order) { try { TotalCutQty = 0; lbTotalQty.Text = ""; if (order != null) { BMachineLoader.Controls.Clear(); var po = SequenceQuery.GetOriginalPo(order); var BeamPos = BeamCutQuery.GetBeamCutPos(po.id); if (BeamPos != null) { int i = 0; foreach (var item in BeamPos) { OrderResult orderResult = new OrderResult(item); TotalCutQty += orderResult.TotalCutQty; BMachineLoader.Controls.Add(orderResult, 0, i); i++; } } } lbTotalCut.Text = TotalCutQty.ToString(); label1.Text = order.PoNumber; lbTotalQty.Text = order.PoQty.ToString(); } catch { } }
public ICollection <BDeviceOrder> MoveOrder(BDeviceOrder _order, int moveType = 1)// 2 : move down { try { using (BeamCutContext = new BeamCutContext(database)) { var order = BeamCutContext.BDeviceOrders.Find(_order.id); int oldPlace = ShareFuncs.GetInt(order.Place); BDeviceOrder changeOrder = new BDeviceOrder(); switch (moveType) { case 2: //move down var porder1 = BeamCutContext.BDeviceOrders.Where(i => i.Place == oldPlace + 1); if (porder1.Count() > 0) { changeOrder = porder1.First(); } else { return(null); } break; default: // move up int place = oldPlace >= 0 ? oldPlace - 1 : 0; if (place < 0) { place = 0; } var porder2 = BeamCutContext.BDeviceOrders.Where(i => i.Place == place); if (porder2.Count() > 0) { changeOrder = porder2.First(); } else { return(null); } break; } order.Place = changeOrder.Place; BeamCutContext.Entry(order).State = System.Data.Entity.EntityState.Modified; BeamCutContext.SaveChanges(); changeOrder.Place = oldPlace; BeamCutContext.Entry(changeOrder).State = System.Data.Entity.EntityState.Modified; BeamCutContext.SaveChanges(); string date = DateTime.Now.ToString("dd/MM/yyyy"); return(BeamCutContext.BDeviceOrders.Where(i => i.Date == date).OrderBy(i => i.Place).ToList()); } } catch { return(null); } }
private void lbBmachineOrder_MouseClick(object sender, MouseEventArgs e) { if (lbBmachineOrder.SelectedItem == null) { return; } BDeviceOrder order = lbBmachineOrder.SelectedItem as BDeviceOrder; UpdateOrderDetail(order); }
public OriginalPO GetOriginalPo(BDeviceOrder bDeviceOrder) { try { using (SequenceContext = new SequenceContext(database)) { return(SequenceContext.OriginalPOes .Where(i => i.PoNumber == bDeviceOrder.PoNumber && i.ProductionLine_Id == bDeviceOrder.ProductionLine_Id && i.Quantity == bDeviceOrder.PoQty ).First()); } } catch { return(null); } }
public ICollection <BDeviceOrder> DeleteOrder(BDeviceOrder _order) { try { using (BeamCutContext = new BeamCutContext(database)) { string date = _order.Date; var order = BeamCutContext.BDeviceOrders.Find(_order.id); BeamCutContext.BDeviceOrders.Remove(order); BeamCutContext.SaveChanges(); return(BeamCutContext.BDeviceOrders.Where(i => i.Date == date).ToList()); } } catch { return(null); } }
public Schedule GetSchedule(BDeviceOrder bDeviceOrder) { try { using (ScheduleContext = new ScheduleContext(database)) { return(ScheduleContext.Schedules.Where( i => i.PoNumber == bDeviceOrder.PoNumber && i.Quantity == bDeviceOrder.PoQty && i.ProductionLine_Id == bDeviceOrder.ProductionLine_Id //&& i.ScheduleClass_Id == bDeviceOrder.ScheduleClass_Id ).First()); } } catch { return(null); } }