private void GetQueryStringVariables()
        {
            m_PointId = int.Parse(Request.QueryString["PointId"]);

            if (Request.QueryString["InstructionId"] != "" && Request.QueryString["InstructionId"] != null)
            {
                m_instructionId   = int.Parse(Request.QueryString["InstructionId"]);
                m_instructionType = (eInstructionType)(int.Parse(Request.QueryString["InstructionTypeId"]));
                m_bookedDateTime  = DateTime.Parse(Request.QueryString["BookedTime"]);
                m_isAnyTime       = (int.Parse(Request.QueryString["IsAnyTime"])) == 1 ? true : false;
                m_hasInstruction  = true;
            }

            m_plannedStartDateTime = DateTime.Parse(Request.QueryString["LegPlannedStart"]);
            m_plannedEndDateTime   = DateTime.Parse(Request.QueryString["LegPlannedEnd"]);

            Facade.IPoint facPoint = new Facade.Point();
            m_point = facPoint.GetPointForPointId(m_PointId);

            string addressString = "<b>" + m_point.Description + "</b> <br/>";

            addressString += m_point.Address.ToString().Replace(Environment.NewLine, "<br/>");

            lblAddress.Text = addressString;

            string instructionType = string.Empty;
            string bookedTimes     = string.Empty;
            string plannedTimes    = string.Empty;

            if (m_hasInstruction)
            {
                instructionType         = "<b>Instruction Type :: " + Utilities.UnCamelCase(m_instructionType.ToString()) + "</b>";
                lblInstructionType.Text = instructionType;
                bookedTimes             = "<b>Booked : </b>" + m_bookedDateTime.ToString("dd/MM HH:mm");
            }
            else
            {
                instructionType         = "<span style=\"color:blue;\">This is a Trunk Leg.</span>";
                lblInstructionType.Text = instructionType;
            }

            plannedTimes           = "<b>Planned Start : </b>" + m_plannedStartDateTime.ToString("dd/MM HH:mm") + "<br/>";
            plannedTimes          += "<b>Planned End : </b>" + m_plannedEndDateTime.ToString("dd/MM HH:mm") + "<br/>";
            lblBookedDateTime.Text = bookedTimes;
            lblPlannedTimes.Text   = plannedTimes;
        }
        private void GetSelectedPallets()
        {
            Entities.Instruction palletHandlingInstruction = new Entities.Instruction();

            eInstructionType selectedPalletAction = (eInstructionType)int.Parse(rcbPalletHandlingAction.SelectedValue);

            foreach (ListViewDataItem lvdi in lvEmptyPallets.Items)
            {
                CheckBox chkResourceSelected = lvdi.FindControl("chkResourceSelected") as CheckBox;

                if (chkResourceSelected != null && chkResourceSelected.Checked)
                {
                    HiddenField hdnResource    = lvdi.FindControl("hdnResource") as HiddenField;
                    HiddenField hidResourceID  = lvdi.FindControl("hidResourceID") as HiddenField;
                    HiddenField hidIsFixedUnit = lvdi.FindControl("hidIsFixedUnit") as HiddenField;
                    ListView    lvItems        = lvdi.FindControl("lvItems") as ListView;

                    int resourceID = 0;
                    int.TryParse(hidResourceID.Value, out resourceID);

                    bool isFixedUnit      = false;
                    int  isFixedUnitValue = 0;
                    int.TryParse(hidIsFixedUnit.Value, out isFixedUnitValue);
                    isFixedUnit = isFixedUnitValue > 0;

                    foreach (ListViewDataItem ilvdi in lvItems.Items)
                    {
                        #region Generate Pallet Orders

                        RadNumericTextBox rntNoOfPallets = ilvdi.FindControl("rntNoOfPallets") as RadNumericTextBox;

                        if (rntNoOfPallets != null && rntNoOfPallets.Value.Value > 0)
                        {
                            HiddenField hdnPalletTypeID = ilvdi.FindControl("hdnPalletTypeID") as HiddenField;
                            HiddenField hdnPalletType   = ilvdi.FindControl("hdnPalletType") as HiddenField;
                            HiddenField hdnIdentifier   = ilvdi.FindControl("hdnIdentifier") as HiddenField;

                            string                  destination    = string.Empty;
                            Entities.Order          palletDelivery = null;
                            Entities.PalletDelivery pd             = null;

                            if (hdnIdentifier != null && hdnIdentifier.Value != string.Empty)
                            {
                                #region Update Order
                                pd = SelectedPalletDelivery;

                                if (pd.PalletOrder.OrderID > 0)
                                {
                                    Entities.PalletDelivery updatedDelivery = null;

                                    if (UpdatedPalletDeliveries.Count > 0)
                                    {
                                        updatedDelivery = UpdatedPalletDeliveries.Find(upd => upd.PalletOrder.OrderID == pd.PalletOrder.OrderID);
                                    }

                                    if (updatedDelivery == null)
                                    {
                                        updatedDelivery = new Entities.PalletDelivery();
                                    }
                                    else
                                    {
                                        UpdatedPalletDeliveries.Remove(updatedDelivery);
                                    }

                                    if (updatedDelivery.PalletOrder == null || updatedDelivery.PalletOrder.OrderID < 1)
                                    {
                                        updatedDelivery.PalletOrder         = GeneratePalletOrder(int.Parse(hdnPalletTypeID.Value), (int)rntNoOfPallets.Value.Value, selectedPalletAction, ref destination);
                                        updatedDelivery.PalletOrder.OrderID = pd.PalletOrder.OrderID;
                                    }
                                    else
                                    {
                                        updatedDelivery.PalletOrder.NoPallets = (int)rntNoOfPallets.Value.Value;
                                    }

                                    updatedDelivery.PalletAction            = selectedPalletAction;
                                    updatedDelivery.PalletActionDescription = Utilities.UnCamelCase(selectedPalletAction.ToString());
                                    updatedDelivery.ResourceID  = resourceID;
                                    updatedDelivery.IsFixedUnit = isFixedUnit;

                                    updatedDelivery.PalletType  = hdnPalletType.Value;
                                    updatedDelivery.Resource    = hdnResource.Value;
                                    updatedDelivery.Destination = destination;

                                    updatedDelivery.UpdatedNoPallets = updatedDelivery.PalletOrder.NoPallets;
                                    //pd.UpdatedNoPallets = updatedDelivery.PalletOrder.NoPallets;
                                    updatedDelivery.IsDirty = true;

                                    UpdatedPalletDeliveries.Add(updatedDelivery);
                                }

                                //pd.PalletOrder.NoPallets = (int)rntNoOfPallets.Value.Value;
                                pd.UpdatedNoPallets = (int)rntNoOfPallets.Value.Value;
                                pd.IsDirty          = true;

                                #endregion
                            }
                            else
                            {
                                #region Generate Order

                                palletDelivery = GeneratePalletOrder(int.Parse(hdnPalletTypeID.Value), (int)rntNoOfPallets.Value.Value, selectedPalletAction, ref destination);

                                pd = new Entities.PalletDelivery();

                                pd.PalletOrder = palletDelivery;

                                pd.PalletAction            = selectedPalletAction;
                                pd.PalletActionDescription = Utilities.UnCamelCase(selectedPalletAction.ToString());
                                pd.ResourceID  = resourceID;
                                pd.IsFixedUnit = isFixedUnit;

                                pd.PalletType  = hdnPalletType.Value;
                                pd.Resource    = hdnResource.Value;
                                pd.Destination = destination;

                                #endregion
                            }

                            PalletDeliveries.Add(pd);
                        }

                        #endregion
                    }
                }
            }
        }