示例#1
0
        private void btnStoreGoodsAndReset_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Entities.GoodsRefusal refusal = PopulateGoodsRefusal();

                // Only continue if the point requirements are met for this goods refusal.
                // The only time this will evaluate to false is if the user has tried to create a new point for either
                // the StorePoint or ReturnPoint and it has failed - the infringements will be displayed in the user control.
                if (refusal.StorePoint != null && (ucReturnedToPoint.PointID > 0 || refusal.ReturnPoint != null))
                {
                    bool   success = false;
                    string userId  = ((Entities.CustomPrincipal)Page.User).UserName;

                    if (refusal.RefusalId == 0)
                    {
                        success = CreateRefusal(refusal, userId);
                    }
                    else
                    {
                        success = UpdateRefusal(refusal, userId);
                    }

                    if (success)
                    {
                        this.MessageBox("Your goods have been recorded.", true);
                    }
                }
            }

            // Reset all the fields except for the store point, return point and order
            ClearGoods();
        }
示例#2
0
        /// <summary>
        /// Populates the details about the shortage goods.
        /// </summary>
        /// <returns>The populated object.</returns>
        private Entities.GoodsRefusal PopulateShortage()
        {
            Entities.GoodsRefusal goodsRefusal = new Entities.GoodsRefusal();

            goodsRefusal.OriginalOrderId = int.Parse(cboOrder.SelectedValue);
            goodsRefusal.Docket          = cboOrder.SelectedValue;

            // Populate the goods refusal object.
            goodsRefusal.RefusalId            = Convert.ToInt32(hidShortageId.Value);
            goodsRefusal.RefusalReceiptNumber = string.Empty;

            goodsRefusal.ReturnPoint = null;
            goodsRefusal.StorePoint  = null;

            eGoodsRefusedType refusedType = (eGoodsRefusedType)Enum.Parse(typeof(eGoodsRefusedType), cboShortageReason.SelectedValue.Replace(" ", ""));

            goodsRefusal.ProductCode     = txtShortageProductCode.Text;
            goodsRefusal.PackSize        = txtShortagePackSize.Text;
            goodsRefusal.ProductName     = txtShortageProductName.Text;
            goodsRefusal.QuantityOrdered = (txtShortageQtyDespatched.Text == String.Empty) ? 0 : Convert.ToInt32(txtShortageQtyDespatched.Text);
            goodsRefusal.QuantityRefused = (txtShortageQty.Text == String.Empty) ? 0 : Convert.ToInt32(txtShortageQty.Text);
            goodsRefusal.RefusalNotes    = txtShortageNotes.Text;
            goodsRefusal.TimeFrame       = DateTime.Now.AddDays(14);
            goodsRefusal.InstructionId   = Convert.ToInt32(hidInstructionId.Value);

            goodsRefusal.RefusalType   = (int)refusedType;
            goodsRefusal.RefusalStatus = eGoodsRefusedStatus.NotApplicable;

            return(goodsRefusal);
        }
