protected void Page_Load(object sender, EventArgs e) { ProductsList.DataSource = ProductsFactory.GetProductsList(); ProductsList.DataBind(); string id = Request.QueryString["id"]; if (Request.QueryString["id"] == null) { Response.Redirect("Index.aspx"); } else { Product p = ProductsFactory.GetProductById(id); productId.InnerText = p.Id; productName.InnerText = p.Name; Nowprice.InnerText = p.Price.ToString(); Oldprice.InnerText = p.OldPrice.ToString(); Introd1.Src = p.ImgPath; Introd2.Src = p.ImgPath2; Detail.InnerText = p.Detail; Tag.InnerText = p.Tag; Class.InnerText = p.Class; } }
private void ListProducts() { var products = this.productService.GetProducts(); ProductsList.DataSource = products; ProductsList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //顾客购买统计 var _db = new WingtipToys.Models.ProductContext(); List <OrderDetail> orderList = _db.OrderDetails.ToList(); PurchaseList.DataSource = orderList; PurchaseList.DataBind(); //销售统计 AdminOperation admin = new AdminOperation(); List <Product> list = admin.GetAllProduct(); ProductsList.DataSource = list; ProductsList.DataBind(); int sumNum = 0; double sumMoeny = 0; foreach (Product p in list) { sumNum += p.Sold; sumMoeny += (double)p.Sold * (double)p.UnitPrice; } SumNumber.Text = "书籍销售总数:" + sumNum.ToString(); SumMoney.Text = "书籍销售总金额:" + sumMoeny.ToString(); }
protected void UpdateViewComputer(Object sender, EventArgs e) { MySqlConnection con = new MySqlConnection("Data Source=localhost;Initial Catalog=sys; User Id=root;password=symbor97;"); MySqlCommand cmd = new MySqlCommand("Select * from computers", con); con.Open(); MySqlDataAdapter adp = new MySqlDataAdapter(cmd); DataTable tab = new DataTable(); adp.Fill(tab); Computer comp = new Computer(); String htmlText = ""; foreach (DataRow row in tab.Rows) { comp.AddAllComponents(row, tab.Columns.Count); htmlText += comp.BuildHtmlComputerItem(row["ConfigurationName"].ToString()); } ComputerComponentContent.Visible = false; computerDisplayList.Visible = true; ContactsPage.Visible = false; FeedbackForm.Visible = false; computerConfigList.InnerHtml = htmlText; con.Close(); ProductsList.DataSource = null; ProductsList.DataBind(); }
protected void AddComputerConfiguration_Click(object sender, EventArgs e) { modalDialogComputer.Visible = true; ProductsList.DataSource = null; ProductsList.DataBind(); CalculateTotalComputerWindow(); ComputerDropDown_SelectedIndexChanged(ComputerDropDown, null); }
public bool UpdateData(List <BLProduct> products) { if (products == null || products.Count == 0) { ProductsList.DataSource = null; Session["products"] = null; ProductsList.DataBind(); MSG.Text = "there is no products"; //error msg return(false); } ProductsList.DataSource = products; Session["products"] = products; ProductsList.DataBind(); MSG.Text = ""; return(true); }
protected void UpdateViewRam(Object sender, EventArgs e) { MySqlConnection con = new MySqlConnection("Data Source=localhost;Initial Catalog=sys; User Id=root;password=symbor97;"); MySqlCommand cmd = new MySqlCommand("Select idComponent, Name, Price, Type from computer_components where Type='Ram'", con); con.Open(); var reader = cmd.ExecuteReader(); ProductsList.DataSource = reader; ProductsList.DataBind(); ComputerComponentContent.Visible = true; computerDisplayList.Visible = false; ContactsPage.Visible = false; FeedbackForm.Visible = false; con.Close(); }
protected void DisplaySearchResults(Object sender, EventArgs e) { MySqlConnection con = new MySqlConnection("Data Source=localhost;Initial Catalog=sys; User Id=root;password=symbor97;"); MySqlCommand cmd = new MySqlCommand("Select idComponent, Name, Price, Type from computer_components where name LIKE '%" + txtSearchMaster.Text.ToString() + "%'", con); con.Open(); var reader = cmd.ExecuteReader(); ProductsList.DataSource = reader; ProductsList.DataBind(); ComputerComponentContent.Visible = true; computerDisplayList.Visible = false; ContactsPage.Visible = false; FeedbackForm.Visible = false; con.Close(); }
protected void Button9_Click(object sender, EventArgs e) { String pname = TextBox3.Text; conn = new MySqlConnection(GetConnectionString()); try { conn.Open(); String sql = " where Product_Name like '%" + pname + "%'"; MySqlCommand comm = new MySqlCommand(mainquery + sql, conn); MySqlDataReader dr = comm.ExecuteReader(); ProductsList.DataSource = dr; ProductsList.DataTextField = maintextfield; ProductsList.DataValueField = mainvaluefield; ProductsList.DataBind(); dr.Close(); } catch (Exception ex) { Response.Write(ex.Message); } finally { conn.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["Items"] == null) { Session["Items"] = new Dictionary <int, int> { }; } if (Session["User"] != null) { LoggedIn.Visible = true; NotLoggedIn.Visible = false; CurrentUserLoggedIn.Text = "Logged in as: " + Session["User"].ToString(); } RecalcCart(); LoadDropDownItems(); MySqlConnection con = new MySqlConnection("Data Source=localhost;Initial Catalog=sys; User Id=root;password=symbor97;"); MySqlCommand cmd = new MySqlCommand("Select idComponent, Name, Price, Type from computer_components", con); con.Open(); var reader = cmd.ExecuteReader(); ProductsList.DataSource = reader; ProductsList.DataBind(); ComputerComponentContent.Visible = true; computerDisplayList.Visible = false; ContactsPage.Visible = false; FeedbackForm.Visible = false; con.Close(); } }
protected void ProductSearch_Click(object sender, EventArgs e) { String product_id = TextBox1.Text; conn = new MySqlConnection(GetConnectionString()); ProductsList.ClearSelection(); try { conn.Open(); String sql = mainquery + "where Product_ID='" + product_id + "'"; MySqlCommand comm = new MySqlCommand(sql, conn); MySqlDataReader dr = comm.ExecuteReader(); ProductsList.DataSource = dr; ProductsList.DataTextField = maintextfield; ProductsList.DataValueField = mainvaluefield; ProductsList.DataBind(); } catch (Exception ex) { Response.Write(ex.Message); } finally { conn.Close(); } }
protected void SpecificationRList7_SelectedIndexChanged(object sender, EventArgs e) { String catid = CategoryList.SelectedValue.ToString(); String subcatid = SubcategoryList.SelectedValue.ToString(); String spec1 = SpecificationRList1.SelectedValue.ToString(); String spec2 = SpecificationRList2.SelectedValue.ToString(); String spec3 = SpecificationRList3.SelectedValue.ToString(); String spec4 = SpecificationRList4.SelectedValue.ToString(); String spec5 = SpecificationRList5.SelectedValue.ToString(); String spec6 = SpecificationRList6.SelectedValue.ToString(); String spec7 = SpecificationRList7.SelectedValue.ToString(); String query1 = "where Sp10_Value='" + spec7 + "' and Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; if (!BrandList.SelectedValue.ToString().Equals("0")) { String brandname = BrandList.SelectedValue.ToString(); query1 += "and Company_Name='" + brandname + "'"; } //brandchanged = false; if (spec2 != "") { query1 += "and Sp5_Value='" + spec2 + "'"; } if (spec3 != "") { query1 += "and Sp6_Value='" + spec3 + "'"; } if (spec4 != "") { query1 += "and Sp7_Value='" + spec4 + "'"; } if (spec5 != "") { query1 += "and Sp8_Value='" + spec5 + "'"; } if (spec6 != "") { query1 += "and Sp9_Value='" + spec6 + "'"; } if (spec1 != "") { query1 += "and Sp4_Value='" + spec1 + "'"; } conn = new MySqlConnection(GetConnectionString()); try { conn.Open(); String sql = mainquery + query1; MySqlCommand comm = new MySqlCommand(sql, conn); MySqlDataReader dr1 = comm.ExecuteReader(); ProductsList.DataSource = dr1; ProductsList.DataTextField = maintextfield; ProductsList.DataValueField = mainvaluefield; ProductsList.DataBind(); dr1.Close(); } catch (Exception ex) { Response.Write(ex.Message); } finally { conn.Close(); } Button4.Visible = true; }
protected void CategoryList_SelectedIndexChanged(object sender, EventArgs e) { String catid = CategoryList.SelectedValue.ToString(); //Response.Write(catid); conn = new MySqlConnection(GetConnectionString()); Specification1.Visible = false; SpecificationRList1.Visible = false; Specification2.Visible = false; SpecificationRList2.Visible = false; Specification3.Visible = false; SpecificationRList3.Visible = false; Specification4.Visible = false; SpecificationRList4.Visible = false; Specification5.Visible = false; SpecificationRList5.Visible = false; Specification6.Visible = false; SpecificationRList6.Visible = false; Specification7.Visible = false; SpecificationRList7.Visible = false; Label5.Visible = false; Label6.Visible = false; TextBox5.Visible = false; TextBox6.Visible = false; Button11.Visible = false; Button12.Visible = false; Button5.Visible = false; try { conn.Open(); MySqlCommand comm = new MySqlCommand("Select Subcategory_Name,Subcategory_ID from Subcategory where Category_ID='" + catid + "'", conn); MySqlDataReader dr = comm.ExecuteReader(); SubcategoryList.DataSource = dr; SubcategoryList.DataTextField = "Subcategory_Name"; SubcategoryList.DataValueField = "Subcategory_ID"; SubcategoryList.DataBind(); dr.Close(); comm.CommandText = "Select Product_ID,CONCAT(Company_Name,' ',Product_Name,' ',Sp4_Value,' ',Sp5_Value,' ',Sp6_Value,' ',Sp7_Value,' ',Sp8_Value,' MRP ',Retail_Price,' WP ',Wholesale_Price,' Stock ',Stock) from Master_Products where Category_ID='" + catid + "'"; MySqlDataReader dr1 = comm.ExecuteReader(); ProductsList.DataSource = dr1; ProductsList.DataTextField = "CONCAT(Company_Name,' ',Product_Name,' ',Sp4_Value,' ',Sp5_Value,' ',Sp6_Value,' ',Sp7_Value,' ',Sp8_Value,' MRP ',Retail_Price,' WP ',Wholesale_Price,' Stock ',Stock)"; ProductsList.DataValueField = "Product_ID"; ProductsList.DataBind(); dr1.Close(); } catch (Exception ex) { Response.Write("In category list"); Response.Write(ex.Message); } finally { conn.Close(); } SubcategoryList.Items.Insert(0, new ListItem("", "0")); }
protected void SubcategoryList_SelectedIndexChanged(object sender, EventArgs e) { String catid = CategoryList.SelectedValue.ToString(); String subcatid = SubcategoryList.SelectedValue.ToString(); //Response.Write(catid); //Response.Write(subcatid); conn = new MySqlConnection(GetConnectionString()); Specification1.Visible = false; SpecificationRList1.Visible = false; Specification2.Visible = false; SpecificationRList2.Visible = false; Specification3.Visible = false; SpecificationRList3.Visible = false; Specification4.Visible = false; SpecificationRList4.Visible = false; Specification5.Visible = false; SpecificationRList5.Visible = false; Specification6.Visible = false; SpecificationRList6.Visible = false; Specification7.Visible = false; SpecificationRList7.Visible = false; try { conn.Open(); String query1 = "Select Product_ID,CONCAT(Company_Name,' ',Product_Name,' ',Sp4_Value,' ',Sp5_Value,' ',Sp6_Value,' ',Sp7_Value,' ',Sp8_Value,' MRP ',Retail_Price,' WP ',Wholesale_Price,' Stock ',Stock) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlCommand comm = new MySqlCommand(query1, conn); MySqlDataReader dr1 = comm.ExecuteReader(); //ProductsList.ClearSelection(); ProductsList.DataSource = dr1; ProductsList.DataTextField = "CONCAT(Company_Name,' ',Product_Name,' ',Sp4_Value,' ',Sp5_Value,' ',Sp6_Value,' ',Sp7_Value,' ',Sp8_Value,' MRP ',Retail_Price,' WP ',Wholesale_Price,' Stock ',Stock)"; ProductsList.DataValueField = "Product_ID"; ProductsList.DataBind(); dr1.Close(); comm.CommandText = "Select DISTINCT(Company_Name) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlDataReader dr2 = comm.ExecuteReader(); BrandList.DataSource = dr2; BrandList.DataTextField = "Company_Name"; BrandList.DataValueField = "Company_Name"; BrandList.DataBind(); dr2.Close(); BrandList.Visible = true; Label4.Visible = true; comm.CommandText = "Select Specification4,Specification5,Specification6,Specification7,Specification8,Specification9,Specification10 from Specifications where Category_ID='" + catid + "' and Subcategory_ID = '" + subcatid + "'"; MySqlDataReader dr3 = comm.ExecuteReader(); String[] Specs = new String[7]; dr3.Read(); for (int i = 0; i < 7; i++) { Specs[i] = dr3.GetValue(i).ToString(); } dr3.Close(); if (Specs[0] != "") { Specification1.Text = Specs[0]; Specification1.Visible = true; } if (Specs[1] != "") { Specification2.Text = Specs[1]; Specification2.Visible = true; } if (Specs[2] != "") { Specification3.Text = Specs[2]; Specification3.Visible = true; } if (Specs[3] != "") { Specification4.Text = Specs[3]; Specification4.Visible = true; } if (Specs[4] != "") { Specification5.Text = Specs[4]; Specification5.Visible = true; } if (Specs[5] != "") { Specification6.Text = Specs[5]; Specification6.Visible = true; } if (Specs[6] != "") { Specification7.Text = Specs[6]; Specification7.Visible = true; } if (Specification1.Visible) { comm.CommandText = "Select DISTINCT(Sp4_Value) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlDataReader dr4 = comm.ExecuteReader(); SpecificationRList1.DataSource = dr4; SpecificationRList1.DataTextField = "Sp4_Value"; SpecificationRList1.DataValueField = "Sp4_Value"; SpecificationRList1.DataBind(); SpecificationRList1.Visible = true; dr4.Close(); } if (Specification2.Visible) { comm.CommandText = "Select DISTINCT(Sp5_Value) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlDataReader dr4 = comm.ExecuteReader(); SpecificationRList2.DataSource = dr4; SpecificationRList2.DataTextField = "Sp5_Value"; SpecificationRList2.DataValueField = "Sp5_Value"; SpecificationRList2.DataBind(); SpecificationRList2.Visible = true; dr4.Close(); } if (Specification3.Visible) { comm.CommandText = "Select DISTINCT(Sp6_Value) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlDataReader dr4 = comm.ExecuteReader(); SpecificationRList3.DataSource = dr4; SpecificationRList3.DataTextField = "Sp6_Value"; SpecificationRList3.DataValueField = "Sp6_Value"; SpecificationRList3.DataBind(); SpecificationRList3.Visible = true; dr4.Close(); } if (Specification4.Visible) { comm.CommandText = "Select DISTINCT(Sp7_Value) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlDataReader dr4 = comm.ExecuteReader(); SpecificationRList4.DataSource = dr4; SpecificationRList4.DataTextField = "Sp7_Value"; SpecificationRList4.DataValueField = "Sp7_Value"; SpecificationRList4.DataBind(); SpecificationRList4.Visible = true; dr4.Close(); } if (Specification5.Visible) { comm.CommandText = "Select DISTINCT(Sp8_Value) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlDataReader dr4 = comm.ExecuteReader(); SpecificationRList5.DataSource = dr4; SpecificationRList5.DataTextField = "Sp8_Value"; SpecificationRList5.DataValueField = "Sp8_Value"; SpecificationRList5.DataBind(); SpecificationRList5.Visible = true; dr4.Close(); } if (Specification6.Visible) { comm.CommandText = "Select DISTINCT(Sp9_Value) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlDataReader dr4 = comm.ExecuteReader(); SpecificationRList6.DataSource = dr4; SpecificationRList6.DataTextField = "Sp9_Value"; SpecificationRList6.DataValueField = "Sp9_Value"; SpecificationRList6.DataBind(); SpecificationRList6.Visible = true; dr4.Close(); } if (Specification7.Visible) { comm.CommandText = "Select DISTINCT(Sp10_Value) from Master_Products where Category_ID='" + catid + "' and Subcategory_ID='" + subcatid + "'"; MySqlDataReader dr4 = comm.ExecuteReader(); SpecificationRList7.DataSource = dr4; SpecificationRList7.DataTextField = "Sp10_Value"; SpecificationRList7.DataValueField = "Sp10_Value"; SpecificationRList7.DataBind(); SpecificationRList7.Visible = true; dr4.Close(); } } catch (Exception ex) { Response.Write(ex.Message); } finally{ conn.Close(); } BrandList.Items.Insert(0, new ListItem("", "0")); }