Beispiel #1
0
        public bool UpdateLTLShipment(LTLShipment2 shipment)
        {
            //Update an existing LTL shipment
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SHIPMENT_UPDATE,
                                                            new object[] {
                    shipment.ShipmentNumber, shipment.BLNumber, shipment.ShipDate,
                    null, (shipment.PickupAppointmentWindowTimeStart != DateTime.MinValue ? shipment.PickupAppointmentWindowTimeStart : null as object), (shipment.PickupAppointmentWindowTimeEnd != DateTime.MinValue ? shipment.PickupAppointmentWindowTimeEnd : null as object),
                    shipment.PickupID, (shipment.PickupDate != DateTime.MinValue ? shipment.PickupDate : null as object),
                    null, (shipment.DeliveryAppointmentWindowTimeStart != DateTime.MinValue ? shipment.DeliveryAppointmentWindowTimeStart : null as object), (shipment.DeliveryAppointmentWindowTimeEnd != DateTime.MinValue ? shipment.DeliveryAppointmentWindowTimeEnd : null as object),
                    shipment.InsidePickup, shipment.InsideDelivery, shipment.LiftGateOrigin, shipment.LiftGateDestination, shipment.SameDayPickup,
                    null, null,
                    null, null, null, shipment.Pallet1Weight, shipment.Pallet1InsuranceValue,
                    null, null, null, shipment.Pallet2Weight, shipment.Pallet2InsuranceValue,
                    null, null, null, shipment.Pallet3Weight, shipment.Pallet3InsuranceValue,
                    null, null, null, shipment.Pallet4Weight, shipment.Pallet4InsuranceValue,
                    null, null, null, shipment.Pallet5Weight, shipment.Pallet5InsuranceValue,
                    shipment.TotalCharge, shipment.UserID
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Beispiel #2
0
        public string CreateLTLShipment(LTLShipment2 shipment)
        {
            //Create a new shipment
            string number = "";

            try {
                object o = new DataService().ExecuteNonQueryWithReturn(SQL_CONNID, USP_SHIPMENT_CREATE,
                                                                       new object[] {
                    "", (shipment.BLNumber != null?shipment.BLNumber:""), shipment.ShipDate, shipment.ClientNumber,
                    shipment.ShipperNumber, null, (shipment.PickupAppointmentWindowTimeStart != DateTime.MinValue ? shipment.PickupAppointmentWindowTimeStart : null as object), (shipment.PickupAppointmentWindowTimeEnd != DateTime.MinValue ? shipment.PickupAppointmentWindowTimeEnd : null as object),
                    null, null,
                    shipment.ConsigneeNumber, null, (shipment.DeliveryAppointmentWindowTimeStart != DateTime.MinValue ? shipment.DeliveryAppointmentWindowTimeStart : null as object), (shipment.DeliveryAppointmentWindowTimeEnd != DateTime.MinValue ? shipment.DeliveryAppointmentWindowTimeEnd : null as object),
                    shipment.InsidePickup, shipment.InsideDelivery, shipment.LiftGateOrigin, shipment.LiftGateDestination, shipment.SameDayPickup,
                    (shipment.ContactName != null?shipment.ContactName:""), (shipment.ContactPhone != null?shipment.ContactPhone:""),
                    null, null, null, shipment.Pallet1Weight, shipment.Pallet1InsuranceValue,
                    null, null, null, shipment.Pallet2Weight, shipment.Pallet2InsuranceValue,
                    null, null, null, shipment.Pallet3Weight, shipment.Pallet3InsuranceValue,
                    null, null, null, shipment.Pallet4Weight, shipment.Pallet4InsuranceValue,
                    null, null, null, shipment.Pallet5Weight, shipment.Pallet5InsuranceValue,
                    shipment.TotalCharge, shipment.UserID
                });
                number = (string)o;
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(number);
        }
Beispiel #3
0
    //Interface
    protected void Page_Load(object sender, EventArgs e)
    {
        //Page load event handler
        try {
            if (!Page.IsPostBack)
            {
                string number = Request.QueryString["number"];
                if (number != null && number.Length > 0)
                {
                    this.mShipment = new FreightGateway().ReadLTLShipment(number);
                }
                ViewState.Add("Shipment", this.mShipment);

                //Setup UI
                OnCurrentClientChanged(null, EventArgs.Empty);
            }
            else
            {
                this.mShipment = ViewState["Shipment"] != null ? (LTLShipment2)ViewState["Shipment"] : null;
            }
            Master.CurrentClientChanged += new EventHandler(OnCurrentClientChanged);
        }
        catch (Exception ex) { Master.ReportError(ex, 3); }
        finally { OnValidateForm(null, EventArgs.Empty); }
    }
Beispiel #4
0
        public bool DispatchLTLShipment(LTLShipment2 shipment)
        {
            //Dispatch an existing LTL shipment
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SHIPMENT_DISPATCH,
                                                            new object[] { shipment.ShipmentNumber, shipment.PickupID, (shipment.PickupDate != DateTime.MinValue ? shipment.PickupDate : null as object), shipment.UserID });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Beispiel #5
0
        public static bool UpdateLTLShipment(LTLShipment2 shipment)
        {
            //Update an existing LTL shipment
            bool updated = false;
            LTLAdminService2Client client = new LTLAdminService2Client();

            try {
                updated = client.UpdateLTLShipmentForAdmin(shipment);
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(updated);
        }
Beispiel #6
0
        public static LTLShipment2 ReadLTLShipment(string shipmentNumber)
        {
            LTLShipment2           ltlShipment = null;
            LTLAdminService2Client client      = new LTLAdminService2Client();

            try {
                ltlShipment = client.ReadLTLShipmentForDispatch(shipmentNumber);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> dfe) { client.Abort(); throw new ApplicationException(dfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(ltlShipment);
        }
Beispiel #7
0
        public static string CreateLTLShipment(LTLShipment2 shipment)
        {
            //Create a new LTL shipment
            string number = "";
            LTLAdminService2Client client = new LTLAdminService2Client();

            try {
                number = client.CreateLTLShipmentForAdmin(shipment);
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(number);
        }
Beispiel #8
0
        public LTLShipment2 ReadLTLShipment(string shipmentNumber)
        {
            //Read an existing LTL shipment
            LTLShipment2            shipment = null;
            LTLClientService2Client client   = new LTLClientService2Client();

            try {
                shipment = client.ReadLTLShipment(shipmentNumber);
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(shipment);
        }
Beispiel #9
0
        public static bool BookLoadTenderQuote(int quoteID, LTLShipment2 shipment)
        {
            //Book an existing LTLLoadTenderQuote
            bool result = false;
            LTLLoadTenderService2Client client = new LTLLoadTenderService2Client();

            try {
                result = client.BookLoadTenderQuote(quoteID, shipment);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(result);
        }
Beispiel #10
0
        private void OnItemClick(object sender, System.EventArgs e)
        {
            //Menu services
            string         number   = "";
            LTLShipment2   shipment = null;
            dlgLTLShipment dlg      = null;

            try {
                ToolStripItem menu = (ToolStripItem)sender;
                switch (menu.Name)
                {
                case "csNew":
                    switch (this.tabShipments.SelectedTab.Name)
                    {
                    case "tabActive":
                        shipment = new LTLShipment2();
                        shipment.ShipmentNumber = "";
                        shipment.ClientNumber   = this.cboClient.SelectedValue.ToString();
                        shipment.ShipDate       = DateTime.Today.AddDays(1);
                        dlg      = new dlgLTLShipment(shipment);
                        dlg.Font = this.Font;
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {
                            this.Cursor = Cursors.WaitCursor;
                            number      = FreightGateway.CreateLTLShipment(shipment);
                            MessageBox.Show(this, "New shipment created.", App.Product, MessageBoxButtons.OK);
                            Refresh();
                        }
                        break;
                    }
                    break;

                case "csOpen":
                    switch (this.tabShipments.SelectedTab.Name)
                    {
                    case "tabActive": number = this.grdShipments.Selected.Rows[0].Cells["ShipmentNumber"].Value.ToString(); break;

                    case "tabSearch": number = this.grdSearch.Selected.Rows[0].Cells["ShipmentNumber"].Value.ToString(); break;
                    }
                    shipment = FreightGateway.ReadLTLShipment(number);
                    dlg      = new dlgLTLShipment(shipment);
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        FreightGateway.UpdateLTLShipment(shipment);
                        MessageBox.Show(this, "Shipment updated.", App.Product, MessageBoxButtons.OK);
                        Refresh();
                    }
                    break;

                case "csCancel":
                    switch (this.tabShipments.SelectedTab.Name)
                    {
                    case "tabActive":
                        number = this.grdShipments.Selected.Rows[0].Cells["ShipmentNumber"].Value.ToString();
                        if (MessageBox.Show(this, "Cancel the shipment# " + number + "?", App.Product, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            this.Cursor = Cursors.WaitCursor;
                            FreightGateway.CancelLTLShipment(number, Environment.UserName);
                            MessageBox.Show(this, "Shipment cancelled.", App.Product, MessageBoxButtons.OK);
                            Refresh();
                        }
                        break;
                    }
                    break;

                case "csRefresh":
                    this.Cursor = Cursors.WaitCursor;
                    Refresh();
                    break;

                case "csPrintLabels":
                    switch (this.tabShipments.SelectedTab.Name)
                    {
                    case "tabActive": number = this.grdShipments.Selected.Rows[0].Cells["ShipmentNumber"].Value.ToString(); break;

                    case "tabSearch": number = this.grdSearch.Selected.Rows[0].Cells["ShipmentNumber"].Value.ToString(); break;
                    }
                    dlgLabels dlgL = new dlgLabels(number);
                    dlgL.Font = this.Font;
                    dlgL.ShowDialog(this);
                    break;

                case "csPrintPaperwork":
                    switch (this.tabShipments.SelectedTab.Name)
                    {
                    case "tabActive": number = this.grdShipments.Selected.Rows[0].Cells["ShipmentNumber"].Value.ToString(); break;

                    case "tabSearch": number = this.grdSearch.Selected.Rows[0].Cells["ShipmentNumber"].Value.ToString(); break;
                    }
                    dlgPaperwork dlgP = new dlgPaperwork(number);
                    dlgP.Font = this.Font;
                    dlgP.ShowDialog(this);
                    break;
                }
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }
Beispiel #11
0
 public void NotifyShipmentCancelled2(LTLClient2 client, LTLShipper2 shipper, LTLConsignee2 consignee, LTLShipment2 shipment, string shipmentNumber, LTLClient2 salesRep)
 {
     try {
         //Send conformation email
         if (client.ContactEmail.Trim().Length > 0)
         {
             string body = getHTMLBody(System.Web.Hosting.HostingEnvironment.MapPath(HTML_SHIPMENT_CANCELLED));
             body = body.Replace("*shipmentNumber*", shipmentNumber);
             body = body.Replace("*clientName*", client.Name);
             body = body.Replace("*clientAddress*", client.AddressLine1 + " " + client.City + ", " + client.State + " " + client.Zip);
             body = body.Replace("*clientContact*", client.ContactName);
             body = body.Replace("txtShipDate", shipment.ShipDate.ToString("MM/dd/yyyy"));
             body = body.Replace("txtOrigin", shipper.Name + " (" + shipper.Zip + ")");
             body = body.Replace("txtDest", consignee.Name + " (" + consignee.Zip + ")");
             body = body.Replace("txtPallets", shipment.Pallets.ToString());
             body = body.Replace("txtWeight", shipment.Weight.ToString());
             body = body.Replace("txtRate", shipment.PalletRate.ToString());
             body = body.Replace("txtFSC", shipment.FuelSurcharge.ToString());
             body = body.Replace("txtAccessorial", shipment.AccessorialCharge.ToString());
             body = body.Replace("txtInsurance", shipment.InsuranceCharge.ToString());
             body = body.Replace("txtTSC", shipment.TollCharge.ToString());
             body = body.Replace("txtCharges", shipment.TotalCharge.ToString());
             new Argix.Enterprise.SMTPGateway().SendMailMessage(this.mEmailAdmin, client.ContactEmail, "Shipment Cancelled", true, body);
             if (salesRep != null)
             {
                 new Argix.Enterprise.SMTPGateway().SendMailMessage(this.mEmailAdmin, salesRep.ContactEmail, "Shipment Cancelled", true, body);
             }
         }
     }
     catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
 }
Beispiel #12
0
    protected void OnCommand(object sender, CommandEventArgs e)
    {
        //
        try {
            if (!Page.IsValid)
            {
                return;
            }
            switch (e.CommandName)
            {
            case "Quote":
                //Validate inputs
                ApplicationException aex = null;
                int maxWeight            = (this.chkShipperLiftGate.Checked || this.chkConsigneeLiftGate.Checked) ? MAX_LIFTGATE_WEIGHT : MAX_WEIGHT;

                if (this.txtShipDate.Text.Length == 0)
                {
                    aex = new ApplicationException("Please enter a valid shipment date of the form yyyy-mm-dd.");
                }
                else if (this.ddlShippers.SelectedIndex < 2)
                {
                    aex = new ApplicationException("Please select a valid shipper.");
                }
                else if (this.ddlConsignees.SelectedIndex < 2)
                {
                    aex = new ApplicationException("Please select a valid consignee.");
                }
                else if (this.txtWeight1.Text.Trim().Length == 0 || (int.Parse(this.txtWeight1.Text) < 1 || int.Parse(this.txtWeight1.Text) > maxWeight))
                {
                    aex = new ApplicationException("Please enter a valid weight for pallet 1 (1 - " + maxWeight + "lbs).");
                }
                else if (this.txtWeight2.Text.Trim().Length > 0 && (int.Parse(this.txtWeight2.Text) < 1 || int.Parse(this.txtWeight2.Text) > maxWeight))
                {
                    aex = new ApplicationException("Please enter a valid weight for pallet 2 (1 - " + maxWeight + "lbs).");
                }
                else if (this.txtWeight3.Text.Trim().Length > 0 && (int.Parse(this.txtWeight3.Text) < 1 || int.Parse(this.txtWeight3.Text) > maxWeight))
                {
                    aex = new ApplicationException("Please enter a valid weight for pallet 3 (1 - " + maxWeight + "lbs).");
                }
                else if (this.txtWeight4.Text.Trim().Length > 0 && (int.Parse(this.txtWeight4.Text) < 1 || int.Parse(this.txtWeight4.Text) > maxWeight))
                {
                    aex = new ApplicationException("Please enter a valid weight for pallet 4 (1 - " + maxWeight + "lbs).");
                }
                else if (this.txtWeight5.Text.Trim().Length > 0 && (int.Parse(this.txtWeight5.Text) < 1 || int.Parse(this.txtWeight5.Text) > maxWeight))
                {
                    aex = new ApplicationException("Please enter a valid weight for pallet 5 (1 - " + maxWeight + "lbs).");
                }
                else if (this.txtInsuranceValue1.Text.Replace("$", "").Trim().Length > 0 && (decimal.Parse(this.txtInsuranceValue1.Text.Replace("$", "")) > MAX_INSURED))
                {
                    aex = new ApplicationException("Maximum insurance value $" + MAX_INSURED.ToString("##,###.00") + ".");
                }
                else if (this.txtInsuranceValue2.Text.Replace("$", "").Trim().Length > 0 && (decimal.Parse(this.txtInsuranceValue2.Text.Replace("$", "")) > MAX_INSURED))
                {
                    aex = new ApplicationException("Maximum insurance value $" + MAX_INSURED.ToString("##,###.00") + ".");
                }
                else if (this.txtInsuranceValue3.Text.Replace("$", "").Trim().Length > 0 && (decimal.Parse(this.txtInsuranceValue3.Text.Replace("$", "")) > MAX_INSURED))
                {
                    aex = new ApplicationException("Maximum insurance value $" + MAX_INSURED.ToString("##,###.00") + ".");
                }
                else if (this.txtInsuranceValue4.Text.Replace("$", "").Trim().Length > 0 && (decimal.Parse(this.txtInsuranceValue4.Text.Replace("$", "")) > MAX_INSURED))
                {
                    aex = new ApplicationException("Maximum insurance value $" + MAX_INSURED.ToString("##,###.00") + ".");
                }
                else if (this.txtInsuranceValue5.Text.Replace("$", "").Trim().Length > 0 && (decimal.Parse(this.txtInsuranceValue5.Text.Replace("$", "")) > MAX_INSURED))
                {
                    aex = new ApplicationException("Maximum insurance value $" + MAX_INSURED.ToString("##,###.00") + ".");
                }
                if (aex == null)
                {
                    //Calculate the quote
                    LTLQuote2 quote = new LTLQuote2();
                    #region Create Quote
                    quote.Created                = DateTime.Now;
                    quote.ShipDate               = DateTime.Parse(this.txtShipDate.Text);
                    quote.ClientID               = Master.CurrentClient.ID;
                    quote.ShipperNumber          = this.ddlShippers.SelectedValue;
                    quote.ConsigneeNumber        = int.Parse(this.ddlConsignees.SelectedValue);
                    quote.Pallet1Weight          = int.Parse(this.txtWeight1.Text);
                    quote.Pallet1Class           = this.ddlClass1.SelectedValue;
                    quote.Pallet1InsuranceValue  = this.txtInsuranceValue1.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue1.Text.Replace("$", "")) : 0.0M;
                    quote.Pallet2Weight          = this.txtWeight2.Text.Trim().Length > 0 ? int.Parse(this.txtWeight2.Text) : 0;
                    quote.Pallet2Class           = this.ddlClass2.SelectedValue;
                    quote.Pallet2InsuranceValue  = this.txtInsuranceValue2.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue2.Text.Replace("$", "")) : 0.0M;
                    quote.Pallet3Weight          = this.txtWeight3.Text.Trim().Length > 0 ? int.Parse(this.txtWeight3.Text) : 0;
                    quote.Pallet3Class           = this.ddlClass3.SelectedValue;
                    quote.Pallet3InsuranceValue  = this.txtInsuranceValue3.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue3.Text.Replace("$", "")) : 0.0M;
                    quote.Pallet4Weight          = this.txtWeight4.Text.Trim().Length > 0 ? int.Parse(this.txtWeight4.Text) : 0;
                    quote.Pallet4Class           = this.ddlClass4.SelectedValue;
                    quote.Pallet4InsuranceValue  = this.txtInsuranceValue4.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue4.Text.Replace("$", "")) : 0.0M;
                    quote.Pallet5Weight          = this.txtWeight5.Text.Trim().Length > 0 ? int.Parse(this.txtWeight5.Text) : 0;
                    quote.Pallet5Class           = this.ddlClass5.SelectedValue;
                    quote.Pallet5InsuranceValue  = this.txtInsuranceValue5.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue5.Text.Replace("$", "")) : 0.0M;
                    quote.InsidePickup           = this.chkShipperInsidePickup.Checked;
                    quote.LiftGateOrigin         = this.chkShipperLiftGate.Checked;
                    quote.AppointmentOrigin      = this.chkShipperAppt.Checked;
                    quote.InsideDelivery         = this.chkConsigneeInsidePickup.Checked;
                    quote.LiftGateDestination    = this.chkConsigneeLiftGate.Checked;
                    quote.AppointmentDestination = this.chkConsigneeAppt.Checked;
                    quote.Pallets                = 0;
                    quote.Weight            = 0;
                    quote.PalletRate        = 0;
                    quote.FuelSurcharge     = 0;
                    quote.AccessorialCharge = 0;
                    quote.InsuranceCharge   = 0;
                    quote.TollCharge        = 0;
                    quote.TotalCharge       = 0;
                    #endregion
                    quote = new FreightGateway().CreateQuote(quote);

                    //Display the quote
                    this.lblEstimatedDeliveryDate.Text = "Estimated delivery by " + quote.EstimatedDeliveryDate.ToString("MM-dd-yyyy");
                    this.txtPallets.Text     = quote.Pallets.ToString();
                    this.txtWeight.Text      = quote.Weight.ToString();
                    this.txtRate.Text        = "$" + quote.PalletRate.ToString();
                    this.txtFSC.Text         = "$" + quote.FuelSurcharge.ToString();
                    this.txtAccessorial.Text = "$" + quote.AccessorialCharge.ToString();
                    this.txtInsurance.Text   = "$" + quote.InsuranceCharge.ToString();
                    this.txtTSC.Text         = "$" + quote.TollCharge.ToString();
                    this.txtCharges.Text     = "$" + quote.TotalCharge.ToString();

                    //Enable booking
                    this.btnSubmit.Enabled = true;
                }
                else
                {
                    resetQuote();
                    Master.ReportError(aex, 3);
                }
                break;

            case "Submit":
                if (this.mShipment == null)
                {
                    //New
                    LTLShipment2 shipment = new LTLShipment2();
                    #region Create shipment
                    shipment.Created               = DateTime.Now;
                    shipment.ClientNumber          = Master.CurrentClient.Number;
                    shipment.ShipDate              = DateTime.Parse(this.txtShipDate.Text);
                    shipment.ShipperNumber         = this.ddlShippers.SelectedValue;
                    shipment.ConsigneeNumber       = int.Parse(this.ddlConsignees.SelectedValue);
                    shipment.Pallet1Weight         = int.Parse(this.txtWeight1.Text);
                    shipment.Pallet1Class          = this.ddlClass1.SelectedValue;
                    shipment.Pallet1InsuranceValue = this.txtInsuranceValue1.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue1.Text.Replace("$", "")) : 0.0M;
                    shipment.Pallet2Weight         = this.txtWeight2.Text.Trim().Length > 0 ? int.Parse(this.txtWeight2.Text) : 0;
                    shipment.Pallet2Class          = this.ddlClass2.SelectedValue;
                    shipment.Pallet2InsuranceValue = this.txtInsuranceValue2.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue2.Text.Replace("$", "")) : 0.0M;
                    shipment.Pallet3Weight         = this.txtWeight3.Text.Trim().Length > 0 ? int.Parse(this.txtWeight3.Text) : 0;
                    shipment.Pallet3Class          = this.ddlClass3.SelectedValue;
                    shipment.Pallet3InsuranceValue = this.txtInsuranceValue3.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue3.Text.Replace("$", "")) : 0.0M;
                    shipment.Pallet4Weight         = this.txtWeight4.Text.Trim().Length > 0 ? int.Parse(this.txtWeight4.Text) : 0;
                    shipment.Pallet4Class          = this.ddlClass4.SelectedValue;
                    shipment.Pallet4InsuranceValue = this.txtInsuranceValue4.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue4.Text.Replace("$", "")) : 0.0M;
                    shipment.Pallet5Weight         = this.txtWeight5.Text.Trim().Length > 0 ? int.Parse(this.txtWeight5.Text) : 0;
                    shipment.Pallet5Class          = this.ddlClass5.SelectedValue;
                    shipment.Pallet5InsuranceValue = this.txtInsuranceValue5.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue5.Text.Replace("$", "")) : 0.0M;
                    shipment.BLNumber              = this.txtBOLNumber.Text;

                    shipment.InsidePickup   = this.chkShipperInsidePickup.Checked;
                    shipment.LiftGateOrigin = this.chkShipperLiftGate.Checked;
                    if (this.chkShipperAppt.Checked)
                    {
                        shipment.PickupAppointmentWindowTimeStart = DateTime.Parse("01-01-2000 " + this.txtShipperApptStart.Text);
                        shipment.PickupAppointmentWindowTimeEnd   = DateTime.Parse("01-01-2000 " + this.txtShipperApptEnd.Text);
                    }
                    shipment.InsideDelivery      = this.chkConsigneeInsidePickup.Checked;
                    shipment.LiftGateDestination = this.chkConsigneeLiftGate.Checked;
                    if (this.chkConsigneeAppt.Checked)
                    {
                        shipment.DeliveryAppointmentWindowTimeStart = DateTime.Parse("01-01-2000 " + this.txtConsigneeApptStart.Text);
                        shipment.DeliveryAppointmentWindowTimeEnd   = DateTime.Parse("01-01-2000 " + this.txtConsigneeApptEnd.Text);
                    }
                    shipment.Pallets           = int.Parse(this.txtPallets.Text);
                    shipment.Weight            = decimal.Parse(this.txtWeight.Text);
                    shipment.PalletRate        = decimal.Parse(this.txtRate.Text.Replace("$", ""));
                    shipment.FuelSurcharge     = decimal.Parse(this.txtFSC.Text.Replace("$", ""));
                    shipment.AccessorialCharge = decimal.Parse(this.txtAccessorial.Text.Replace("$", ""));
                    shipment.InsuranceCharge   = decimal.Parse(this.txtInsurance.Text.Replace("$", ""));
                    shipment.TollCharge        = decimal.Parse(this.txtTSC.Text.Replace("$", ""));
                    shipment.TotalCharge       = decimal.Parse(this.txtCharges.Text.Replace("$", ""));
                    shipment.UserID            = Membership.GetUser().UserName;
                    shipment.LastUpdated       = DateTime.Now;
                    #endregion
                    string number = new FreightGateway().CreateLTLShipment(shipment);
                    Master.ShowMessageBox("New shipment " + shipment.ShipmentNumber + " has been created.");
                }
                else
                {
                    //Update
                    #region Update shipment
                    this.mShipment.ShipDate              = DateTime.Parse(this.txtShipDate.Text);
                    this.mShipment.Pallet1Weight         = int.Parse(this.txtWeight1.Text);
                    this.mShipment.Pallet1Class          = this.ddlClass1.SelectedValue;
                    this.mShipment.Pallet1InsuranceValue = this.txtInsuranceValue1.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue1.Text.Replace("$", "")) : 0.0M;
                    this.mShipment.Pallet2Weight         = this.txtWeight2.Text.Trim().Length > 0 ? int.Parse(this.txtWeight2.Text) : 0;
                    this.mShipment.Pallet2Class          = this.ddlClass2.SelectedValue;
                    this.mShipment.Pallet2InsuranceValue = this.txtInsuranceValue2.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue2.Text.Replace("$", "")) : 0.0M;
                    this.mShipment.Pallet3Weight         = this.txtWeight3.Text.Trim().Length > 0 ? int.Parse(this.txtWeight3.Text) : 0;
                    this.mShipment.Pallet3Class          = this.ddlClass3.SelectedValue;
                    this.mShipment.Pallet3InsuranceValue = this.txtInsuranceValue3.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue3.Text.Replace("$", "")) : 0.0M;
                    this.mShipment.Pallet4Weight         = this.txtWeight4.Text.Trim().Length > 0 ? int.Parse(this.txtWeight4.Text) : 0;
                    this.mShipment.Pallet4Class          = this.ddlClass4.SelectedValue;
                    this.mShipment.Pallet4InsuranceValue = this.txtInsuranceValue4.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue4.Text.Replace("$", "")) : 0.0M;
                    this.mShipment.Pallet5Weight         = this.txtWeight5.Text.Trim().Length > 0 ? int.Parse(this.txtWeight5.Text) : 0;
                    this.mShipment.Pallet5Class          = this.ddlClass5.SelectedValue;
                    this.mShipment.Pallet5InsuranceValue = this.txtInsuranceValue5.Text.Replace("$", "").Trim().Length > 0 ? decimal.Parse(this.txtInsuranceValue5.Text.Replace("$", "")) : 0.0M;
                    this.mShipment.InsidePickup          = this.chkShipperInsidePickup.Checked;
                    this.mShipment.LiftGateOrigin        = this.chkShipperLiftGate.Checked;
                    if (this.chkShipperAppt.Checked)
                    {
                        this.mShipment.PickupAppointmentWindowTimeStart = DateTime.Parse("01-01-2000 " + this.txtShipperApptStart.Text);
                        this.mShipment.PickupAppointmentWindowTimeEnd   = DateTime.Parse("01-01-2000 " + this.txtShipperApptEnd.Text);
                    }
                    this.mShipment.InsideDelivery      = this.chkConsigneeInsidePickup.Checked;
                    this.mShipment.LiftGateDestination = this.chkConsigneeLiftGate.Checked;
                    if (this.chkConsigneeAppt.Checked)
                    {
                        this.mShipment.DeliveryAppointmentWindowTimeStart = DateTime.Parse("01-01-2000 " + this.txtConsigneeApptStart.Text);
                        this.mShipment.DeliveryAppointmentWindowTimeEnd   = DateTime.Parse("01-01-2000 " + this.txtConsigneeApptEnd.Text);
                    }
                    this.mShipment.Pallets           = int.Parse(this.txtPallets.Text);
                    this.mShipment.Weight            = decimal.Parse(this.txtWeight.Text);
                    this.mShipment.PalletRate        = decimal.Parse(this.txtRate.Text.Replace("$", ""));
                    this.mShipment.FuelSurcharge     = decimal.Parse(this.txtFSC.Text.Replace("$", ""));
                    this.mShipment.AccessorialCharge = decimal.Parse(this.txtAccessorial.Text.Replace("$", ""));
                    this.mShipment.InsuranceCharge   = decimal.Parse(this.txtInsurance.Text.Replace("$", ""));
                    this.mShipment.TollCharge        = decimal.Parse(this.txtTSC.Text.Replace("$", ""));
                    this.mShipment.TotalCharge       = decimal.Parse(this.txtCharges.Text.Replace("$", ""));
                    this.mShipment.UserID            = Membership.GetUser().UserName;
                    this.mShipment.LastUpdated       = DateTime.Now;
                    #endregion
                    bool updated = new FreightGateway().UpdateLTLShipment(this.mShipment);
                    Master.ShowMessageBox("Shipment " + this.mShipment.ShipmentNumber + " has been updated.");
                }
                this.btnSubmit.Enabled = false;
                this.btnCancel.Text    = "Close";
                break;

            case "Cancel":
                Response.Redirect("~/Client/Shipments.aspx", false);
                break;
            }
        }
        catch (ApplicationException ex) { Master.ReportError(ex, 3); }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }