예제 #1
0
        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); }
        }
예제 #2
0
        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); }
        }
예제 #3
0
        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); }
        }
예제 #4
0
 public ICollection <ShoeComponent> GetShoeComponents(string _shoeModel, string _shoeModelName)
 {
     try
     {
         List <ShoeComponent> ShoeComponents = new List <ShoeComponent>();
         var modelComponent = GetModelComponents(_shoeModel, _shoeModelName);
         foreach (var item in modelComponent)
         {
             ShoeComponents.Add(GetShoeComponent(ShareFuncs.GetInt(item.ShoeComponent_Id)));
         }
         return(ShoeComponents);
     }
     catch { return(null); }
 }
예제 #5
0
        public List <BeamCutSize> GetBeamCutSizes(int seq1Id, int seq2Id)
        {
            try
            {
                List <BeamCutSize> Sizes = new List <BeamCutSize>();

                using (BeamCutContext = new BeamCutContext(database))
                {
                    var currentSeq1 = GetBeamCutSeq(seq1Id);
                    var currentSeq2 = GetBeamCutSeq(seq2Id);
                    if (currentSeq1.BeamCutPo_Id != currentSeq2.BeamCutPo_Id)
                    {
                        return(null);
                    }

                    var clonePo = GetBeamCutPo(ShareFuncs.GetInt(currentSeq1.BeamCutPo_Id));

                    foreach (var seq in clonePo.BeamCutSeqs)
                    {
                        if (seq.SequenceNo >= currentSeq1.SequenceNo && seq.SequenceNo <= currentSeq2.SequenceNo)
                        {
                            var sizes = GetBeamCutSize(seq.id);
                            foreach (var size in sizes)
                            {
                                var ss = Sizes.Where(i => i.SizeId == size.SizeId);
                                if (ss.Count() > 0)
                                {
                                    ss.First().SizeQty += size.SizeQty;
                                    ss.First().CutQty  += size.CutQty;
                                }
                                else
                                {
                                    Sizes.Add(size);
                                }
                            }
                        }
                    }
                }
                return(Sizes);
            }
            catch { return(null); }
        }
예제 #6
0
 public ICollection <ShoeComponent> GetModelComponents(string _shoeModel)
 {
     try
     {
         List <ShoeComponent> results = new List <ShoeComponent>();
         var modelComponents          = GetShoeModel(_shoeModel).ModelComponents;
         int i = 0;
         foreach (var item in modelComponents)
         {
             i++;
             ShoeComponent component = GetShoeComponent(ShareFuncs.GetInt(item.ShoeComponent_Id));
             CuttingType   cuttype   = GetCuttingType(ShareFuncs.GetInt(item.CuttingType_Id));
             component.CuttingType  = cuttype;
             component.Index        = i;
             component.AddToEkanban = true;
             results.Add(component);
         }
         return(results);
     }
     catch { return(null); }
 }
예제 #7
0
 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); }
 }
예제 #8
0
        public int[] GetTotalSelectSequenceQty(BeamCutSeq seq1, BeamCutSeq seq2)
        {
            int total    = 0;
            int totalCut = 0;

            try
            {
                var po = GetBeamCutPo(ShareFuncs.GetInt(seq1.BeamCutPo_Id));
                if (po == null)
                {
                    return(null);
                }
                foreach (var item in po.BeamCutSeqs)
                {
                    if (item.SequenceNo >= seq1.SequenceNo && item.SequenceNo <= seq2.SequenceNo)
                    {
                        total    += ShareFuncs.GetInt(item.SequenceQty);
                        totalCut += ShareFuncs.GetInt(item.CutQty);
                    }
                }
                return(new int[] { total, totalCut });
            }
            catch { return(null); }
        }
예제 #9
0
 public BeamCutPo AddNewBeamCutPo(int?originalPoId, int?componentId)
 {
     return(AddNewBeamCutPo(ShareFuncs.GetInt(originalPoId), ShareFuncs.GetInt(componentId)));
 }
예제 #10
0
        public BeamCutPo CloneOriginalPo(int scheduleId, int componentId)
        {
            try
            {
                SequenceQuery  sequenceQuery  = new SequenceQuery(database);
                ScheduleQuery  scheduleQuery  = new ScheduleQuery(database);
                ComponentQuery componentQuery = new ComponentQuery(database);

                var schedule = scheduleQuery.GetSchedule(scheduleId);
                if (schedule == null)
                {
                    return(null);
                }

                var originalPo = sequenceQuery.GetOriginalPo(schedule);

                if (originalPo == null)
                {
                    return(null);
                }

                if (FindOriginalPo(originalPo.id, componentId))
                {
                    Console.WriteLine("Po is already added\r\nContinue.");
                    return(null);
                }
                // New BeamCutPo
                var beamCutPo = AddNewBeamCutPo(originalPo.id, componentId);

                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, componentId, 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), componentId, 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); }
        }
