private void LoginCode() { string Snum = TextBoxuser.Text.Trim(); string Spwd = TextBoxpwd.Text.Trim(); string lbip = Labelip.Text; string msg = ""; if (Snum != "" && Spwd != "") { if (LearnSite.Common.WordProcess.IsNum(Snum) && LearnSite.Common.WordProcess.IsEnNum(Spwd)) { LearnSite.Model.Students model = new LearnSite.Model.Students(); LearnSite.BLL.Students bll = new LearnSite.BLL.Students(); int loginm = LearnSite.Common.XmlHelp.LoginMode();//获取登录方式 0表示个人密码方式登录 1表示班级密码方式登录 if (loginm == 1) { if (bll.ExistsLogin(Snum, Spwd)) { model = bll.SnumGetModel(Snum);//查询该学号和班级密码的学生是否存在,存在返回实体,不存在返回null } else { model = null; } } else { if (bll.ExistsLoginSelf(Snum, Spwd)) { model = bll.GetStudentModel(Snum, Spwd);//查询该学号密码学生是否存在,存在返回实体,不存在返回null } else { model = null; } } if (model != null) { int Qgrade = model.Sgrade.Value; int Qclass = model.Sclass.Value; int Qsid = model.Sid; string Qname = model.Sname; int Qsyear = model.Syear.Value; int Qterm = Int32.Parse(LearnSite.Common.XmlHelp.GetTerm()); if (LearnSite.Common.XmlHelp.GetSingleLogin()) //如果是单点登录 { if (!LearnSite.Common.App.IsLogin(Snum)) //如果不在线 { if (LearnSite.Common.CookieHelp.SetStudentCookies(model, Labelip.Text)) //写cookies { DateTime LoginTime = DateTime.Now; LearnSite.BLL.Signin gbll = new LearnSite.BLL.Signin(); gbll.SigninToday(Snum, LoginTime, lbip, Qgrade, Qterm, Qsid, Qname, Qclass, Qsyear); //签到 Btnlogin.Enabled = false; LearnSite.Common.App.AppKickUserRemove(Snum); //将踢除列表中的学号去掉(2011-9-20修) LearnSite.Common.App.AppUserAdd(Snum); //给网站全局变量列表中增加该用户 System.Threading.Thread.Sleep(200); OpenJump(Qgrade, Qclass); //跳转选择 } else { msg = "请不要换机,否则无法登录!"; } } else { msg = "该用户已经在其他电脑登录!<br/>请询问老师或查看当前是否是你自己的学号!"; } } else { if (LearnSite.Common.CookieHelp.SetStudentCookies(model, lbip))//写cookies { DateTime LoginTime = DateTime.Now; LearnSite.BLL.Signin gbll = new LearnSite.BLL.Signin(); gbll.SigninToday(Snum, LoginTime, lbip, Qgrade, Qterm, Qsid, Qname, Qclass, Qsyear);//签到 Btnlogin.Enabled = false; System.Threading.Thread.Sleep(200); OpenJump(Qgrade, Qclass);//跳转选择 } else { msg = "请不要换机,否则无法登录!"; } } } else { string msgstr = "『当前为班级密码模式』"; if (loginm == 0) { msgstr = "『当前为个人密码模式』"; } msg = "用户名或密码错误!" + msgstr; TextBoxuser.Text = ""; TextBoxpwd.Text = ""; } } else { msg = "用户名或密码含有非法字符,学号必须为数字"; } } Labelmsg.Text = msg; }