예제 #1
0
 public ShoeComponent AddNewShoeComponent(ShoeComponent _shoeComponent)
 {
     try
     {
         using (ShoeContext = new ShoeContext(database))
         {
             _shoeComponent = ShoeContext.ShoeComponents.Add(_shoeComponent);
             ShoeContext.SaveChanges();
             return(_shoeComponent);
         }
     }
     catch { return(null); }
 }
예제 #2
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); }
        }
예제 #3
0
        public ShoeComponent GetAndAddShoeComponent(ShoeComponent _shoeComponent)
        {
            try
            {
                ShoeComponent shoeComponent = GetShoeComponent(_shoeComponent.Reference);

                if (shoeComponent == null)
                {
                    shoeComponent = AddNewShoeComponent(_shoeComponent);
                }

                return(shoeComponent);
            }
            catch { return(null); }
        }
예제 #4
0
        public ShoeComponent GetAndAddShoeComponent(string _shoeComponentRef)
        {
            try
            {
                ShoeComponent shoeComponent = GetShoeComponent(_shoeComponentRef);

                if (shoeComponent == null)
                {
                    shoeComponent = AddNewShoeComponent(new ShoeComponent {
                        Reference = _shoeComponentRef
                    });
                }

                return(shoeComponent);
            }
            catch { return(null); }
        }
예제 #5
0
 public ShoeComponent AddNewShoeComponent(string _shoeComponentRef)
 {
     try
     {
         using (ShoeContext = new ShoeContext(database))
         {
             ShoeComponent shoeComponent = new ShoeComponent
             {
                 Reference = _shoeComponentRef,
             };
             var result = ShoeContext.ShoeComponents.Add(shoeComponent);
             ShoeContext.SaveChanges();
             return(result);
         }
     }
     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 Component_t(ShoeComponent _component)
 {
     id   = _component.Id;
     Name = ShareFuncs.ConvertToUnSign(_component.Reference);
 }
예제 #9
0
        // handle update component to database
        private void Handle_CuttingComponents(DataTable table, bool auto_cut)
        {
            string Select_ModelName = "";
            int    initial_row      = 4;

            string cutting_type = "auto";

            if (!auto_cut)
            {
                cutting_type        = "beam";
                initial_row         = 2;
                unblock.TotalModel2 = 0;
            }
            else
            {
                unblock.TotalModel1 = 0;
            }

            BeginInvoke(new MethodInvoker(() =>
            {
                lb_Exeption2.Text    = "...";
                progressBar2.Value   = 0;
                progressBar2.Maximum = table.Rows.Count - initial_row;
            }));

            for (int i = initial_row; i < table.Rows.Count; i++)
            {
                BeginInvoke(new MethodInvoker(() =>
                {
                    progressBar2.Value++;
                    lb_TotalModel1.Text = unblock.TotalModel1.ToString();
                    lb_TotalModel2.Text = unblock.TotalModel2.ToString();
                }));

                var    row                  = table.Rows[i];
                object model_name           = row[1]; // model name column
                object model                = row[2]; // model column
                object first_component_cell = row[5]; // first column of parts
                object samemodel            = row[4]; // first column of parts
                object articleCell          = row[5];

                if (model_name != null)
                {
                    if (model_name.ToString() != "")
                    {
                        Select_ModelName = model_name.ToString();
                    }
                }

                if (model != null && model.ToString() != "")
                {
                    ShoeModel Select_Model = new ShoeModel
                    {
                        Model_Number = model.ToString().Trim().ToUpper(),
                        Model_Name   = Select_ModelName.Trim().ToUpper()
                    };


                    Select_Model = unblock.ComponentQuery.GetAndAddShoeModel(Select_Model);

                    if (Select_Model == null)
                    {
                        continue;
                    }

                    if (auto_cut)
                    {
                        unblock.TotalModel1++;
                    }
                    else
                    {
                        unblock.TotalModel2++;
                    }

                    if (first_component_cell != null && first_component_cell.ToString() != "")
                    {
                        List <ShoeComponent> Select_Components = new List <ShoeComponent>();
                        for (int c = 0; c < 30; c++)
                        {
                            if (row[c + 5] != null)
                            {
                                string cellvalue = row[c + 5].ToString().Trim();

                                // break out from the for loop
                                if (cellvalue == "" ||
                                    cellvalue == " " ||
                                    cellvalue == "  " ||
                                    cellvalue.IndexOf("  ") > -1)
                                {
                                    break;
                                }

                                ShoeComponent shoeComponent = unblock.ComponentQuery.GetAndAddShoeComponent(cellvalue.Trim());
                                if (shoeComponent != null)
                                {
                                    Select_Components.Add(shoeComponent);
                                }
                            }
                        }

                        CuttingType ctype = unblock.ComponentQuery.GetCuttingType(cutting_type);

                        if (Select_Components.Count > 0)
                        {
                            foreach (ShoeComponent c in Select_Components)
                            {
                                unblock.ComponentQuery.AddNewModelComponent(Select_Model.Id, c.Id, ctype.id);
                            }
                        }
                    }
                }
                BeginInvoke(new MethodInvoker(() =>
                {
                    lb_Exeption2.Text = $"{progressBar2.Value * 100 / progressBar2.Maximum} %";
                }));
            }
        }