Example #1
0
        /// <summary>
        /// Saves the TDC shipment line.
        /// </summary>
        /// <param name="shipmentLine">The shipment line.</param>
        /// <returns></returns>
        public static int SaveLine(TDCShipmentLine shipmentLine)
        {
            try
            {
                // Make sure the shipment line is valid
                if (shipmentLine.IsValid)
                {
                    // Save the shipment line to the db
                    shipmentLine.Id = DataAccessProvider.Instance().SaveTDCShipmentLine(shipmentLine);

                    // Get the checksum for the entity
                    FrameworkController.GetChecksum(shipmentLine, "ShipmentLine");
                }
                else
                {
                    // Entity is not valid
                    throw new InValidBusinessObjectException(shipmentLine);
                }
            }
            catch (Exception ex)
            {
                // Log an throw if configured to do so
                if (ExceptionPolicy.HandleException(ex, "Business Logic"))
                {
                    throw;
                }

                // Failed
                return(-1);
            }

            // Done
            return(shipmentLine.Id);
        }
        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);
            }
        }
Example #3
0
        private void DoLines(PersistableBusinessObject sourceObject, PersistableBusinessObject destinationObject,
                             string sourceSystem, string destinationSystem)
        {
            List <ShipmentLine> lines = ((TDCShipment)destinationObject).ShipmentLines;

            for (int i = 0; i < lines.Count; i++)
            {
                TDCShipmentLine newline = new TDCShipmentLine();
                MappingController.Map(lines[i], newline, sourceSystem, destinationSystem, null);
                lines[i] = newline;
            }
        }
Example #4
0
        static internal TDCShipmentLine PopulateLineItem()
        {
            TDCShipmentLine tdcShipmentLine = new TDCShipmentLine();

            //tdcShipmentLine.ConversionQuantity = 1;
            tdcShipmentLine.Description1      = "Description1";
            tdcShipmentLine.LoadCategoryCode  = "xx";
            tdcShipmentLine.ProductCode       = "ProductCode";
            tdcShipmentLine.QuantityUnit      = "unit";
            tdcShipmentLine.UpdatedBy         = "UpdatedBy";
            tdcShipmentLine.OriginalQuantity  = 5;
            tdcShipmentLine.Quantity          = 4;
            tdcShipmentLine.IsISO9000Approved = true;
            return(tdcShipmentLine);
        }
Example #5
0
 protected void discoveryShipmentLines_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         // Find the content panel
         Control contentCtrl = e.Item.FindControl("panelContent");
         // Find the form view
         FormView formViewCtrl = (FormView)contentCtrl.FindControl("TDCShipmentLineFormView");
         // Get the shipment line
         TDCShipmentLine tdcShipmenLine = e.Item.DataItem as TDCShipmentLine;
         // Add it to a list for data binding
         List <TDCShipmentLine> tdcShipmentLines = new List <TDCShipmentLine>(1);
         tdcShipmentLines.Add(tdcShipmenLine);
         // Set the mode of the form view
         formViewCtrl.ChangeMode(((tdcShipmenLine.Id == SelectedItemIndex) && InEditMode) ? FormViewMode.Edit : FormViewMode.ReadOnly);
         // Bind the form view data
         formViewCtrl.DataSource = tdcShipmentLines;
         formViewCtrl.DataBind();
     }
 }
Example #6
0
        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);
                }
            }
        }