Example #1
0
        /// <summary>
        /// Configures the reasons so that only valid shortage reasons appear in the shortage dropdown, whilst other reasons
        /// appear in the refusal drop down.
        /// </summary>
        private void ConfigureReasons()
        {
            using (Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal())
                m_shortageReasons = facGoods.GetReasonTypes();

            for (int rowIndex = 0; rowIndex < m_shortageReasons.Tables[0].Rows.Count; rowIndex++)
            {
                eGoodsRefusedType type = (eGoodsRefusedType)(int)m_shortageReasons.Tables[0].Rows[rowIndex]["RefusalTypeId"];

                switch (type)
                {
                case eGoodsRefusedType.Shorts:
                    break;

                case eGoodsRefusedType.OverAndAccepted:
                    break;

                default:
                    // Remove this option.
                    m_shortageReasons.Tables[0].Rows.RemoveAt(rowIndex);
                    rowIndex--;
                    break;
                }
            }
        }
Example #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);
        }
Example #3
0
        private void cboRefusalType_SelectedIndexChanged(object sender, EventArgs e)
        {
            eGoodsRefusedType goodsRefusalType = (eGoodsRefusedType)Enum.Parse(typeof(eGoodsRefusedType), cboRefusalType.SelectedValue);

            if (goodsRefusalType == eGoodsRefusedType.Shorts)
            {
                lblReturnTypeHeading.Text = "Shorts";
                lblQuantityRefused.Text   = "Quantity Short";
            }
            if (goodsRefusalType == eGoodsRefusedType.OverAndAccepted
                ||
                goodsRefusalType == eGoodsRefusedType.OverAndReturned
                )
            {
                lblReturnTypeHeading.Text = "Overs";
                lblQuantityRefused.Text   = "Quantity Over";
            }
        }
Example #4
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;
                }
            }
        }
Example #5
0
        private void dgGoods_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                // The id of the goods refusal we are working with.
                int refusalId = Convert.ToInt32(e.Item.Cells[1].Text);

                switch (e.CommandName.ToLower())
                {
                case "edit":
                    // Check the refusal type.
                    eGoodsRefusedType type = (eGoodsRefusedType)Enum.Parse(typeof(eGoodsRefusedType), e.Item.Cells[1].Text.Replace(" ", ""));

                    if (type == eGoodsRefusedType.Shorts || type == eGoodsRefusedType.OverAndAccepted)
                    {
                        Response.Redirect("shortage.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&instructionId=" + m_instructionId.ToString() + "&refusalId=" + refusalId + "&csid=" + this.CookieSessionID);
                    }
                    else
                    {
                        Response.Redirect("refusal.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&instructionId=" + m_instructionId.ToString() + "&refusalId=" + refusalId + "&csid=" + this.CookieSessionID);
                    }
                    break;

                case "delete":
                    Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.TakeCallIn);
                    bool success = false;

                    using (Facade.IGoodsRefusal facGoodsRefusal = new Facade.GoodsRefusal())
                        success = facGoodsRefusal.Delete(refusalId, this.Page.User.Identity.Name);

                    if (success)
                    {
                        BindGoods();
                    }
                    break;
                }
            }
        }
Example #6
0
        private void dgGoods_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView row = (DataRowView)e.Item.DataItem;

                ////////////////////////////////////////////////////////
                int refusalId                = (int)row["RefusalId"];
                eGoodsRefusedType type       = (eGoodsRefusedType)row["RefusalTypeId"];
                HtmlAnchor        hypRefusal = (HtmlAnchor)e.Item.FindControl("hypRefusal");
                if (type == eGoodsRefusedType.Shorts || type == eGoodsRefusedType.OverAndAccepted)
                {
                    hypRefusal.HRef      = "shortage.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&instructionId=" + m_instructionId.ToString() + "&refusalId=" + refusalId + "&t=2" + "&csid=" + this.CookieSessionID;
                    hypRefusal.InnerText = refusalId.ToString();
                }
                else
                {
                    hypRefusal.HRef      = "refusal.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&instructionId=" + m_instructionId.ToString() + "&refusalId=" + refusalId + "&t=1" + this.CookieSessionID;
                    hypRefusal.InnerText = refusalId.ToString();
                }

                ///////////////////////////////////////////////////////

                int storePointId = 0;
                if (row["StorePointId"] != DBNull.Value)
                {
                    storePointId = (int)row["StorePointId"];
                }
                int returnPointId = 0;
                if (row["ReturnPointId"] != DBNull.Value)
                {
                    returnPointId = (int)row["ReturnPointId"];
                }

                if (storePointId != 0 || returnPointId != 0)
                {
                    Facade.IPoint facPoint = new Facade.Point();
                    if (storePointId != 0)
                    {
                        Label lblStoreAt = (Label)e.Item.FindControl("lblStoreAt");

                        Entities.Point storePoint = facPoint.GetPointForPointId(storePointId);
                        lblStoreAt.Text = storePoint.OrganisationName + ", " + storePoint.PostTown.TownName;

                        Uri pointAddressUri = new Uri(Request.Url, Page.ResolveUrl("~/Point/GetPointAddressHtml.aspx"));
                        lblStoreAt.Attributes.Add("onMouseOver", "ShowPoint('" + pointAddressUri.ToString() + "', '" + storePointId.ToString() + "')");
                        lblStoreAt.Attributes.Add("onMouseOut", "HidePoint()");
                    }

                    if (returnPointId != 0)
                    {
                        Label lblReturnTo = (Label)e.Item.FindControl("lblReturnTo");

                        Entities.Point returnPoint = facPoint.GetPointForPointId(returnPointId);
                        lblReturnTo.Text = returnPoint.OrganisationName + ", " + returnPoint.PostTown.TownName;

                        Uri pointAddressUri = new Uri(Request.Url, Page.ResolveUrl("~/Point/GetPointAddressHtml.aspx"));
                        lblReturnTo.Attributes.Add("onMouseOver", "ShowPoint('" + pointAddressUri.ToString() + "', '" + returnPointId.ToString() + "')");
                        lblReturnTo.Attributes.Add("onMouseOut", "HidePoint()");
                    }
                }

                // Only allow goods of status Outstanding to be edited or deleted (unless this is a return job).
                if (row["RefusalStatusId"] != DBNull.Value)
                {
                    eGoodsRefusedStatus status = (eGoodsRefusedStatus)row["RefusalStatusId"];

                    //if ((status != eGoodsRefusedStatus.Outstanding && type != eGoodsRefusedType.Shorts && type != eGoodsRefusedType.OverAndAccepted) && m_job.JobType != eJobType.Return)
                    //{
                    //    // This has been commented out following a desire by Tony to be able to view the details - instead the Update Goods button is disabled.
                    //    //((Button) e.Item.Cells[8].Controls[0]).Enabled = false;
                    //    ((Button) e.Item.Cells[8].Controls[0]).Text = "View";
                    //    ((Button) e.Item.Cells[10].Controls[0]).Enabled = false;
                    //}
                }
            }
        }
Example #7
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);
        }
Example #8
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;
                }
            }
        }
Example #9
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";
        }