示例#3
0
        /// <summary>
        /// Record the refused/returned goods details.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStoreGoods_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Entities.GoodsRefusal refusal = PopulateGoodsRefusal();

                // Only continue if the point requirements are met for this goods refusal.
                // The only time this will evaluate to false is if the user has tried to create a new point for either
                // the StorePoint or ReturnPoint and it has failed - the infringements will be displayed in the user control.
                if (refusal.StorePoint != null && (ucReturnedToPoint.PointID > 0 || refusal.ReturnPoint != null))
                {
                    bool   success = false;
                    string userId  = ((Entities.CustomPrincipal)Page.User).UserName;

                    if (refusal.RefusalId == 0)
                    {
                        success = CreateRefusal(refusal, userId);
                    }
                    else
                    {
                        success = UpdateRefusal(refusal, userId);
                    }

                    if (success)
                    {
                        Response.Redirect("tabReturns.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&instructionId=" + m_instructionId.ToString() + "&csid=" + this.CookieSessionID);
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Updates the goods refusal record.
        /// </summary>
        /// <param name="refusal">The GoodsRefusal object.</param>
        /// <param name="userId">The user updating the refusal.</param>
        /// <returns>Success indicator.</returns>
        private bool UpdateRefusal(Entities.GoodsRefusal refusal, string userId)
        {
            bool success = false;

            using (Facade.IGoodsRefusal facGoodsRefusal = new Facade.GoodsRefusal())
                success = facGoodsRefusal.Update(refusal, userId);

            return(success);
        }
示例#5
0
        /// <summary>
        /// Creates the goods refusal record against the current instruction and point.
        /// </summary>
        /// <param name="refusal">The GoodsRefusal object.</param>
        /// <param name="userId">The user recording the refusal.</param>
        /// <returns>Success indicator.</returns>
        private bool CreateRefusal(Entities.GoodsRefusal refusal, string userId)
        {
            bool success = false;

            m_instructionId = Convert.ToInt32(hidInstructionId.Value);

            using (Facade.IGoodsRefusal facGoodsRefusal = new Facade.GoodsRefusal())
                success = facGoodsRefusal.Create(refusal, m_job.JobType, m_instructionId, userId);

            return(success);
        }
示例#6
0
        /// <summary>
        /// Binds the shortage the user has selected to edit to the shortage.
        /// </summary>
        /// <param name="refusalId">The unique id of the goods refusal to edit.</param>
        private void BindShortage(int refusalId)
        {
            Entities.GoodsRefusal selectedGoodsRefusal = null;

            using (Facade.IGoodsRefusal facGoodsRefusal = new Facade.GoodsRefusal())
                selectedGoodsRefusal = facGoodsRefusal.GetForRefusalId(refusalId);

            if (selectedGoodsRefusal != null)
            {
                // Bind the information to the panel.
                ClearShortages();
                hidShortageId.Value = refusalId.ToString();

                if (selectedGoodsRefusal.Docket != string.Empty)
                {
                    cboShortageDocket.ClearSelection();
                    cboShortageDocket.Items.FindByValue(selectedGoodsRefusal.Docket.ToString()).Selected = true;
                }

                txtShortageProductName.Text   = selectedGoodsRefusal.ProductName;
                txtShortageProductCode.Text   = selectedGoodsRefusal.ProductCode;
                txtShortagePackSize.Text      = selectedGoodsRefusal.PackSize;
                txtShortageQtyDespatched.Text = selectedGoodsRefusal.QuantityOrdered.ToString();
                txtShortageQty.Text           = selectedGoodsRefusal.QuantityRefused.ToString();

                cboShortageReason.ClearSelection();
                eGoodsRefusedType refusalType = (eGoodsRefusedType)selectedGoodsRefusal.RefusalType;
                cboShortageReason.Items.FindByText(Utilities.UnCamelCase(Enum.GetName(typeof(eGoodsRefusedType), refusalType))).Selected = true;
                txtShortageNotes.Text = selectedGoodsRefusal.RefusalNotes;

                if ((selectedGoodsRefusal.RefusalStatus != eGoodsRefusedStatus.Outstanding && selectedGoodsRefusal.RefusalType != (int)eGoodsRefusedType.Shorts && selectedGoodsRefusal.RefusalType != (int)eGoodsRefusedType.OverAndAccepted) && m_job.JobType != eJobType.Return)
                {
                    btnStoreShortage.Enabled = false;
                }
                else
                {
                    btnStoreShortage.Enabled = true;
                }
            }
        }
示例#7
0
        private void btnStoreShortage_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Entities.GoodsRefusal refusal = PopulateShortage();

                bool   success = false;
                string userId  = ((Entities.CustomPrincipal)Page.User).UserName;

                if (refusal.RefusalId == 0)
                {
                    success = CreateRefusal(refusal, userId);
                }
                else
                {
                    success = UpdateRefusal(refusal, userId);
                }

                if (success)
                {
                    Response.Redirect("tabReturns.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&instructionId=" + m_instructionId.ToString() + "&csid=" + this.CookieSessionID);
                }
            }
        }
