Created
January 18, 2020 20:05
-
-
Save Gr8z/8ca4be723ff9bf4fea0e24b2675e8dd1 to your computer and use it in GitHub Desktop.
Web Tech snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SqlCommand cmd = new SqlCommand("TRUNCATE TABLE Cart", con); | |
cmd.ExecuteNonQuery(); | |
gvCart.DataBind(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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