protected void submit_Click(object sender, EventArgs e)
 {
     string userName = Tools.safeUserInput(username.Text.Trim());
     string passWord = Tools.safeUserInput(password.Text.Trim());
     if (userName.Length < 1) { MessageBox.Show(this, "用户名不能为空"); return; }
     if (passWord.Length < 1) { MessageBox.Show(this, "密码不能为空"); return; }
     administratorBLL adminbll = new administratorBLL();
     string loginMessage = adminbll.Login(userName, passWord);
     if (loginMessage.Equals("1"))
     {
         string stuIdStr = adminbll.GetModel(userName).id.ToString();
         Session["status"] = "true";
         Session["UserId"] = stuIdStr;
         Session["type"] = "1";
         MessageBox.ShowAndRedirect(this, "登录成功!", "student.aspx");
     }
     else
     {
         if (loginMessage.Equals("2"))
         {
             string stuIdStr = adminbll.GetModel(userName).id.ToString();
             Session["status"] = "true";
             Session["UserId"] = stuIdStr;
             Session["type"] = "2";
             MessageBox.ShowAndRedirect(this, "登录成功!", "student.aspx");
         }
         else
         {
             Session["status"] = "false";
             Session["UserId"] = "0";
             Session["type"] = "0";
             MessageBox.ShowAndRedirect(this, loginMessage, "logout.aspx");
         }
     }
 }
 private void initial()
 {
     int userId = Convert.ToInt32(Session["UserId"]);
     administratorBLL adminbll = new administratorBLL();
     string username = adminbll.GetModel(userId).userName;
     if (username != null) userName = username;
     if (Session["type"].ToString().Equals("1")) {
         Panel1.Visible = true;
         Panel2.Visible = false;
     }
     if (Session["type"].ToString().Equals("2"))
     {
         Panel2.Visible = true;
         Panel1.Visible = false;
     }
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     administratorBLL AdminBLL=new administratorBLL();
     administrator Admin = AdminBLL.GetModel(Convert.ToInt32(Session["UserId"]));
     string passwordStr1 = Tools.safeUserInput(passWordTB1.Text.Trim());
     string passwordStr2 = Tools.safeUserInput(passWordTB2.Text.Trim());
     if (passwordStr1.Length < 1 || passwordStr2.Length < 1)
     {
         MessageBox.Show(this, "密码不能为空!");
         return;
     }
     else {
         if (passwordStr1.Equals(passwordStr2))
         {
             Admin.passWord = Tools.encrypt(passwordStr1);
             AdminBLL.Update(Admin);
             MessageBox.Show(this, "修改成功!");
         }
         else {
             MessageBox.Show(this, "两次密码不同!");
             return;
         }
     }
 }