示例#8
0
        /// <summary>
        /// Populates the details about the refused/returned goods.
        /// </summary>
        /// <returns>The populated object.</returns>
        private Entities.GoodsRefusal PopulateGoodsRefusal()
        {
            Entities.GoodsRefusal goodsRefusal = new Entities.GoodsRefusal();

            goodsRefusal.Docket          = cboOrder.SelectedValue;
            goodsRefusal.OriginalOrderId = int.Parse(cboOrder.SelectedValue);

            // Populate the goods refusal object.
            goodsRefusal.RefusalId            = Convert.ToInt32(hidRefusalId.Value);
            goodsRefusal.RefusalReceiptNumber = txtReceiptNumber.Text;

            // Set the return point.
            //if (cboGoodsReturnPoint.Text != String.Empty)
            //{
            // Configure the return point.
            int returnPoint = 0;

            //	if (cboGoodsReturnPoint.Value == String.Empty)
            //	{
            // A new return point has been specified.
            //returnPoint = CreateNewPoint(Convert.ToInt32(cboGoodsReturnOrganisation.Value), cboGoodsReturnOrganisation.Text, Convert.ToInt32(cboGoodsReturnTown.Value), cboGoodsReturnPoint.Text, txtGoodsReturnAddressLine1.Text, txtGoodsReturnAddressLine2.Text, txtGoodsReturnAddressLine3.Text, txtGoodsReturnPostTown.Text, txtGoodsReturnCounty.Text, txtGoodsReturnPostCode.Text, Convert.ToDecimal(txtGoodsReturnLongitude.Text), Convert.ToDecimal(txtGoodsReturnLatitude.Text), Convert.ToInt32(hidGoodsReturnTrafficArea.Value), ((Entities.CustomPrincipal) Page.User).UserName);
            //	}
            //	else

            returnPoint = ucReturnedToPoint.PointID;

            if (returnPoint > 0)
            {
                Facade.IPoint facPoint = new Facade.Point();
                goodsRefusal.ReturnPoint = facPoint.GetPointForPointId(returnPoint);
            }
            //}

            eGoodsRefusedType refusedType = (eGoodsRefusedType)Enum.Parse(typeof(eGoodsRefusedType), cboGoodsReasonRefused.SelectedValue.Replace(" ", ""));

            // Set the store point.
            int storePoint = 0;

            //if (cboGoodsStorePoint.Value == String.Empty)
            //{
            //if (cboGoodsStorePoint.Text != String.Empty)
            //{
            // A new store point has been specified.
            //storePoint = CreateNewPoint(Convert.ToInt32(cboGoodsStoreOrganisation.Value), cboGoodsStoreOrganisation.Text, Convert.ToInt32(cboGoodsStoreTown.Value), cboGoodsStorePoint.Text, txtGoodsStoreAddressLine1.Text, txtGoodsStoreAddressLine2.Text, txtGoodsStoreAddressLine3.Text, txtGoodsStorePostTown.Text, txtGoodsStoreCounty.Text, txtGoodsStorePostCode.Text, Convert.ToDecimal(txtGoodsStoreLongitude.Text), Convert.ToDecimal(txtGoodsStoreLatitude.Text), Convert.ToInt32(hidGoodsStoreTrafficArea.Value), ((Entities.CustomPrincipal) Page.User).UserName);
            //}
            //}
            //else

            storePoint = ucStoredAtPoint.PointID;

            if (storePoint > 0)
            {
                Facade.IPoint facPoint = new Facade.Point();
                goodsRefusal.StorePoint = facPoint.GetPointForPointId(storePoint);
            }

            goodsRefusal.RefusalLocation = (eGoodsRefusedLocation)Enum.Parse(typeof(eGoodsRefusedLocation), cboLocation.SelectedValue.Replace(" ", ""));
            goodsRefusal.ProductCode     = txtProductCode.Text;
            goodsRefusal.PackSize        = txtPackSize.Text;
            goodsRefusal.ProductName     = txtProductName.Text;
            goodsRefusal.QuantityOrdered = (txtQuantityOrdered.Text == String.Empty) ? 0 : Convert.ToInt32(txtQuantityOrdered.Text);
            goodsRefusal.QuantityRefused = (txtQuantityReturned.Text == String.Empty) ? 0 : Convert.ToInt32(txtQuantityReturned.Text);
            goodsRefusal.RefusalNotes    = txtGoodsNotes.Text;
            goodsRefusal.TimeFrame       = rdiReturnDate.SelectedDate.HasValue ? rdiReturnDate.SelectedDate.Value : DateTime.Now.AddDays(Orchestrator.Globals.Configuration.RefusalNoOfDaysToReturnGoods);
            goodsRefusal.InstructionId   = Convert.ToInt32(hidInstructionId.Value);

            goodsRefusal.NoPallets      = Convert.ToInt32(rntNoPallets.Value.Value);
            goodsRefusal.NoPalletSpaces = Convert.ToDecimal(rntNoPalletSpaces.Value.Value);

            goodsRefusal.RefusalType   = Convert.ToInt32(cboGoodsReasonRefused.SelectedItem.Value);
            goodsRefusal.RefusalStatus = (eGoodsRefusedStatus)Enum.Parse(typeof(eGoodsRefusedStatus), cboGoodsStatus.SelectedValue.Replace(" ", ""));

            Facade.IInstruction  facInstruction = new Facade.Instruction();
            Entities.Instruction instruction    = facInstruction.GetInstruction(m_instructionId);

            int deviationReasonId;

            int.TryParse(this.cboDeviationReason.SelectedValue, out deviationReasonId);

            if (deviationReasonId == 0)
            {
                goodsRefusal.DeviationReasonId = -1;
            }
            else
            {
                goodsRefusal.DeviationReasonId = deviationReasonId;
            }

            goodsRefusal.RefusedFromPointId = instruction.PointID;

            return(goodsRefusal);
        }
