Exemplo n.º 1
0
 // method that displays whether an AutoPolicy
 // is in a state with no-fault auto insurance
 public static void PolicyInNoFaultState(AutoPolicy policy)
 {
     Console.WriteLine("The auto policy:");
     Console.Write($"Account #: {policy.AccountNumber}; ");
     Console.WriteLine($"Car: {policy.MakeAndModel};");
     Console.Write($"State {policy.State}; ");
     Console.Write($"{(policy.IsNoFaultState ? "is": " is not")}");
     Console.WriteLine(" a no-fault state\n");
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                //Retrieve autopolicy from session from general information page
                AutoPolicy    policy = (AutoPolicy)(System.Web.HttpContext.Current.Session["autoPolicy"]);
                SqlConnection conn   = Website.getSQLConnection();
                SqlCommand    cmd    = Website.getSQLCommand(conn);
                cmd.CommandText = "GetAutoPolicyInfo";
                SqlDataReader reader;
                conn.Open();
                cmd.Parameters.AddWithValue("@QuoteID", policy.quoteID);
                reader = cmd.ExecuteReader();
                reader.Read();
                policy.bodilyInjuryLimit            = Website.getSafeString(reader, 0);
                policy.propertyDamageLimit          = Website.getSafeString(reader, 1);
                policy.uninsuredBodilyInjuryLimit   = Website.getSafeString(reader, 2);
                policy.uninsuredPropertyDamageLimit = Website.getSafeString(reader, 3);
                policy.medicalExpense = Website.getSafeString(reader, 4);
                try
                {
                    policy.incomeLoss = reader.GetBoolean(5);
                }
                catch (Exception ex)
                {
                }

                ddlBodilyInjuryLimit.SelectedValue    = policy.bodilyInjuryLimit;
                ddlPropertyDamageLimit.SelectedValue  = policy.propertyDamageLimit;
                lblUninsuredMotoristBodyAmount.Text   = policy.uninsuredBodilyInjuryLimit;
                lblUninsuredPropertyDamageAmount.Text = policy.uninsuredPropertyDamageLimit;
                ddlMedicalExpense.SelectedValue       = policy.medicalExpense;
                try
                {
                    if (policy.incomeLoss == false)
                    {
                        ddlIncomeLoss.SelectedIndex = 1;
                    }
                    else if (policy.incomeLoss == true)
                    {
                        ddlIncomeLoss.SelectedIndex = 2;
                    }
                    else
                    {
                        ddlIncomeLoss.SelectedIndex = 0;
                    }
                }
                catch { }
            }
            catch (Exception ex)
            {
            }
        }
        Page.Validate();
    }
Exemplo n.º 3
0
    static void Main()
    {
        // create two AutoPolicy objects
        AutoPolicy policy1 = new AutoPolicy(11111111, "Toyota Camry", "NJ");
        AutoPolicy policy2 = new AutoPolicy(22222222, "Ford Fusion", "ME");

        // display whether each policy is in a no-fault state
        PolicyInNoFaultState(policy1);
        PolicyInNoFaultState(policy2);
    }
Exemplo n.º 4
0
 protected void btnContinue_Click(object sender, EventArgs e)
 {
     Page.Validate();
     if (!Page.IsValid)
     {
         lblRequiredFieldError.Text = "Please enter a value for all required fields";
     }
     else
     {
         try
         {
             AutoPolicy autoPolicy = new AutoPolicy();
             autoPolicy.quoteID             = (Guid)(System.Web.HttpContext.Current.Session["quoteID"]);
             autoPolicy.startDate           = Convert.ToDateTime(txtStartDate.Text);
             autoPolicy.scheduledPayment    = ddlScheduledPayments.SelectedItem.Text;
             autoPolicy.accidentForgiveness = Convert.ToBoolean(ddlAccidentForgiveness.SelectedValue);
             autoPolicy.ageUnderSix         = Convert.ToBoolean(ddlAgeUnder6.SelectedValue);
             if (txtChildBirthDate.Text != "")
             {
                 autoPolicy.childBirthDate = Convert.ToDateTime(txtChildBirthDate.Text);
             }
             autoPolicy.homePolicy         = ddlHomePolicy.SelectedItem.Text;
             autoPolicy.yearsCurrentPolicy = ddlYearsCurrentPolicy.SelectedItem.Text;
             Quote quote = (Quote)(System.Web.HttpContext.Current.Session["quote"]);
             if (ddlHearAboutUs.SelectedValue == "Other")
             {
                 quote.reference = txtDescribeHearOfUs.Text;
             }
             else
             {
                 quote.reference = ddlHearAboutUs.SelectedItem.Text;
             }
             autoPolicy.reference = quote.reference;
             autoPolicy.setAutoGeneralInfo();
             Session["autoPolicy"] = autoPolicy;
             Session["quote"]      = quote;
             Response.Redirect("Policy.aspx");
         }
         catch (SqlException ex)
         {
             lblRequiredFieldError.Text = ex.ToString();
         }
     }
 }
