using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.IO; using System.Drawing; using System.Net; using System.Net.Mail; public partial class _Default : System.Web.UI.Page { string fileName_n; SqlConnection cn = new SqlConnection("Server=103.48.50.60,1232;DataBase=caishipolychem;uid=caishipolychem;pwd=Chandan@1234"); SqlCommand com = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(); DataSet ds = new DataSet(); protected void Page_Load(object sender, EventArgs e) { string a; if (Session["a"] == null) { Response.Redirect("adminlogin.aspx"); } else { a = Session["a"].ToString(); } } protected void Button1_Click(object sender, EventArgs e) { string s = "./productpic/"; DateTime dtNow = DateTime.Now; Random r = new Random(); string n = r.Next(1, 1000).ToString(); string path = s; HttpFileCollection uploadFileCol = Request.Files; HttpPostedFile file = uploadFileCol[0]; string fileExt = Path.GetExtension(file.FileName); string fileName = n + Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath("./productpic/") + fileName); fileName_n = ("./productpic/") + fileName; Image1.ImageUrl = fileName_n; } protected void Button2_Click(object sender, EventArgs e) { if (txtproduct.Text ==""||CKEditorControl1.Text ==""||Image1.ImageUrl=="") { string strscript = ""; Page.RegisterStartupScript("popup", strscript); } else { cn.Open(); string sql = "insert into divinesurgical(category,product,des,picture)values('" + ddlcategory.Text + "','" + txtproduct.Text + "','" + CKEditorControl1.Text + "','" + Image1.ImageUrl + "')"; SqlCommand cmd = new SqlCommand(sql, cn); cmd.ExecuteNonQuery(); cn.Close(); Response.Redirect("controlpanel.aspx"); } } protected void Button3_Click(object sender, EventArgs e) { if (TextBox1.Text == "") { string strscript = ""; Page.RegisterStartupScript("popup", strscript); } else { cn.Open(); string sqldelete = "delete from divinesurgical where id='" + TextBox1.Text + "'"; SqlCommand cmd = new SqlCommand(sqldelete, cn); cmd.ExecuteNonQuery(); cn.Close(); string strscript = ""; Page.RegisterStartupScript("popup", strscript); TextBox1.Text = ""; } } }