예제 #1
0
    protected void OnCommand(object sender, CommandEventArgs e)
    {
        //
        try {
            switch (e.CommandName)
            {
            case "Submit":
                if (this.mConsignee == null)
                {
                    //New
                    LTLConsignee consignee = new LTLConsignee();
                    consignee.ClientID        = Master.CurrentClient.ID;
                    consignee.Name            = this.txtName.Text;
                    consignee.AddressLine1    = this.txtStreet.Text;
                    consignee.AddressLine2    = "";
                    consignee.City            = this.txtCity.Text;
                    consignee.State           = this.txtState.Text;
                    consignee.Zip             = this.txtZip.Text;
                    consignee.Zip4            = "";
                    consignee.WindowStartTime = DateTime.Parse("01-01-2000 " + this.txtWindowOpen.Text);
                    consignee.WindowEndTime   = DateTime.Parse("01-01-2000 " + this.txtWindowClose.Text);
                    consignee.ContactName     = this.txtContactName.Text;
                    consignee.ContactPhone    = this.txtContactPhone.Text;
                    consignee.ContactEmail    = this.txtContactEmail.Text;
                    consignee.Status          = "A";
                    consignee.UserID          = Membership.GetUser().UserName;
                    consignee.LastUpdated     = DateTime.Now;
                    int id = new FreightGateway().CreateLTLConsignee(consignee);
                    ScriptManager.RegisterStartupScript(this.txtName, typeof(TextBox), "Consignee", "alert('New consignee " + consignee.Name + " has been created.');", true);
                }
                else
                {
                    //Update
                    this.mConsignee.AddressLine1    = this.txtStreet.Text;
                    this.mConsignee.AddressLine2    = "";
                    this.mConsignee.City            = this.txtCity.Text;
                    this.mConsignee.State           = this.txtState.Text;
                    this.mConsignee.Zip             = this.txtZip.Text;
                    this.mConsignee.Zip4            = "";
                    this.mConsignee.WindowStartTime = DateTime.Parse("01-01-2000 " + this.txtWindowOpen.Text);
                    this.mConsignee.WindowEndTime   = DateTime.Parse("01-01-2000 " + this.txtWindowClose.Text);
                    this.mConsignee.ContactName     = this.txtContactName.Text;
                    this.mConsignee.ContactPhone    = this.txtContactPhone.Text;
                    this.mConsignee.ContactEmail    = this.txtContactEmail.Text;
                    this.mConsignee.UserID          = Membership.GetUser().UserName;
                    this.mConsignee.LastUpdated     = DateTime.Now;
                    bool updated = new FreightGateway().UpdateLTLConsignee(this.mConsignee);
                    ScriptManager.RegisterStartupScript(this.txtName, typeof(TextBox), "Consignee", "alert('Consignee " + this.mConsignee.Name + " has been updated.');", true);
                }
                this.btnSubmit.Enabled = false;
                this.btnCancel.Text    = "Close";
                break;

            case "Cancel":
                Response.Redirect(this.mCallingURI + "?view=consignees", false);
                break;
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }
예제 #2
0
 protected void OnZipChanged(object sender, EventArgs e)
 {
     //Event handler for change in zip
     try {
         //Validate the zip is servicable; display city/state if it is; notify and log unsupported zips if not
         string zipCode = this.txtZip5.Text;
         if (this.mConsignee == null && zipCode.Trim().Length == 5)
         {
             ServiceLocation location = new FreightGateway().ReadServiceLocation(zipCode);
             if (location == null)
             {
                 this.txtZip5.Text = "";
                 this.txtZip5.Focus();
                 throw new ApplicationException(zipCode + " is currently not supported for delivery.");
             }
             else
             {
                 this.txtCity.Text  = location.City.Trim();
                 this.txtState.Text = location.State.Trim();
                 this.txtName.Focus();
             }
         }
     }
     catch (Exception ex) { Master.ReportError(ex, 3); }
 }
예제 #3
0
 protected void OnCurrentClientChanged(object sender, EventArgs e)
 {
     //Event handler for change in sleected client
     try {
         LTLClient client = new FreightGateway().ReadLTLClient(int.Parse(this.cboClients.SelectedValue));
         Session["currentclient"] = client;
         if (this.CurrentClientChanged != null)
         {
             this.CurrentClientChanged(sender, e);
         }
     }
     catch (Exception ex) { ReportError(ex, 3); }
 }
예제 #4
0
    protected void OnBookQuote(object sender, EventArgs e)
    {
        //
        if (!Page.IsValid)
        {
            return;
        }
        try {
            LTLShipment shipment = new LTLShipment();
            shipment.Created                = DateTime.Now;
            shipment.ClientID               = Master.CurrentClient.ID;
            shipment.ShipDate               = DateTime.Parse(this.txtShipDate.Text);
            shipment.ShipperID              = int.Parse(this.ddlShippers.SelectedValue);
            shipment.ConsigneeID            = int.Parse(this.ddlConsignees.SelectedValue);
            shipment.Pallet1Weight          = int.Parse(this.txtWeight1.Text);
            shipment.Pallet1Class           = this.ddlClass1.SelectedValue;
            shipment.Pallet1InsuranceValue  = this.txtInsuranceValue1.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue1.Text) : 0;
            shipment.Pallet2Weight          = this.txtWeight2.Text.Trim().Length > 0 ? int.Parse(this.txtWeight2.Text) : 0;
            shipment.Pallet2Class           = this.ddlClass2.SelectedValue;
            shipment.Pallet2InsuranceValue  = this.txtInsuranceValue2.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue2.Text) : 0;
            shipment.Pallet3Weight          = this.txtWeight3.Text.Trim().Length > 0 ? int.Parse(this.txtWeight3.Text) : 0;
            shipment.Pallet3Class           = this.ddlClass3.SelectedValue;
            shipment.Pallet3InsuranceValue  = this.txtInsuranceValue3.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue3.Text) : 0;
            shipment.Pallet4Weight          = this.txtWeight4.Text.Trim().Length > 0 ? int.Parse(this.txtWeight4.Text) : 0;
            shipment.Pallet4Class           = this.ddlClass4.SelectedValue;
            shipment.Pallet4InsuranceValue  = this.txtInsuranceValue4.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue4.Text) : 0;
            shipment.Pallet5Weight          = this.txtWeight5.Text.Trim().Length > 0 ? int.Parse(this.txtWeight5.Text) : 0;
            shipment.Pallet5Class           = this.ddlClass5.SelectedValue;
            shipment.Pallet5InsuranceValue  = this.txtInsuranceValue5.Text.Trim().Length > 0 ? int.Parse(this.txtInsuranceValue5.Text) : 0;
            shipment.InsidePickup           = this.chkInsideO.Checked;
            shipment.LiftGateOrigin         = this.chkLiftGateO.Checked;
            shipment.AppointmentOrigin      = this.txtApptO.Text.Trim().Length > 0 ? DateTime.Parse(this.txtApptO.Text) : DateTime.MinValue;
            shipment.InsideDelivery         = this.chkInsideD.Checked;
            shipment.LiftGateDestination    = this.chkLiftGateD.Checked;
            shipment.AppointmentDestination = this.txtApptD.Text.Trim().Length > 0 ? DateTime.Parse(this.txtApptD.Text) : DateTime.MinValue;
            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;

            int id = new FreightGateway().CreateLTLShipment(shipment);
            Response.Redirect("~/Client/Shipments.aspx", false);
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }
예제 #5
0
 public static void Trace(string message, LogLevel level)
 {
     //Trace
     if (level >= _Config.TraceLevel)
     {
         TraceMessage m = new TraceMessage();
         m.Name     = "Argix10";
         m.Source   = App.Product;
         m.User     = Environment.UserName;
         m.Computer = Environment.MachineName;
         m.LogLevel = level;
         m.Message  = message;
         FreightGateway.WriteLogEntry(m);
     }
 }
