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 TDCShipmentLineFormView_OnItemCommand(Object sender, FormViewCommandEventArgs e) { if (e.CommandName == "Save") { try { // Get the form view FormView tdcShipmentLineFormView = (FormView)sender; // Get the existing shipment line TDCShipmentLine tdcShipmentLine = TDCShipmentLineController.GetLine((int)tdcShipmentLineFormView.DataKey.Value); // Bind ui to shipment line instance tdcShipmentLine.Description1 = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtDescription1")).Text; tdcShipmentLine.Description2 = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtDescription2")).Text; tdcShipmentLine.ConversionInstructions = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtConversionInstructions")).Text; tdcShipmentLine.Packing = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtPacking")).Text; tdcShipmentLine.ProductCode = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtProductCode")).Text; string quantity = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtQuantity")).Text; tdcShipmentLine.Quantity = Convert.ToInt32(Null.GetNull(quantity, "0")); tdcShipmentLine.QuantityUnit = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtQuantityUnit")).Text; tdcShipmentLine.CustomerReference = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtCustomerReference")).Text; string conversionQuantity = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtConversionQuantity")).Text; tdcShipmentLine.ConversionQuantity = Convert.ToInt32(Null.GetNull(conversionQuantity, "0")); tdcShipmentLine.IsPanel = ((CheckBox)tdcShipmentLineFormView.Row.FindControl("chkIsPanel")).Checked; tdcShipmentLine.IsISO9000Approved = ((CheckBox)tdcShipmentLineFormView.Row.FindControl("chkIsISO9000Approved")).Checked; tdcShipmentLine.LoadCategoryCode = ((DropDownList)tdcShipmentLineFormView.Row.FindControl("ddlLoadCategory")).SelectedValue; string netWeight = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtNetWeight")).Text; tdcShipmentLine.NetWeight = Convert.ToDecimal(Null.GetNull(netWeight, "0")); string width = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtWidth")).Text; tdcShipmentLine.Width = Convert.ToInt32(Null.GetNull(width, "0")); string length = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtLength")).Text; tdcShipmentLine.Length = Convert.ToInt32(Null.GetNull(length, "0")); string volume = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtVolume")).Text; tdcShipmentLine.Volume = Convert.ToDecimal(Null.GetNull(volume, "0")); string microns = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtMicrons")).Text; tdcShipmentLine.Microns = Convert.ToInt32(Null.GetNull(microns, "0")); string grammage = ((TextBox)tdcShipmentLineFormView.Row.FindControl("txtGrammage")).Text; tdcShipmentLine.Grammage = Convert.ToInt32(Null.GetNull(grammage, "0")); // Save the shipment line TDCShipmentLineController.SaveLine(tdcShipmentLine); // Rebind the list of shipments discoveryShipmentLines.DataBind(); // Notify any listners that we've updated a shipment line if (null != SaveComplete) { // Fire the event SaveComplete(this, new EventArgs()); } // Display message ((DiscoveryPage)Page).DisplayMessage("The shipment line was updated.", DiscoveryMessageType.Success); } catch (Exception ex) { // Display message ((DiscoveryPage)Page).DisplayMessage(String.Concat("There was a problem updating the shipment line. ", ex.Message), DiscoveryMessageType.Error); } } }