protected void Page_Load(object sender, EventArgs e) { Label5.Text = (string)Session["CurrentCustomer"]; if (Session["RefinedList"] == null) { AdoMethods cs = new AdoMethods(); GridView1.DataSource = cs.AllProducts(); GridView1.DataBind(); } else { GridView1.DataSource = (DataTable)Session["RefinedList"]; GridView1.DataBind(); } if (Session["ShoppingCartList"] != null) { List <int> clickedList = new List <int>(); clickedList = Session["ShoppingCartList"] as List <int>; foreach (var prodId in clickedList) { foreach (GridViewRow row in GridView1.Rows) { Button button = row.FindControl("Button2") as Button; if (prodId == int.Parse(button.CommandArgument)) { button.Text = "Tillagd i kundvagnen"; button.BackColor = System.Drawing.Color.MistyRose; } } } } }
protected void LinkButton1_Click(object sender, EventArgs e) { AdoMethods am = new AdoMethods(); int customerid = am.GetCustomerID((string)Session["CurrentCustomer"]); am.EmptyShoppingCart(customerid); Session.Clear(); FormsAuthentication.SignOut(); FormsAuthentication.RedirectToLoginPage("~/Login.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid) { AdoMethods am = new AdoMethods(); if (am.UserAthentication(TextBox1.Text, TextBox2.Text)) { Session["CurrentCustomer"] = TextBox1.Text; FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, RememberMe.Checked); } else { Label2.Text = "* Inloggning misslyckades!"; } } }
protected void FillShoppingCart() { List <int> shoppingList = new List <int>(); shoppingList = (List <int>)Session["ShoppingCartList"]; AdoMethods am = new AdoMethods(); int customerid = am.GetCustomerID((string)Session["CurrentCustomer"]); foreach (var item in shoppingList) { am.ShoppingCart(item, customerid); } GridView2.DataSource = am.ShoppingCartItemsList(); GridView2.DataBind(); Label7.Text = am.TotalPrice().ToString(); }
protected void ClearPage() { AdoMethods am = new AdoMethods(); int customerid = am.GetCustomerID((string)Session["CurrentCustomer"]); Session["ShoppingCartList"] = null; TextBox2.Text = ""; am.EmptyShoppingCart(customerid); GridView2.Visible = false; TextBox2.Visible = false; Label3.Visible = false; Label6.Visible = false; Label7.Visible = false; Label10.Visible = false; Button1.Visible = false; Label9.Text = "Ordern skapades! Tack för din order!"; }
protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid) { AdoMethods am = new AdoMethods(); am.RegisterCustomer( TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, (int.Parse(TextBox5.Text)), TextBox6.Text, TextBox9.Text, TextBox7.Text ); Label1.Text = "Ny kund skapades!"; } }
protected void Button1_Click(object sender, EventArgs e) { if (Session["ShoppingCartList"] != null) { AdoMethods am = new AdoMethods(); int customerid = am.GetCustomerID((string)Session["CurrentCustomer"]); string deliveryAd = TextBox2.Text; foreach (GridViewRow row in GridView2.Rows) { TextBox tb = row.FindControl("TextBox1") as TextBox; Label lab = row.FindControl("Label8") as Label; am.AddNewOrder(customerid, Convert.ToInt32(lab.Text), Convert.ToInt32(tb.Text), deliveryAd); } ClearPage(); } }
protected void Button1_Click1(object sender, EventArgs e) { int? category = (DropDownList1.SelectedValue != "") ? (int?)(DropDownList1.SelectedIndex) : null; string color = (DropDownList2.SelectedItem.Value.ToString() != "") ? DropDownList2.SelectedItem.Value.ToString(): null; int? price = (DropDownList3.SelectedValue != "") ? (int?)DropDownList3.SelectedIndex : null; string sort = DropDownList4.SelectedItem.Value.ToString(); DataSet ds = new DataSet(); AdoMethods am = new AdoMethods(); ds = am.RefineSearch(category, color, price); if (sort != "") { ds.Tables[0].DefaultView.Sort = "Price " + sort; } GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); Session["RefinedList"] = ds.Tables[0]; }