Skip to content

Instantly share code, notes, and snippets.

@Gr8z
Created January 18, 2020 20:05
Show Gist options
  • Save Gr8z/8ca4be723ff9bf4fea0e24b2675e8dd1 to your computer and use it in GitHub Desktop.
Save Gr8z/8ca4be723ff9bf4fea0e24b2675e8dd1 to your computer and use it in GitHub Desktop.
Web Tech snippets
fuImage.SaveAs(Request.PhysicalApplicationPath +"./images/"+ fuImage.FileName.ToString());
b = "./images/" + fuImage.FileName.ToString();
SqlCommand cmd = new SqlCommand("INSERT INTO Fruits (FruitName, FruitPrice, FruitImage) VALUES (@FruitName, @FruitPrice, @FruitImagePath)", con);
cmd.Parameters.AddWithValue("@FruitName", txtFruitName.Text);
cmd.Parameters.AddWithValue("@FruitPrice", txtFruitPrice.Text);
cmd.Parameters.AddWithValue("@FruitImagePath", b.ToString());
cmd.ExecuteNonQuery();
gvFruits.DataBind();
int rowIndex = ((sender as Button).NamingContainer as GridViewRow).RowIndex;
int fID = Convert.ToInt32(gvFruits.DataKeys[rowIndex].Values[0]);
SqlCommand cmd = new SqlCommand("INSERT INTO Cart (FruitName, FruitPrice, FruitImage) SELECT FruitName, FruitPrice, FruitImage FROM Fruits WHERE fruitID = '" + fID + "'", con);
cmd.ExecuteNonQuery();
SqlCommand cmd = new SqlCommand("TRUNCATE TABLE Cart", con);
cmd.ExecuteNonQuery();
gvCart.DataBind();
int rowIndex = ((sender as LinkButton).NamingContainer as GridViewRow).RowIndex;
int mID = Convert.ToInt32(gvCart.DataKeys[rowIndex].Values[0]);
SqlCommand cmd = new SqlCommand("DELETE FROM Cart WHERE CartID = '" + mID + "'", con);
cmd.ExecuteNonQuery();
SqlCommand cmd = new SqlCommand("SELECT * FROM users WHERE username=@username AND password=@password", con);
cmd.Parameters.AddWithValue("@Username", Username.Text);
cmd.Parameters.AddWithValue("@Password", Password.Text);
int count = (int) cmd.ExecuteScalar();
if (count > 0) {
Session["Username"] = Username.Text;
} else {
// shit
}
SqlCommand cmd = new SqlCommand("INSERT INTO MemberLogin (Username, Password) VALUES (@Username, @Password)", con);
cmd.Parameters.AddWithValue("@Username", Username.Text);
cmd.Parameters.AddWithValue("@Password", Password.Text);
cmd.ExecuteNonQuery();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment