protected void lbUndo_Click(object sender, EventArgs e)
        {
            LinkButton lbUndo = sender as LinkButton;

            if (lbUndo.CommandArgument.Length > 1)
            {
                Entities.PalletDelivery pd = PalletDeliveries.SingleOrDefault(lpd => lpd.Identifier == lbUndo.CommandArgument);

                if (pd != null)
                {
                    Entities.PalletDelivery foundUpdatedPalletDelivery = UpdatedPalletDeliveries.FirstOrDefault(fupd => fupd.PalletOrder.OrderID == pd.PalletOrder.OrderID);

                    if (foundUpdatedPalletDelivery != null)
                    {
                        UpdatedPalletDeliveries.Remove(foundUpdatedPalletDelivery);
                    }

                    pd.UpdatedNoPallets = 0;
                    pd.IsDirty          = false;
                    pd.ToBeRemoved      = false;

                    Rebind(null);

                    btnGenerateUpdate.Visible = !PalletDeliveries.Exists(lpds => lpds.IsDirty || lpds.PalletOrder.OrderID < 1);
                }
            }
        }
        protected void lbRemove_Click(object sender, EventArgs e)
        {
            LinkButton lbRemove = sender as LinkButton;

            if (lbRemove.CommandArgument.Length > 1)
            {
                Entities.PalletDelivery pd = PalletDeliveries.SingleOrDefault(lpd => lpd.Identifier == lbRemove.CommandArgument);

                if (pd != null)
                {
                    if (pd.PalletOrder.OrderID > 0)
                    {
                        pd.ToBeRemoved = true;
                        pd.IsDirty     = true;
                    }
                    else
                    {
                        PalletDeliveries.Remove(pd);
                    }
                }
            }

            GetSelectedPallets();
            Rebind(null);
            ClearPalletHandling();

            btnGenerateUpdate.Visible = !PalletDeliveries.Exists(lpds => lpds.IsDirty || lpds.PalletOrder.OrderID < 1);
        }
        private void LoadExistingPalletHandling(Entities.PalletDelivery selectedPalletDelivery)
        {
            List <Entities.PalletDelivery> lpds = new List <Entities.PalletDelivery>();

            if (PalletDeliveries.Count > 0 && selectedPalletDelivery != null && PalletDeliveries.Exists(pd => pd.PalletOrder.OrderID == selectedPalletDelivery.PalletOrder.OrderID))
            {
                PalletDeliveries.Remove(selectedPalletDelivery);
            }

            if (UpdatedPalletDeliveries.Count > 0)
            {
                List <int> uppd = new List <int>();
                foreach (Entities.PalletDelivery pd in UpdatedPalletDeliveries)
                {
                    uppd.Add(pd.PalletOrder.OrderID);
                }

                lpds.AddRange(PalletDeliveries.Where(lpd => !uppd.Contains(lpd.PalletOrder.OrderID)));
                lpds.AddRange(UpdatedPalletDeliveries.Where(lpd => selectedPalletDelivery == null || lpd.PalletOrder.OrderID != selectedPalletDelivery.PalletOrder.OrderID));
            }
            else
            {
                lpds = PalletDeliveries;
            }

            lvExisingPalletHandling.DataSource = lpds;
            lvExisingPalletHandling.DataBind();
        }
        private void ConfigureDisplay()
        {
            // Bind the handle method
            rcbPalletHandlingAction.Items.Clear();
            rcbPalletHandlingAction.Items.Add(new RadComboBoxItem(Utilities.UnCamelCase(eInstructionType.LeavePallets.ToString()), ((int)eInstructionType.LeavePallets).ToString()));
            rcbPalletHandlingAction.Items.Add(new RadComboBoxItem(Utilities.UnCamelCase(eInstructionType.DeHirePallets.ToString()), ((int)eInstructionType.DeHirePallets).ToString()));
            rcbPalletHandlingAction.ClearSelection();

            // Setting currency culture
            CultureInfo systemCulture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

            rntPalletDeliveryCharge.Culture = systemCulture;

            ClearPalletHandling();

            // Bind the job information.
            LoadJob();
            LoadEmptyPallets(null);

            if (m_emptyPalletCount == 0)
            {
                palletButtonBar.Style.Add("display", "none");
            }

            btnCancelUpdate.Style.Add("display", "none");
            LoadExistingPalletHandling(null);

            btnGenerateUpdate.Visible = !PalletDeliveries.Exists(lpds => lpds.IsDirty || lpds.PalletOrder.OrderID < 1);
        }
        void btnCancelUpdate_Click(object sender, EventArgs e)
        {
            btnCancelUpdate.Style.Add("display", "none");
            palletButtonBar.Style.Add("display", "none");
            btnGenerateUpdate.Style.Remove("display");
            btnGenerate.Text = "Generate";

            PalletDeliveries.Add(SelectedPalletDelivery);

            Rebind(null);
            ClearPalletHandling();

            btnGenerateUpdate.Visible = !PalletDeliveries.Exists(lpds => lpds.IsDirty || lpds.PalletOrder.OrderID < 1);
        }
        void btnGenerate_Click(object sender, EventArgs e)
        {
            btnCancelUpdate.Style.Add("display", "none");
            palletButtonBar.Style.Add("display", "none");
            btnGenerateUpdate.Style.Remove("display");

            Entities.PalletDelivery currentPalletDelivery = null;

            if (btnGenerate.Text == "Update" && SelectedPalletDelivery.PalletOrder.OrderID > 0)
            {
                currentPalletDelivery = SelectedPalletDelivery;
            }

            GetSelectedPallets();
            //LoadEmptyPallets(currentPalletDelivery);
            //LoadExistingPalletHandling(null);
            Rebind(null);

            btnGenerate.Text = "Generate";
            ClearPalletHandling();

            btnGenerateUpdate.Visible = !PalletDeliveries.Exists(lpds => lpds.IsDirty || lpds.PalletOrder.OrderID < 1);
        }