Exemple #1
0
 private void showQuote(LTLQuote2 quote)
 {
     //
     try {
         if (quote != null)
         {
             this.lblEstimatedDeliveryDate.Text = quote.EstimatedDeliveryDate.ToShortDateString();
             //this.txtPallets.Text = quote.Pallets.ToString("#0");
             //this.txtWeight.Text = quote.Weight.ToString("#0");
             this.txtRate.Text         = quote.PalletRate.ToString("#0.00");
             this.txtFSC.Text          = quote.FuelSurcharge.ToString("#0.00");
             this.txtAccessorials.Text = quote.AccessorialCharge.ToString("#0.00");
             this.txtInsurance.Text    = quote.InsuranceCharge.ToString("#0.00");
             this.txtTSC.Text          = quote.TollCharge.ToString("#0.00");
             this.txtTotal.Text        = quote.TotalCharge.ToString("#0.00");
         }
         else
         {
             quote = null;
             this.lblEstimatedDeliveryDate.Text = "";
             //this.txtPallets.Text = this.txtWeight.Text = "";
             this.txtRate.Text = this.txtFSC.Text = this.txtAccessorials.Text = this.txtInsurance.Text = this.txtTSC.Text = this.txtTotal.Text = "";
         }
     }
     catch (Exception ex) { App.ReportError(ex, false, LogLevel.Error); }
 }
