private bool CanBeRemovedFromDrop(Entities.Instruction dropInstruction, Entities.Order order, out string message) { var messageFragments = new List <string>(); // This order can only be removed from this delivery and placed on a trunk if: // * This would not result in the breaking of the chain - to test this the order's collection run delivery point must match the delivery run collection point. // * No refusals have been logged against this instruction - it is possible to remove the call-in but keep the refusal. if (order.CollectionRunDeliveryPointID != order.DeliveryRunCollectionPointID) { messageFragments.Add("The Order's Collection Point does not match the Collection Point on the Run."); } var facGoodsRefusal = new Facade.GoodsRefusal(); var dsGoodsRefusal = facGoodsRefusal.GetRefusalsForInstructionIdAndOrderId(dropInstruction.InstructionID, order.OrderID); if (dsGoodsRefusal.Tables[0].Rows.Count > 0) { messageFragments.Add("Refusals Logged"); } if (messageFragments.Count > 0) { message = String.Format("This Order cannot be Converted - {0}", String.Join(", ", messageFragments.ToArray())); grdOrdersOnDrop.ItemStyle.BackColor = System.Drawing.Color.FromName("FireBrick"); grdOrdersOnDrop.ItemStyle.ForeColor = System.Drawing.Color.White; } else { message = String.Empty; } errorMessage = message; return(messageFragments.Count == 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; } } }
/// <summary> /// Retrieves the goods that have been returned/refused for this point and populates the goods datagrid. /// </summary> private void BindGoods() { using (Facade.IGoodsRefusal facGoodsRefusal = new Facade.GoodsRefusal()) { DataSet dsGoods = facGoodsRefusal.GetRefusalsForInstructionId(m_instructionId); dgGoods.DataSource = dsGoods; dgGoods.DataBind(); int goodsCount = 0; foreach (DataGridItem item in dgGoods.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { goodsCount++; } } if (goodsCount == 0) { lblGoodsCount.Text = "There are no goods stored."; dgGoods.Visible = false; } else { lblGoodsCount.Text = "There are " + goodsCount.ToString() + " refused or returned goods stored."; dgGoods.Visible = true; } } }
/// <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); }
/// <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); }
private void PopulateRefusals() { Facade.IGoodsRefusal facRefusals = new Facade.GoodsRefusal(); DataSet ds = facRefusals.GetGoodsRefusedForJob(JobId); dgRefusals.DataSource = ds; dgRefusals.DataBind(); if (ds.Tables[0].Rows.Count > 0) { pnlRefusals.Visible = true; } }
//---------------------------------------------------------------------------------- void grdRefusals_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal(); int clientId = cboClient.SelectedValue == "" ? 0 : Convert.ToInt32(cboClient.SelectedValue); int collectionPointId = ucCollectionPoint.SelectedPoint == null ? 0 : ucCollectionPoint.SelectedPoint.PointId; DateTime startDate = rdiStartDate.SelectedDate.HasValue ? rdiStartDate.SelectedDate.Value : new DateTime(1900, 01, 01); DateTime endDate = rdiEndDate.SelectedDate.HasValue ? rdiEndDate.SelectedDate.Value : new DateTime(1900, 01, 01); //Set the date range to be the entire day endDate = endDate.Subtract(endDate.TimeOfDay).Add(new TimeSpan(23, 59, 59)); m_ds = facGoods.GetShortsAndOversWithDates(clientId, startDate, endDate, collectionPointId, chkAlreadyChecked.Checked); grdRefusals.DataSource = m_ds; }
private void LoadReturnJobReport() { // Configure the Session variables used to pass data to the report NameValueCollection reportParams = new NameValueCollection(); // Client Name & Id if (cboClient.SelectedValue != "") { reportParams.Add("Client", Convert.ToString(cboClient.Text)); reportParams.Add("ClientId", Convert.ToString(cboClient.SelectedValue)); } // Date Range if (Convert.ToDateTime(Session["StartDate"]).Date != DateTime.MinValue) { reportParams.Add("startDate", Convert.ToDateTime(Session["StartDate"]).ToString("dd/MM/yy")); } if (Convert.ToDateTime(Session["EndDate"]).Date != DateTime.MinValue) { reportParams.Add("endDate", Convert.ToDateTime(Session["EndDate"]).ToString("dd/MM/yy")); } string m_jobIdCSV = GetJobIdCSV(); // Dataset Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal(); DataSet ds = facGoods.GetJobDetailsForJobIdCSV(m_jobIdCSV); //------------------------------------------------------------------------------------- // Load Report Section //------------------------------------------------------------------------------------- Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable] = eReportType.GoodsReturnJob; Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable] = ds; Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable] = String.Empty; Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table"; Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable] = reportParams; if (cboClient.SelectedValue != "") { reportViewer.IdentityId = int.Parse(cboClient.SelectedValue); } // Show the user control reportViewer.Visible = true; }
private bool UpdateGoodsRefused() { Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal(); bool retVal = false; string userName = ((Entities.CustomPrincipal)Page.User).UserName; retVal = facGoods.Update(_goodsRefused, userName); //if (IsWindowed && _goodsRefused.RefusalLocation != OldLocation) //{ // DataAccess.Audit dacAudit = new Orchestrator.DataAccess.Audit(); // string details = string.Format("Goods refusalID : {0} on originating runID : {1} location updated from : {2} to : {3}", _goodsRefused.RefusalId.ToString(), _goodsRefused.JobId.ToString(), OldLocation.ToString(), _goodsRefused.RefusalLocation.ToString()); // dacAudit.AuditEvent((int)eAuditEvent.RefusedGoodsLocationUpdatedNoJobUsed, _goodsRefused.RefusalId, details, userName); //} return(retVal); }
/// <summary> /// Populate Static Controls /// </summary> private void PopulateStaticControls() { if (IsWindowed) { btnReturnToRefusedGoods.Text = "Cancel"; } if (_isUpdate) { this.btnAdd.Text = "Update Goods Refused"; } else { this.btnAdd.Text = "Add Goods Refused"; } Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal(); DataSet dsReasonType = facGoods.GetReasonTypes(); cboRefusalType.DataSource = dsReasonType; cboRefusalType.DataTextField = "Description"; cboRefusalType.DataValueField = "RefusalTypeId"; cboRefusalType.DataBind(); cboGoodsStatus.Items.Clear(); cboGoodsStatus.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eGoodsRefusedStatus))); cboGoodsStatus.DataBind(); cboLocation.DataTextField = "Description"; cboLocation.DataValueField = "RefusalLocationId"; cboLocation.DataSource = from locations in EF.DataContext.Current.GoodsRefusalLocationSet where locations.RefusalLocationId != 2 && locations.RefusalLocationId != 3 && locations.RefusalLocationId != 4 select new { locations.RefusalLocationId, locations.Description }; cboLocation.DataBind(); this.LoadDeviationReasonCodes(); }
private void PriceRefusals() { TextBox txtCharge = null; string userId = ((Entities.CustomPrincipal)Page.User).UserName; decimal amount = 0; int refusalId = 0; foreach (GridViewRow row in gvRefusals.Rows) { txtCharge = (TextBox)row.FindControl("txtRefusalCharge"); if (decimal.Parse(txtCharge.Text, System.Globalization.NumberStyles.Currency) > 0) { amount = decimal.Parse(txtCharge.Text, System.Globalization.NumberStyles.Currency); refusalId = int.Parse(row.Attributes["__key"].ToString()); using (Facade.IGoodsRefusal facRefusal = new Facade.GoodsRefusal()) facRefusal.SetRefusalCharge(refusalId, amount, userId); } } }
/// <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; } } }
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; } } }
private bool AddGoodsRefused() { Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal(); bool retVal = false; string userName = ((Entities.CustomPrincipal)Page.User).UserName; eJobType jobType = eJobType.Normal; using (Facade.IInstruction facInstruction = new Facade.Instruction()) { Entities.Instruction instruction = facInstruction.GetInstruction(_instructionId); using (Facade.IJob facJob = new Facade.Job()) { Entities.Job job = facJob.GetJob(instruction.JobId); jobType = job.JobType; } } retVal = facGoods.Create(_goodsRefused, jobType, _instructionId, userName); if (!retVal) { lblConfirmation.Text = "There was an error adding the Goods Refused, please try again."; lblConfirmation.Visible = true; lblConfirmation.ForeColor = Color.Red; retVal = false; } else { btnAdd.Text = "Update Goods Refused"; this.ReturnValue = "Refresh_Redeliveries_And_Refusals"; this.Close(); } return(retVal); }
private void Save() { List <int> refusalIdsChecked = new List <int>(); List <int> refusalIdsNotChecked = new List <int>(); foreach (GridItem item in grdRefusals.Items) { if (item is GridDataItem) { using (CheckBox chk = (CheckBox)item.FindControl("chkSelectShort")) { int refusalId = int.Parse(chk.Attributes["RefusalId"]); if (chk.Checked) { refusalIdsChecked.Add(refusalId); } else { refusalIdsNotChecked.Add(refusalId); } } } } Facade.IGoodsRefusal facGoodsRefusal = new Facade.GoodsRefusal(); if (refusalIdsChecked.Count > 0) { facGoodsRefusal.UpdateShortAndOverChecked(refusalIdsChecked, true, ((Entities.CustomPrincipal)Page.User).UserName); } if (refusalIdsNotChecked.Count > 0) { facGoodsRefusal.UpdateShortAndOverChecked(refusalIdsNotChecked, false, ((Entities.CustomPrincipal)Page.User).UserName); } grdRefusals.Rebind(); }
/// <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; } } }
private void GoodsReturnJob() { Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal(); DataSet ds = null; int clientId = cboClient.SelectedValue == "" ? 0 : Convert.ToInt32(cboClient.SelectedValue); DateTime startDate = Convert.ToDateTime(dteStartDate.SelectedDate.Value); DateTime endDate = Convert.ToDateTime(dteEndDate.SelectedDate.Value); int includeReceipt = 0; includeReceipt = (int)Enum.Parse(typeof(eWithOrWithout), rdoClientReceipt.SelectedValue.ToString().Replace(" ", "")); if ((eWithOrWithout)Enum.Parse(typeof(eWithOrWithout), rdoClientReceipt.SelectedValue.ToString().Replace(" ", "")) == eWithOrWithout.All) { includeReceipt = 0; } if (startDate != DateTime.MinValue || endDate != DateTime.MinValue) { ds = facGoods.GetReturnJobswithDates(clientId, startDate, endDate, includeReceipt); } else { if (clientId == 0) { ds = facGoods.GetReturnJobs(includeReceipt); } else { ds = facGoods.GetReturnJobswithParams(clientId, includeReceipt); } } if (ds.Tables[0].Rows.Count != 0) { pnlReturnJobs.Visible = true; ds.Tables[0].Columns.Add("Include", typeof(Boolean)); dgReturnJobs.Visible = true; dgReturnJobs.DataSource = ds; dgReturnJobs.DataBind(); if (cboClient.SelectedValue == "") { btnReport.Visible = btnReportBottom.Visible = false; dgReturnJobs.Levels[0].Columns["Include"].Visible = false; } else { dgReturnJobs.Levels[0].Columns["Include"].Visible = true; btnReport.Visible = btnReportBottom.Visible = true; } ViewState[C_REFUSALDS_VS] = ds; } else { pnlReturnJobs.Visible = false; lblNote.Text = "There are no return runs for given criteria."; lblNote.ForeColor = Color.Red; lblNote.Visible = true; btnReport.Visible = btnReportBottom.Visible = false; } }
// 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"; }