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;public partial class Login : System.Web.UI.Page{ protected void btnLogin_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(3000);//停留3秒 string userName = this.txtUserName.Text.Trim();//账号 string password = this.txtPassword.Text.Trim();//密码 string retypePwd = this.txtRetypePwd.Text.Trim();//重新输入的密码 //用户在聊天室中,但此次输入的密码不正确,提示 if (Room.Instance.UserIsChatting(userName)&&Room.Instance.GetUser(userName).Password != password) { this.lblMessage.Text = "请输入正确密码"; } else//成功登录 { if (!Room.Instance.UserIsChatting(userName))//输入的账号没有正在聊天 { Room.Instance.AddUser(userName, password);//添加用户 //发送一条系统消息 Room.Instance.SendMessage(String.Format("{0} 进入了聊天室", userName)); } Room.Instance.GetUser(userName).Update(); FormsAuthentication.RedirectFromLoginPage(userName, false); } }}

评论