Exemple #2
0
 private void overrideQuote()
 {
     //
     try {
         if (this.mQuote != null)
         {
             //Validate total charge does not go below the total charge minimum
             decimal totalCharge = decimal.Parse(this.txtTotal.Text);
             if (totalCharge >= this.mQuote.TotalChargeMin)
             {
                 //Update the quote
                 this.mQuote.LTLQuote.TotalCharge = totalCharge;
                 LTLQuote2 quote = FreightGateway.CreateQuoteForSalesRep(this.mQuote.LTLQuote);
                 this.txtRate.Text = quote.PalletRate.ToString();
                 this.txtFSC.Text  = quote.FuelSurcharge.ToString();
             }
             else
             {
                 //Restore the quote
                 this.txtTotal.Text = this.mQuote.LTLQuote.TotalCharge.ToString();
                 this.txtTotal.Focus();
                 MessageBox.Show("The total charge cannot be less than " + this.mQuote.TotalChargeMin.ToString(), App.Product, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
     catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
 }
Exemple #3
0
        private void OnCommandClick(object sender, System.EventArgs e)
        {
            //Event handler for button selection
            this.Cursor = Cursors.WaitCursor;
            try {
                Button btn = (Button)sender;
                switch (btn.Name)
                {
                case "btnQuote":
                    this.Cursor = Cursors.WaitCursor;
                    showQuote(null);
                    LTLQuote2 quote = new LTLQuote2();
                    #region Create Quote
                    quote.ID                     = 0;
                    quote.Created                = DateTime.Now;
                    quote.ShipDate               = this.dtpShipDate.Value;
                    quote.ClientID               = int.Parse(this.cboClient.SelectedValue.ToString());
                    quote.OriginZip              = this.txtShipperZip.Text;
                    quote.DestinationZip         = this.txtConsigneeZip.Text;
                    quote.Pallet1Class           = quote.Pallet2Class = quote.Pallet3Class = quote.Pallet4Class = quote.Pallet5Class = "FAK";
                    quote.Pallet1Weight          = int.Parse(this.grdPallets.Rows[0].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint);
                    quote.Pallet1InsuranceValue  = decimal.Parse(this.grdPallets.Rows[0].Cells["InsuranceValue"].Value.ToString());
                    quote.Pallet2Weight          = this.grdPallets.Rows.Count > 1 ? int.Parse(this.grdPallets.Rows[1].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint) : 0;
                    quote.Pallet2InsuranceValue  = this.grdPallets.Rows.Count > 1 ? decimal.Parse(this.grdPallets.Rows[1].Cells["InsuranceValue"].Value.ToString()) : 0;
                    quote.Pallet3Weight          = this.grdPallets.Rows.Count > 2 ? int.Parse(this.grdPallets.Rows[2].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint) : 0;
                    quote.Pallet3InsuranceValue  = this.grdPallets.Rows.Count > 2 ? decimal.Parse(this.grdPallets.Rows[2].Cells["InsuranceValue"].Value.ToString()) : 0;
                    quote.Pallet4Weight          = this.grdPallets.Rows.Count > 3 ? int.Parse(this.grdPallets.Rows[3].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint) : 0;
                    quote.Pallet4InsuranceValue  = this.grdPallets.Rows.Count > 3 ? decimal.Parse(this.grdPallets.Rows[3].Cells["InsuranceValue"].Value.ToString()) : 0;
                    quote.Pallet5Weight          = this.grdPallets.Rows.Count > 4 ? int.Parse(this.grdPallets.Rows[4].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint) : 0;
                    quote.Pallet5InsuranceValue  = this.grdPallets.Rows.Count > 4 ? decimal.Parse(this.grdPallets.Rows[4].Cells["InsuranceValue"].Value.ToString()) : 0;
                    quote.InsidePickup           = this.chkShipperInsidePickup.Checked;
                    quote.LiftGateOrigin         = this.chkShipperLiftGate.Checked;
                    quote.AppointmentOrigin      = this.chkShipperAppt.Checked;
                    quote.SameDayPickup          = this.chkShipperSameDay.Checked;
                    quote.InsideDelivery         = this.chkConsigneeInsideDelivery.Checked;
                    quote.LiftGateDestination    = this.chkConsigneeLiftGate.Checked;
                    quote.AppointmentDestination = this.chkConsigneeAppt.Checked;
                    quote.Pallets                = 0;
                    quote.Weight                 = quote.PalletRate = quote.FuelSurcharge = quote.AccessorialCharge = quote.InsuranceCharge = quote.TollCharge = quote.TotalCharge = 0.0M;
                    #endregion
                    quote = FreightGateway.CreateQuote(quote);
                    this.mQuotes.Add(quote);
                    this.grdQuotes.Refresh();
                    showQuote(quote);
                    break;

                case "btnClear":
                    this.txtShipperZip.Text       = this.txtConsigneeZip.Text = "";
                    this.chkShipperAppt.Checked   = this.chkShipperInsidePickup.Checked = this.chkShipperLiftGate.Checked = this.chkShipperSameDay.Checked = false;
                    this.chkConsigneeAppt.Checked = this.chkConsigneeInsideDelivery.Checked = this.chkConsigneeLiftGate.Checked = false;
                    this.mPallets.Clear();
                    this.lblEstimatedDeliveryDate.Text = "";
                    //this.txtPallets.Text = this.txtWeight.Text = "";
                    this.txtRate.Text = this.txtFSC.Text = this.txtAccessorials.Text = this.txtInsurance.Text = this.txtTSC.Text = this.txtTotal.Text = "";
                    break;
                }
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
            finally { this.Cursor = Cursors.Default; }
        }
Exemple #4
0
        public static LTLQuote2 CreateQuote(LTLQuote2 quote)
        {
            //Create a new LTL Quote
            LTLAdminService2Client client = new LTLAdminService2Client();

            try {
                quote = client.CreateQuoteForAdmin(quote);
            }
            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(quote);
        }
Exemple #5
0
 public void CreateQuoteLogEntry(LTLQuote2 quote)
 {
     //Log a quote
     try {
         new DataService().ExecuteNonQuery(SQL_CONNID, USP_QUOTELOG_INSERT,
                                           new object[] {
             quote.ShipDate, quote.OriginZip, quote.DestinationZip,
             quote.Pallets, quote.Weight,
             quote.PalletRate, quote.FuelSurcharge,
             quote.InsidePickupCharge, quote.InsideDeliveryCharge,
             quote.AppointmentOriginCharge, quote.AppointmentDestinationCharge,
             quote.LiftGateOriginCharge, quote.LiftGateDestinationCharge,
             quote.InsuranceCharge, quote.TollCharge, quote.SameDayPickupCharge, quote.TotalCharge, quote.ClientID
         });
     }
     catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
 }
Exemple #6
0
        public DataSet GetQuoteWithOverride(LTLQuote2 quote)
        {
            //
            DataSet ltlQuote = null;

            try {
                ltlQuote = new DataService().FillDataset(SQL_CONNID, USP_QUOTEWITHOVERRIDE_GET, TBL_QUOTE,
                                                         new object[] {
                    quote.ShipDate, quote.OriginZip, quote.DestinationZip,
                    quote.InsidePickup, quote.InsideDelivery,
                    quote.AppointmentOrigin, quote.AppointmentDestination,
                    quote.LiftGateOrigin, quote.LiftGateDestination, quote.SameDayPickup,
                    quote.Pallet1InsuranceValue, quote.Pallet2InsuranceValue, quote.Pallet3InsuranceValue, quote.Pallet4InsuranceValue, quote.Pallet5InsuranceValue,
                    quote.Pallets, quote.ClientID, quote.TotalCharge
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(ltlQuote);
        }
Exemple #7
0
    protected void OnCommand(object sender, CommandEventArgs e)
    {
        //
        LTLQuote2 quote = null;

        try {
            if (!Page.IsValid)
            {
                return;
            }
            switch (e.CommandName)
            {
            case "Quote":
                //Reset

                //Validate inputs
                ApplicationException aex = null;
                int maxWeight            = (this.chkLiftGateO.Checked || this.chkLiftGateD.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.txtOriginZip.Text.Length != 5)
                {
                    aex = new ApplicationException("Please enter a valid 5-digit origin zip code.");
                }
                else if (this.txtDestZip.Text.Length != 5)
                {
                    aex = new ApplicationException("Please enter a valid 5-digit destination zip code.");
                }
                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
                    quote = new LTLQuote2();
                    #region Create Quote
                    quote.Created  = DateTime.Now;
                    quote.ShipDate = DateTime.Parse(this.txtShipDate.Text);
                    if (Master.CurrentClient != null)
                    {
                        quote.ClientID = Master.CurrentClient.ID;
                    }
                    quote.OriginZip              = this.txtOriginZip.Text;
                    quote.DestinationZip         = this.txtDestZip.Text;
                    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.chkInsideO.Checked;
                    quote.LiftGateOrigin         = this.chkLiftGateO.Checked;
                    quote.AppointmentOrigin      = this.chkApptO.Checked;
                    quote.InsideDelivery         = this.chkInsideD.Checked;
                    quote.LiftGateDestination    = this.chkLiftGateD.Checked;
                    quote.AppointmentDestination = this.chkApptD.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);

                    //Show 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.btnEnroll.Enabled = true;
                }
                else
                {
                    resetQuote();
                    Master.ReportError(aex, 3);
                }
                break;

            case "Enroll":
                quote                        = new LTLQuote2();
                quote.Created                = DateTime.Now;
                quote.ShipDate               = DateTime.Parse(this.txtShipDate.Text);
                quote.OriginZip              = this.txtOriginZip.Text;
                quote.DestinationZip         = this.txtDestZip.Text;
                quote.Pallet1Weight          = int.Parse(this.txtWeight1.Text);
                quote.Pallet1Class           = this.ddlClass1.SelectedValue;
                quote.Pallet1InsuranceValue  = this.txtInsuranceValue1.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue1.Text) : 0;
                quote.Pallet2Weight          = this.txtWeight2.Text.Trim().Length > 0 ? int.Parse(this.txtWeight2.Text) : 0;
                quote.Pallet2Class           = this.ddlClass2.SelectedValue;
                quote.Pallet2InsuranceValue  = this.txtInsuranceValue2.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue2.Text) : 0;
                quote.Pallet3Weight          = this.txtWeight3.Text.Trim().Length > 0 ? int.Parse(this.txtWeight3.Text) : 0;
                quote.Pallet3Class           = this.ddlClass3.SelectedValue;
                quote.Pallet3InsuranceValue  = this.txtInsuranceValue3.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue3.Text) : 0;
                quote.Pallet4Weight          = this.txtWeight4.Text.Trim().Length > 0 ? int.Parse(this.txtWeight4.Text) : 0;
                quote.Pallet4Class           = this.ddlClass4.SelectedValue;
                quote.Pallet4InsuranceValue  = this.txtInsuranceValue4.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue4.Text) : 0;
                quote.Pallet5Weight          = this.txtWeight5.Text.Trim().Length > 0 ? int.Parse(this.txtWeight5.Text) : 0;
                quote.Pallet5Class           = this.ddlClass5.SelectedValue;
                quote.Pallet5InsuranceValue  = this.txtInsuranceValue5.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue5.Text) : 0;
                quote.InsidePickup           = this.chkInsideO.Checked;
                quote.LiftGateOrigin         = this.chkLiftGateO.Checked;
                quote.AppointmentOrigin      = this.chkApptO.Checked;
                quote.InsideDelivery         = this.chkInsideD.Checked;
                quote.LiftGateDestination    = this.chkLiftGateD.Checked;
                quote.AppointmentDestination = this.chkApptD.Checked;
                quote.Pallets                = int.Parse(this.txtPallets.Text);
                quote.Weight                 = decimal.Parse(this.txtWeight.Text);
                quote.PalletRate             = decimal.Parse(this.txtRate.Text.Replace("$", ""));
                quote.FuelSurcharge          = decimal.Parse(this.txtFSC.Text.Replace("$", ""));
                quote.AccessorialCharge      = decimal.Parse(this.txtAccessorial.Text.Replace("$", ""));
                quote.InsuranceCharge        = decimal.Parse(this.txtInsurance.Text.Replace("$", ""));
                quote.TollCharge             = decimal.Parse(this.txtTSC.Text.Replace("$", ""));
                quote.TotalCharge            = decimal.Parse(this.txtCharges.Text.Replace("$", ""));

                Session.Add("Quote", quote);
                Response.Redirect("~/Enroll.aspx", false);
                break;
            }
        }
        catch (ApplicationException ex) { Master.ReportError(ex, 3); }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }
Exemple #8
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            //Event handler for form load event
            try {
                //Set control defaults
                #region Grid customizations from normal layout (to support cell editing)
                this.grdRates.DisplayLayout.Bands[0].Override.RowFilterMode = RowFilterMode.AllRowsInBand;
                #endregion

                //Get all tariffs and create dataset schema
                this.mRates = new DataSet();
                this.mRates.Tables.Add("LTLRatesTable");
                this.mRates.Tables["LTLRatesTable"].Columns.Add("Origin");
                this.mRates.Tables["LTLRatesTable"].Columns.Add("Destination");
                this.mRates.Tables["LTLRatesTable"].Columns.Add("NMFC");
                this.mRates.Tables["LTLRatesTable"].Columns.Add("Weight");
                DataModule[] tariffs = FinanceGateway.GetAvailableTariffs();
                for (int k = 0; k < tariffs.Length; k++)
                {
                    this.mRates.Tables["LTLRatesTable"].Columns.Add(tariffs[k].effectiveDateField);
                }
                this.mRates.Tables["LTLRatesTable"].Columns.Add("PSP");
                this.mRates.AcceptChanges();

                //Loop thru all delivery locations
                DataSet destinations = FinanceGateway.ViewDeliveryZips();
                DataRow row          = null;
                //for(int j = 0; j < destinations.Tables["DeliveryZipTable"].Rows.Count; j=j+100) {
                for (int j = 0; j < 5; j++)
                {
                    //Get an LTL rate for each tariff for this destination
                    row                = this.mRates.Tables["LTLRatesTable"].NewRow();
                    row["Origin"]      = "07657";
                    row["Destination"] = destinations.Tables["DeliveryZipTable"].Rows[j]["Zip"].ToString();
                    row["NMFC"]        = "50";
                    row["Weight"]      = "1500";
                    for (int i = 0; i < tariffs.Length; i++)
                    {
                        //Setup the request for NMFC=50, weight=100lbs, Origin=Ridgefield
                        DataModule tariff = tariffs[i];

                        LTLRateShipmentSimpleRequest request = new LTLRateShipmentSimpleRequest();
                        request.tariffNameField            = tariff != null ? tariff.tariffNameField : "";
                        request.shipmentDateCCYYMMDDField  = tariff != null ? tariff.effectiveDateField : "";
                        request.destinationCountryField    = request.originCountryField = "USA";
                        request.originPostalCodeField      = "07657";
                        request.destinationPostalCodeField = destinations.Tables["DeliveryZipTable"].Rows[j]["Zip"].ToString();
                        LTLRequestDetail detail = new LTLRequestDetail();
                        detail.nmfcClassField = "50";
                        detail.weightField    = "1500";
                        request.detailsField  = new LTLRequestDetail[] { detail };

                        //Get the LTL rate and add a datarow
                        LTLRateShipmentSimpleResponse response = FinanceGateway.CalculateLTLSimpleRate(request);
                        row[tariff.effectiveDateField] = response.totalChargeField;
                    }

                    //Get the PSP rate for this destination
                    LTLQuote2 quote = new LTLQuote2();
                    quote.ShipDate       = DateTime.Today;
                    quote.OriginZip      = "07657";
                    quote.DestinationZip = destinations.Tables["DeliveryZipTable"].Rows[j]["Zip"].ToString();
                    quote.Pallet1Weight  = 100;
                    quote      = FreightGateway.CreateQuote(quote);
                    row["PSP"] = quote.TotalCharge.ToString();

                    //Ad the results for this destination
                    this.mRates.Tables["LTLRatesTable"].Rows.Add(row);
                }
                this.grdRates.DataSource = this.mRates;
                this.grdRates.DataMember = "LTLRatesTable";
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
        }
Exemple #9
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); }
    }