📄 reg.aspx.cs
字号:
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;
public partial class reg : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void B1_Click(object sender, EventArgs e)
{
string nname = TextBox5.Text;
int ncount = 0;
for (int i = 0; i < nname.Length; i++)
{
if ((nname[i] > 64 && nname[i] < 91) || (nname[i] > 96 && nname[i] < 123) || (nname[i] == 32))
{
ncount = ncount;
}
else
{
ncount++;
}
}
if (ncount == 0)
{
Label2.Text = " ";
}
else
{
Label2.Text = "*Name should contain Alphabets only";
}
string lname = TextBox4.Text;
int lcount = 0;
for (int i = 0; i < lname.Length; i++)
{
if ((lname[i] > 64 && lname[i] < 91) || (lname[i] > 96 && lname[i] < 123) || (lname[i] == 32))
{
lcount = lcount;
}
else
{
lcount++;
}
}
if (lcount == 0)
{
Label25.Text = " ";
}
else
{
Label25.Text = "* last Name should contain Alphabets only";
}
//code for pin_code
string pno = TextBox7.Text;
int pc = 0;
if (pno.Length == 6)
{
for (int i = 0; i < pno.Length; i++)
{
if (pno[i] > 47 && pno[i] < 58)
{
pc = pc;
}
else
{
pc++;
}
}
if (pc == 0)
{
Label10.Text = " ";
}
else
{
Label10.Text = "* pin code should contain numeric digits only";
}
}
else
{
Label10.Text = "enter valid pin code";
}
//city
string cname = TextBox8.Text;
int ccount = 0;
for (int i = 0; i < cname.Length; i++)
{
if ((cname[i] > 64 && cname[i] < 91) || (cname[i] > 96 && cname[i] < 123) || (cname[i] == 32))
{
ccount = ccount;
}
else
{
ccount++;
}
}
if (ccount == 0)
{
Label11.Text = " ";
}
else
{
Label11.Text = "*city should contain Alphabets only";
}
//state
string sname = TextBox9.Text;
int scount = 0;
for (int i = 0; i < sname.Length; i++)
{
if ((sname[i] > 64 && sname[i] < 91) || (sname[i] > 96 && sname[i] < 123) || (sname[i] == 32))
{
scount = scount;
}
else
{
scount++;
}
}
if (scount == 0)
{
Label12.Text = " ";
}
else
{
Label12.Text = "*state Name should contain Alphabets only";
}
//code for telephone no
string tno = TextBox11.Text;
int tc = 0;
if (tno.Length == 10||tno.Length==11)
{
for (int i = 0; i < tno.Length; i++)
{
if (tno[i] > 47 && tno[i] < 58)
{
tc = tc;
}
else
{
tc++;
}
}
if (tc == 0)
{
Label13.Text = " ";
}
else
{
Label13.Text = "* telephone no should contain numeric digits only";
}
}
else
{
Label13.Text = "enter valid telephone no";
}
//code for mobile no
string mno = TextBox13.Text;
int mc = 0;
if (mno.Length == 10 || mno.Length == 11)
{
for (int i = 0; i < mno.Length; i++)
{
if (mno[i] > 47 && mno[i] < 58)
{
mc = mc;
}
else
{
mc++;
}
}
if (mc == 0)
{
Label14.Text = " ";
}
else
{
Label14.Text = "* mobile no should contain numeric digits only";
}
}
else
{
Label14.Text = "enter valid mobile no";
}
//code for fax no
string fno = TextBox14.Text;
int fc = 0;
if (fno.Length == 10 || fno.Length == 11)
{
for (int i = 0; i < fno.Length; i++)
{
if (fno[i] > 47 && fno[i] < 58)
{
fc = fc;
}
else
{
fc++;
}
}
if (fc == 0)
{
Label16.Text = " ";
}
else
{
Label16.Text = "* fax no should contain numeric digits only";
}
}
else
{
Label16.Text = "enter valid fax no";
}
//password length
string len;
len=TextBox3.Text;
if(len.Length<6)
{
Label23.Text="password length should not be less then six";
}
else
{
Label23.Text=" ";
}
if( ncount==0 && lcount==0 && pc==0 && ccount==0 && scount==0 && tc==0 && mc==0 && fc==0&&len.Length>5)
{
int i=0;
SqlConnection con=new SqlConnection("Data Source=.;Initial Catalog=epropertydb;Integrated Security=True");
con.Open();
SqlCommand cmd=new SqlCommand();
cmd.Connection=con;
cmd.CommandText="select *from userdetails";
SqlDataReader dr;
dr=cmd.ExecuteReader();
while(dr.Read()==true)
{
if(TextBox2.Text==dr[0].ToString())
{
i++;
}
}
con.Close();
if(i==0)
{
SqlConnection conn=new SqlConnection("Data Source=.;Initial Catalog=epropertydb;Integrated Security=True");
conn.Open();
SqlCommand cmdd=new SqlCommand();
cmdd.Connection=conn;
cmdd.CommandText="insert into userdetails values ('"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox5.Text+"','"+TextBox4.Text+"','"+TextBox6.Text+"','"+TextBox7.Text+"','"+TextBox8.Text+"','"+TextBox9.Text+"','" + TextBox11.Text + "','"+TextBox13.Text+"','"+TextBox4.Text+"','"+TextBox12.Text+"')";
cmdd.ExecuteNonQuery();
conn.Close();
Session["uid"] = TextBox2.Text;
Response.Redirect("home.aspx");
}
else
{
Label24.Text="enter another id";
}
}
}
/* SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=epropertydb;Integrated Security=True");
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("insert into userdetails values ('"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox5.Text+"','"+TextBox4.Text+"','"+TextBox6.Text+"','"+TextBox7.Text+"','"+TextBox8.Text+"','"+TextBox9.Text+"','" + TextBox11.Text + "','"+TextBox13.Text+"','"+TextBox4.Text+"','"+TextBox12.Text+"')",conn);
DataSet ds = new DataSet();
da.Fill(ds);
conn.Close();
Response.Redirect("home.aspx");*/
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox3_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox5_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox6_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox7_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox8_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox9_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox10_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox11_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox12_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox13_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox14_TextChanged(object sender, EventArgs e)
{
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
protected void TextBox3_TextChanged1(object sender, EventArgs e)
{
}
protected void TextBox4_TextChanged1(object sender, EventArgs e)
{
}
protected void TextBox6_TextChanged1(object sender, EventArgs e)
{
}
protected void TextBox2_TextChanged1(object sender, EventArgs e)
{
}
protected void TextBox5_TextChanged1(object sender, EventArgs e)
{
}
protected void TextBox9_TextChanged1(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -