Example #1
0
        protected void RegisterBtn_Click(object sender, EventArgs e)
        {
            string dobString = Year.SelectedItem.ToString() + "-" + Month.SelectedItem.ToString() + "-" + Day.SelectedItem.ToString();

            Customer newCust  = new Customer(Firstnametxt.Text, Lastnametxt.Text, dobString, Emailtxt.Text, PhoneNumbertxt.Text);
            string   username = UserNametxt.Text;
            string   passHash = ConnectionClass.getHashedPassword(Passwordtxt.Text);

            if (ConnectionClass.UsernameExists(username))
            {
                //it's the label in the top right hand corner of the menu
                Label lbl = Master.FindControl("Label1") as Label;
                lbl.Text         = "That username already exists!";
                UserNametxt.Text = "";
                UserNametxt.Focus();
                return;
            }
            ConnectionClass.RegisterAccount(newCust, username, passHash);
            Response.Redirect("Login.aspx");
        }
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string nameSaveBTN        = TextBoxName.Text;
                string lastNameSaveBTN    = TextBoxLastName.Text;
                string phoneNumberSaveBTN = TextBoxPhone.Text;
                string emailSaveBTN       = TextBoxEmail.Text;
                string inquirySaveBTN     = DropDownListInquiry.SelectedValue;
                string methodContact      = RadioButtonListMethod.SelectedValue;
                string message            = TextBoxMessage.Text;

                Info infoSaveBTN = new Info(nameSaveBTN, lastNameSaveBTN, phoneNumberSaveBTN, emailSaveBTN, inquirySaveBTN, methodContact, message);
                ConnectionClass.AddInfo(infoSaveBTN);
                LabelDB.Text = "Uploaded Successfully!";
            }
            catch
            {
                LabelDB.Text = "Upload Failed!";
            }
        }
        protected void button_Click(Object sender, EventArgs e)
        {
            if (flag)
            {
                Response.Redirect("~/Login.aspx");
                return;
            }

            Button      thisBtn = sender as Button;
            HiddenField hidden  = thisBtn.Parent.Controls[2] as HiddenField;
            int         id      = int.Parse(hidden.ID);
            Order       o       = Session["ActiveOrder"] as Order;

            ConnectionClass.addCartItem(id, o.ID);

            thisBtn.Text     = "Added to Cart";
            thisBtn.Enabled  = false;
            thisBtn.CssClass = "btn btn-primary btn-disabled btn-asp-special";

            Button neighbor = thisBtn.Parent.Controls[1] as Button;

            neighbor.Visible = true;
            neighbor.Text    = "Remove from Cart";
        }
Example #4
0
        protected void LogInbtn_Click(object sender, EventArgs e)
        {
            int i = (int)Session["LoginAttempts"];

            if (i >= 5)
            {
                LogInLabel.Text = "Too many unsuccesful login attempts, please try again later.";
            }

            string username = UserNametxtbox.Text;
            string passHash = ConnectionClass.getHashedPassword(Passwordtxtbox.Text);

            if (ConnectionClass.LoginMatched(username, passHash))
            {
                Session["ActiveUser"] = ConnectionClass.getLoggedInCustomer(username);
                Response.Redirect("Islands.aspx");
            }
            else
            {
                LogInLabel.Text = "Incorrect Username and Password";
                i++;
                Session["LoginAttempts"] = i;
            }
        }
        protected void GenerateContent()
        {
            int records = islands.Count;

            //figure out how many row elements we need to display every island in the table.
            //each row element contains up to 3 column elements, representing a record from the database
            //so if the number of records is a multiple of 3 we need 1/3rd as many rows as records
            //if not, we need 1/3rd as many rows, +1 extra row to hold the leftover records.
            HtmlGenericControl[] rows = (records % 3 == 0) ? new HtmlGenericControl[records / 3]
                : new HtmlGenericControl[(records / 3) + 1];

            //HtmlGenericControl[] cols = new HtmlGenericControl[12];
            Island island;

            for (int i = 0; i < rows.Length; i++)
            {
                rows[i] = new HtmlGenericControl("div");
                rows[i].Attributes.Add("class", "row");
                PlaceHolder1.Controls.Add(rows[i]);
                for (int j = 0; j < 3; j++)
                {
                    //do not attempt to put any more records in the current row if we have
                    //reached the end of the data source
                    if (index >= records)
                    {
                        break;
                    }

                    HtmlGenericControl col = new HtmlGenericControl("div");
                    HtmlGenericControl h2  = new HtmlGenericControl("h2");
                    Label lbl1             = new Label();
                    Image img                    = new Image();
                    HtmlGenericControl p         = new HtmlGenericControl("p");
                    Label lbl2                   = new Label();
                    HtmlGenericControl ul        = new HtmlGenericControl("ul");
                    HtmlGenericControl l1        = new HtmlGenericControl("li");
                    HtmlGenericControl l2        = new HtmlGenericControl("li");
                    HtmlGenericControl l3        = new HtmlGenericControl("li");
                    HtmlGenericControl p2        = new HtmlGenericControl("p");
                    Button             btn       = new Button();
                    Button             unloadBtn = new Button();
                    HiddenField        hidden    = new HiddenField();

                    col.Attributes.Add("class", "col-md-4");

                    island = islands[index];
                    index++;

                    hidden.ID = string.Format("{0}", island.ID);


                    lbl1.Text = island.Name.ToUpper();

                    img.CssClass = "island-img";
                    img.ImageUrl = "https://i.imgur.com/" + island.ImageUrl;
                    img.Height   = 300;
                    img.Width    = 350;

                    lbl2.Text = island.Description;

                    l1.Attributes.Add("class", "loc-bullet");
                    l1.InnerText = island.Location;

                    l2.Attributes.Add("class", "size-bullet");
                    l2.InnerText = string.Format("{0} acre(s)", island.Acres);

                    l3.Attributes.Add("class", "money-bullet");
                    l3.InnerText = string.Format("${0:n0}", island.Price);

                    if (!flag && ConnectionClass.HasCartItem(o, int.Parse(hidden.ID)))
                    {
                        btn.CssClass = "btn btn-primary btn-disabled btn-asp-special";
                        btn.Enabled  = false;
                        btn.Text     = "Added to Cart";
                        btn.Click   += new EventHandler(button_Click);

                        unloadBtn.CssClass = "btn btn-danger";
                        unloadBtn.Text     = "Remove from Cart";
                        unloadBtn.Visible  = true;
                        unloadBtn.Click   += new EventHandler(unload_Click);
                    }
                    else
                    {
                        btn.CssClass = "btn btn-primary btn-asp-special";
                        btn.Text     = "Add to Cart";
                        btn.Click   += new EventHandler(button_Click);

                        unloadBtn.CssClass = "btn btn-danger";
                        unloadBtn.Text     = "Remove from Cart";
                        unloadBtn.Visible  = false;
                        unloadBtn.Click   += new EventHandler(unload_Click);
                    }

                    rows[i].Controls.Add(col);
                    col.Controls.Add(h2);
                    h2.Controls.Add(lbl1);
                    col.Controls.Add(img);
                    col.Controls.Add(p);
                    col.Controls.Add(ul);

                    ul.Controls.Add(l1);
                    ul.Controls.Add(l2);
                    ul.Controls.Add(l3);

                    p.Controls.Add(lbl2);
                    col.Controls.Add(p2);
                    p2.Controls.Add(btn);
                    p2.Controls.Add(unloadBtn);
                    p2.Controls.Add(hidden);
                }
            }
        }
