protected void Button1_Click(object sender, EventArgs e) { Models.Connection gcon = new Models.Connection(); Models.ClearTextBox ct = new Models.ClearTextBox(); Models.Categories cat = new Models.Categories(); cat.CatName = TextBox1.Text; cat.Add(cat); Response.Write("<script>alert('Successfully Inserted Category')</script>"); //Response.Redirect("AdminHome.aspx"); ct.ClearTextbox(TextBox1); }
protected void Button2_Click(object sender, EventArgs e) { Models.Connection gcon = new Models.Connection(); Models.ClearTextBox ct = new Models.ClearTextBox(); Models.Products pro = new Models.Products(); pro.name = TextBox1.Text; pro.description = TextBox2.Text; pro.price = Convert.ToInt32(TextBox3.Text); pro.quantity = Convert.ToInt32(TextBox4.Text); SqlCommand com = new SqlCommand("select Cid from CategoryView where CategoryName ='" + DropDownList1.Text + "'", gcon.getConnection()); SqlDataReader rd = com.ExecuteReader(); while (rd.Read()) { pro.categoryID = Convert.ToInt32(rd["Cid"].ToString()); } pro.path = Label1.Text; pro.Add(pro); Response.Write("<script>alert('Successfully Inserted Product')</script>"); //Response.Redirect("AdminHome.aspx"); ct.ClearTextbox(TextBox1, TextBox2, TextBox3, TextBox4); Label1.Text = ""; Image1.ImageUrl = ""; }