private void login_Click(object sender, EventArgs e) { string postData = "uid={0}&pwd={1}&yzm={2}&Submit2.x=18&Submit2.y=18&Submit2=%CC%E1%BD%BB"; postData = String.Format(postData, stuNum.Text.ToString(), pwd.Text.ToString(), code.Text.ToString()); string ret = web.postData(loginUrl, postData, Encoding.GetEncoding("GB2312"), refer, true); if (ret.Contains("验证码输入错误")) { MessageBox.Show("验证码错误"); codeImg.Image = web.getCodeImg(codeImgUrl, refer); } else if (ret.Contains("学号或密码错误")) { MessageBox.Show("学号或密码错误"); codeImg.Image = web.getCodeImg(codeImgUrl, refer); } else { if (remember.Checked) { INI.WriteIniData("user", "uid", stuNum.Text.ToString(), @".\helper.ini"); string password = pwd.Text.ToString(); password = Crypt.Encrypt(password); INI.WriteIniData("user", "pwd", password, @".\helper.ini"); } else { // 取消记忆 INI.WriteIniData("user", "uid", "", @".\helper.ini"); INI.WriteIniData("user", "pwd", "", @".\helper.ini"); } username = Regex.Match(ret, "<SPAN>欢迎您:([^<]+)", RegexOptions.Multiline | RegexOptions.IgnoreCase).Groups[1].ToString(); this.DialogResult = DialogResult.OK; } }
public LoginForm(ref Web web) { InitializeComponent(); this.web = web; web.getPage(refer,Encoding.GetEncoding("GB2312"),null,true); codeImg.Image = web.getCodeImg(codeImgUrl, refer); stuNum.Text = INI.ReadIniData("user", "uid", "", @".\helper.ini"); string password = INI.ReadIniData("user", "pwd", "", @".\helper.ini"); if (password != "") this.remember.Checked = true; if(password != "") pwd.Text = Crypt.Decrypt(password); this.AcceptButton = login; }
public LoginForm(ref Web web) { InitializeComponent(); this.web = web; web.getPage(refer, Encoding.GetEncoding("GB2312"), null, true); codeImg.Image = web.getCodeImg(codeImgUrl, refer); stuNum.Text = INI.ReadIniData("user", "uid", "", @".\helper.ini"); string password = INI.ReadIniData("user", "pwd", "", @".\helper.ini"); if (password != "") { this.remember.Checked = true; } if (password != "") { pwd.Text = Crypt.Decrypt(password); } this.AcceptButton = login; }