-
Notifications
You must be signed in to change notification settings - Fork 1
/
farmerregister.aspx.cs
43 lines (41 loc) · 1.69 KB
/
farmerregister.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class farmerregister : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "FARMER_0" + ID();
TextBox1.ReadOnly = true;
}
public int ID()
{
con.Open();
int ID = 0;
SqlCommand cmd = new SqlCommand("select count(*) from farmerreg", con);
ID = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
con.Close();
return ID;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox10.Text == TextBox11.Text)
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into farmerreg (farid,farname,dob,age,genderr,mailidd,mobno,aadharr,workexp,pass) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + DropDownList1.SelectedItem.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox10.Text + "')", con);
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(Page.GetType(), "Validation", "<script language='javascript'>alert('Registered Successfully..');window.location='Farmerlogin.aspx';</script>");
}
else
{
Response.Write("<script>alert('Password Mismatch')</script>");
}
}
}