Exemplo n.º 1
0
        public (RememberType, string) EditRememberType(RememberType baseType)
        {
            ResetAcc();

            this._label1.Text   = Resources.Editor_CreateNewRememberType_DialogResult_;
            this._textBox1.Text = baseType.IsOkOrYes() ? Resources.Editor_CreateNewTypeHolder__True : "0";
            this._label2.Text   = Resources.Editor_CreateNewTypeHolder_Description_;
            this._textBox2.Text = baseType.Description;
            this._label3.Text   = Resources.Editor_CreateNewRememberType_Extension_;
            this._textBox3.Text = baseType.Type;

            var ret = ShowDialog();

            this.DialogResult = DialogResult.Retry;

            if (ret == DialogResult.Yes)
            {
                return(new RememberType(this._textBox2.Text, this._textBox1.Text == Resources.Editor_CreateNewTypeHolder__True ? DialogResult.Yes : DialogResult.No, this._textBox3.Text), this._textBox3.Text);
            }
            return(baseType, baseType.Type);

            throw new NotSupportedException();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 记住用户信息
        /// </summary>
        /// <param name="Type">记住用户信息类别</param>
        /// <returns></returns>
        public bool RememberUserInfo(Master info, RememberType type)
        {
            if (type == RememberType.RememberName)
            {
                //记住帐号7天
                CookieHelper.SetCookie("MasterName", info.Username, DateTime.Now.AddDays(7));
            }
            else if (type == RememberType.RememberNameAndPwd)
            {

                //md5哈希加密
                string sercret = Tools.GetMD5(info.Password);
                //同时记住帐号和密码7天
                CookieHelper.SetCookie("MasterName", info.Username, DateTime.Now.AddDays(7));
                CookieHelper.SetCookie("MasterPwd", sercret, DateTime.Now.AddDays(7));
            }
            else
            {
                return false;
            }
            return true;
        }