示例#9
0
        /// <summary>
        /// Binds the goods refusal the user has selected to edit to the goods refusal panel.
        /// </summary>
        /// <param name="refusalId">The unique id of the goods refusal to edit.</param>
        private void BindGoodsRefusal(int refusalId)
        {
            Entities.GoodsRefusal selectedGoodsRefusal = null;

            using (Facade.IGoodsRefusal facGoodsRefusal = new Facade.GoodsRefusal())
                selectedGoodsRefusal = facGoodsRefusal.GetForRefusalId(refusalId);

            if (selectedGoodsRefusal != null)
            {
                // Bind the goods information to the panel.
                ClearGoods();
                //cboGoodsType.ClearSelection();
                //cboGoodsType.Items.FindByValue(Utilities.UnCamelCase(Enum.GetName(typeof(eReturnType), (eReturnType)selectedGoodsRefusal.ReturnType))).Selected = true;
                hidRefusalId.Value = refusalId.ToString();

                //if (selectedGoodsRefusal.Docket != string.Empty)
                //{
                //cboDocket.ClearSelection();
                //ListItem docketItem = cboDocket.Items.FindByValue(selectedGoodsRefusal.Docket.ToString());

                //if (docketItem != null)
                //docketItem.Selected = true;
                //}

                if (selectedGoodsRefusal.NewOrderId.HasValue && selectedGoodsRefusal.NewOrderId.Value > 0)
                {
                    this.cboOrder.Enabled = false;
                }
                else
                {
                    this.cboOrder.Enabled = true;
                }

                this.cboOrder.ClearSelection();
                this.cboOrder.Items.FindItemByValue(selectedGoodsRefusal.OriginalOrderId.ToString()).Selected = true;

                txtProductName.Text      = selectedGoodsRefusal.ProductName;
                txtProductCode.Text      = selectedGoodsRefusal.ProductCode;
                txtReceiptNumber.Text    = selectedGoodsRefusal.RefusalReceiptNumber;
                txtPackSize.Text         = selectedGoodsRefusal.PackSize;
                txtQuantityOrdered.Text  = selectedGoodsRefusal.QuantityOrdered.ToString();
                txtQuantityReturned.Text = selectedGoodsRefusal.QuantityRefused.ToString();

                rntNoPallets.Value      = selectedGoodsRefusal.NoPallets;
                rntNoPalletSpaces.Value = Convert.ToDouble(selectedGoodsRefusal.NoPalletSpaces);

                cboGoodsReasonRefused.ClearSelection();
                eGoodsRefusedType refusalType = (eGoodsRefusedType)selectedGoodsRefusal.RefusalType;
                cboGoodsReasonRefused.Items.FindByText(Utilities.UnCamelCase(Enum.GetName(typeof(eGoodsRefusedType), refusalType))).Selected = true;
                cboGoodsStatus.ClearSelection();
                cboGoodsStatus.Items.FindByText(Utilities.UnCamelCase(Enum.GetName(typeof(eGoodsRefusedStatus), selectedGoodsRefusal.RefusalStatus))).Selected = true;
                cboLocation.ClearSelection();

                ListItem selectedItem = cboLocation.Items.FindByText(Utilities.UnCamelCase(Enum.GetName(typeof(eGoodsRefusedLocation), selectedGoodsRefusal.RefusalLocation)));
                if (selectedItem == null)
                {
                    string   value   = Utilities.UnCamelCase(Enum.GetName(typeof(eGoodsRefusedLocation), selectedGoodsRefusal.RefusalLocation));
                    ListItem newItem = new ListItem(value, value);
                    cboLocation.Items.Add(newItem);
                    newItem.Selected = true;
                }

                rdiReturnDate.SelectedDate = selectedGoodsRefusal.TimeFrame.Date;
                txtGoodsNotes.Text         = selectedGoodsRefusal.RefusalNotes;
                if (selectedGoodsRefusal.ReturnPoint != null)
                {
                    m_GoodsReturnIdentityId         = selectedGoodsRefusal.ReturnPoint.IdentityId;
                    m_GoodsReturnPointId            = selectedGoodsRefusal.ReturnPoint.PointId;
                    ucReturnedToPoint.SelectedPoint = selectedGoodsRefusal.ReturnPoint;
                }
                if (selectedGoodsRefusal.StorePoint != null)
                {
                    m_GoodsStoreIdentityId        = selectedGoodsRefusal.StorePoint.IdentityId;
                    m_GoodsStorePointId           = selectedGoodsRefusal.StorePoint.PointId;
                    ucStoredAtPoint.SelectedPoint = selectedGoodsRefusal.StorePoint;
                }

                if (selectedGoodsRefusal.DeviationReasonId.HasValue)
                {
                    cboDeviationReason.SelectedValue = selectedGoodsRefusal.DeviationReasonId.Value.ToString();
                }

                if ((selectedGoodsRefusal.RefusalStatus != eGoodsRefusedStatus.Outstanding && selectedGoodsRefusal.RefusalType != (int)eGoodsRefusedType.Shorts && selectedGoodsRefusal.RefusalType != (int)eGoodsRefusedType.OverAndAccepted) && m_job.JobType != eJobType.Return)
                {
                    btnStoreGoods.Enabled = false;
                }
                else
                {
                    btnStoreGoods.Enabled = true;
                }
            }
        }
