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"); } }
void grdOrders_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item) { Telerik.Web.UI.GridItem item = e.Item as Telerik.Web.UI.GridItem; int invoiceId = Convert.ToInt32(((System.Data.DataRowView)e.Item.DataItem)["InvoiceId"].ToString()); string invoicePdfLocation = ((System.Data.DataRowView)e.Item.DataItem)["InvoicePdfLocation"].ToString(); int orderId = Convert.ToInt32(((System.Data.DataRowView)e.Item.DataItem)["OrderId"].ToString()); bool isPalletNetwork = (bool)(((System.Data.DataRowView)e.Item.DataItem)["IsPalletNetwork"]); bool isExported = !string.IsNullOrEmpty((((System.Data.DataRowView)e.Item.DataItem)["IntegrationReference"]).ToString()); eOrderStatus orderStatus = (eOrderStatus)(Convert.ToInt32(((System.Data.DataRowView)e.Item.DataItem)["OrderStatusId"].ToString())); string collectionPointDescription = ((System.Data.DataRowView)e.Item.DataItem)["CollectionPointDescription"].ToString(); string deliveryPointDescription = ((System.Data.DataRowView)e.Item.DataItem)["DeliveryPointDescription"].ToString(); Label lblCollectFromPoint = (Label)item.FindControl("lblCollectFromPoint"); lblCollectFromPoint.Text = collectionPointDescription; Label lblDeliverToPoint = (Label)item.FindControl("lblDeliverToPoint"); lblDeliverToPoint.Text = deliveryPointDescription; int orderLcid = Convert.ToInt32(((System.Data.DataRowView)e.Item.DataItem)["OrderLcid"].ToString()); int orderGroupLcid = 0; if (((System.Data.DataRowView)e.Item.DataItem)["OrderGroupLcid"].ToString() != string.Empty) { orderGroupLcid = Convert.ToInt32(((System.Data.DataRowView)e.Item.DataItem)["OrderGroupLcid"].ToString()); } System.Globalization.CultureInfo culture = null; if (orderGroupLcid > 0) { culture = new CultureInfo(orderGroupLcid); } else { culture = new CultureInfo(orderLcid); } // Rate:: formatted for current order culture. Label lblRate = (Label)item.FindControl("lblRate"); if (((System.Data.DataRowView)e.Item.DataItem)["DisplayRate"].ToString() != string.Empty) { lblRate.Text = Convert.ToDecimal(((System.Data.DataRowView)e.Item.DataItem)["DisplayRate"]).ToString("C", culture); } else { lblRate.Text = " "; } // Pod link Facade.POD facPod = new Orchestrator.Facade.POD(); Orchestrator.Entities.POD scannedPOD = facPod.GetForOrderID(orderId); HyperLink hypPod = (HyperLink)item.FindControl("hypPod"); if (scannedPOD != null) { hypPod.Visible = true; hypPod.Text = string.Format("POD:{0}", scannedPOD.PODId); hypPod.NavigateUrl = scannedPOD.ScannedFormPDF.Trim(); hypPod.Target = "_blank"; } else if (scannedPOD == null && (orderStatus == eOrderStatus.Delivered || orderStatus == eOrderStatus.Invoiced)) { hypPod.Visible = false; hypPod.Text = ""; hypPod.NavigateUrl = ""; } // Invoice link HyperLink hypInvoice = (HyperLink)e.Item.FindControl("hypInvoice"); if (invoiceId <= 0) { hypInvoice.Text = ""; hypInvoice.NavigateUrl = ""; } else { hypInvoice.NavigateUrl = Orchestrator.Globals.Configuration.WebServer + invoicePdfLocation; hypInvoice.Text = string.Format("Invoice:{0}", invoiceId); hypInvoice.Target = "_blank"; } // order id link HyperLink hypOrderId = (HyperLink)e.Item.FindControl("hypOrderId"); hypOrderId.Text = orderId.ToString(); // If the order is unapproved, take the client to the update order page // otherwise take the user to the client order profile screen. if (orderStatus == eOrderStatus.Pending || orderStatus == eOrderStatus.Awaiting_Approval) { hypOrderId.NavigateUrl = string.Format("ClientManageOrder.aspx?Oid={0}", orderId); } else { // show the order profile link. hypOrderId.NavigateUrl = string.Format("javascript:openResizableDialogWithScrollbars('ClientOrderProfile.aspx?wiz=true&Oid={0}',560,700);", orderId); hypOrderId.Target = ""; } //Order status Label lblOrderStatus = (Label)e.Item.FindControl("lblOrderStatus"); string orderStatusText = string.Empty; switch (orderStatus) { case eOrderStatus.Pending: orderStatusText = "Pending"; break; case eOrderStatus.Awaiting_Approval: orderStatusText = "Unapproved"; break; case eOrderStatus.Approved: orderStatusText = "Approved"; break; case eOrderStatus.Delivered: orderStatusText = "Delivered"; break; case eOrderStatus.Invoiced: orderStatusText = "Invoiced"; break; case eOrderStatus.Cancelled: orderStatusText = "Cancelled"; break; case eOrderStatus.Rejected: orderStatusText = "Rejected"; break; default: break; } lblOrderStatus.Text = orderStatusText; if (Orchestrator.Globals.Configuration.PalletNetworkLabelID == eReportType.PalletNetworkLabel) { if (isExported) { e.Item.BackColor = System.Drawing.Color.LightGreen; } } } }