예제 #6
0
 protected void OnConsigneeZipChanged(object sender, EventArgs e)
 {
     //
     try {
         string          zipCode  = this.txtConsigneeZip.Text;
         ServiceLocation location = new FreightGateway().ReadServiceLocation(zipCode);
         if (location == null)
         {
             this.txtConsigneeZip.Text = "";
             this.txtConsigneeZip.Focus();
             throw new ApplicationException(zipCode + " is currently not supported for delivery.");
         }
     }
     catch (Exception ex) { Master.ReportError(ex, 3); }
 }
예제 #7
0
 protected void OnZipChanged(object sender, EventArgs e)
 {
     //
     try {
         string          zipCode  = this.txtZip.Text;
         ServiceLocation location = new FreightGateway().ReadPickupLocation(zipCode);
         if (location == null)
         {
             this.txtZip.Text = "";
             this.txtZip.Focus();
             throw new ApplicationException(zipCode + " is currently not supported for pickup.");
         }
         else
         {
             this.txtCity.Text  = location.City.Trim();
             this.txtState.Text = location.State.Trim();
             this.txtName.Focus();
         }
     }
     catch (Exception ex) { Master.ReportError(ex, 3); }
 }
예제 #8
0
    protected void OnShipmentCommand(object sender, CommandEventArgs e)
    {
        //Event handler for change in view
        string number = "";

        try {
            switch (e.CommandName)
            {
            case "New":
                Response.Redirect("~/Client/Shipment.aspx?number=", false);
                break;

            case "Update":
                number = this.grdShipments.SelectedDataKey.Value.ToString();
                Response.Redirect("~/Client/Shipment.aspx?number=" + number, false);
                break;

            case "Cancel":
                //Cancel the selected shipment
                number = this.grdShipments.SelectedDataKey.Value.ToString();
                bool cancelled = new FreightGateway().CancelLTLShipment(number, Membership.GetUser().UserName);

                //Update view
                this.grdShipments.DataBind();
                this.mView = 0;

                //Notify client
                Master.ShowMessageBox("Shipment " + number + " has been cancelled.");
                break;

            case "Search":
                this.odsSearch.SelectParameters["clientNumber"].DefaultValue = Master.CurrentClient.Number;
                this.grdSearch.DataBind();
                this.mView = 1;
                break;
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
        finally { OnValidateForm(null, EventArgs.Empty); }
    }
예제 #9
0
    protected void OnLoggedIn(object sender, EventArgs e)
    {
        //
        try {
            MembershipUser user = Membership.GetUser(this.LoginUser.UserName);
            Session["user"] = user;
            if (user != null)
            {
                //Get the client account for the current login
                LTLClient2 client = new FreightGateway().ReadLTLClient(int.Parse(Profile.GetProfile(user.UserName).ClientID));
                Session["client"]        = client;
                Session["currentclient"] = client;

                //Get the sales rep for the current client (if applicable)
                if (new MembershipServices(this.LoginUser.UserName).IsAdmin)
                {
                    //Load list of all clients for admin
                    LTLClientDataset clients = new FreightGateway().GetLTLClientList(null);
                    Session["clients"] = clients;
                }
                else if (new MembershipServices(this.LoginUser.UserName).IsSalesRep)
                {
                    //Sales rep for current client
                    Session["salesrep"] = client;

                    //Load list of clients for sales rep
                    LTLClientDataset clients = new FreightGateway().GetLTLClientList(client.Number);
                    Session["clients"] = clients;
                }
                else if (new MembershipServices(this.LoginUser.UserName).IsClient&& client.SalesRepClientNumber.Length > 0)
                {
                    //Client with sales rep
                    LTLClient2 salesRep = new FreightGateway().ReadLTLClientByNumber(client.SalesRepClientNumber);
                    Session["salesrep"] = salesRep;
                }
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }
예제 #10
0
 //Interface
 protected void Page_Init(object sender, EventArgs e)
 {
     //Event handler for load event
     try {
         if (!Page.IsPostBack)
         {
             if (Session["terminals"] == null)
             {
                 string terminalID = Request.QueryString["location"];
                 if (terminalID == null || terminalID.Trim().Length == 0)
                 {
                     terminalID = "0";
                 }
                 Session["terminalcode"] = terminalID;
                 TerminalDataset terminals = new FreightGateway().GetTerminals(int.Parse(terminalID));
                 Session["terminals"] = terminals;
             }
             this.cboTerminal.DataSource = (TerminalDataset)Session["terminals"];
             this.cboTerminal.DataBind();
         }
     }
     catch (Exception ex) { ReportError(ex, 3); }
 }
예제 #11
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); }
    }
예제 #12
0
 public DispatchConfiguration()
 {
     //Constructor
     this.mConfig = FreightGateway.GetUserConfiguration(App.Product, new string[] { Environment.UserName, Environment.MachineName });
 }
예제 #13
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); }
    }
