protected void btnLogin_Click(object sender, EventArgs e) { try { if (Page.IsValid) { //验证验证码。 if (tbValidCode.Text != StringSecurity.DESDecrypt(Request.Cookies["AreYouHuman"].Value)) { panelErrorValidCode.Visible = true; tbPassword.Focus(); return; } //验证登录ID和密码。 Staff s = StaffSrv.GetStaffByLoginIdAndPassword(tbLoginId.Text.Trim(), tbPassword.Text.Trim()); if (s == null) { panelErrorPassword.Visible = true; tbPassword.Focus(); return; } else { if (s.Disabled == 1)//被禁用。 { panelStaffDisabled.Visible = true; tbLoginId.Focus(); return; } } //在Cookie中保存登录ID。 HttpCookie hcLoginId = new HttpCookie("LoginId", s.LoginId); hcLoginId.Expires = DateTime.Now.AddMonths(1); Response.Cookies.Add(hcLoginId); //在Cookie中保存界面样式选择。 HttpCookie hcInterfaceStyle = new HttpCookie("InterfaceStyle", ddlInterfaceStyle.SelectedValue); hcInterfaceStyle.Expires = DateTime.Now.AddMonths(1); Response.Cookies.Add(hcInterfaceStyle); //保存登录信息。 SessionUtil.SavaStaffSession(new StaffSession(s.LoginId, s.IsInnerUser)); FormsAuthentication.RedirectFromLoginPage(s.LoginId, false); //登陆成功。 loginSuccessfully = true; } } catch (Exception ex) { log.Error(null, ex); throw; } }
private void button3_Click(object sender, EventArgs e) { textBox6.Text = StringSecurity.DESDecrypt(textBox5.Text); }