public Orchestrator.WebUI.ws.MappingServices.Point GetPoint(int pointID) { Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point(); Orchestrator.Entities.Point selectedPoint = facPoint.GetPointForPointId(pointID); Orchestrator.WebUI.ws.MappingServices.Point p = new Orchestrator.WebUI.ws.MappingServices.Point(); p.PointID = selectedPoint.PointId; p.Description = selectedPoint.Description; p.Latitide = (double)selectedPoint.Latitude; p.Longitude = (double)selectedPoint.Longitude; p.GeofencePoints = new List <double[]>(); string points = string.Empty; for (int i = 0; i < selectedPoint.Geofence.STNumPoints(); i++) { SqlGeography point = selectedPoint.Geofence.STPointN(i + 1); double[] latLon = new double[2] { (double)point.Lat, (double)point.Long }; p.GeofencePoints.Add(latLon); //points = point.Lat.ToString() + ',' + point.Long.ToString() + '|'; } return(p); }
public string GetAddressForPoint(int pointID) { string address = string.Empty; Orchestrator.Facade.Point facPoint = new Orchestrator.Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(pointID); address = point.Address.ToString(); address = address.Replace("\n", ""); address = address.Replace("\r", "<br>"); return(address); }
public void cboPoint_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e) { Orchestrator.Entities.Point selectedPoint = null; if (cboPoint.SelectedValue != String.Empty) { Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point(); selectedPoint = facPoint.GetPointForPointId(this.PointID); } UpdateControls(selectedPoint); }
protected void grdDepots_ItemDataBound(object sender, GridItemEventArgs e) { //If the Grid Item is the EditForm and it is being shown if (e.Item.ItemType == GridItemType.EditFormItem && e.Item.IsInEditMode) { //Get the Point and Code controls from the EditForm Orchestrator.WebUI.Controls.Point ucPoint = (Orchestrator.WebUI.Controls.Point)e.Item.FindControl("ucPoint"); TextBox txtCode = (TextBox)e.Item.FindControl("txtCode"); TextBox txtHubIdentifier = (TextBox)e.Item.FindControl("txtHubIdentifier"); RadComboBox cboPrintOnLabel = (RadComboBox)e.Item.FindControl("cboPrintOnLabel"); //If the EditForm is being shown for a new Depot default the values if (e.Item.OwnerTableView.IsItemInserted) { //Set the default values for a new Depot txtCode.Text = string.Empty; txtHubIdentifier.Text = string.Empty; cboPrintOnLabel.SelectedIndex = 1; ucPoint.Reset(); } else { int depotId = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["DepotId"]; using (var uow = DIContainer.CreateUnitOfWork()) { var depotRepo = DIContainer.CreateRepository <Repositories.IDepotRepository>(uow); var depot = depotRepo.Find(depotId); Facade.Point facPoint = new Orchestrator.Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(depot.PointID); ucPoint.SelectedPoint = point; txtCode.Text = depot.Code; txtHubIdentifier.Text = depot.HubIdentifier; if (depot.PrintOnLabel == null || depot.PrintOnLabel == false) { cboPrintOnLabel.SelectedIndex = 1; } else { cboPrintOnLabel.SelectedIndex = 0; } } } } }
//----------------------------------------------------------------------------------------------------------- private Orchestrator.WebUI.Services.Point GetPointForWebService(int pointID) { Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point(); Orchestrator.Entities.Point selectedPoint = facPoint.GetPointForPointId(pointID); Orchestrator.WebUI.Services.Point p = new Orchestrator.WebUI.Services.Point(); p.PointID = selectedPoint.PointId; p.Description = selectedPoint.Description; p.Latitide = (double)selectedPoint.Latitude; p.Latitude = (double)selectedPoint.Latitude; // added a correctly spelt version but left the old one to prevent having to change everything. p.Longitude = (double)selectedPoint.Longitude; p.ClosestTownID = selectedPoint.PostTown.TownId; p.ClosestTown = selectedPoint.PostTown.TownName; p.IdentityID = selectedPoint.IdentityId; p.OrganisationName = selectedPoint.OrganisationName; p.PointNotes = selectedPoint.PointNotes; p.PointCode = selectedPoint.PointCode; p.PhoneNumber = selectedPoint.PhoneNumber; p.AddressID = selectedPoint.Address.AddressId; p.AddressLine1 = selectedPoint.Address.AddressLine1; p.AddressLine2 = selectedPoint.Address.AddressLine2; p.AddressLine3 = selectedPoint.Address.AddressLine3; p.PostTown = selectedPoint.Address.PostTown; p.County = selectedPoint.Address.County; p.PostCode = selectedPoint.Address.PostCode; p.CountryID = selectedPoint.Address.CountryId; p.CountryDescription = selectedPoint.Address.CountryDescription; p.GeofencePoints = new List <LatLong>(); string points = string.Empty; for (int i = 0; i < selectedPoint.Geofence.STNumPoints(); i++) { SqlGeography point = selectedPoint.Geofence.STPointN(i + 1); LatLong latLon = new LatLong() { Latitude = (double)point.Lat, Longitude = (double)point.Long }; p.GeofencePoints.Add(latLon); } return(p); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int orderId = Convert.ToInt32(Request.QueryString["OrderId"].ToString()); int pointId = Convert.ToInt32(Request.QueryString["PointId"].ToString()); string pointType = Request.QueryString["PType"].ToString(); if (pointType.ToUpper() == "D") { pointType = "delivery"; } else if (pointType.ToUpper() == "C") { pointType = "collection"; } // Set the page title. this.Master.WizardTitle = string.Format("Approve {0} point for order {1}", pointType, orderId);; lblProposedPoint.Text = string.Format("Please approve the proposed {0} point for order {1}", pointType, orderId); lblProposedPoint.Font.Bold = true; lblAlternativePoint.Text = string.Format("... or choose an alternative {0} point for order {1}", pointType, orderId); lblAlternativePoint.Font.Bold = true; Facade.Point facPoint = new Orchestrator.Facade.Point(); this.Point = facPoint.GetPointForPointId(pointId); string fullAddress = this.Point.Address.ToString(); fullAddress = fullAddress.Replace("\n", ""); fullAddress = fullAddress.Replace("\r", "<br>"); lblFullAddress.Text = this.Point.OrganisationName + "<br />" + fullAddress; string jsInjection = @" try { resizeTo(630, 730); } catch (err) { } window.focus(); moveTo(30, 20);"; this.ClientScript.RegisterClientScriptBlock(this.GetType(), "ApproveOnly", jsInjection, true); } }
public Orchestrator.WebUI.Services.Point UpdatePoint(Orchestrator.WebUI.Services.Point p, string userId) { Orchestrator.WebUI.Services.Point returnPoint = null; Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point(); Orchestrator.Entities.Point selectedPoint = facPoint.GetPointForPointId(p.PointID); selectedPoint.Description = p.Description; selectedPoint.Latitude = (decimal)p.Latitide; selectedPoint.Longitude = (decimal)p.Longitude; selectedPoint.PostTown.TownId = p.ClosestTownID; selectedPoint.PostTown.TownName = p.ClosestTown; selectedPoint.PointNotes = p.PointNotes; selectedPoint.PointCode = p.PointCode; selectedPoint.PhoneNumber = p.PhoneNumber; selectedPoint.Address.AddressLine1 = p.AddressLine1; selectedPoint.Address.AddressLine2 = p.AddressLine2; selectedPoint.Address.AddressLine3 = p.AddressLine3; selectedPoint.Address.PostTown = p.PostTown; selectedPoint.Address.County = p.County; selectedPoint.Address.PostCode = p.PostCode; selectedPoint.Address.CountryId = p.CountryID; selectedPoint.Address.CountryDescription = p.CountryDescription; Entities.FacadeResult facResult = facPoint.Update(selectedPoint, userId); if (facResult.Success) { returnPoint = this.GetPointForWebService(selectedPoint.PointId); } else { foreach (BusinessRuleInfringement i in facResult.Infringements) { p.ErrorMeesage += String.Format("{0} : {1}{2}", i.Key, i.Description, Environment.NewLine); } returnPoint = p; } return(returnPoint); }
protected void btnApprovePoint_Click(object sender, EventArgs e) { int orderId = Convert.ToInt32(Request.QueryString["OrderId"].ToString()); int pointId = Convert.ToInt32(Request.QueryString["PointId"].ToString()); Facade.Point facPoint = new Orchestrator.Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(pointId); Facade.IOrganisation facOrg = new Facade.Organisation(); Entities.Organisation org = facOrg.GetForName(point.OrganisationName); Entities.FacadeResult res = null; using (TransactionScope ts = new TransactionScope()) { if (org.IdentityStatus == eIdentityStatus.Unapproved) { // Set the identityStatus to approved org.IdentityStatus = eIdentityStatus.Active; facOrg.Update(org, this.Page.User.Identity.Name); } point.PointStateId = ePointState.Approved; res = facPoint.Update(point, this.Page.User.Identity.Name); ts.Complete(); } if (res.Success) { this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ApprovePoint", "window.opener.__doPostBack('','Refresh');window.close();", true); } else { idErrors.Infringements = res.Infringements; idErrors.DisplayInfringments(); idErrors.Visible = true; } }
//-------------------------------------------------------------------------------------------------------- public void btnAddTrunkPoint_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(this.txtMultiTrunkName.Text.Trim())) { // if this is the first point being added the multi-trunk object will be null if (this.multiTrunk == null) { this.multiTrunk = new Orchestrator.Entities.MultiTrunk(); this.multiTrunk.MultiTrunkId = -1; } this.multiTrunk.IsEnabled = this.chkIsEnabled.Checked; this.multiTrunk.Description = this.txtMultiTrunkName.Text.Trim(); if (this.multiTrunk.TrunkPoints == null) { this.multiTrunk.TrunkPoints = new List <Orchestrator.Entities.MultiTrunkPoint>(); } Entities.MultiTrunkPoint trunkPoint = new Orchestrator.Entities.MultiTrunkPoint(-1, this.multiTrunk.MultiTrunkId, this.ucCollectionPoint.PointID, Convert.ToInt32(this.txtDefaultDuration.Value), this.multiTrunk.TrunkPoints.Count); Facade.Point facPoint = new Orchestrator.Facade.Point(); trunkPoint.Point = facPoint.GetPointForPointId(trunkPoint.PointId); this.multiTrunk.TrunkPoints.Add(trunkPoint); this.PopulateTrunkPointsRepeater(this.multiTrunk.TrunkPoints); this.ucCollectionPoint.Reset(); this.txtDefaultDuration.Text = String.Empty; this.VS_MultiTrunk = this.multiTrunk; } }
private void DisplayOrder(Orchestrator.Entities.Order order) { Orchestrator.Facade.IOrganisation facOrg = new Orchestrator.Facade.Organisation(); Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point(); Orchestrator.Facade.IReferenceData facRefData = new Orchestrator.Facade.ReferenceData(); Orchestrator.Facade.IPOD facPOD = new Orchestrator.Facade.POD(); Orchestrator.Facade.IOrder facOrd = new Orchestrator.Facade.Order(); order.ClientInvoiceID = facOrd.ClientInvoiceID(OrderID); Orchestrator.Facade.Organisation facOrgD = new Orchestrator.Facade.Organisation(); Orchestrator.Entities.Point collectionPoint = facPoint.GetPointForPointId(order.CollectionPointID); Orchestrator.Entities.Point deliveryPoint = facPoint.GetPointForPointId(order.DeliveryPointID); Orchestrator.Entities.POD scannedPOD = facPOD.GetForOrderID(order.OrderID); Orchestrator.Entities.Scan scannedBookingForm = null; CurrentCulture = new CultureInfo(order.LCID); ExchangeRateID = order.ExchangeRateID; lblOrderHeading.Text = string.Format("Order {0}", order.OrderID); this.lblOrderStatus.Text = order.OrderStatus.ToString(); if (((Entities.CustomPrincipal) this.Page.User).IsInRole(((int)eUserRole.SubConPortal).ToString())) { this.btnPIL.Visible = false; this.btnCreateDeliveryNote.Visible = false; this.btnCreateDeliveryNote2.Visible = false; this.btnPIL2.Visible = false; plcBooking.Visible = false; plcPOD.Visible = false; // get cost for subby and display as rate. (The rate the subby is being paid) Facade.IJobSubContractor jobSubContractor = new Facade.Job(); if (order != null && order.JobSubContractID > 0) { Entities.JobSubContractor js = jobSubContractor.GetSubContractorForJobSubContractId(order.JobSubContractID); CultureInfo subbyCulture = new CultureInfo(js.LCID); if (Orchestrator.Globals.Configuration.MultiCurrency) { this.lblRate.Text = string.Format(rateTemplate, js.ForeignRate.ToString("C", subbyCulture), js.Rate.ToString("C")); } else { this.lblRate.Text = js.Rate.ToString("C", subbyCulture); } } this.tblSubbyRate.Visible = true; this.trRate.Visible = false; this.trInvoiceId.Visible = false; } else { this.tblSubbyRate.Visible = false; //If the order has a scanned Booking Form get it so that //a link to it can be displayed if (order.BookingFormScannedFormId != null) { Orchestrator.Facade.Form facBF = new Orchestrator.Facade.Form(); scannedBookingForm = facBF.GetForScannedFormId(order.BookingFormScannedFormId.Value); } //this.lblOrderID.Text = order.OrderID.ToString(); this.lblOrderStatus.Text = order.OrderStatus.ToString().Replace("_", " "); if (scannedBookingForm != null) { hlBookingFormLink.Visible = true; hlBookingFormLink.NavigateUrl = scannedBookingForm.ScannedFormPDF.Trim(); aScanBookingForm.InnerHtml = "| Re-Scan"; aScanBookingForm.HRef = @"javascript:ReDoBookingForm(" + scannedBookingForm.ScannedFormId + "," + order.OrderID.ToString() + ");"; } else { hlBookingFormLink.Visible = false; aScanBookingForm.InnerHtml = "Scan"; aScanBookingForm.HRef = @"javascript:NewBookingForm(" + order.OrderID.ToString() + ");"; } plcPOD.Visible = false; if (Orchestrator.Globals.Configuration.MultiCurrency) { this.lblRate.Text = string.Format(rateTemplate, order.ForeignRate.ToString("C", CurrentCulture), order.Rate.ToString("C")); } else { this.lblRate.Text = order.ForeignRate.ToString("C", CurrentCulture); } trRate.Visible = !order.IsInGroup; if (order.ClientInvoiceID <= 0) { lblInvoiceNumber.Text = "None Assigned"; } else { lblInvoiceNumber.Text = order.ClientInvoiceID.ToString(); string PDFLink = order.PDFLocation.ToString(); lblInvoiceNumber.NavigateUrl = Orchestrator.Globals.Configuration.WebServer + PDFLink; } } this.lblLoadNumber.Text = order.CustomerOrderNumber; this.lblDeliveryOrderNo.Text = order.DeliveryOrderNumber; this.lblCollectionPoint.Text = collectionPoint.Address.ToString(); this.lblDeliverTo.Text = deliveryPoint.Address.ToString(); this.lblCollectDateTime.Text = (order.CollectionIsAnytime == true ? (order.CollectionDateTime.ToString("dd/MM/yy") + " AnyTime") : (order.CollectionDateTime.ToString("dd/MM/yy HH:mm"))); this.lblDeliveryDateTime.Text = (order.DeliveryIsAnytime == true ? (order.DeliveryDateTime.ToString("dd/MM/yy") + " AnyTime") : (order.DeliveryDateTime.ToString("dd/MM/yy HH:mm"))) + order.DeliveryAnnotation; this.lblPallets.Text = order.NoPallets.ToString() + " " + Orchestrator.Facade.PalletType.GetForPalletTypeId(order.PalletTypeID).Description; this.lblPalletSpaces.Text = order.PalletSpaces.ToString("0.##"); this.lblGoodsType.Text = Orchestrator.Facade.GoodsType.GetForGoodsTypeId(order.GoodsTypeID).Description; this.lblWeight.Text = Convert.ToInt32(order.Weight).ToString() + " " + Orchestrator.Facade.WeightType.GetForWeightTypeId(order.WeightTypeID).ShortCode; this.repReferences.DataSource = order.OrderReferences; this.repReferences.DataBind(); this.lblCartons.Text = order.Cases.ToString(); if (order.Notes == null || order.Notes.Length == 0) { this.lblNotes.Text = " "; } else { this.lblNotes.Text = order.Notes; } if (order.CreateDateTime != DateTime.MinValue) { lblCreated.Text = order.CreatedBy + " on " + order.CreateDateTime.ToString("dd/MM/yy HH:mm"); } lblOrderServiceLevel.Text = order.OrderServiceLevel; if (order.BusinessTypeID > 0) { Orchestrator.Facade.IBusinessType facBusinessType = new Orchestrator.Facade.BusinessType(); Orchestrator.Entities.BusinessType businessType = facBusinessType.GetForBusinessTypeID(order.BusinessTypeID); lblBusinessType.Text = businessType.Description; } else { lblBusinessType.Text = "Not Set"; } plcCancellation.Visible = order.OrderStatus == eOrderStatus.Cancelled; if (order.OrderStatus == eOrderStatus.Cancelled) { lblCancellationReason.Text = order.CancellationReason; lblCancelledBy.Text = order.CancelledBy; lblCancelledAt.Text = order.CancelledAt.ToString("dd/MM/yy HH:mm"); } }
protected void btnSubmitAlternative_Click(object sender, EventArgs e) { if (ucPoint.PointID > 0) { int orderId = Convert.ToInt32(Request.QueryString["OrderId"].ToString()); int pointId = Convert.ToInt32(Request.QueryString["PointId"].ToString()); string pointType = Request.QueryString["PType"].ToString(); if (pointType.ToUpper() == "D") { pointType = "delivery"; } else if (pointType.ToUpper() == "C") { pointType = "collection"; } Facade.Point facPoint = new Orchestrator.Facade.Point(); this.Point = facPoint.GetPointForPointId(pointId); this.Point.PointStateId = ePointState.Rejected; Facade.IOrder facOrder = new Orchestrator.Facade.Order(); Entities.Order order = facOrder.GetForOrderID(orderId); switch (pointType) { case "delivery": order.DeliveryPointID = ucPoint.PointID; break; case "collection": order.CollectionPointID = ucPoint.PointID; break; default: break; } bool failTheTransaction = false; using (TransactionScope ts = new TransactionScope()) { // Do not set the point to rejected when submitting an alternative, doing so // may causse problems for other unapproved invoices that use the same point. if (!failTheTransaction) { // Update the orders collection or delivery point to the alternative point. bool orderUpdated = false; orderUpdated = facOrder.Update(order, this.User.Identity.Name); if (!orderUpdated) { failTheTransaction = true; } } if (!failTheTransaction) { ts.Complete(); this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SubmitAlternativePoint", "window.opener.__doPostBack('','Refresh');window.close();", true); } } } else { // User must first select an alternative point. } }
private void PointEditMode() { if (PointID > 0 || SelectedPoint != null) { ScriptManager.GetCurrent(Page).SetFocus(cboCountry); btnCreatePoint.Visible = false; btnAlterPoint.Visible = true; cboNewPointOwner.Enabled = false; lblError.Text = String.Empty; lblError.Visible = false; // Clear Previous Values cboClosestTown.ClearSelection(); cboCountry.ClearSelection(); txtAddressLine1.Text = ""; txtAddressLine2.Text = ""; txtAddressLine3.Text = ""; txtPostTown.Text = ""; txtPostCode.Text = ""; txtCounty.Text = ""; txtPointNotes.Text = ""; hidLat.Value = ""; hidLon.Value = ""; this.txtPointCode.Text = String.Empty; this.hdnSetPointRadius.Value = String.Empty; // Get the point and populate the fields. Facade.Point facPoint = new Orchestrator.Facade.Point(); Entities.Point point = null; if (SelectedPoint == null) { point = SelectedPoint; } else { point = facPoint.GetPointForPointId(this.PointID); } EditPointLoadCountry(); using (var uow = DIContainer.CreateUnitOfWork()) { var userRepo = DIContainer.CreateRepository <IUserRepository>(uow); var user = userRepo.FindByName(point.CreatorUserId); if (user != null) { txtCreatedBy.Text = user.FullName; } else { txtCreatedBy.Text = point.CreatorUserId; } if (!string.IsNullOrEmpty(point.LastUpdaterUserId)) { user = userRepo.FindByName(point.LastUpdaterUserId); if (user != null) { txtLastModifiedBy.Text = user.FullName; } else { txtLastModifiedBy.Text = point.LastUpdaterUserId; } } } txtCreationDate.Text = point.CreationDate.ToLongDateString(); if (point.LastUpdateDate != null) { txtLastModificationDate.Text = point.LastUpdateDate.Value.ToLongDateString(); } txtDescription.Text = point.Description; txtAddressLine1.Text = point.Address.AddressLine1; txtAddressLine2.Text = point.Address.AddressLine2; txtAddressLine3.Text = point.Address.AddressLine3; txtPostTown.Text = point.PostTown.TownName; txtPostCode.Text = point.Address.PostCode; txtCounty.Text = point.Address.County; txtPointNotes.Text = point.PointNotes; this.txtPointCode.Text = point.PointCode; hidLat.Value = point.Latitude.ToString(); hidLon.Value = point.Longitude.ToString(); this.txtPhoneNumber.Text = point.PhoneNumber; cboCountry.Text = point.Address.CountryDescription; cboCountry.SelectedValue = point.Address.CountryId.ToString(); // Set closest town combo cboClosestTown.Text = point.PostTown.TownName; cboClosestTown.SelectedValue = point.PostTown.TownId.ToString(); // Set traffic area PopulateTrafficAreaControl(); cboTrafficArea.Items.FindItemByValue(point.Address.TrafficArea.TrafficAreaId.ToString()).Selected = true; // Get/set the organisation cboNewPointOwner.Text = point.OrganisationName; pnlPoint.Visible = false; pnlNewPoint.Visible = true; this.rfvAddressLine1.Enabled = this.RequireAddressLine1; lblFullAddress.Text = string.Empty; pnlFullAddress.Visible = false; } else { try { ScriptManager.GetCurrent(Page).SetFocus(cboNewPointOwner); } catch { } // this is becuase we do not want to show the cancel button from the add point page. if (Request.QueryString["allowclose"] != null && Convert.ToBoolean(Request.QueryString["allowclose"].ToString()) == false) { btnCancel.Visible = false; } btnCreatePoint.Visible = true; btnAlterPoint.Visible = false; cboNewPointOwner.Enabled = true; lblError.Text = String.Empty; lblError.Visible = false; // Clear Previous Values //cboClosestTown.ClearSelection(); if (string.IsNullOrEmpty(cboNewPointOwner.SelectedValue)) { cboNewPointOwner.SelectedValue = ""; cboNewPointOwner.Text = ""; } else { // this s a new point for a client so do not allow the organisation to be changed. cboNewPointOwner.Enabled = false; } txtCreatedBy.Text = ((CustomPrincipal)Page.User).Name; txtCreationDate.Text = DateTime.Now.ToLongDateString(); txtLastModifiedBy.Text = string.Empty; txtLastModificationDate.Text = string.Empty; cboClosestTown.SelectedValue = ""; cboClosestTown.Text = ""; txtAddressLine1.Text = ""; txtAddressLine2.Text = ""; txtAddressLine3.Text = ""; txtPostTown.Text = ""; txtPostCode.Text = ""; txtCounty.Text = ""; hidLat.Value = ""; hidLon.Value = ""; txtPointNotes.Text = ""; txtDescription.Text = " - "; this.txtPointCode.Text = ""; this.txtPhoneNumber.Text = ""; pnlPoint.Visible = false; pnlNewPoint.Visible = true; this.rfvAddressLine1.Enabled = this.RequireAddressLine1; lblFullAddress.Text = string.Empty; pnlFullAddress.Visible = false; PopulateTrafficAreaControl(); EditPointLoadCountry(); cboCountry.SelectedIndex = 0; } inpCreateNewPointSelected.Value = bool.TrueString; }
void btnAlterPoint_Click(object sender, EventArgs e) { Page.Validate("AlterPoint"); if (Page.IsValid) { int ownerID = 0; #region Validate that the Point Name is Unique for this Organisation bool foundPointName = false; lblError.Visible = false; Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(PointID); ownerID = new Facade.Organisation().GetForName(cboNewPointOwner.Text).IdentityId; DataSet pointNames = facPoint.GetAllForOrganisation(ownerID, ePointType.Any, txtDescription.Text); foreach (DataRow row in pointNames.Tables[0].Rows) { if (((string)row["Description"]) == txtDescription.Text && point.PointId != (int)row["PointId"]) { foundPointName = true; } } #endregion if (foundPointName) { lblError.Text = "The Description must be unique for this organisation."; lblError.ForeColor = Color.Red; lblError.Visible = true; pnlPoint.Visible = false; pnlNewPoint.Visible = true; pnlFullAddress.Visible = false; } else { Orchestrator.Facade.IPostTown facPostTown = new Orchestrator.Facade.Point(); Orchestrator.Entities.PostTown town = facPostTown.GetPostTownForTownId(int.Parse(cboClosestTown.SelectedValue)); // Set the point owner and description point.OrganisationName = cboPoint.Text; point.IdentityId = ownerID; point.Description = txtDescription.Text; point.PointCode = this.txtPointCode.Text; // Get the point type switch (this.PointType) { case ePointType.Collect: point.Collect = true; break; case ePointType.Deliver: point.Deliver = true; break; case ePointType.Any: point.Collect = true; point.Deliver = true; break; } // set the address Orchestrator.Entities.Address address = new Orchestrator.Entities.Address(); address.AddressLine1 = txtAddressLine1.Text; address.AddressLine2 = txtAddressLine2.Text; address.AddressLine3 = txtAddressLine3.Text; address.AddressType = eAddressType.Point; address.County = txtCounty.Text; address.CountryDescription = this.cboCountry.Text; address.CountryId = Convert.ToInt32(this.cboCountry.SelectedValue); address.IdentityId = ownerID; decimal latitude = 0; if (decimal.TryParse(hidLat.Value, out latitude)) { address.Latitude = latitude; } decimal longitude = 0; if (decimal.TryParse(hidLon.Value, out longitude)) { address.Longitude = longitude; } address.PostCode = txtPostCode.Text.ToUpper(); address.PostTown = txtPostTown.Text; if (address.TrafficArea == null) { address.TrafficArea = new Orchestrator.Entities.TrafficArea(); } Facade.IOrganisation facOrganisation = new Facade.Organisation(); Orchestrator.Entities.Organisation organisation = facOrganisation.GetForIdentityId(point.IdentityId); // set the radius if the address was changed by addressLookup // if the org has a default, use it, if not, use the system default. if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value)) { if (organisation.Defaults != null) { if (organisation.Defaults.Count > 0 && organisation.Defaults[0].DefaultGeofenceRadius.HasValue) { point.Radius = organisation.Defaults[0].DefaultGeofenceRadius; } else { point.Radius = Globals.Configuration.GPSDefaultGeofenceRadius; } } else { point.Radius = Globals.Configuration.GPSDefaultGeofenceRadius; } } // Get the Traffic Area for this Point address.TrafficArea.TrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue); point.Address = address; point.Longitude = address.Longitude; point.Latitude = address.Latitude; point.PostTown = town; point.PointNotes = txtPointNotes.Text; if (ClientUserOrganisationIdentityID > 0) { point.PointStateId = ePointState.Unapproved; } else { point.PointStateId = ePointState.Approved; } point.PhoneNumber = txtPhoneNumber.Text; string userId = ((Orchestrator.Entities.CustomPrincipal)Page.User).UserName; // Create the new point Entities.FacadeResult result = facPoint.Update(point, userId); if (result.Success) { // get the Point with all parts populated. this.SelectedPoint = point; cboPoint.Text = point.Description; cboPoint.SelectedValue = point.IdentityId.ToString() + "," + point.PointId.ToString(); pnlNewPoint.Visible = false; pnlPoint.Visible = true; inpCreateNewPointSelected.Value = string.Empty; } else { for (int i = 0; i < result.Infringements.Count; i++) { lblError.Text += result.Infringements[i].Description + Environment.NewLine; } lblError.ForeColor = Color.Red; lblError.Visible = true; pnlPoint.Visible = false; pnlNewPoint.Visible = true; pnlFullAddress.Visible = false; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //this.CboCountryLoad(); rfvPoint.Enabled = PointSelectionRequired; Orchestrator.Facade.IPoint facPoint = new Orchestrator.Facade.Point(); Orchestrator.Entities.Point selectedPoint = facPoint.GetPointForPointId(this.PointID); if (this.Width.Value != 0) { this.cboPoint.Width = this.Width; this.cboClosestTown.Width = this.Width; } //Reset the Depot this.Depot = string.Empty; this.CountryCode = string.Empty; if (selectedPoint != null) { cboPoint.SelectedValue = selectedPoint.IdentityId.ToString() + "," + selectedPoint.PointId.ToString(); if (ShowFullAddress) { string fullAddress = selectedPoint.Address.ToString(); fullAddress = fullAddress.Replace("\n", ""); fullAddress = fullAddress.Replace("\r", "<br>"); lblFullAddress.Text = fullAddress; pnlFullAddress.Visible = true; } if (!String.IsNullOrEmpty(selectedPoint.Address.PostCode)) { //Change to only show the first depot for a postcode (as there should be only one anyway) //Get the Depot Codes for this Point's PostCode //string depots = string.Empty; //foreach (string depotCode in // EF.Depot.GetForPostCode(selectedPoint.Address.PostCode).Select(d => d.Code)) //{ // depots += depotCode + ", "; //} //if (depots.Length > 0) //{ // depots = depots.Remove(depots.Length - 2); // lblDepot.Text = string.Format("Depot {0}", depots); //} //else // lblDepot.Text = ""; //We have a postcode so try to lookup a depot var depot = EF.Depot.GetForPostCode(selectedPoint.Address.PostCode).FirstOrDefault(); if (depot != null) { this.Depot = depot.Code; this.CountryCode = depot.CountryCode ?? string.Empty; } } if (this.IsDepotVisible) { lblDepot.Text = string.Format("Depot {0}", this.Depot); } this.lnkPointGeography.OnClientClick = "javascript:" + this.ClientID + "_UpdateGeography(" + selectedPoint.PointId + "); return false;"; } if (this.EditMode) { this.PointEditMode(); } } else { this.divDuplicateAddress.Visible = false; } }