Example #1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     cn.Open();
     try
     {
         //string pass = encrypt(txtpass.Text);
         string s1 = null;
         if (rbEntrance.Checked)
         {
             s1 = "insert into registration values('" + rbEntrance.Text + "','" + ddlCourse.Text + "','" + txtEmail.Text + "','" + encrypt(txtpass.Text) + "','" + ddlSalute.Text + "','" + txtName.Text + "','" + ddlGen.Text + "','" + txtadrress.Text + "','" + txtcontact.Text + "','" + FileUploadPic.FileName + "','" + ddlSecQ.Text + "','" + txtSecA.Text + "','" + txtYOPx.Text + "','" + txtPercX.Text + "','" + txtBoardX.Text + "','" + txtYOPxii.Text + "','" + txtPercXii.Text + "','" + txtBoardXii.Text + "')";
             //Label1.Text = s1;
             cmd = new SqlCommand(s1, cn);
             cmd.ExecuteNonQuery();
             FileUploadPic.SaveAs(Server.MapPath("profilepicture") + "\\" + FileUploadPic.FileName);
             Label1.Text = "Registration Successful!!";
             Label2.Text = "";
             Label3.Text = "";
         }
         else if (rbAcademic.Checked)
         {
             Label2.Text = "Sorry!! This service is temporarily unavailable!!";
             Label1.Text = "";
             Label3.Text = "";
         }
     }
     catch
     {
         Label1.Text = "";
         Label2.Text = "";
         Label3.Text = "Registration Unsuccessful!!";
     }
     cn.Close();
 }
Example #2
0
        protected void ButtonAddPro_Click1(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);

            conn.Open();
            FileUploadPic.SaveAs(Server.MapPath("~/pic/") + Path.GetFileName(FileUploadPic.FileName));
            string     insertQuery = "insert into Products (name,price,image) values(@name,@price,@image)";
            string     link        = "pic/" + Path.GetFileName(FileUploadPic.FileName);
            SqlCommand com         = new SqlCommand(insertQuery, conn);

            com.Parameters.AddWithValue("@name", TextBoxPN.Text);
            com.Parameters.AddWithValue("@price", TextBoxPri.Text);
            com.Parameters.AddWithValue("@image", link);


            com.ExecuteNonQuery();
            Response.Write("Upload is Successful");
            Response.Redirect("admin.aspx");

            conn.Close();
        }