示例#10
0
        private void PopulateGoodsRefused()
        {
            if (ViewState["goodsrefused"] == null)
            {
                _goodsRefused = new Entities.GoodsRefusal();
            }
            else
            {
                _goodsRefused = (Entities.GoodsRefusal)ViewState["goodsrefused"];
            }

            if (_goodsRefused != null)
            {
                _goodsRefused.JobId                = Convert.ToInt32(hypRefusalRunId.InnerText);
                _goodsRefused.OrganisationName     = lblClient.Text;
                _goodsRefused.RefusalId            = _refusalId;
                _goodsRefused.OriginalOrderId      = _goodsRefused.RefusalId > 0 ? _goodsRefused.OriginalOrderId : _orderId;
                _goodsRefused.Docket               = lblDocket.Text;
                _goodsRefused.ProductName          = txtProductName.Text;
                _goodsRefused.QuantityOrdered      = Convert.ToInt32(rntQuantityOrdered.Value.Value.ToString());
                _goodsRefused.QuantityRefused      = Convert.ToInt32(rntQuantityRefused.Value.Value.ToString());
                _goodsRefused.PackSize             = txtPackSize.Text;
                _goodsRefused.ProductCode          = txtProductCode.Text;
                _goodsRefused.RefusalType          = (int)(eGoodsRefusedType)Enum.Parse(typeof(eGoodsRefusedType), (cboRefusalType.SelectedValue));
                _goodsRefused.TimeFrame            = rdiTimeFrame.SelectedDate.HasValue ? rdiTimeFrame.SelectedDate.Value : DateTime.MinValue;
                _goodsRefused.RefusalNotes         = txtRefusalNotes.Text;
                _goodsRefused.RefusalReceiptNumber = txtReceiptNumber.Text;
                _goodsRefused.RefusalStatus        = (eGoodsRefusedStatus)Enum.Parse(typeof(eGoodsRefusedStatus), cboGoodsStatus.SelectedValue.Replace(" ", ""));

                if (cboLocation.Visible)
                {
                    _goodsRefused.RefusalLocation = (eGoodsRefusedLocation)Convert.ToInt32(cboLocation.SelectedValue);
                }

                if (chkAtStore.Visible && chkAtStore.Checked)
                {
                    _goodsRefused.RefusalLocation = eGoodsRefusedLocation.AtStore;
                }

                if (ucStoreAtPoint.SelectedPoint != null)
                {
                    _goodsRefused.StorePoint = ucStoreAtPoint.SelectedPoint;
                }

                if (ucReturnToPoint.SelectedPoint != null)
                {
                    _goodsRefused.ReturnPoint = ucReturnToPoint.SelectedPoint;
                }

                int deviationReasonId;
                int.TryParse(this.cboDeviationReason.SelectedValue, out deviationReasonId);

                if (deviationReasonId == 0)
                {
                    _goodsRefused.DeviationReasonId = -1;
                }
                else
                {
                    _goodsRefused.DeviationReasonId = deviationReasonId;
                }
            }
        }
