public void checkSwap() { bool needsSwap = false; PalletGroup swappedPallet = new PalletGroup(this.Length, this.Width, this.Height, this.NumPiece); swappedPallet.SwapDims(); if (this.Length <= 96) { if (this.NumPiece == 1 && this.Width < this.Length) { needsSwap = true; } else if (this.Width > 48 && this.Length <= 48) { needsSwap = true; } else if (this.Length <= 48 && this.Width < this.Length) { needsSwap = true; } else if (PalletCalc.calcLinFeet(swappedPallet, false) < PalletCalc.calcLinFeet(this, false)) { needsSwap = true; } } if (needsSwap) { this.SwapDims(); } }
/************************** * Adding Pallets * ************************/ //adds a pallet to the list based on the current input, needs its own method private void addButton_Click(object sender, EventArgs e) { bool hasZero = false; TextBox[] inputBoxList = new TextBox[5] { piecesTextBox, lengthTextBox, widthTextBox, heightTextBox, weightTextBox }; int[] numBoxArray = new int[5]; hasZero = loadFromInput(inputBoxList, numBoxArray); if (hasZero) { MessageBox.Show("No Field Can Be 0"); } else { PalletGroup newPallet = new PalletGroup(numBoxArray, stackCheckBox.Checked); if (newPallet.checkDims()) { addToPalletList(newPallet); } else { MessageBox.Show("If length exceeds 336in or weight per pallet is over 4000lbs use Exclusive Use rate. If height or width exceed 96in use flatbed"); } } }
//Checks the supplied pallet to see if the dims should be swapped to minimize linear feet //adds the pallet to the ListBox and resets the entry and focus for next entry private void addToPalletList(PalletGroup toAdd) { toAdd.checkSwap(); if (toAdd.Stack && toAdd.Height > 48) { toAdd.Stack = false; MessageBox.Show("Stackable freight cannot exceed 48\""); } boxListBox.Items.Add(toAdd); clearEntryFields(); calcAllButton.Enabled = true; boxListBox.Focus(); boxListBox.SelectedIndex = (boxListBox.Items.Count - 1); }
//calculates the linear feet of all groups in the listbox private int calcAllLinFeet() { int linFeetTotal = 0; int totalWeight = 0; for (int i = 0; i < boxListBox.Items.Count; i++) { PalletGroup j = getPalletAtIndex(i); linFeetTotal += PalletCalc.calcLinFeet(j, false); totalWeight += j.Weight; } if (linFeetTotal < totalWeight / 1000) { return(totalWeight / 1000); } return(linFeetTotal); }
//returns the linear feet for the given pallet group. calcWeight2Feet option //allows to return a pure linear feet if false, or return the greater of calc //by dim or calc by weight if true public static int calcLinFeet(PalletGroup current, bool calcWeight2Feet) { int howManyWide = (current.Width < 96) ? 96 / current.Width : 1; int heightMultiple = 96 / current.Height; int linFeetByWeight = ((int)Math.Ceiling(current.Weight / 1000.00)); int linearFeet; if (current.Stack) { howManyWide *= heightMultiple; } int howManyLong = current.NumPiece / howManyWide; int leftOver = current.NumPiece % howManyWide; int linearInches = (howManyLong * current.Length); if (leftOver > 0) { if (leftOver * current.Length <= 96 && current.Length > current.Width) { linearInches += current.Width; } else { linearInches += current.Length; } } linearFeet = (int)Math.Ceiling((double)linearInches / 12); if (linearFeet < linFeetByWeight && calcWeight2Feet) { return(linFeetByWeight); } return(linearFeet); }
public static string calcClass(PalletGroup current) { double poundsPer = PalletCalc.getPCF(current); if (poundsPer >= 50) { return(50.ToString()); } else if (poundsPer < 50 && poundsPer >= 35) { return(55.ToString()); } else if (poundsPer < 35 && poundsPer >= 30) { return(60.ToString()); } else if (poundsPer < 30 && poundsPer >= 22.5) { return(65.ToString()); } else if (poundsPer < 22.5 && poundsPer >= 15) { return(70.ToString()); } else if (poundsPer < 15 && poundsPer >= 13.5) { return(77.5.ToString()); } else if (poundsPer < 13.5 && poundsPer >= 12) { return(85.ToString()); } else if (poundsPer < 12 && poundsPer >= 10.5) { return(92.5.ToString()); } else if (poundsPer < 10.5 && poundsPer >= 9) { return(100.ToString()); } else if (poundsPer < 9 && poundsPer >= 8) { return(110.ToString()); } else if (poundsPer < 8 && poundsPer >= 7) { return(125.ToString()); } else if (poundsPer < 7 && poundsPer >= 6) { return(150.ToString()); } else if (poundsPer < 6 && poundsPer >= 5) { return(175.ToString()); } else if (poundsPer < 5 && poundsPer >= 4) { return(200.ToString()); } else if (poundsPer < 4 && poundsPer >= 3) { return(250.ToString()); } else if (poundsPer < 3 && poundsPer >= 2) { return(300.ToString()); } else if (poundsPer < 2 && poundsPer >= 1) { return(400.ToString()); } else { return(500.ToString()); } }
public static double getPCF(PalletGroup current) { double cubicFeet = ((current.Length * current.Width * current.Height) * current.NumPiece) / 1728; return(current.Weight / cubicFeet); }
private void calcFreighClass() { PalletGroup current = getPalletAtIndex(boxListBox.SelectedIndex); calcDensityLabel.Text = PalletCalc.calcClass(current); }