예제 #1
0
        protected void btnOrderType_Click(object sender, EventArgs e)
        {
            Order       o   = new Order();
            ServiceZips zip = new ServiceZips();

            zip.ServiceZip = txtZip.Text.ToString();
            List <ServiceZips> zips = ServiceZipsDA.GetAllServiceZips();

            foreach (ServiceZips z in zips)
            {
                if (zip.ServiceZip == z.ServiceZip)
                {
                    o.StoreNum = z.StoreNum;

                    if (rdoCarryOut.Checked)
                    {
                        o.OrderType       = "carryout";
                        o.OrderEstimation = "20";
                    }
                    else
                    {
                        o.OrderType       = "delivery";
                        o.OrderEstimation = "50";
                    }

                    Session["Order"] = o;
                    Response.Redirect("~/Views/Menu.aspx");
                }
                else
                {
                }
            }
        }
예제 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Customer changedCustomer = (Customer)Session["Customer"];
            bool     noErrors        = true;

            switch ((string)Session["ValueChanging"])
            {
            case ("Email"):
                List <Customer> cc           = CustomerDA.GetAllCustomers();
                bool            noDuplicates = false;
                foreach (Customer c in cc)
                {
                    if (c.CustomerLogin == txtChangedValue.Text)
                    {
                        lblError.Text    = "That email is already claimed, try a different email";
                        lblError.Visible = true;
                        noDuplicates     = false;
                        noErrors         = false;
                        break;
                    }
                    else
                    {
                        noDuplicates = true;
                    }
                }
                if (noDuplicates)
                {
                    changedCustomer.CustomerLogin = txtChangedValue.Text;
                }
                break;

            case ("First Name"):
                changedCustomer.CustomerFirst = txtChangedValue.Text;
                break;

            case ("Last Name"):
                changedCustomer.CustomerLast = txtChangedValue.Text;
                break;

            case ("Phone"):
                changedCustomer.CustomerPhone = txtChangedValue.Text;
                break;

            case ("Address"):
                changedCustomer.CustomerAddress = txtChangedValue.Text;
                break;

            case ("City"):
                changedCustomer.CustomerCity = txtChangedValue.Text;
                break;

            case ("Zip"):
                ServiceZips zz = new ServiceZips();
                zz.ServiceZip = txtChangedValue.Text.ToString();
                List <ServiceZips> zips = ServiceZipsDA.GetAllServiceZips();
                foreach (ServiceZips z in zips)
                {
                    if (zz.ServiceZip == z.ServiceZip)
                    {
                        changedCustomer.CustomerZip  = txtChangedValue.Text;
                        changedCustomer.PrimaryStore = zz.StoreNum;
                    }
                    else
                    {
                        lblError.Text    = "We can't deliver to that zipcode, contact us with further questions";
                        lblError.Visible = true;
                        noErrors         = false;
                    }
                }
                break;
            }
            if (noErrors)
            {
                CustomerDA.UpdateCustomer(changedCustomer);
                Session["Customer"] = changedCustomer;
                Response.Redirect("~/CustomerPages/ManageCustomer");
            }
        }
예제 #3
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            string firstName = txtFirstName.Text;
            string lastName  = txtLastName.Text;
            string address   = txtAddress.Text;
            string city      = txtCity.Text;
            string state     = cmboState.SelectedValue;
            string zip       = txtZip.Text;
            string phone     = txtPhone.Text;
            string login     = txtLogin.Text;
            string password  = BCrypt.Net.BCrypt.HashPassword(txtPassword.Text, 10);

            Customer c = new Customer();

            c.CustomerFirst    = firstName;
            c.CustomerLast     = lastName;
            c.CustomerAddress  = address;
            c.CustomerCity     = city;
            c.CustomerState    = state;
            c.CustomerPhone    = phone;
            c.CustomerLogin    = login;
            c.CustomerPassword = password;

            ServiceZips zz = new ServiceZips();

            zz.ServiceZip = txtZip.Text.ToString();
            List <ServiceZips> zips = ServiceZipsDA.GetAllServiceZips();

            foreach (ServiceZips z in zips)
            {
                if (zz.ServiceZip == z.ServiceZip)
                {
                    c.CustomerZip  = zz.ServiceZip;
                    c.PrimaryStore = z.StoreNum;
                    List <Customer> cc           = CustomerDA.GetAllCustomers();
                    bool            noDuplicates = false;
                    foreach (Customer checker in cc)
                    {
                        if (checker.CustomerLogin == c.CustomerLogin)
                        {
                            lblError.Text    = "That email is already taken, try another one or try logging in";
                            lblError.Visible = true;
                            noDuplicates     = false;
                            break;
                        }
                        else
                        {
                            noDuplicates = true;
                        }
                    }
                    if (noDuplicates)
                    {
                        Session["customer"] = c;
                        CustomerDA.AddCustomer(c);
                        //SmtpClient needs a host and port passed to it
                        SmtpClient client = new SmtpClient();

                        //where you declare the host
                        client.Host = "smtp.gmail.com";

                        //where you declare the port
                        client.Port = 587;

                        client.EnableSsl             = true;
                        client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        client.UseDefaultCredentials = false;
                        client.Credentials           = new NetworkCredential("*****@*****.**", "NotAnEasyPassword");
                        MailAddress from    = new MailAddress("*****@*****.**");
                        MailAddress to      = new MailAddress(login);
                        MailMessage message = new MailMessage(from, to);
                        message.Subject = "Your new account!";
                        message.Body    = "Thank you for signing up for your new account " + firstName + "\nWe hope you enjoy the pizza!\n\nYour new account information,\n\n\tLogin:\t" + login + "\n\tPassword:\t" + password + "\n\tFirst Name:\t" + firstName + "\n\tLast Name:\t" + lastName + "\n\tAddress:\t" + address + "\n\tCity:\t" + city +
                                          "\n\tState:\t" + state + "\n\tPhone:\t" + phone;
                        message.BodyEncoding = System.Text.Encoding.UTF8;
                        //this is closed off for when there is no host or port, can't send mail unless it's online
                        client.Send(message);


                        Response.Redirect("~/");
                    }
                }
            }
            if (lblError.Text == "")
            {
                lblError.Text    = "Something went wrong with creating your account, \nWe may be unable to deliver to you currently,\nContact us if you have questions.";
                lblError.Visible = true;
            }
        }