private void cmbRack_SelectedIndexChanged(object sender, EventArgs e) { ShelfRowColumn src = new ShelfRowColumn(); if (cmbRack.SelectedValue != null) { int shelfID = int.Parse(cmbRack.SelectedValue.ToString()); src.LoadColumnsForShelf(shelfID); cmbColumn.DataSource = src.DefaultView; cmbColumn.Enabled = true; src.LoadRowsForShelf(shelfID); cmbRow.DataSource = src.DefaultView; cmbRow.Enabled = true; } }
/// <summary> /// Gets the percentage grid for. /// </summary> /// <param name="shelfID">The shelf ID.</param> /// <returns></returns> public static DataTable GetPercentageGridFor(int shelfID) { // create the table DataTable dtbl = new DataTable(); ShelfRowColumn src = new ShelfRowColumn(); src.LoadColumnsForShelf(shelfID); while (!src.EOF) { dtbl.Columns.Add(src.Label, typeof(float)); src.MoveNext(); } ShelfRowColumn srcrows = new ShelfRowColumn(); srcrows.LoadRowsForShelf(shelfID); PalletLocation pl = new PalletLocation(); while (!srcrows.EOF) { src.Rewind(); DataRowView drv = dtbl.DefaultView.AddNew(); while (!src.EOF) { pl.LoadPalletLocationFor(shelfID, src.Index, srcrows.Index); if (pl.RowCount > 0) { { if (pl.IsColumnNull("PalletID")) { pl.UsedVolume = 0; } else { Pallet p = new Pallet(); p.LoadByPrimaryKey(pl.PalletID); pl.UsedVolume = p.CalculateCurrentVolume(pl.PalletID); pl.Save(); } } pl.PercentUsed = pl.AvailableVolume == 0 ? 0 : Convert.ToDouble((pl.UsedVolume / pl.AvailableVolume) * 100); pl.Save(); drv[src.Label] = pl.PercentUsed; } src.MoveNext(); } srcrows.MoveNext(); } return dtbl; }