コード例 #1
0
        protected void CartButton_Click(object sender, EventArgs e)
        {
            List <Purchase> shoppingcart;

            if (Session["cart"] == null)
            {
                Cart.InnerHtml = "<h1>Your Shopping Cart is Empty</h1>";
            }
            else
            {
                OrderButton.Visible = true;
                shoppingcart        = (List <Purchase>)Session["cart"];
                Cart.InnerHtml      = " ";

                foreach (Purchase p in shoppingcart)
                {
                    var     price = "0.0";
                    decimal dec;
                    string  ProductId = p.Productid.ToString();
                    string  salquery  = "SELECT * FROM Products where ProductId  =@ProductId";
                    using (SqlDataReader f = SQLhelper.ExecuteQuery(salquery, CommandType.Text, new SqlParameter(parameterName: "@ProductId", value: (ProductId))))
                    {
                        while (f.Read())
                        {
                            dec             = Convert.ToDecimal(f[3]);
                            price           = f[3].ToString();
                            Cart.InnerHtml += f[1].ToString() + dec;
                        }
                    }
                    Cart.InnerHtml += "     Total price is:£" + price + "    ";
                }
            }
        }
コード例 #2
0
        //protected void LinkButton1_Click(object sender, EventArgs e)
        //{

        //}

        protected void Veiw_Click(object sender, EventArgs e)
        {
            using (SqlDataReader k = SQLhelper.ExecuteQuery("SELECT [Id],[CatagoryName] FROM [dbo].[ Catagory]"))
            {
                string test = " ";
                string txt2 = (string)Session["s"];
                while (k.Read())
                {
                    test += $"<div runat=\"server\" style=\"background-color:cadetblue\">" +
                            $"<a href=WebForm3.aspx?id=" + k["Id"] + " ><big>" + k["CatagoryName"] + "</big></a><br>" +
                            $"<div/>";
                    if (HttpContext.Current.Session["s"] != null)
                    {
                        Div2.InnerHtml = "Currently Logged User is  " + txt2.ToString() + "<br><div></div>";
                        //LogIn.Enabled = false;
                    }
                    else
                    {
                        Div2.InnerHtml = "No one Logged in" + "<br><div></div>";
                    }
                    Div4.InnerHtml = $"<a href=AllProducts.aspx><big>all products</big></a><br>";
                }
                PlaceHolder2.Controls.Add(new Literal {
                    Text = test
                });
            }
        }
