Fill the information and click on 'Generate Id' ..The otp will get sent to you in your mail.
Generate_id Link button code-
protected void LinkButton1_Click(object sender, EventArgs e)
{
string s = ConfigurationManager.AppSettings["db"];
cn = new SqlConnection(s);
cn.Open();
string q = "select max(roll)+1 from gen_id ";
cm = new SqlCommand(q, cn);
SmtpClient sm = new SmtpClient("student-cell.com", 25);
sm.Credentials = new System.Net.NetworkCredential("contact@student-cell.com", "Fg8@or61");
sm.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mm = new MailMessage("contact@student-cell.com", TextBox3.Text);
if(TextBox3.Text == "" )
{
Response.Write("Please enter the email id");
}
else
{
mm.Subject = "ID GENERATED!!!";
Random rm = new Random();
int k = (int)(rm.NextDouble() * 999);
mm.Body = "Dear Employee, your id is" + "EMP" + "-" + DateTime.Now.ToString("yyy") + "-" + cm.ExecuteScalar().ToString()+ "-" + k;
mm.IsBodyHtml = true;
sm.Send(mm);
string qu = "insert into gen_id values('" + TextBox1.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox2.Text + "','" + "EMP" + "-" + DateTime.Now.ToString("yyy") + "-" + cm.ExecuteScalar().ToString() + "-" + k + "','" + TextBox6.Text + "')";
cm = new SqlCommand(qu, cn);
cm.ExecuteNonQuery();
}
}
Click on Login Button.
protected void Button2_Click(object sender, EventArgs e)
{
string s = ConfigurationManager.AppSettings["db"];
cn = new SqlConnection(s);
cn.Open();
string q = "select * from gen_id where roll='" + TextBox6.Text + "'";
cm = new SqlCommand(q, cn);
dr = cm.ExecuteReader();
if (dr.Read())
{
TextBox1.Text = dr["name"].ToString();
TextBox3.Text = dr["email"].ToString();
TextBox4.Text = dr["mobile"].ToString();
TextBox2.Text = dr["age"].ToString();
}
else
{
dr.Close();
Response.Write("no records found");
}
}
Comments
Post a Comment