Exemplo n.º 5
0
    protected void btnContinue_Click(object sender, EventArgs e)
    {
        Page.Validate();
        if (!Page.IsValid)
        {
            lblRequiredFieldError.Text = "Please enter a value for all required fields";
        }
        else
        {
            try
            {
                Guid       quoteID    = (Guid)(System.Web.HttpContext.Current.Session["quoteID"]);
                AutoPolicy autoPolicy = (AutoPolicy)(System.Web.HttpContext.Current.Session["autoPolicy"]);
                autoPolicy.quoteID                      = quoteID;
                autoPolicy.bodilyInjuryLimit            = ddlBodilyInjuryLimit.SelectedItem.Text;
                autoPolicy.propertyDamageLimit          = ddlPropertyDamageLimit.SelectedItem.Text;
                autoPolicy.uninsuredBodilyInjuryLimit   = lblUninsuredMotoristBodyAmount.Text;
                autoPolicy.uninsuredPropertyDamageLimit = lblUninsuredPropertyDamageAmount.Text;
                autoPolicy.medicalExpense               = ddlMedicalExpense.SelectedItem.Text;
                try
                {
                    autoPolicy.incomeLoss = Convert.ToBoolean(ddlIncomeLoss.SelectedItem.Value);
                }
                catch
                {
                }
                autoPolicy.setAutoPolicy();
                //Check to see if any vehicles exist for a quote
                //If vehicle exists, user is directed to vehicle display page
                //If no vehicles exist, the user is directed to the vehicle information page

                Response.Redirect("AssignmentHub.aspx");
            }
            catch (SqlException ex)
            {
                lblRequiredFieldError.Text = ex.ToString();
            }
        }
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        cvCorrectStartDate.ValueToCompare = DateTime.Now.ToShortDateString();
        cvChildBirthdate.ValueToCompare   = DateTime.Now.ToShortDateString();
        if (!IsPostBack)
        {
            try
            {
                Guid       quoteID = (Guid)(System.Web.HttpContext.Current.Session["quoteID"]);
                AutoPolicy policy  = new AutoPolicy();
                policy.quoteID = quoteID;
                SqlConnection conn = Website.getSQLConnection();
                SqlCommand    cmd  = Website.getSQLCommand(conn);
                cmd.CommandText = "GetAutoGeneralInfo";
                SqlDataReader reader;
                conn.Open();
                cmd.Parameters.AddWithValue("@QuoteID", policy.quoteID);
                reader = cmd.ExecuteReader();

                //Fill classes
                reader.Read();
                try
                {
                    policy.startDate = reader.GetDateTime(0);
                }
                catch (Exception ex)
                {
                    policy.startDate = DateTime.MinValue;
                }
                policy.scheduledPayment = Website.getSafeString(reader, 1);
                try
                {
                    policy.accidentForgiveness = reader.GetBoolean(2);
                }
                catch (Exception ex) { policy.accidentForgiveness = null; }
                try
                {
                    policy.ageUnderSix = reader.GetBoolean(3);
                }
                catch (Exception ex) { policy.ageUnderSix = null; }
                try
                {
                    policy.childBirthDate = reader.GetDateTime(4);
                }
                catch (Exception ex)
                {
                    policy.childBirthDate = DateTime.MinValue;
                }
                policy.homePolicy         = Website.getSafeString(reader, 5);
                policy.yearsCurrentPolicy = Website.getSafeString(reader, 6);

                //Load datafields
                if (policy.startDate == DateTime.MinValue)
                {
                    txtStartDate.Text = "";
                }
                else
                {
                    txtStartDate.Text = policy.startDate.Date.ToString("d");
                }
                ddlScheduledPayments.SelectedValue = policy.scheduledPayment;
                if (policy.accidentForgiveness == null)
                {
                    ddlAccidentForgiveness.SelectedIndex = 0;
                }
                else if (policy.accidentForgiveness == false)
                {
                    ddlAccidentForgiveness.SelectedIndex = 1;
                }
                else
                {
                    ddlAccidentForgiveness.SelectedIndex = 2;
                }
                if (policy.ageUnderSix == null)
                {
                    ddlAgeUnder6.SelectedIndex = 0;
                }
                else if (policy.ageUnderSix == false)
                {
                    ddlAgeUnder6.SelectedIndex = 1;
                }
                else
                {
                    ddlAgeUnder6.SelectedIndex = 2;
                }
                if (policy.childBirthDate == DateTime.MinValue)
                {
                    txtChildBirthDate.Text = "";
                }
                else
                {
                    lblChildBirthDate.Visible = true;
                    txtChildBirthDate.Visible = true;
                    rfvChildBirthDate.Visible = true;
                    cvChildBirthdate.Visible  = true;
                    cuvChildBirthDate.Visible = true;
                    DateTime childBirthDate = (DateTime)policy.childBirthDate;
                    txtChildBirthDate.Text = childBirthDate.Date.ToString("d");
                }
                ddlHomePolicy.SelectedValue         = policy.homePolicy;
                ddlYearsCurrentPolicy.SelectedValue = policy.yearsCurrentPolicy;
                Quote quote = (Quote)(System.Web.HttpContext.Current.Session["quote"]);

                try
                {
                    ddlHearAboutUs.SelectedValue = ddlHearAboutUs.Items.FindByValue(quote.reference).Value;
                }
                catch (Exception ex)
                {
                    if (quote.reference == null)
                    {
                        ddlHearAboutUs.SelectedIndex = 0;
                    }
                    else
                    {
                        ddlHearAboutUs.SelectedIndex = 14;
                        txtDescribeHearOfUs.Text     = quote.reference;
                        txtDescribeHearOfUs.Visible  = true;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            Page.Validate();
        }
    }