¶àýÌå±ÏÒµ¼ÍÄî²á±¨¸æ ÏÂÔر¾ÎÄ

¼þÖÐʵÏÖ¡£ÆäÖ÷Òª´úÂëÈçÏ£º

void Application_Start(object sender, EventArgs e) {// ÔÚÓ¦ÓóÌÐòÆô¶¯Ê±ÔËÐеĴúÂë Application[\] = 0; }

void Session_Start(object sender, EventArgs e) {// ÔÚлỰÆô¶¯Ê±ÔËÐеĴúÂë Application.Lock();

Application[\] = (int)Application[\] + 1; Application.UnLock(); }

void Session_End(object sender, EventArgs e) {// ÔڻỰ½áÊøʱÔËÐеĴúÂë¡£ Application.Lock();

Application[\] = (int)Application[\] - 1; Application.UnLock();

}

4.2 µÇ¼ҳÃ棨login.aspx£©

4.2.1¹¦Äܼò½é

ÿ¸öÓû§Òª½øÈëϵͳǰ¶¼±ØÐëÏȵǼ£¬Èç¹ûÓû§ÊÇÀÏÓû§Ö»ÐèÊäÈëÕýÈ·Óû§ÃûºÍÃÜÂëºóµã»÷µÇ¼°´Å¥ºó¼´¿ÉµÇ¼£¬Èç¹ûÓû§ÊÇÐÂÓû§¿ÉÒÔµã»÷´øÁ¬½ÓµÄ°´Å¥×¢²áÓû§£¬×¢²áÍêºó¼´¿ÉÊäÈëÓû§ÃûºÍÃÜÂëºóµÇ½½øϵͳ¡£µÇ¼ҳÃæÈçͼ4.2.1Ëùʾ

ͼ4.2.1 µÇ¼ҳÃæͼ

4.2.2 ǰ̨Ö÷Òª´úÂë

- 11 -

Width=\×¢²áÓû§>>

4.2.3 ºǫ́Ö÷Òª´úÂë

µ±Óû§ÔÚÎı¾¿òtextuserºÍtextpwdÖÐÊäÈëÓû§ÃûºÍÃÜÂëʱ²éѯÊý¾Ý¿âÖÐusertableÕâÕűíÖеÄloginºÍpasswordÁУ¬µ±Îı¾¿òÖÐÊäÈëµÄֵͬʱÄܺÍÊý¾Ý¿âÖÐloginºÍ passwordÁÐÆ¥ÅäµÄֵʱµÇ¼³É¹¦£¬·ñÔòµÇ¼ʧ°Ü¡£

string userName = textuser.Text;

string userPwd = textpwd.Text;

SqlConnection con = conn.createconnection(); con.Open();

SqlCommand cmd = new SqlCommand(\ + userName + \ + userPwd + \, con);

SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; DataSet dataset = new DataSet(); adapter.Fill(dataset);

if (dataset.Tables[0].Rows.Count > 0) {

Response.Redirect(\); } else {

Response.Write(\Óû§»òÃÜÂë²»ÕýÈ·\\\); }

con.Close();

4.3 ×¢²áÒ³Ã棨register.aspx£©

4.3.1¹¦Äܼò½é

µ±ÓÐÐÂÓû§ÐèÒª½øÈëϵͳʱ£¬±ØÐëÏÈÌøתµ½´ËÒ³ÃæÀ´½øÐÐÐÂÓû§µÄ×¢²á£¬ÔÚ×¢²áÖÐÕæ

- 12 -

ʵÐÕÃû£¬µÇ½ÃûºÍÃÜÂëÈýÏî²»ÄÜΪ¿Õ£¬µ±Óû§Ñ¡ÔñÁËij¸öϵʱ£¬°à¼¶Ïî»á×Ô¶¯Óëϵ¶ÔÓ¦ÏÔʾ³öÀ´¡£µÇ¼Ãû²»ÄÜÖظ´£¬µ±Óû§ÊäÈëÒ»¸öµÇ¼ÃûʱҳÃæ»á×Ô¶¯Ìá½»µ½·þÎñÆ÷È¥ÑéÖ¤µÇ½ÃûÊÇ·ñÒÑ´æÔÚʹÓÃÁË¡°TextChanged¡±Ê¼þ¡£×¢²áÒ³ÃæÈçͼ4.3.1Ëùʾ

ͼ4.3.1×¢²áÒ³Ãæ 4.3.2 ºǫ́Ö÷Òª´úÂë

Page_Load()ºÍddlxb_SelectedIndexChanged()ʼþÖ÷ҪʵÏÖϵ±ðÓë°à¼¶µÄÁª¶¯¼ÈÑ¡ÔñÁËij¸öϵÔò½«¸ÃϵËùÓеİ༶ÏÔʾ³öÀ´¡££¨ÆäËüϵµÄ°à¼¶²»»áÏÔʾ³öÀ´£©

protected void Page_Load(object sender, EventArgs e) {

if (!this.IsPostBack) {

SqlConnection con = conn.createconnection(); con.Open();

SqlCommand cmd = new SqlCommand(\, con); SqlDataReader sdr = cmd.ExecuteReader(); ddlxb.DataSource = sdr; ddlxb.DataTextField = \; ddlxb.DataValueField = \; ddlxb.DataBind(); sdr.Close();

SqlCommand cmdbj = new SqlCommand(\ + ddlxb.SelectedValue, con);

sdr = cmdbj.ExecuteReader(); ddlbj.DataSource = sdr; ddlbj.DataTextField = \;

ddlbj.DataValueField = \; ddlbj.DataBind(); sdr.Close(); con.Close(); } }

- 13 -

protected void ddlxb_SelectedIndexChanged(object sender, EventArgs e) {

string proid = ddlxb.SelectedValue;

SqlConnection con = conn.createconnection(); con.Open();

SqlCommand cmd = new SqlCommand(\ + proid, con); SqlDataReader sdr = cmd.ExecuteReader(); ddlbj.DataSource = sdr; ddlbj.DataTextField = \;

ddlbj.DataValueField = \; ddlbj.DataBind(); sdr.Close(); con.Close();

}

ÏÂÃæ´úÂëÖ÷ҪʵÏÖµ±Óû§µã»÷Ò³ÃæµÄ×¢²á°´Å¥Ê±½«Óû§ÌîдµÄ×ÊÁÏдÈëÊý¾Ý¿âÖС£

protected void Butzc_Click(object sender, EventArgs e)

{ string dd = (ddlxb.SelectedItem).ToString();//»ñÈ¡ddlxbÏÂÀ­ÁбíÖеÄÖµ string cc = (ddlbj.SelectedItem).ToString(); SqlConnection con = conn.createconnection(); con.Open();

SqlCommand comd = new SqlCommand(\, con); comd.ExecuteNonQuery();

if (textpwd1.Text == \ && textpwd2.Text == \) {

Labpd.Text = \ÃÜÂë²»ÄÜΪ¿Õ...\; textpwd1.Focus(); }

else if (textpwd1.Text == textpwd2.Text && textpwd1.Text != \ && textpwd2.Text != \) {

SqlCommand cm = new SqlCommand(\

usertable(login,password,name,sex,rxtime,xb,bj,sj,qq,email,gzdw) values('\ +

textuser1.Text + \ + textpwd1.Text + \ + textname.Text + \ + ddlsex.Text + \ + ddltime.Text + \ + dd + \ + cc + \ + textsj.Text + \ + textqq.Text + \ + textemail.Text + \ + textgzdw.Text + \, con); cm.ExecuteNonQuery(); con.Close();

Response.Write(\×¢²á³É¹¦~£¡

');window.location.href='login.aspx'\); }else

{ Labpd.Text = \ÃÜÂë²»Ò»ÖÂ...\; textpwd1.Focus(); }}

ÏÂÃæ´úÂëÖ÷ҪʵÏÖ×Ô¶¯²éѯÊý¾Ý¿âÅжÏÓû§ÊÇ·ñÒÑ´æÔÚ£¬ÕâÀïÊ×ÏÈÒª½«Îı¾¿òµÄoutopostbackÊôÐÔÉèÖÃΪtrue¡£

- 14 -