Beispiel #1
0
        public bool SaveToFile(String path, bool encrypt = false, String pwd = null)
        {
            if (encrypt && pwd == null)
            {
                return(false);
            }

            string data = "";

            foreach (Score tmp in score)
            {
                data += tmp.cid + "#";
                data += tmp.name + "#";
                data += tmp.teacher + "#";
                data += tmp.term + "#";
                data += tmp.kind + "#";
                data += tmp.credit + "#";
                data += tmp.hours + "#";
                data += tmp.score + "#";
                data += tmp.other + "\n";
            }
            data += "--------\n";
            foreach (DictionaryEntry tmp in is_important)
            {
                data += tmp.Key + "\n";
            }
            if (encrypt)
            {
                data = Crypt.Encrypt(data, pwd);
                if (data == "")
                {
                    return(false);
                }
                data = "encrypted\n" + data;
            }
            File.WriteAllText(path, data);
            return(true);
        }
Beispiel #2
0
        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;
            }
        }