Login.aspx.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using LYFZ.Command;
  8. namespace LYFZ.WeixinServers.WeiXinAPP
  9. {
  10. public partial class Login : System.Web.UI.Page
  11. {
  12. public string CookieSavePassword = "";
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. if (!IsPostBack)
  16. {
  17. /* #if DEBUG
  18. Response.Redirect("index.aspx");
  19. #endif*/
  20. if (CommonHandler.CheckLogin(this))
  21. {
  22. this.Response.Redirect("index.aspx");
  23. }
  24. else if (LYFZ.Command.Command_Cookie.GetCookie(SaveAccount)!=null)
  25. {
  26. this.txtuser.Value = LYFZ.Command.Command_Cookie.GetCookie(SaveAccount);
  27. CookieSavePassword = LYFZ.Command.Command_Cookie.GetCookie(SavePassword);
  28. this.txtpwd.Value = CookieSavePassword;
  29. this.cbxJiZhumima.Checked = true;
  30. }
  31. }
  32. }
  33. string SaveAccount = "SaveAccount";
  34. string SavePassword = "SavePassword";
  35. protected void lbtnLogin_Click(object sender, EventArgs e)
  36. {
  37. // LYFZ.Command.Command_Cookie.SaveCookie("","",0);
  38. // Response.Redirect("index.aspx");
  39. string userName=this.txtuser.Value.Trim();
  40. string password = this.txtpwd.Value.Trim();
  41. if (userName.Length <= 0 || password.Length <= 0)
  42. {
  43. MessageBox.Show(this, "请输入正确的帐号和登录密码!");
  44. }
  45. else {
  46. LYFZ.WeixinServiceDate.DAL.DAL_AdminUser userDal = new WeixinServiceDate.DAL.DAL_AdminUser();
  47. LYFZ.WeixinServiceDate.Model.Model_AdminUser userModel = (LYFZ.WeixinServiceDate.Model.Model_AdminUser)userDal.GetModelObject("Account", userName);
  48. if (userModel.ID > 0)
  49. {
  50. if (userModel.Account == userName && userModel.Password == password)
  51. {
  52. if (this.cbxJiZhumima.Checked)
  53. {
  54. LYFZ.Command.Command_Cookie.SaveCookie(SaveAccount, userModel.Account, 259200);
  55. LYFZ.Command.Command_Cookie.SaveCookie(SavePassword, userModel.Password, 259200);
  56. }
  57. else {
  58. LYFZ.Command.Command_Cookie.ClearCookie(SaveAccount);
  59. LYFZ.Command.Command_Cookie.ClearCookie(SavePassword);
  60. }
  61. LYFZ.Command.Command_Session.AddObject("Login", userModel,300);
  62. this.Response.Redirect("index.aspx");
  63. }
  64. else
  65. {
  66. MessageBox.Show(this, "输入帐号和登录密码不正确!");
  67. }
  68. }
  69. else {
  70. MessageBox.Show(this, "输入的登录帐号不存在!");
  71. }
  72. }
  73. }
  74. }
  75. }