private void mobjButtonLogon_Click(object sender, EventArgs e) { /* MD5 md5 = MD5.Create(); * byte[] bytePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(this.mobjTextPassword.Text.Trim())); * string resultPwd = System.Text.UTF8Encoding.Unicode.GetString(bytePwd); */ string resultPwd = CHelperClass.UserMd5(this.mobjTextPassword.Text.Trim()); if (mobjCheckSavePassword.Checked) { Context.Cookies["Username"] = this.mobjTextUsername.Text; Context.Cookies["Password"] = this.mobjTextPassword.Text; //Context.Cookies["Password"] = this.mobjTextPassword.Text; //Context.Cookies["Lang"] = this.mobjComboLanguage.SelectedIndex.ToString(); } else { Context.Cookies["Username"] = ""; Context.Cookies["Password"] = ""; //Context.Cookies["Lang"] = "0"; } try { CUserEntity user = new CUserEntity(MidLayerSettings.ConnectionString); user = user.Login(mobjTextUsername.Text, resultPwd); Context.Session["CurrentUser"] = user; // Context.CurrentUICulture = ((LanguageOption)mobjComboLanguage.SelectedItem).Culture; mobjLabelMessage.Text = ""; Context.Session.IsLoggedOn = true; } catch (Exception ex) { mobjLabelMessage.Text = "Invalid username or password."; MessageBox.Show("µÇ¼ʧ°Ü£º" + ex.ToString(), "Îĵµ¹ÜÀíϵͳ", MessageBoxButtons.OK, MessageBoxIcon.Error); Context.Session.IsLoggedOn = false; } /* * if(this.mobjTextUsername.Text=="webgui" && this.mobjTextPassword.Text=="webgui") * { * Context.Session.IsLoggedOn = true; * Context.CurrentUICulture = ((LanguageOption)mobjComboLanguage.SelectedItem).Culture; * mobjLabelMessage.Text=""; * } * else * { * mobjLabelMessage.Text = "Invalid username or password."; * Context.Session.IsLoggedOn = false; * } */ }
private void loginBtn_Click(object sender, EventArgs e) { if (memberBox.Text == "" || passwordBox.Text == "") { return; } try { _user = new CUserEntity(MidLayerSettings.ConnectionString); _user = _user.Login(memberBox.Text, passwordBox.Text); Context.Session["CurrentUser"] = _user; Context.Session.IsLoggedOn = true; this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show("登录失败:", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); Context.Session.IsLoggedOn = false; } }