private void btnAdd_Click(object sender, EventArgs e) { if (cmbColumn.SelectedValue != null && cmbRow.SelectedValue != null) { // TODO: add the saving logic here. PalletLocation pl = new PalletLocation(); pl.LoadPalletLocationFor(cmbRack.SelectedValue.ToString(), cmbColumn.SelectedValue.ToString(), cmbRow.SelectedValue.ToString()); //Console.WriteLine(cmbRack.SelectedValue); //Console.WriteLine(cmbColumn.SelectedValue); //pl.LoadPreferredLocationsFor(itemId); //lstPreferredPalletLocation.DataSource = pl.DefaultView; (lstPreferredPalletLocation.DataSource as DataView).Table.Merge(pl.DefaultView.Table, true, MissingSchemaAction.Add); } grpPalletLocation.Visible = false; }
/// <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; }