示例#11
0
        // Ensure this method is called only once, from Page_Load
        private void LoadGoodsRefused()
        {
            //if (_createPendingGoodsRefused)
            //{
            //    _goodsRefused = null;
            //    _goodsRefused = PendingRefusals.Find(rr => rr.Guid == _guid);

            //    if (_goodsRefused == null)
            //    {
            //        _goodsRefused = new Orchestrator.Entities.GoodsRefusal();
            //        _goodsRefused.Guid = _guid = Guid.NewGuid().ToString();
            //        SetDefaultValues();
            //        return;
            //    }
            //    SetDefaultValues();
            //}
            //else
            //{
            if (ViewState["goodsrefused"] == null)
            {
                Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal();

                if (!_createPendingGoodsRefused)
                {
                    _goodsRefused = facGoods.GetForRefusalId(_refusalId);
                }

                ViewState["goodsrefused"] = _goodsRefused;
            }
            else
            {
                _goodsRefused = (Entities.GoodsRefusal)ViewState["goodsrefused"];
            }
            //}

            if (_goodsRefused != null)
            {
                _orderId = _goodsRefused.OriginalOrderId;

                hypRefusalRunId.HRef      = string.Format("javascript:OpenRunDetails({0});", _goodsRefused.JobId.ToString());
                hypRefusalRunId.InnerText = _goodsRefused.JobId.ToString();

                var returnRunIds =
                    (from i in EF.DataContext.Current.InstructionSet
                     from cd in i.CollectDrops
                     where cd.Order.OrderId == _goodsRefused.NewOrderId
                     select i.Job.JobId).Distinct().ToList();

                rptReturnRunLinks.DataSource = returnRunIds;
                rptReturnRunLinks.DataBind();

                this.lblDocket.Text = _goodsRefused.Docket;

                lblDateDelivered.Text = _goodsRefused.DateDelivered.ToShortDateString();
                lblClient.Text        = _goodsRefused.OrganisationName;

                txtPackSize.Text    = _goodsRefused.PackSize.ToString();
                txtProductCode.Text = _goodsRefused.ProductCode;

                eGoodsRefusedType refusalType = (eGoodsRefusedType)Convert.ToInt32(_goodsRefused.RefusalType);

                ListItem selectedItem = cboRefusalType.Items.FindByValue(_goodsRefused.RefusalType.ToString());
                if (selectedItem != null)
                {
                    cboRefusalType.ClearSelection();
                    selectedItem.Selected = true;
                }

                rdiTimeFrame.SelectedDate = _goodsRefused.TimeFrame;

                txtProductName.Text      = _goodsRefused.ProductName;
                rntQuantityRefused.Value = Convert.ToDouble(_goodsRefused.QuantityRefused);
                rntQuantityOrdered.Value = Convert.ToDouble(_goodsRefused.QuantityOrdered);
                txtRefusalNotes.Text     = _goodsRefused.RefusalNotes;
                txtReceiptNumber.Text    = _goodsRefused.RefusalReceiptNumber;
                cboGoodsStatus.ClearSelection();
                cboGoodsStatus.Items.FindByText(Utilities.UnCamelCase(Enum.GetName(typeof(eGoodsRefusedStatus), _goodsRefused.RefusalStatus))).Selected = true;
                cboLocation.ClearSelection();
                //cboLocation.Items.FindByValue(((int)_goodsRefused.RefusalLocation).ToString()).Selected = true;
                ListItem li = cboLocation.Items.FindByValue(((int)_goodsRefused.RefusalLocation).ToString());
                if (_goodsRefused.RefusalStatus == eGoodsRefusedStatus.Returned || _goodsRefused.RefusalStatus == eGoodsRefusedStatus.Dumped)
                {
                    cboLocation.Enabled = false;
                }

                if (_goodsRefused.StorePointId > 0)
                {
                    ucStoreAtPoint.SelectedPoint = _goodsRefused.StorePoint;
                }

                if (_goodsRefused.ReturnPointId > 0)
                {
                    ucReturnToPoint.SelectedPoint = _goodsRefused.ReturnPoint;
                }

                if (_goodsRefused.DeviationReasonId.HasValue)
                {
                    cboDeviationReason.SelectedValue = _goodsRefused.DeviationReasonId.Value.ToString();
                }

                lblAtStore.Visible = false;
                chkAtStore.Visible = false;

                if (li != null) // The currently location is either On or Off Trailer. Show the radio option to switch between these two options only.
                {
                    cboLocation.Items.FindByValue(li.Value).Selected = true;
                    lblLocation.Visible = false;
                }
                else // Show the current location.
                {
                    cboLocation.Visible        = false;
                    rfvCurrentLocation.Enabled = false;

                    lblLocation.Visible = true;
                    lblLocation.Text    = Utilities.UnCamelCase(_goodsRefused.RefusalLocation.ToString());

                    if (_goodsRefused.RefusalLocation != eGoodsRefusedLocation.AtStore) // We are not At Store (and not On or Off Trailer) so show the checkbox to set to At Store.
                    {
                        lblAtStore.Visible = true;
                        chkAtStore.Visible = true;
                    }
                }
            }

            btnAdd.Text = "Update";
        }