예제 #14
0
    protected void OnSubmit(object sender, EventArgs e)
    {
        //
        if (!Page.IsValid)
        {
            return;
        }
        try {
            //Validate
            ApplicationException aex = null;
            //if (this.txtTaxIDNumber.Text.Length != 10) aex = new ApplicationException("Please enter a valid federal taxID number of the form xx-xxxxxxx.");
            if (aex == null)
            {
                //Set all objects before creating anything
                LTLClient2 client = new LTLClient2();
                client.Name                  = this.txtCompanyName.Text;
                client.AddressLine1          = this.txtCompanyStreet.Text;
                client.AddressLine2          = "";
                client.City                  = this.txtCompanyCity.Text;
                client.State                 = this.txtCompanyState.Text;
                client.Zip                   = this.txtCompanyZip.Text;
                client.Zip4                  = "";
                client.ContactName           = this.txtContactName.Text;
                client.ContactPhone          = this.txtContactPhone.Text;
                client.ContactEmail          = this.txtContactEmail.Text;
                client.CorporateName         = this.txtCorporateName.Text;
                client.CorporateAddressLine1 = this.txtCorporateStreet.Text;
                client.CorporateAddressLine2 = "";
                client.CorporateCity         = this.txtCorporateCity.Text;
                client.CorporateState        = this.txtCorporateState.Text;
                client.CorporateZip          = this.txtCorporateZip.Text;
                client.CorporateZip4         = "";
                client.TaxID                 = "";
                client.BillingAddressLine1   = this.txtBillingStreet.Text;
                client.BillingAddressLine2   = "";
                client.BillingCity           = this.txtBillingCity.Text;
                client.BillingState          = this.txtBillingState.Text;
                client.BillingZip            = this.txtBillingZip.Text;
                client.BillingZip4           = "";
                //TODO: client.Approved = false;
                client.UserID      = this.txtUserName.Text;
                client.LastUpdated = DateTime.Today;

                //Is this created by a salesRep? Then set sales rep reference on new client
                if (Master.SalesRep != null)
                {
                    client.SalesRepClientNumber = Master.SalesRep.Number;
                }

                //Create a new membership account
                MembershipCreateStatus status = MembershipCreateStatus.Success;
                Membership.CreateUser(this.txtUserName.Text, this.txtPassword.Text, this.txtContactEmail.Text, null, null, true, out status);
                switch (status)
                {
                case MembershipCreateStatus.Success:
                    //Add user to the client role
                    Roles.AddUserToRole(this.txtUserName.Text, "client");

                    //If this fails rollback the new login
                    try {
                        //Create the client
                        int clientID = new FreightGateway().CreateLTLClient(client);
                        client.ID = clientID;       //Add the ID for enrolling shippers, consignees, etc

                        //Create user profile and set properties value
                        ProfileCommon profile = Profile.GetProfile(this.txtUserName.Text);
                        profile.ClientID = clientID.ToString();
                        profile.Save();

                        //Send welcome message to new client and sales rep (if a sales rep created this enrollment)
                        new NotifyService().NotifyWelcome(this.txtUserName.Text, this.txtContactEmail.Text, this.txtPassword.Text, client);
                        if (Master.SalesRep != null)
                        {
                            new NotifyService().NotifyWelcome(this.txtUserName.Text, Master.SalesRep.ContactEmail, this.txtPassword.Text, client);
                        }

                        //Update client list if there is one (admin or sales rep)
                        if (Master.Clients != null)
                        {
                            if (new MembershipServices().IsAdmin)
                            {
                                Session["clients"] = new FreightGateway().GetLTLClientList("");
                            }
                            else if (new MembershipServices().IsSalesRep)
                            {
                                Session["clients"] = new FreightGateway().GetLTLClientList(Master.Client.Number);
                            }
                        }

                        //Go to pickup log
                        Response.Redirect("~/Client/Shipments.aspx", false);
                    }
                    catch (Exception ex) {
                        Membership.DeleteUser(this.txtUserName.Text);
                        Master.ReportError(ex, 4);
                    }
                    break;

                case MembershipCreateStatus.DuplicateUserName:
                    Master.ReportError(new ApplicationException("This login username already exists."), 3);
                    break;

                case MembershipCreateStatus.InvalidPassword:
                    Master.ReportError(new ApplicationException("Password should be minimum 6 characters long."), 3);
                    break;

                case MembershipCreateStatus.UserRejected:
                    break;
                }
            }
            else
            {
                Master.ReportError(aex, 3);
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }
예제 #15
0
    protected void OnSubmit(object sender, EventArgs e)
    {
        //Submit a quote
        if (!Page.IsValid)
        {
            return;
        }
        try {
            //Validate inputs
            ApplicationException aex = null;
            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) > 1500))
            {
                aex = new ApplicationException("Please enter a valid weight for pallet 1 (1 - 1500lbs).");
            }
            else if (this.txtWeight2.Text.Trim().Length > 0 && (int.Parse(this.txtWeight2.Text) < 1 || int.Parse(this.txtWeight2.Text) > 1500))
            {
                aex = new ApplicationException("Please enter a valid weight for pallet 2 (1 - 1500lbs).");
            }
            else if (this.txtWeight3.Text.Trim().Length > 0 && (int.Parse(this.txtWeight3.Text) < 1 || int.Parse(this.txtWeight3.Text) > 1500))
            {
                aex = new ApplicationException("Please enter a valid weight for pallet 3 (1 - 1500lbs).");
            }
            else if (this.txtWeight4.Text.Trim().Length > 0 && (int.Parse(this.txtWeight4.Text) < 1 || int.Parse(this.txtWeight4.Text) > 1500))
            {
                aex = new ApplicationException("Please enter a valid weight for pallet 4 (1 - 1500lbs).");
            }
            else if (this.txtWeight5.Text.Trim().Length > 0 && (int.Parse(this.txtWeight5.Text) < 1 || int.Parse(this.txtWeight5.Text) > 1500))
            {
                aex = new ApplicationException("Please enter a valid weight for pallet 5 (1 - 1500lbs).");
            }
            else if (this.txtInsuranceValue1.Text.Trim().Length > 0 && (int.Parse(this.txtInsuranceValue1.Text) > 10000))
            {
                aex = new ApplicationException("Maximum insurance value $10,000.");
            }
            else if (this.txtInsuranceValue2.Text.Trim().Length > 0 && (int.Parse(this.txtInsuranceValue2.Text) > 10000))
            {
                aex = new ApplicationException("Maximum insurance value $10,000.");
            }
            else if (this.txtInsuranceValue3.Text.Trim().Length > 0 && (int.Parse(this.txtInsuranceValue3.Text) > 10000))
            {
                aex = new ApplicationException("Maximum insurance value $10,000.");
            }
            else if (this.txtInsuranceValue4.Text.Trim().Length > 0 && (int.Parse(this.txtInsuranceValue4.Text) > 10000))
            {
                aex = new ApplicationException("Maximum insurance value $10,000.");
            }
            else if (this.txtInsuranceValue5.Text.Trim().Length > 0 && (int.Parse(this.txtInsuranceValue5.Text) > 10000))
            {
                aex = new ApplicationException("Maximum insurance value $10,000.");
            }
            if (aex == null)
            {
                //Calculate the quote
                LTLQuote quote = new LTLQuote();
                quote.Created                = DateTime.Now;
                quote.ShipDate               = DateTime.Parse(this.txtShipDate.Text);
                quote.ShipperID              = int.Parse(this.ddlShippers.SelectedValue);
                quote.ConsigneeID            = int.Parse(this.ddlConsignees.SelectedValue);
                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.txtApptO.Text.Length > 0;
                quote.InsideDelivery         = this.chkInsideD.Checked;
                quote.LiftGateDestination    = this.chkLiftGateD.Checked;
                quote.AppointmentDestination = this.txtApptD.Text.Length > 0;
                quote.Pallets                = 0;
                quote.Weight            = 0;
                quote.PalletRate        = 0;
                quote.FuelSurcharge     = 0;
                quote.AccessorialCharge = 0;
                quote.InsuranceCharge   = 0;
                quote.TollCharge        = 0;
                quote.TotalCharge       = 0;
                quote = new FreightGateway().CreateQuote(quote);

                //Update the quote
                //this.lblTransit.Text = quote.TransitMin.ToString() + " - " + quote.TransitMax.ToString() + " days transit";
                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.btnBook.Enabled = true;
            }
            else
            {
                resetQuote();
                Master.ReportError(aex, 3);
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }
예제 #16
0
    protected void OnCommand(object sender, CommandEventArgs e)
    {
        //
        try {
            switch (e.CommandName)
            {
            case "Validate":
                bool verified = verifyAddress(this.txtName.Text, this.txtAddressLine1.Text, this.txtAddressLine2.Text, this.txtCity.Text, this.txtState.Text, this.txtZip5.Text, this.txtZip4.Text);
                if (verified)
                {
                    ViewState["AddressValid"] = true;
                    Master.ShowMessageBox("The Address has been validated.");
                }
                break;

            case "ChooseAddress":
                //Choose user address as valid address
                this.txtName.Text         = this.txtSrcName.Text;
                this.txtAddressLine1.Text = this.txtSrcAddressLine1.Text;
                this.txtAddressLine2.Text = this.txtSrcAddressLine2.Text;
                this.txtCity.Text         = this.txtSrcCity.Text;
                this.txtState.Text        = this.txtSrcState.Text;
                this.txtZip5.Text         = this.txtSrcZip5.Text;
                this.txtZip4.Text         = this.txtSrcZip4.Text;

                ViewState["AddressValid"]    = true;
                this.mvwPage.ActiveViewIndex = 0;
                break;

            case "ChooseUSPSAddress":
                //Choose USPS address as valid address
                this.txtName.Text         = this.txtUSPSName.Text;
                this.txtAddressLine1.Text = this.txtUSPSAddressLine1.Text;
                this.txtAddressLine2.Text = this.txtUSPSAddressLine2.Text;
                this.txtCity.Text         = this.txtUSPSCity.Text;
                this.txtState.Text        = this.txtUSPSState.Text;
                this.txtZip5.Text         = this.txtUSPSZip5.Text;
                this.txtZip4.Text         = this.txtUSPSZip4.Text;

                ViewState["AddressValid"]    = true;
                this.mvwPage.ActiveViewIndex = 0;
                break;

            case "Submit":
                if (this.mConsignee == null)
                {
                    //New- ensure the address is valid
                    if (!this.mAddressValid)
                    {
                        this.mAddressValid        = verifyAddress(this.txtName.Text, this.txtAddressLine1.Text, this.txtAddressLine2.Text, this.txtCity.Text, this.txtState.Text, this.txtZip5.Text, this.txtZip4.Text);
                        ViewState["AddressValid"] = this.mAddressValid;
                    }
                    if (this.mAddressValid)
                    {
                        LTLConsignee2 consignee = new LTLConsignee2();
                        consignee.ClientNumber    = Master.CurrentClient.Number;
                        consignee.Name            = this.txtName.Text;
                        consignee.AddressLine1    = this.txtAddressLine1.Text;
                        consignee.AddressLine2    = this.txtAddressLine2.Text;
                        consignee.City            = this.txtCity.Text;
                        consignee.State           = this.txtState.Text;
                        consignee.Zip             = this.txtZip5.Text;
                        consignee.Zip4            = this.txtZip4.Text;
                        consignee.WindowTimeStart = DateTime.Parse("01-01-2000 " + this.txtWindowOpen.Text);
                        consignee.WindowTimeEnd   = DateTime.Parse("01-01-2000 " + this.txtWindowClose.Text);
                        consignee.ContactName     = this.txtContactName.Text;
                        consignee.ContactPhone    = this.txtContactPhone.Text;
                        consignee.ContactEmail    = this.txtContactEmail.Text;
                        consignee.UserID          = Membership.GetUser().UserName;
                        consignee.LastUpdated     = DateTime.Now;
                        int number = new FreightGateway().CreateLTLConsignee(consignee);

                        this.btnValidate.Enabled = this.btnSubmit.Enabled = false;
                        this.btnCancel.Text      = "Close";
                        Master.ShowMessageBox("New consignee " + consignee.Name + " has been created.");
                    }
                }
                else
                {
                    //Update
                    this.mConsignee.Name            = this.txtName.Text;
                    this.mConsignee.AddressLine1    = this.txtAddressLine1.Text;
                    this.mConsignee.AddressLine2    = this.txtAddressLine2.Text;
                    this.mConsignee.Zip4            = this.txtZip4.Text;
                    this.mConsignee.WindowTimeStart = DateTime.Parse("01-01-2000 " + this.txtWindowOpen.Text);
                    this.mConsignee.WindowTimeEnd   = DateTime.Parse("01-01-2000 " + this.txtWindowClose.Text);
                    this.mConsignee.ContactName     = this.txtContactName.Text;
                    this.mConsignee.ContactPhone    = this.txtContactPhone.Text;
                    this.mConsignee.ContactEmail    = this.txtContactEmail.Text;
                    this.mConsignee.UserID          = Membership.GetUser().UserName;
                    this.mConsignee.LastUpdated     = DateTime.Now;
                    bool updated = new FreightGateway().UpdateLTLConsignee(this.mConsignee);

                    this.btnValidate.Enabled = this.btnSubmit.Enabled = false;
                    this.btnCancel.Text      = "Close";
                    Master.ShowMessageBox("Consignee " + this.mConsignee.Name + " has been updated.");
                }
                break;

            case "Cancel":
                Response.Redirect(this.mCallingURI + "?view=consignees", false);
                break;
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }
예제 #17
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); }
        }
