Ejemplo n.º 1
0
        private void calcPallet()
        {
            string dept = cmbDepartment.Text;
            int    freePalletID;
            int    oldPalletID;
            double doorNum = Convert.ToDouble(txtDoorNumber.Text);



            Door       d = new Door(doorNum);
            Order      o = new Order(d._orderID, dept);
            Pallet     p = new Pallet(o._belongsToPallet);
            Allocation a = new Allocation(cmbDepartment.Text);

            switch (dept)
            {
            case "Weld":

                //CELOTEX WRAPPER
                if (d._infillID == 8)
                {
                    MessageBox.Show("This door has a Celotex core. Please place in a trolley", "Celotex door", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (o._orderMass > 2)
                    {
                        if (o._belongsToPallet == 0)
                        {
                            frmAllocationType frmAT = new frmAllocationType(false);
                            frmAT.ShowDialog();

                            if (Allocation._getAllocationType == "Manual")
                            {
                                freePalletID = Convert.ToInt32(Allocation._getManualPallet);
                            }
                            else
                            {
                                freePalletID = a._getFreePallet;
                            }

                            //INSERT DOOR RECORD
                            addDoorToPallet(d._doorID, o._orderID, freePalletID, dept);

                            //UPDATE PALLET NUMBER
                            updatePalletStatus(freePalletID);
                            MessageBox.Show("Please add this door number to pallet: " + freePalletID, "Pallet Allocation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            if (p._palletMass + d._doorMass <= Pallet.maxPalletMass)
                            {
                                //ADD TO EXISTING PALLET o._belongsToPallet
                                addDoorToPallet(d._doorID, o._orderID, o._belongsToPallet, dept);

                                MessageBox.Show("Please add this door number to pallet: " + o._belongsToPallet, "Pallet Allocation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                //sets the pallet as not free in buffing as it has doors on it
                                //updatePalletDepartment(o._belongsToPallet, "Buff");
                                frmAllocationType frmAT = new frmAllocationType(false);
                                frmAT.ShowDialog();

                                if (Allocation._getAllocationType == "Manual")
                                {
                                    freePalletID = Convert.ToInt32(Allocation._getManualPallet);
                                }
                                else
                                {
                                    freePalletID = a._getFreePallet;
                                }

                                //INSERT DOOR RECORD
                                addDoorToPallet(d._doorID, o._orderID, freePalletID, dept);

                                //UPDATE PALLET NUMBER
                                updatePalletStatus(freePalletID);


                                MessageBox.Show("Please add this door number to pallet: " + freePalletID, "Pallet Allocation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                    else if (d._infillID != 3)
                    {
                        //UNSURE

                        frmAllocationType frmAT = new frmAllocationType(true);
                        frmAT.ShowDialog();

                        if (Allocation._getAllocationType == "Manual")
                        {
                            freePalletID = Convert.ToInt32(Allocation._getManualPallet);
                        }
                        else
                        {
                            freePalletID = a._getFreePallet;
                        }

                        //INSERT DOOR RECORD
                        addDoorToPallet(d._doorID, o._orderID, freePalletID, dept);

                        //UPDATE PALLET NUMBER
                        updatePalletStatus(freePalletID);
                        MessageBox.Show("Please add this door number to pallet: " + freePalletID, "Pallet Allocation", MessageBoxButtons.OK, MessageBoxIcon.Information);


                        ////
                    }
                    else
                    {
                        MessageBox.Show("This door can be placed in the racking.", "Place in racking", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }


                break;

            case "Buff":

                //UPDATES THE PALLET TO THE BUFFING DEPARTMENT
                o._dept     = "Weld";
                oldPalletID = d._belongsToPallet;
                updatePalletDepartment(d._belongsToPallet, o._dept);
                //DELETE DOOR FROM PREVIOUS OPERATION PALLET
                d.removeFromExistingPallet();
                //CHECK IF PALLET IS NOW FREE
                p._palletID = oldPalletID;


                //ONLY RUN IF THE PALLET IS EMPTY
                if (p.isPalletEmpty() == true)
                {
                    p.emptyPallet();
                    updatePalletDepartment(p._palletID, "Weld");
                }

                o._dept     = "Buff";
                p._palletID = o._belongsToPallet;

                if (o._orderMass > 2)
                {
                    if (o._belongsToPallet == 0)
                    {
                        frmAllocationType frmAT = new frmAllocationType(false);
                        frmAT.ShowDialog();

                        if (Allocation._getAllocationType == "Manual")
                        {
                            freePalletID = Convert.ToInt32(Allocation._getManualPallet);
                        }
                        else
                        {
                            freePalletID = a._getFreePallet;
                        }
                        //INSERT DOOR RECORD
                        addDoorToPallet(d._doorID, o._orderID, freePalletID, dept);

                        //UPDATE PALLET NUMBER
                        updatePalletStatus(freePalletID);
                        MessageBox.Show("Please add this door number to pallet: " + freePalletID, "Pallet Allocation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        if (p._palletMass + d._doorMass <= Pallet.maxPalletMass)
                        {
                            //ADD TO EXISTING PALLET o._belongsToPallet
                            addDoorToPallet(d._doorID, o._orderID, o._belongsToPallet, dept);

                            MessageBox.Show("Please add this door number to pallet: " + o._belongsToPallet, "Pallet Allocation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            //sets the pallet as not free in buffing as it has doors on it
                            //updatePalletDepartment(o._belongsToPallet, "Buff");

                            frmAllocationType frmAT = new frmAllocationType(false);
                            frmAT.ShowDialog();

                            if (Allocation._getAllocationType == "Manual")
                            {
                                freePalletID = Convert.ToInt32(Allocation._getManualPallet);
                            }
                            else
                            {
                                freePalletID = a._getFreePallet;
                            }
                            //INSERT DOOR RECORD
                            addDoorToPallet(d._doorID, o._orderID, freePalletID, dept);

                            //UPDATE PALLET NUMBER
                            updatePalletStatus(freePalletID);


                            MessageBox.Show("Please add this door number to pallet: " + freePalletID, "Pallet Allocation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else if (d._infillID != 3)
                {
                    //UNSURE

                    frmAllocationType frmAT = new frmAllocationType(true);
                    frmAT.ShowDialog();

                    if (Allocation._getAllocationType == "Manual")
                    {
                        freePalletID = Convert.ToInt32(Allocation._getManualPallet);
                    }
                    else
                    {
                        freePalletID = a._getFreePallet;
                    }

                    //INSERT DOOR RECORD
                    addDoorToPallet(d._doorID, o._orderID, freePalletID, dept);

                    //UPDATE PALLET NUMBER
                    updatePalletStatus(freePalletID);
                    MessageBox.Show("Please add this door number to pallet: " + freePalletID, "Pallet Allocation", MessageBoxButtons.OK, MessageBoxIcon.Information);


                    ////
                }
                else
                {
                    //MessageBox.Show("This door can be placed in the racking.", "Place in racking", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }



                break;

            case "Paint":


                //UPDATES THE PALLET TO THE Painting DEPARTMENT
                o._dept     = "Buff";
                oldPalletID = d._belongsToPallet;
                o._dept     = "Paint";
                updatePalletDepartment(d._belongsToPallet, o._dept);
                o._dept = "Buff";
                //DELETE DOOR FROM PREVIOUS OPERATION PALLET
                d.removeFromExistingPallet();
                //CHECK IF PALLET IS NOW FREE
                p._palletID = oldPalletID;

                //ONLY RUN IF THE PALLET IS EMPTY
                if (p.isPalletEmpty() == true)
                {
                    p.emptyPallet();
                    //updatePalletDepartment(p._palletID,"Weld");
                }


                break;

            default:
                break;
            }


            this.c_view_palletizer_visual_doorTableAdapter.Fill(this.order_databaseDataSet.c_view_palletizer_visual_door);
            this.c_view_palletizer_visualTableAdapter.Fill(this.order_databaseDataSet.c_view_palletizer_visual);
            dgVisual.Refresh();
            dgVisualDoor.Refresh();
            //commented out due to automation issues
            // if (cmbDepartment.Text == "Paint")
            // {
            //   Application.Exit();
            //}

            //Allocation a = new Allocation();
            //MessageBox.Show(a.getFreePallet(cmbDepartment.Text).ToString());
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            frmAllocationType frmAT = new frmAllocationType(false);

            frmAT.ShowDialog();
        }