Example #6
0
        protected void GenerateContent()
        {
            if (!loggedOut && !noItems)
            {
                foreach (CartItem item in cartItems)
                {
                    HtmlGenericControl row    = new HtmlGenericControl("div");
                    HtmlGenericControl col1   = new HtmlGenericControl("div");
                    Image previewImg          = new Image();
                    HtmlGenericControl col2   = new HtmlGenericControl("div");
                    HtmlGenericControl h4     = new HtmlGenericControl("h4");
                    HtmlGenericControl ul     = new HtmlGenericControl("ul");
                    HtmlGenericControl l1     = new HtmlGenericControl("li");
                    HtmlGenericControl l2     = new HtmlGenericControl("li");
                    HtmlGenericControl l3     = new HtmlGenericControl("li");
                    HiddenField        hidden = new HiddenField();
                    Button             btn    = new Button();

                    row.Attributes.Add("class", "row");
                    col1.Attributes.Add("class", "col-md-5");

                    col2.Attributes.Add("class", "col-md-7");
                    col2.Attributes.Add("style", "background-color:#EEEEEE;");
                    previewImg.CssClass = "preview";

                    Island island = ConnectionClass.getCartIsland(item);
                    total += island.Price;

                    previewImg.ImageUrl = "https://i.imgur.com/" + island.ImageUrl;
                    h4.InnerText        = island.Name.ToUpper();

                    l1.Attributes.Add("class", "loc-bullet");
                    l1.InnerText = island.Location;

                    l2.Attributes.Add("class", "size-bullet");
                    l2.InnerText = string.Format("{0} acre(s)", island.Acres);

                    l3.Attributes.Add("class", "money-bullet");
                    l3.InnerText = string.Format("${0:n0}", island.Price);

                    hidden.Value = "" + item.ID;
                    btn.CssClass = "btn btn-danger btn-cart-special";
                    btn.Text     = "Remove from Cart";
                    btn.Click   += new EventHandler(btnRemove_Click);

                    itemsPlaceHolder.Controls.Add(row);
                    row.Controls.Add(col1);
                    col1.Controls.Add(previewImg);

                    row.Controls.Add(col2);
                    col2.Controls.Add(h4);
                    col2.Controls.Add(ul);
                    ul.Controls.Add(l1);
                    ul.Controls.Add(l2);
                    ul.Controls.Add(l3);
                    col2.Controls.Add(hidden);
                    col2.Controls.Add(btn);
                }

                HtmlGenericControl s_row  = new HtmlGenericControl("div");
                HtmlGenericControl s_col1 = new HtmlGenericControl("div");
                HtmlGenericControl s_col2 = new HtmlGenericControl("div");
                HtmlGenericControl s_p1   = new HtmlGenericControl("p");
                HtmlGenericControl s_p2   = new HtmlGenericControl("p");

                s_row.Attributes.Add("class", "row");
                s_col1.Attributes.Add("class", "col-md-8");
                s_col2.Attributes.Add("class", "col-md-4");

                s_p1.InnerText = string.Format("{0} island(s)", count);
                s_p2.InnerText = string.Format("${0:n}", total);

                summaryPlaceHolder.Controls.Add(s_row);
                s_row.Controls.Add(s_col1);
                s_col1.Controls.Add(s_p1);
                s_row.Controls.Add(s_col2);
                s_col2.Controls.Add(s_p2);

                taxes                = (long)(total * 0.05);
                fees.InnerText       = string.Format("${0:n}", taxes);
                grandtotal.InnerText = string.Format("${0:n}", total + taxes);

                btnCheckout.Click += new EventHandler(btnCheckout_Click);
            }
            else
            {
                summary.Visible = false;
                HtmlGenericControl h1 = new HtmlGenericControl("h1");
                HtmlGenericControl h3 = new HtmlGenericControl("h3");
                if (loggedOut)
                {
                    Response.Redirect("~/Login.aspx");
                    return;
                }
                h1.InnerText = "No items to display.";
                h3.InnerText = "You have not added any items to your cart. Try adding some from the Islands page!";
                itemsPlaceHolder.Controls.Add(h1);
                itemsPlaceHolder.Controls.Add(h3);
            }
        }
Example #7
0
 protected void btnReset_Click(object sender, EventArgs e)
 {
     ConnectionClass.resetSoldStatus();
     Response.Redirect("~/Islands.aspx");
 }