예제 #11
0
 public BeamCutDevice GetBeamCutDevice(int?bdeviceId)
 {
     return(GetBeamCutDevice(ShareFuncs.GetInt(bdeviceId)));
 }
예제 #12
0
 public BeamCutInterface GetBeamInterfaceByScheduleId(int?_scheduleId)
 {
     return(GetBeamInterfaceByScheduleId(ShareFuncs.GetInt(_scheduleId)));
 }
예제 #13
0
 public OriginalPO GetOriginalPo(EKanbanLoading _ekanbanLoading)
 {
     return(GetOriginalPo(ShareFuncs.GetInt(_ekanbanLoading.OriginalPo_Id)));
 }
예제 #14
0
 public ICollection <BDeviceOrder> GetAllBDeviceOrders(int?deviceId)
 {
     return(GetAllBDeviceOrders(ShareFuncs.GetInt(deviceId)));
 }
예제 #15
0
 public Building GetBuilding(int?_buildingId)
 {
     return(GetBuilding(ShareFuncs.GetInt(_buildingId)));
 }
예제 #16
0
 public BeamCutInterface GetBeamInterfaceById(int?_bInterfaceId)
 {
     return(GetBeamInterfaceById(ShareFuncs.GetInt(_bInterfaceId)));
 }
예제 #17
0
        public List <BeamCutPo> CloneOriginalPo(int scheduleId)
        {
            try
            {
                SequenceQuery  sequenceQuery  = new SequenceQuery(database);
                ScheduleQuery  scheduleQuery  = new ScheduleQuery(database);
                ComponentQuery componentQuery = new ComponentQuery(database);

                var schedule = scheduleQuery.GetSchedule(scheduleId);
                if (schedule == null)
                {
                    return(null);
                }

                var components = componentQuery.GetModelComponents(schedule.Model).Where(i => i.CuttingType.id == 2).ToList();

                if (components == null)
                {
                    return(null);
                }

                var originalPo = sequenceQuery.GetOriginalPo(schedule);

                if (originalPo == null)
                {
                    return(null);
                }

                // make return value
                List <BeamCutPo> PoList = new List <BeamCutPo>();

                foreach (var component in components)
                {
                    if (FindOriginalPo(originalPo.id, component.Id))
                    {
                        Console.WriteLine("Po is already added\r\nContinue.");
                        continue;
                    }
                    // New BeamCutPo
                    var beamCutPo = AddNewBeamCutPo(originalPo.id, component.Id);

                    if (beamCutPo == null)
                    {
                        continue;
                    }

                    // 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, component.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), component.Id, beamCutPo.id);
                            if (beamSize == null)
                            {
                                continue;
                            }
                            // make return value
                            beamSeq.BeamCutSizes.Add(beamSize);
                        }
                        // make return value
                        beamCutPo.BeamCutSeqs.Add(beamSeq);
                    }
                    // make return value
                    PoList.Add(beamCutPo);
                }

                return(PoList);
            }
            catch { return(null); }
        }
예제 #18
0
 public List <BeamCutPo> CloneOriginalPo(int?scheduleId)
 {
     return(CloneOriginalPo(ShareFuncs.GetInt(scheduleId)));
 }
예제 #19
0
 public BeamCutPo GetBeamCutPo(int?clonePoId)
 {
     return(GetBeamCutPo(ShareFuncs.GetInt(clonePoId)));
 }
예제 #20
0
 public ICollection <ProductionLine> GetProductionLines(int?_buildingId)
 {
     return(GetProductionLines(ShareFuncs.GetInt(_buildingId)));
 }
예제 #21
0
 public List <BeamCutSize> GetBeamCutSize(int?beamSeqId)
 {
     return(GetBeamCutSize(ShareFuncs.GetInt(beamSeqId)));
 }
예제 #22
0
 public ProductionLine GetProductionLine(int?_productionLineId)
 {
     return(GetProductionLine(ShareFuncs.GetInt(_productionLineId)));
 }
예제 #23
0
 public BeamCutInterface GetBeamInterfaceByOriginalPo(int?_originalPoId)
 {
     return(GetBeamInterfaceByOriginalPo(ShareFuncs.GetInt(_originalPoId)));
 }
예제 #24
0
        //public OriginalPO GetOriginalPo(BeamCutComponent _beamcutComponent)
        //{
        //    return GetOriginalPo(ShareFuncs.GetInt(_beamcutComponent.OriginalPo_Id));
        //}

        public OriginalPO GetOriginalPo(OriginalPOsequence _originalPOsequence)
        {
            return(GetOriginalPo(ShareFuncs.GetInt(_originalPOsequence.OriginalPO_Id)));
        }
예제 #25
0
 public ICollection <BeamCutPo> GetBeamCutPos(int?originalPoId)
 {
     return(GetBeamCutPos(ShareFuncs.GetInt(originalPoId)));
 }