protected void saveBtn_Click(object sender, EventArgs e)
 {
     if (!Session["check"].ToString().Trim().Equals("1")) {
         Session["check"] = "0";
         Panel1.Visible = true;
         Panel2.Visible = false;
         return;
     }
     string passwordStr1 = Tools.safeUserInput(passWordTB1.Text.ToString().Trim());
     string passwordStr2 = Tools.safeUserInput(passWordTB2.Text.ToString().Trim());
     if (passwordStr1.Equals(passwordStr2))
     {
         studentBLL StudentBLL = new studentBLL();
         student Student = StudentBLL.GetModel(ViewState["stuId"].ToString());
         Student.passWord = Tools.encrypt(passwordStr1);
         try
         {
             StudentBLL.Update(Student);
         }
         catch
         {
             MessageBox.Show(this, "密码修改失败!");
             return;
         }
         MessageBox.ShowAndRedirect(this, "密码修改成功!", "Default.aspx");
     }
     else {
         MessageBox.Show(this, "密码不一致!");
         return;
     }
 }
 protected void changeBtn_Click(object sender, EventArgs e)
 {
     string passWordStr1 = Tools.safeUserInput(passWordTB1.Text.ToString().Trim());
     string passWordStr2 = Tools.safeUserInput(passWordTB2.Text.ToString().Trim());
     if (passWordStr1.Length > 0 && passWordStr2.Length > 0 && passWordStr1.Equals(passWordStr2))
     {
         studentBLL StudentBLL = new studentBLL();
         student Student = StudentBLL.GetModel(Session["UserId"].ToString().Trim());
         Student.passWord = Tools.encrypt(passWordStr1);
         try
         {
             if (StudentBLL.Update(Student))
             {
                 MessageBox.Show(this, "修改成功!");
                 initial(Session["UserId"].ToString().Trim());
             }
             else MessageBox.Show(this, "修改失败!");
         }
         catch
         {
             MessageBox.Show(this, "修改失败!");
         }
     }
     else {
         MessageBox.Show(this, "密码为空或者密码不同!");
     }
 }
 protected void saveBtn_Click(object sender, EventArgs e)
 {
     string emailStr = Tools.safeUserInput(emailTB.Text.ToString().Trim());
     string cellPhoneStr = Tools.safeUserInput(cellPhoneTB.Text.ToString().Trim());
     studentBLL StudentBLL = new studentBLL();
     student Student = StudentBLL.GetModel(Session["UserId"].ToString().Trim());
     Student.phone = cellPhoneStr;
     Student.email = emailStr;
     try
     {
         if (StudentBLL.Update(Student))
         {
             MessageBox.Show(this, "修改成功!");
             initial(Session["UserId"].ToString().Trim());
         }
         else MessageBox.Show(this, "修改失败!");
     }
     catch
     {
         MessageBox.Show(this, "修改失败!");
     }
 }
    protected void updateStudentBtn_Click(object sender, EventArgs e)
    {
        student Student = new student();
        if (isTextBoxEmpty(stuIdTB, "学生学号")) Student.stuId = getText(stuIdTB);
        else return;
        if (isTextBoxEmpty(nameTB, "学生姓名")) Student.name = getText(nameTB);
        else return;
        Student.sex = sexDDL.SelectedItem.Value;
        if (isTextBoxEmpty(nationTB, "民族")) Student.nation = getText(nationTB);
        else return;
        if (isTextBoxEmpty(birthdayTB, "出生日期"))
        {
            string birthday = getText(birthdayTB);
            if (birthday.Length != 8)
            {
                MessageBox.Show(this, "出生日期格式不正确!");
                return;
            }
            Student.birthday = birthday;
        }
        else return;
        if (isTextBoxEmpty(certificateTypeTB, "证件类型")) Student.certificateType = getText(certificateTypeTB);
        else return;
        if (isTextBoxEmpty(certificateIdTB, "证件号码")) Student.certificateId = getText(certificateIdTB);
        else return;
        if (isTextBoxEmpty(schoolYearTB, "入学时间")) Student.admissionDate = getText(schoolYearTB);
        else return;
        if (isTextBoxEmpty(majorIdTB, "专业代码")) Student.majorId = getText(majorIdTB);
        else return;
        if (isTextBoxEmpty(majorNameTB, "专业名称")) Student.majorName = getText(majorNameTB);
        else return;
        if (isTextBoxEmpty(colleageTB, "所在学院")) Student.colleage = getText(colleageTB);
        else return;
        Student.classType = getText(classTypeTB);
        Student.degree = getText(degreeTB);
        Student.type = getText(typeTB);
        Student.placeOfWork = getText(placeOfWorkTB);
        Student.workPhone = getText(workPhoneTB);
        if (isTextBoxEmpty(phoneTB, "移动电话")) Student.phone = getText(phoneTB);
        else return;
        Student.email = getText(emailTB);
        Student.address = getText(addressTB);
        Student.zipCode = getText(zipCodeTB);
        string passWord = Tools.safeUserInput(passWordTB.Text.Trim().ToString());
        studentBLL StudentBLL = new studentBLL();
        if (passWord.Length < 1) Student.passWord = StudentBLL.GetModel(id).passWord;
        else Student.passWord = Tools.encrypt(passWord);

        if (StudentBLL.GetModel(id).stuId != Student.stuId)
        {
            examrecordBLL ExamRecordBLL = new examrecordBLL();
            studentloginlogBLL StudentLoginLogBLL = new studentloginlogBLL();
            try
            {
                StudentBLL.Add(Student);
                ExamRecordBLL.repalaceStuId(StudentBLL.GetModel(id).stuId, Student.stuId);
                StudentLoginLogBLL.repalaceStuId(StudentBLL.GetModel(id).stuId, Student.stuId);
                StudentBLL.Delete(id);

            }
            catch
            {
                MessageBox.Show(this, "更新失败!");
            }
        }
        if (Session["StuId"].ToString().Trim().Equals(getText(stuIdTB)))
        {
            Student.id = id;
            try
            {
                StudentBLL.Update(Student);
            }
            catch
            {
                MessageBox.Show(this, "更新失败!");
            }
        }
        MessageBox.ShowAndRedirect(this, "更新成功!", "student.aspx");
    }