protected void Page_Load(object sender, EventArgs e) { SQLDataClass.getAllProducts(); txtMessage.Text = ""; if (!IsPostBack) { DisplayRow((int)Session["Prog3_Index"]); } string Output = ""; SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["UWPCS3870ConnectionString1"].ConnectionString); conn.Open(); string insertQuery = "Select Role from Users where UserName = '******'"; SqlCommand com = new SqlCommand(insertQuery, conn); //com.ExecuteNonQuery(); SqlDataReader item = com.ExecuteReader(); while (item.Read()) { Output = item.GetValue(0).ToString(); } conn.Close(); if (!Output.Contains("Admin")) { Response.Redirect("Default.aspx"); } }
public static void getAllProducts() { if (SQLDataClass.prodAdapter == null) { SQLDataClass.setupProdAdapter(); } }
protected void Page_Load(object sender, EventArgs e) { SQLDataClass.getAllProducts(); this.DataBind(); if (!IsPostBack) { DisplayRow((int)Application["Prog3_Index"]); } }
protected void Page_Load(object sender, EventArgs e) { SQLDataClass.getAllProducts(); txtMessage.Text = ""; if (!IsPostBack) { DisplayRow((int)Session["Prog3_Index"]); } }
protected void Page_Load(object sender, EventArgs e) { SQLDataClass.getAllProducts(); this.DataBind(); //txtID.Text = (string)Application["Prog2_ProductID"]; //txtQuantity.Text = (string)Application["Prog2_ProductQuantity"]; //txtPrice.Text = Application["Prog2_ProductPrice"].ToString(); txtID.Focus(); }
protected void btnUpdate_Click(object sender, EventArgs e) { try { string theID = txtID.Text; string newName = txtName.Text; double newPrice = double.Parse(txtPrice.Text.Replace("$", "")); string newDesc = txtDescription.Text; SQLDataClass.UpdateProduct(theID, newName, newPrice, newDesc); txtMessage.Text = "Record updated."; SQLDataClass.getAllProducts(); } catch (Exception ex) { txtMessage.Text = "Product Not Updated: " + ex.Message; } }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //Prog2 Application["Prog2_ProductID"] = ""; Application["Prog2_ProductPrice"] = ""; Application["Prog2_ProductQuantity"] = ""; Application["Prog2_Computed"] = false; //Prog3 Application["Prog3_Index"] = 0; Application["Prog3_ID"] = ""; SQLDataClass.setupProdAdapter(); }
protected void btnAdd_Click(object sender, EventArgs e) { if (btnAdd.Text == "Add") { btnDelete.Enabled = false; btnNext.Enabled = false; btnPrevious.Enabled = false; btnFirst.Enabled = false; btnLast.Enabled = false; btnUpdate.Enabled = false; btnAdd.Text = "Save"; clearTextFields(); } else { btnDelete.Enabled = true; btnNext.Enabled = true; btnPrevious.Enabled = true; btnFirst.Enabled = true; btnLast.Enabled = true; btnUpdate.Enabled = true; try { btnAdd.Text = "Add"; string theID = txtID.Text; string newName = txtName.Text; double newPrice = double.Parse(txtPrice.Text.Replace("$", "")); string newDesc = txtDescription.Text; SQLDataClass.InsertProduct(theID, newName, newPrice, newDesc); txtMessage.Text = "Record added."; SQLDataClass.getAllProducts(); } catch (Exception ex) { txtMessage.Text = "Product Not Added: " + ex.Message; } } }
protected void btnDelete_Click(object sender, EventArgs e) { try { string theID = txtID.Text; SQLDataClass.DeleteProduct(theID); txtMessage.Text = "Record deleted."; SQLDataClass.getAllProducts(); int index = (int)Application["Prog3_Index"] - 1; if (index < 0) { index = 0; } Application["Prog3_index"] = index; DisplayRow(index); } catch (Exception ex) { txtMessage.Text = "Product Not Deleted: " + ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { SQLDataClass.getAllProducts(); }
protected void Page_Load(object sender, EventArgs e) { SQLDataClass.getAllProducts(); ProductGrid.DataSource = SQLDataClass.tblProduct; ProductGrid.DataBind(); }
protected void Application_Start(object sender, EventArgs e) { SQLDataClass.setupProdAdapter(); }