예제 #18
0
    protected void OnManageCommand(object sender, CommandEventArgs e)
    {
        //
        try {
            switch (e.CommandName)
            {
            case "AccountUpdate":
                ApplicationException aex = null;
                //if (this.txtTaxIDNumber.Text.Length != 10) aex = new ApplicationException("Please enter a valid federal taxID number of the form xx-xxxxxxx.");
                if (aex == null)
                {
                    LTLClient client = new LTLClient();
                    client.ID                    = int.Parse(this.lblID.Text);
                    client.Name                  = this.txtCompanyName.Text;
                    client.AddressLine1          = this.txtCompanyStreet.Text;
                    client.AddressLine2          = "";
                    client.City                  = this.txtCompanyCity.Text;
                    client.State                 = this.txtCompanyState.Text;
                    client.Zip                   = this.txtCompanyZip.Text;
                    client.Zip4                  = "";
                    client.ContactName           = this.txtContactName.Text;
                    client.ContactPhone          = this.txtContactPhone.Text;
                    client.ContactEmail          = this.txtContactEmail.Text;
                    client.CorporateName         = this.txtCorporateName.Text;
                    client.CorporateAddressLine1 = this.txtCorporateStreet.Text;
                    client.CorporateAddressLine2 = "";
                    client.CorporateCity         = this.txtCorporateCity.Text;
                    client.CorporateState        = this.txtCorporateState.Text;
                    client.CorporateZip          = this.txtCorporateZip.Text;
                    client.CorporateZip4         = "";
                    client.TaxIDNumber           = this.txtTaxIDNumber.Text;
                    client.BillingAddressLine1   = this.txtBillingStreet.Text;
                    client.BillingAddressLine2   = "";
                    client.BillingCity           = this.txtBillingCity.Text;
                    client.BillingState          = this.txtBillingState.Text;
                    client.BillingZip            = this.txtBillingZip.Text;
                    client.BillingZip4           = "";
                    client.Status                = "A";
                    client.UserID                = Master.User.UserName;
                    client.LastUpdated           = DateTime.Now;
                    //if(Master.SalesRep != null) client.SalesRepClientID = Master.SalesRep.ID;
                    bool updated = new FreightGateway().UpdateLTLClient(client);

                    //Update Membership account email
                    //MembershipUserCollection members = Membership.FindUsersByEmail(Master.CurrentClient.ContactEmail);
                    //foreach (MembershipUser member in members) {
                    //    if (member.Email == Master.CurrentClient.ContactEmail) {
                    //        member.Email = this.txtContactEmail.Text;
                    //        break;
                    //    }
                    //}

                    //Confirmation
                    Master.ShowMessageBox("Client " + client.Name + " has been updated.");
                }
                else
                {
                    Master.ReportError(aex, 3);
                }
                break;

            case "ShipperNew":
                Response.Redirect("~/Client/Shipper.aspx?id=0", false);
                break;

            case "ShipperUpdate":
                Response.Redirect("~/Client/Shipper.aspx?id=" + this.grdShippers.SelectedDataKey.Value.ToString(), false);
                break;

            case "ConsigneeNew":
                Response.Redirect("~/Client/Consignee.aspx?id=0", false);
                break;

            case "ConsigneeUpdate":
                Response.Redirect("~/Client/Consignee.aspx?id=" + this.grdConsignees.SelectedDataKey.Value.ToString(), false);
                break;
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
    }