//用户验证码是否输入正确 private void Y_Load(object sender, EventArgs e) { code = YZM.CreateRandomCode(4); //一个图片信息 picY.BackgroundImage = YZM.CreateValidateGraphic(code); //输入验证码验证 }
public void inputY_TextChanged(object sender, EventArgs e) { if (inputY.Text.Trim().Length == 4) { if (inputY.Text.Trim() != code) { code = YZM.CreateRandomCode(4); //一个图片信息 picY.BackgroundImage = YZM.CreateValidateGraphic(code); //输入验证码验证 } else { Variable.fl = false; this.Visible = false; login.loginBut_Click(sender, e); #if false UserLogin userLogin = new UserLogin(); userLogin.Name = name; userLogin.Pwd = psw.Trim(); protocolqq.mode = 0; protocolqq.ope = 0; protocolqq.data = userLogin; //这个线程会睡1秒 Variable.client.SendMsg(protocolqq); //Thread.Sleep(1000); if (Variable.IsLogin) { Variable.fl = false; login.loginBut_Click(sender, e); //将该用户的用户名-密码-头像-勾选记住密码、自动登录记录到本地文件 #region 将这个类写入文件 l.I = userLogin.Name; l.H = Variable.user.HeadId; //用户勾选了记住密码才想文件中存入密码 if (userLogin.Remember == 1) { l.P = userLogin.Pwd; } else { l.P = ""; } l.R = userLogin.Remember; l.A = userLogin.AutoLogin; // FileStream fs = new FileStream("LocalMess.bin", FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); // 选在集合中是否存在用户名 if (ls.ContainsKey(l.I)) { ls.Remove(l.I); } ls.Add(l.I, l); //要先将l类先设为可以序列化(即在类的前面加[Serializable]) bf.Serialize(fs, ls); //user.Password = this.PassWord.Text; fs.Close(); #endregion //显示主窗口 Main form = new Main(); this.Visible = false; form.Show(); } else { errorPsw.Visible = true; } #endif } } }