//Inserting
registration data of user!!!
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
string inscmd = "Insert into Registration(Username,
Password,EmailAddress,FullName,CNIC,city) Values(@UserName, @Password,
@EmailAddress, @FullName, @CNIC, @City)";
SqlCommand InsertUser = new SqlCommand(inscmd, con);
InsertUser.Parameters.AddWithValue("@UserName", TextBoxUN.Text);
InsertUser.Parameters.AddWithValue("@Password", TextBoxPass.Text);
InsertUser.Parameters.AddWithValue("@EmailAddress", TextBoxEA.Text);
InsertUser.Parameters.AddWithValue("@FullName", TextBoxFN.Text);
InsertUser.Parameters.AddWithValue("@CNIC", TextBoxCNIC.Text);
InsertUser.Parameters.AddWithValue("@City",
DropDownListCity.SelectedItem.ToString());
try
{
con.Open();
//Response.Write("Trying
...");
InsertUser.ExecuteNonQuery();
con.Close();
}
catch(SqlException ex)
{
Response.Write(ex.Message);
Response.Write("Failed!!!
...");
Response.Write("<b>Something
really bad happened .. try again later</b>");
}
//send mail message
after user fills registration form
try
{
MailMessage msg = new
MailMessage();
msg.From = new
MailAddress("pankaj.ics@gmail.com");
msg.To.Add(TextBoxEA.Text);
msg.Subject = "Your
Registration is confirmed! ";
msg.Body = "Dear
" + TextBoxFN.Text + " Your
Registration to motion voter system has been confirmed. .. Kindly note down
your Voter's Identity Number(VIN) required for your login";
SmtpClient Sc = new
SmtpClient("smtp.gmail.com");
Sc.Port = 587;
Sc.Credentials = new
NetworkCredential("pankaj.ics@gmail.com","password");
Sc.EnableSsl = true;
Sc.Send(msg);
Response.Write("Sent!!!
... ");
Response.Redirect("Login.aspx");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
No comments:
Post a Comment