private void lookUpEdit1_EditValueChanged(object sender, EventArgs e)
        {
            selectedRackID = Convert.ToInt32(lkRackID2.EditValue);
            //gridControl1.DataSource = null;
            //gridView1.Columns.Clear();

            BackgroundWorker bw = new BackgroundWorker();
            bw.WorkerReportsProgress = true;
            DataTable dtbl = PalletLocation.GetIDItemDataTableFor(selectedRackID, bw);

            gridView2.Columns.Clear();

            ShelfRowColumn src = new ShelfRowColumn();
            src.LoadColumnsForShelf(selectedRackID);
            while (!src.EOF)
            {
               GridColumn gc =  gridView2.Columns.Add();
               gc.FieldName = src.Index.ToString();
               gc.Caption = src.Label;
               gc.Visible = true;
               gc.ColumnEdit = repositoryItemButtonEdit1;
               src.MoveNext();
            }

            gridItemDetailByLocation.DataSource = dtbl;

            // bind
            lkHighlightItems.Properties.DataSource = Shelf.GetItemsOnShelf( selectedRackID );
        }
        private void lkRackID2_EditValueChanged(object sender, EventArgs e)
        {
            selectedRackID = Convert.ToInt32(lkRackID2.EditValue);

            gridItemDetailByLocation.DataSource = null;
            if (!bw.IsBusy)
            {
                bw.RunWorkerAsync();
            }

            // THIS OPTION HAS BEEN DISABLED FOR THE TIME BEING
            //lkFrom.Properties.DataSource = PalletLocation.GetNonFree(selectedRackID);
            //lkTo.Properties.DataSource = PalletLocation.GetFreeIn(selectedRackID);
            gridItemMovementView.Columns.Clear();

            var src = new ShelfRowColumn();
            src.LoadColumnsForShelf(selectedRackID);
            while (!src.EOF)
            {
                GridColumn gc = gridItemMovementView.Columns.Add();
                gc.FieldName = src.Index.ToString();
                gc.Caption = src.Label;
                gc.Visible = true;
                repositoryItemButtonEdit1.AllowFocused = true;
                gc.ColumnEdit = repositoryItemButtonEdit1;
                src.MoveNext();
            }
        }
        /// <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;
        }