コード例 #3
0
      protected void Page_Load(object sender, EventArgs e)
      {
          StringBuilder table = new StringBuilder();
          string        RequestQueryString = Request.QueryString["Id"];

          string salquery = "SELECT * FROM Products where ProductId  =@ProductId";

          using (SqlDataReader f = SQLhelper.ExecuteQuery(salquery, CommandType.Text, new SqlParameter(parameterName: "@ProductId", value: (RequestQueryString))))
          {
              string x = (string)Session[name : "s"];
              //table.Append(value: "< div >x</ div >");
              string twenty = string.Empty;
              table.Append("<table border='1'>");
              table.Append("<tr><th>ID</th><th>phone</th><th>Description</th><th>price</th><th>stock</th></tr>");
              var sql = "<h1> ";
              while (f.Read())
              {
                  if (f[5].ToString() != string.Empty)
                  {
                      table.Replace("<tr><th>ID</th><th>phone</th><th>Description</th><th>price</th><th>stock</th></tr>", "<tr><th>ID</th><th>phone</th><th>Description</th><th>price</th><th>stock</th><th>image</th></tr>");
                  }
                  productid = (int)f[0];
                  Price     = f[2].ToString();
                  table.Append("<tr>");
                  table.Append("<td>" + f[0] + "</td>");
                  table.Append("<td>" + f[1] + "</td>");
                  table.Append("<td>" + f[2] + "</td>");
                  table.Append("<td>" + f[3] + "</td>");
                  table.Append("<td>" + f[4] + "</td>");
                  if (f[5].ToString() != string.Empty)
                  {
                      table.Append("<td>" + f[5] + "</td>");

                      Image1.ImageUrl = f[5].ToString();


                      //twenty = " <table border='1'> < asp:Image id = \"Image1\" runat=\"server\" ImageUrl = \"~" + f[5] + " \"/></table>";
                  }  //AlternateText = "Image text"ImageAlign = "left"+" < img src =\"" + f[5].ToString() +"\" width=100  />"
                  table.Append("</tr>");

                  //   sql += (f[0].ToString() +" "+ f[1].ToString() +" "+ f[2].ToString() +" "+ "</h1>");
              }
              table.Append("</table>");
              PlaceHolder2.Controls.Add(new Literal {
                    Text = table.ToString()
                });
              PlaceHolder2.Controls.Add(new Literal {
                    Text = twenty
                });
              // PlaceHolder2.Controls.Add(new Literal { Text = sql.ToString() });
          }
      }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (SqlDataReader r = SQLhelper.ExecuteQuery(query: "select * from dbo.Products"))
            {
                while (r.Read())
                {
                    //  HELLO.InnerHtml = (r[0]+" "+ r[1] + " " + r[2] + " " + r[3] );



                    //    Response.Write(r[0]);
                }
            }
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            h.Open();
            SqlDataAdapter j = new SqlDataAdapter("SELECT * FROM Products where ProductId = ProductId ", h);

            j.SelectCommand.ExecuteNonQuery();
            DataTable dt = new DataTable();

            j.Fill(dt);
            h.Close();
            grid.DataSource = dt;
            grid.DataBind();



            StringBuilder table = new StringBuilder();


            string salquery = "SELECT * FROM Products where ProductId=ProductId ";

            using (SqlDataReader f = SQLhelper.ExecuteQuery(salquery))
            {
                string x = (string)Session["s"];
                table.Append("<div id=\"Div1\" runat=\"server\"  style=\"color: #33CC33; background-color: violet\">" + "enjoy browsing " + x);
                table.Append("<table border='1' bgcolor=\" #00ffff\" >");
                table.Append("<tr><th>ID</th><th>phone</th><th>Description</th><th>price</th><th>stock</th>");
                table.Append("</tr>");

                var sql = "<h1> ";
                while (f.Read())
                {
                    table.Append("<tr>");
                    table.Append("<td>" + f[0] + "</td>");
                    table.Append("<td>" + f[1] + "</td>");
                    table.Append("<td>" + f[2] + "</td>");
                    table.Append("<td>" + f[3] + "</td>");
                    table.Append("<td>" + f[4] + "</td>");

                    table.Append("</tr>");

                    sql += (f[0].ToString() + " " + f[1].ToString() + " " + f[2].ToString() + " " + "</h1>");
                }
                table.Append("</table></ div >");
                PlaceHolder1.Controls.Add(new Literal {
                    Text = table.ToString()
                });
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // string x= "SELECT * FROM [dbo].[Products] inner join [dbo].[ProductCatagory]on Products.ProductId=ProductCatagory.ProductId and ProductCatagory.CategoryId= @CatId ";
            string x = "SELECT * FROM [dbo].[Products] inner join [dbo].[ProductCatagory] on ProductCatagory.CategoryId= @CatId  and Products.ProductId=ProductCatagory.ProductId";

            string CatId = Request.QueryString["Id"];

            using (SqlDataReader k = SQLhelper.ExecuteQuery(x, CommandType.Text, new SqlParameter("@CatId", Int32.Parse(CatId))))
            {
                string y = (string)Session["s"];

                while (k.Read())      //&& Session["s"] != null
                {
                    Div1.InnerHtml += $"<div  background-color: violet>";
                    Div1.InnerHtml += $"<a href=WebForm2.aspx?id={k["ProductId"].ToString()}><big>{k["Name"]}</big></a><br>";
                    Div1.InnerHtml += $"<div/>";
                }
            }
        }