protected void btnAddLine_Click(object sender, EventArgs e) { try { // Load the shipment we're adding the line to Discovery.BusinessObjects.TDCShipment tdcShipment = TDCShipmentController.GetShipment( Convert.ToInt32(Request.QueryString["Id"])); // Create a new shipment line TDCShipmentLine tdcLine = new TDCShipmentLine(); tdcLine.Id = -1; tdcLine.ShipmentId = tdcShipment.Id; tdcLine.UpdatedBy = Page.User.Identity.Name; tdcLine.ConversionInstructions = txtConversionInstructions.Text; tdcLine.ConversionQuantity = Convert.ToInt32(txtConversionQuantity.Text); tdcLine.CustomerReference = txtCustomerReference.Text; tdcLine.Description1 = txtDescription1.Text; tdcLine.Description2 = txtDescription2.Text; tdcLine.Grammage = Convert.ToInt32(txtGrammage.Text); tdcLine.NetWeight = Convert.ToDecimal(txtNetWeight.Text); tdcLine.IsISO9000Approved = chkIsISO9000Approved.Checked; tdcLine.IsPanel = chkIsPanel.Checked; tdcLine.Length = Convert.ToInt32(txtLength.Text); tdcLine.LineNumber = tdcShipment.ShipmentLines.Count + 1; tdcLine.LoadCategoryCode = ddlLoadCategory.SelectedValue; tdcLine.Microns = Convert.ToInt32(txtMicrons.Text); tdcLine.Packing = txtPacking.Text; tdcLine.ProductCode = tdcShipment.Type.ToString(); tdcLine.ProductGroup = txtProductGroup.Text; tdcLine.Quantity = Convert.ToInt32(txtQuantity.Text); tdcLine.QuantityUnit = txtQuantityUnit.Text; tdcLine.Volume = Convert.ToDecimal(txtVolume.Text); tdcLine.Width = Convert.ToInt32(txtWidth.Text); // Add the shipment line to the shipment TDCShipmentLineController.SaveLine(tdcLine); // Update the UI if (null != SaveComplete) { // Notify others that we've split the shipment SaveComplete(this, new EventArgs()); } // Display message ((DiscoveryPage)Page).DisplayMessage(String.Format("Line #{0} product code {1} was added to shipment {2}.", tdcLine.LineNumber, tdcLine.ProductCode, tdcShipment.ShipmentNumber), DiscoveryMessageType.Success); } catch (Exception ex) { // Display message ((DiscoveryPage)Page).DisplayMessage(String.Concat("There was an error saving the shipment line. ", ex.Message), DiscoveryMessageType.Error); } }
protected void btnSplitConfirm_Click(object sender, EventArgs e) { try { // Load the shipment we need to split Discovery.BusinessObjects.TDCShipment tdcShipment = TDCShipmentController.GetShipment(Convert.ToInt32(Request.QueryString["Id"])); // Reset the split shipment splitShipment = null; // Get the lines and quantities, etc and split the shipment splitShipment = tdcShipment.SplitShipment( GetLineSplits(), AlterSourceQuantities, AlterWeightsAndVolumes, Page.User.Identity.Name); // See if we've got something to do if (null != splitShipment) { // Re-bind the data dataSourceShipmentLines.DataBind(); // Update the UI if (null != SaveComplete) { // Notify others that we've split the shipment SaveComplete(this, new EventArgs()); } // Display message ((DiscoveryPage)Page).DisplayMessage(String.Format("Shipment {0}-{1} was split creating shipment <a href=\"TDCShipment.aspx?Id={4}\">{2}-{3}</a>.", tdcShipment.ShipmentNumber, tdcShipment.DespatchNumber, splitShipment.ShipmentNumber, splitShipment.DespatchNumber, splitShipment.Id), DiscoveryMessageType.Success); } else { // Display message ((DiscoveryPage)Page).DisplayMessage("The shipment was <b>not</b> split as no quantities greater than 0 (zero) were specified.", DiscoveryMessageType.Information); } } catch (Exception ex) { // Display message ((DiscoveryPage)Page).DisplayMessage(String.Concat("There was a problem splitting the shipment. ", ex.Message), DiscoveryMessageType.Error); // We failed to split the shipment splitShipment = null; } }
protected void btnTDCShipmentDetails_Click(object sender, System.EventArgs e) { // Get the opco code, shipment number and the despatch number string[] shipmentParams = ((System.Web.UI.WebControls.IButtonControl)sender).CommandArgument.Split('|'); // Get the tdc shipment Discovery.BusinessObjects.TDCShipment tdcShipment = TDCShipmentController.GetShipment(shipmentParams[0], shipmentParams[1], shipmentParams[2]); if (null != tdcShipment) { // Redirect to the tdc shipment page Response.Redirect(string.Concat("~/Shipments/TDCShipment.aspx?Id=", tdcShipment.Id)); } }
protected void btnPrintDelColl_Click(object sender, System.EventArgs e) { try { // Print the shipment TDCShipmentController.GetShipment(Convert.ToInt32(((System.Web.UI.WebControls.IButtonControl)sender).CommandArgument)).PrintDeliveryCollectionNote(); // Display message ((DiscoveryPage)this.Page).DisplayMessage("The delivery/collection note was printed successfully.", DiscoveryMessageType.Success); } catch (Exception ex) { // Display message ((DiscoveryPage)this.Page).DisplayMessage("There was an error printing the delivery/collection note.", DiscoveryMessageType.Error); } }
/// <summary> /// Saves the commander orders. /// </summary> /// <param name="requestMessage">The request message.</param> /// <returns></returns> private SubscriberStatusEnum SaveCommanderOrders(RequestMessage requestMessage) { foreach (CommanderSalesOrder salesOrder in salesOrders) { //check to see if a commander order already exists for this order reference CommanderSalesOrder previousRecord = CommanderController.GetSalesOrder(salesOrder.OrderReference, false); if (previousRecord != null) { //check to see if the related shipment exists and if it has been sent to the warehouse yet TDCShipment relatedShipment = TDCShipmentController.GetShipment(requestMessage.SourceSystem, previousRecord.OrderReference, "NA"); if (relatedShipment != null) { if (Null.NullDate != relatedShipment.SentToWMS) { ////log //LogEntry logEntry=new LogEntry(); //logEntry.Message = "blah"; //Logger.Write(logEntry); // throw new Exception("This message has already been sent to the warehouse."); return(SubscriberStatusEnum.Processed); } } salesOrder.Id = previousRecord.Id; foreach (CommanderSalesOrderLine commanderSalesOrderLine in salesOrder.Lines) { commanderSalesOrderLine.CommanderSalesOrderId = previousRecord.Id; } } //save salesOrder and lines try { int savedId = CommanderController.SaveSalesOrder(salesOrder, true); } catch (InValidBusinessObjectException ex) { //log exception } } return(SubscriberStatusEnum.Processed); }
protected void discoveryShipments_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Sort": { // Bind data discoveryShipments.DataBind(); // Done break; } case "OpCoDetail": { if (null != Redirecting) { OpCoRedirectEventArg redirectEventArgs = new OpCoRedirectEventArg(); Redirecting(ref redirectEventArgs); if (!redirectEventArgs.CancelRedirect) { // Redirect to the details page Response.Redirect(string.Format("~/Shipments/OpCoShipment.aspx?Id={0}&{1}", e.CommandArgument.ToString(), Discovery.Utility.UIHelper.GenerateUrlReferrer(HttpContext.Current, new string[] { redirectEventArgs.QueryParams, string.Concat("PageIndex=", discoveryPager.PageIndex.ToString()), string.Concat("PageSize=", discoveryPager.PageSize.ToString()), string.Concat("SortExpression=", string.Concat(discoveryShipments.SortExpression, " ", discoveryShipments.SortDirection.ToString())) }))); } } // Done; break; } case "TDCDetail": { if (null != Redirecting) { OpCoRedirectEventArg redirectEventArgs = new OpCoRedirectEventArg(); Redirecting(ref redirectEventArgs); if (!redirectEventArgs.CancelRedirect) { // Get the opco code, shipment number and the despatch number for the tdc shipment string[] shipmentParams = e.CommandArgument.ToString().Split('|'); // Get the tdc shipment Discovery.BusinessObjects.TDCShipment tdcShipment = TDCShipmentController.GetShipment(shipmentParams[0], shipmentParams[1], shipmentParams[2]); if (null != tdcShipment) { // Redirect to the details page Response.Redirect(string.Format("~/Shipments/TDCShipment.aspx?Id={0}&{1}", tdcShipment.Id, Discovery.Utility.UIHelper.GenerateUrlReferrer(HttpContext.Current, new string[] { redirectEventArgs.QueryParams, string.Concat("PageIndex=", discoveryPager.PageIndex.ToString()), string.Concat("PageSize=", discoveryPager.PageSize.ToString()), string.Concat("SortExpression=", string.Concat(discoveryShipments.SortExpression, " ", discoveryShipments.SortDirection.ToString())) }))); } } } // Done; break; } case "AuditDetail": { if (null != Redirecting) { OpCoRedirectEventArg redirectEventArgs = new OpCoRedirectEventArg(); Redirecting(ref redirectEventArgs); if (!redirectEventArgs.CancelRedirect) { // Redirect to the details page Response.Redirect(string.Format("~/Admin/MessageAudit.aspx?Id={0}&{1}", e.CommandArgument.ToString(), Discovery.Utility.UIHelper.GenerateUrlReferrer(HttpContext.Current, new string[] { redirectEventArgs.QueryParams, string.Concat("PageIndex=", discoveryPager.PageIndex.ToString()), string.Concat("PageSize=", discoveryPager.PageSize.ToString()), string.Concat("SortExpression=", string.Concat(discoveryShipments.SortExpression, " ", discoveryShipments.SortDirection.ToString())) }))); } } // Done break; } case "MapToTdc": { // Get the opco shipment Discovery.BusinessObjects.OpCoShipment opCoShipment = OpCoShipmentController.GetShipment(Convert.ToInt32(e.CommandArgument)); // Make sure that we found the shipment if (null != opCoShipment && opCoShipment.Id != -1) { // We have the shipment, now map it to a tdc shipment if not mapped if (opCoShipment.Status == Shipment.StatusEnum.NotMapped) { // The new shipment TDCShipment tdcShipment; try { //see if there is an existing TDCShipment TDCShipment existingTDCShipment = TDCShipmentController.GetShipment( opCoShipment.OpCoCode, opCoShipment.ShipmentNumber, opCoShipment.DespatchNumber); // Map opco shipment tdcShipment = opCoShipment.MapToTDC(existingTDCShipment, Page.User.Identity.Name, false); // Update the opco shipment status OpCoShipmentController.UpdateShipmentStatus(opCoShipment); // Display message DiscoveryPage.DisplayMessage(string.Format("The OpCo shipment was mapped to a new TDC shipment <a href=\"TDCShipment.aspx?Id={0}\">{1}-{2}</a>.", tdcShipment.Id, tdcShipment.ShipmentNumber, tdcShipment.DespatchNumber), DiscoveryMessageType.Success, Page.Master); } catch (Exception ex) { DiscoveryPage.DisplayMessage(ex.Message, DiscoveryMessageType.Error, Page.Master); } // Status changed, re bind the data discoveryShipments.DataBind(); } } // Done; break; } } }
protected void discoveryShipments_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Sort": { // Bind data discoveryShipments.DataBind(); // Done break; } case "OpCoDetail": { // See if we have a redirecting delegate if (null != Redirecting) { TDCRedirectEventArg redirectEventArgs = new TDCRedirectEventArg(); Redirecting(ref redirectEventArgs); // Do we continue redirecting? if (!redirectEventArgs.CancelRedirect) { // Redirect to the details page Response.Redirect(string.Format("~/Shipments/OpCoShipment.aspx?Id={0}&{1}", e.CommandArgument.ToString(), Discovery.Utility.UIHelper.GenerateUrlReferrer(HttpContext.Current, new string[] { redirectEventArgs.QueryParams, string.Concat("PageIndex=", discoveryPager.PageIndex.ToString()), string.Concat("PageSize=", discoveryPager.PageSize.ToString()), string.Concat("SortExpression=", string.Concat(discoveryShipments.SortExpression, " ", discoveryShipments.SortDirection.ToString())) }))); } } // Done; break; } case "TDCDetail": { // See if we have a redirecting delegate if (null != Redirecting) { TDCRedirectEventArg redirectEventArgs = new TDCRedirectEventArg(); Redirecting(ref redirectEventArgs); // Do we continue redirecting? if (!redirectEventArgs.CancelRedirect) { // Redirect to the details page Response.Redirect(string.Format("~/Shipments/TDCShipment.aspx?Id={0}&{1}", e.CommandArgument.ToString(), Discovery.Utility.UIHelper.GenerateUrlReferrer(HttpContext.Current, new string[] { redirectEventArgs.QueryParams, string.Concat("PageIndex=", discoveryPager.PageIndex.ToString()), string.Concat("PageSize=", discoveryPager.PageSize.ToString()), string.Concat("SortExpression=", string.Concat(discoveryShipments.SortExpression, " ", discoveryShipments.SortDirection.ToString())) }))); } } // Done; break; } case "AuditDetail": { if (null != Redirecting) { TDCRedirectEventArg redirectEventArgs = new TDCRedirectEventArg(); Redirecting(ref redirectEventArgs); if (!redirectEventArgs.CancelRedirect) { // Redirect to the details page Response.Redirect(string.Format("~/Admin/MessageAudit.aspx?Id={0}&{1}", e.CommandArgument.ToString(), Discovery.Utility.UIHelper.GenerateUrlReferrer(HttpContext.Current, new string[] { redirectEventArgs.QueryParams, string.Concat("PageIndex=", discoveryPager.PageIndex.ToString()), string.Concat("PageSize=", discoveryPager.PageSize.ToString()), string.Concat("SortExpression=", string.Concat(discoveryShipments.SortExpression, " ", discoveryShipments.SortDirection.ToString())) }))); } } // Done break; } case "PrintDelColl": { try { // Print the shipment TDCShipmentController.GetShipment(Convert.ToInt32(e.CommandArgument)).PrintDeliveryCollectionNote(); // Display message ((DiscoveryPage)this.Page).DisplayMessage("The delivery/collection note was printed successfully.", DiscoveryMessageType.Success); } catch (Exception ex) { // Display message ((DiscoveryPage)this.Page).DisplayMessage("There was an error printing the delivery/collection note.", DiscoveryMessageType.Error); } // Done break; } case "PrintTransConv": { try { // Print the shipment TDCShipmentController.GetShipment(Convert.ToInt32(e.CommandArgument)).PrintTransferConversionNote(); // Display message ((DiscoveryPage)this.Page).DisplayMessage("The transfer/conversion note was printed successfully.", DiscoveryMessageType.Success); } catch (Exception ex) { // Display message ((DiscoveryPage)this.Page).DisplayMessage("There was an error printing the transfer/conversion note.", DiscoveryMessageType.Error); } // Done break; } } }
/// <summary> /// Processes the request. /// </summary> /// <param name="requestMessage">The request message.</param> public override void ProcessRequest(RequestMessage requestMessage) { try { // Get the opco shipment from the request processor if (!RequestProcessor.RequestDictionary.ContainsKey("OpCoShipment") || RequestProcessor.RequestDictionary["OpCoShipment"] == null) { // Failed to retrieve the opco shipment from the processor throw new Exception("Attempting to map an Op Co Shipment but it was not found in the Request Processor. Make sure that the shipment parser has been subscribed before the shipment mapper."); } // Get the cached opco shipment from the processor opCoShipment = (OpCoShipment)RequestProcessor.RequestDictionary["OpCoShipment"]; // Get the audit entry from the processor if we have one (optional) if (RequestProcessor.RequestDictionary.ContainsKey("AuditEntry") && RequestProcessor.RequestDictionary["AuditEntry"] != null) { // Get the cached audit entry from the processor auditEntry = (MessageAuditEntry)RequestProcessor.RequestDictionary["AuditEntry"]; } // ***************************************************************** // ** SEE IF WE HAVE AN EXISTING OPCO SHIPMENT // ***************************************************************** // See if we already have the shipment in the db existingOpCoShipment = OpCoShipmentController.GetShipment( opCoShipment.OpCoCode, opCoShipment.ShipmentNumber, opCoShipment.DespatchNumber); // Did we find an existing opco shipment if (null != existingOpCoShipment) { // We've found the shipment, make sure that our sequence number is later if (existingOpCoShipment.OpCoSequenceNumber >= opCoShipment.OpCoSequenceNumber) { // Consume the message as it's old Status = SubscriberStatusEnum.Processed; // Log that the shipment cannot be updated Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEntry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry( string.Format("Unable to update existing opco shipment {0} - {1} for for opco {2}. The request sequence number is {3} but sequence {4} has already been processed.", opCoShipment.ShipmentNumber, opCoShipment.DespatchNumber, opCoShipment.OpCoCode, opCoShipment.OpCoSequenceNumber, existingOpCoShipment.OpCoSequenceNumber), "Request Management", 0, 0, TraceEventType.Information, "Request Management", null); // Write to the log Logger.Write(logEntry); // done return; } else { // See if we need to update the tdc shipment if (existingOpCoShipment.Status == Shipment.StatusEnum.Mapped) { // ***************************************************************** // ** SEE IF WE HAVE AN EXISTING TDC SHIPMENT // ***************************************************************** // Get the existing tdc shipment existingTDCShipment = TDCShipmentController.GetShipment( opCoShipment.OpCoCode, opCoShipment.ShipmentNumber, opCoShipment.DespatchNumber); // Did we find an existing tdc shipment? if (null != existingTDCShipment) { // See if the tdc shipment can be updated if (existingTDCShipment.Status != Shipment.StatusEnum.Mapped) { // Consume the message, we can't make the update Status = SubscriberStatusEnum.Consumed; // Log that the shipment cannot be updated Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEntry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry( string.Format("Unable to update existing tdc shipment {0} - {1} for for opco {2}. The status of the existing tdc shipment is {3} disallowing this update.", existingTDCShipment.ShipmentNumber, existingTDCShipment.DespatchNumber, existingTDCShipment.OpCoCode, existingTDCShipment.Status), "Request Management", 0, 0, TraceEventType.Information, "Request Management", null); // Write to the log Logger.Write(logEntry); // done return; } } else { // We should have found the tdc shipment Status = SubscriberStatusEnum.Failed; // Log that the tdc shipment cannot be updated Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEntry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry( string.Concat("Unable to update tdc shipment ", opCoShipment.ShipmentNumber, "-", opCoShipment.DespatchNumber, " for opco ", opCoShipment.OpCoCode, ". The tdc shipment was not found."), "Request Management", 0, 0, TraceEventType.Error, "Request Management", null); // Write to the log Logger.Write(logEntry); // done return; } } } } // ***************************************************************** // ** SAVE OR UPDATE THE OPCO SHIPMENT // ***************************************************************** // See if we have an existing opco shipment if (null != existingOpCoShipment) { // Update existing opco shipment opCoShipment = (OpCoShipment)existingOpCoShipment.UpdateFromShipment(opCoShipment); } // Specify that the shipment was updated by this subscriber opCoShipment.UpdatedBy = this.GetType().FullName; // See if the shipment has been cancelled if (0 == opCoShipment.TotalLineQuantity) { // Cancel the shipment opCoShipment.Status = Shipment.StatusEnum.Cancelled; } else if (opCoShipment.OpCoHeld) { // Hold the shipment opCoShipment.Status = Shipment.StatusEnum.Held; } // See if we have an audit entry (not required) if (null != auditEntry) { // Store the audit entry id opCoShipment.AuditId = auditEntry.Id; } // Save the opco shipment to the db if (-1 != OpCoShipmentController.SaveShipment(opCoShipment)) { // Cache the opco shipment for other subscribers RequestProcessor.RequestDictionary["OpCoShipment"] = opCoShipment; // ***************************************************************** // ** MAP AND SAVE THE TDC SHIPMENT // ***************************************************************** // We only create the TDC Shipment if the OpCo Shipment has not been cancelled // If it has been cancelled and we have an existing TDC Shipment we still update it if (opCoShipment.Status != Shipment.StatusEnum.Cancelled || null != existingTDCShipment) { try { // Map the opco shipment to a new tdc shipment tdcShipment = opCoShipment.MapToTDC(existingTDCShipment, this.GetType().FullName, true); // Store the tdc shipment for other subscribers RequestProcessor.RequestDictionary["TDCShipment"] = tdcShipment; } catch (Exception ex) { // Log that the shipment cannot be updated Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEntry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry( string.Format("The opco shipment {0} - {1} for opco {2} has a status of NOTMAPPED. The error was {3}", opCoShipment.ShipmentNumber, opCoShipment.DespatchNumber, opCoShipment.OpCoCode, ex.Message), "Request Management", 0, 0, TraceEventType.Error, "Request Management", null); // Write to the log Logger.Write(logEntry); } } // Processed Status = SubscriberStatusEnum.Processed; } else { // We failed to save the op co shipment } } catch (Exception ex) { // Store the exception LastError = ex; // Failed Status = SubscriberStatusEnum.Failed; } finally { // Cleanup existingOpCoShipment = null; existingTDCShipment = null; } }
protected void TDCShipmentLineFormView_OnDataBound(object sender, EventArgs e) { // If we're in read only mode see if we can switch to edit mode if (((FormView)sender).CurrentMode == FormViewMode.ReadOnly) { // Find the edit button ImageButton editButton = DiscoveryPage.GetControl <ImageButton>("ButtonEdit", (FormView)sender); // See if we found the edit button (depends when we're data binding) if (editButton != null) { // Do we already have the shipment if (shipment == null) { // Seed can edit canEdit = false; // Make sure we have a query string value if (null != Request.QueryString["id"]) { // Get the shipment shipment = TDCShipmentController.GetShipment(Convert.ToInt32(Request.QueryString["id"])); // Now we have the shipment, load the load category codes // See if we can edit the line if (null != shipment && shipment.Id > 0) { canEdit = ( /* Not Complete */ ( shipment.Status != Shipment.StatusEnum.Completed ) && ( ( shipment.Type == Shipment.TypeEnum.WHS && DiscoveryPage.HasRule("Shipment: Edit Warehouse Order Detail", Context.User) ) || ( shipment.Type == Shipment.TypeEnum.ADH && DiscoveryPage.HasRule("Shipment: Edit Ad-Hoc Order Detail", Context.User) ) || ( shipment.Type == Shipment.TypeEnum.OPCO && DiscoveryPage.HasRule("Shipment: Edit TDC Shipment Detail", Context.User) ) ) ); } } } // Update the visibility editButton.Visible = canEdit; } } }