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 checkBtn_Click(object sender, EventArgs e)
    {
        string stuIdStr = Tools.safeUserInput(stuIdTB.Text.ToString().Trim());
        string idStr = Tools.safeUserInput(idTB.Text.ToString().Trim());
        if (stuIdStr.Length < 1) {
            MessageBox.Show(this, "学号不能为空!");
            return;
        }
        if (idStr.Length < 1) {
            MessageBox.Show(this, "身份证号不能为空!");
            return;
        }
        studentBLL StudentBLL = new studentBLL();
        student Student = StudentBLL.GetModel(stuIdStr);
        if (Student == null) {
            MessageBox.Show(this, "你输入的学号不存在!");
            return;
        }
        if (Student.certificateId.Equals(idStr))
        {
            Session["check"] = "1";
            ViewState["stuId"] = stuIdStr;
            Panel1.Visible = false;
            Panel2.Visible = true;

        }
        else
        {
            Session["check"] = "0";
            MessageBox.Show(this, "您输入的学号与身份证号不匹配!");
            return;
        }
    }
 protected void loginBtn_Click(object sender, EventArgs e)
 {
     string userName = Tools.safeUserInput(stuIdTB.Text.Trim());
     string passWord = Tools.safeUserInput(passwordTB.Text.Trim());
     string yzmStr = yzmTB.Text.Trim();
     if (userName.Length < 1) { MessageBox.Show(this, "用户名不能为空"); return; }
     if (passWord.Length < 1) { MessageBox.Show(this, "密码不能为空"); return; }
     if (yzmStr.Length < 1) { MessageBox.Show(this, "验证码不能为空"); return; }
     if (yzmStr.Equals(Request.Cookies["CheckCode"].Value.ToString()))
     {
         studentBLL StudentBLL = new studentBLL();
         string loginMessage = StudentBLL.Login(userName, passWord);
         if (loginMessage.Equals("1"))
         {
             string stuIdStr = StudentBLL.GetModel(userName).stuId.ToString();
             Session["status"] = "true";
             Session["UserId"] = stuIdStr;
             Session["type"] = "2";
             studentloginlogBLL StudentLoginLogBLL = new studentloginlogBLL();
             StudentLoginLogBLL.login(Request.ServerVariables["REMOTE_ADDR"].ToString(), stuIdStr);
             MessageBox.ShowAndRedirect(this, "登录成功!", "student.aspx");
         }
         else
         {
             Session["status"] = "false";
             Session["UserId"] = "0";
             Session["type"] = "0";
             MessageBox.ShowAndRedirect(this, loginMessage, "logout.aspx");
         }
     }
     else {
         MessageBox.ShowAndRedirect(this, "验证码错误!", "logout.aspx");
         return;
     }
 }
 protected void initial(string stuId)
 {
     studentBLL StudentBLL = new studentBLL();
     student Student = StudentBLL.GetModel(stuId);
     stuIdStr = Student.stuId;
     nameStr = Student.name;
     majorNameStr = Student.majorName;
     idStr = Student.certificateId;
     emailTB.Text = Student.email;
     cellPhoneTB.Text = Student.phone;
 }
 protected void InitializePage()
 {
     studentBLL StudentBAll = new studentBLL();
     student Student = StudentBAll.GetModel(stuId);
     stuIdStr = Student.stuId;
     nameStr = Student.name;
     sexStr = Student.sex;
     colleageStr = Student.colleage;
     majorStr = Student.majorName;
     if (Student.admissionDate != null && Student.admissionDate.ToString().Length == 6)
         schoolTimeStr = Student.admissionDate.Insert(4, "年").Insert(7, "年");
     examrecordBLL ExamRecordBLL = new examrecordBLL();
     zongXueFenStr = ExamRecordBLL.SumCredit(stuId);
     xueWeiKeZongXueFenStr = ExamRecordBLL.SumGXWCredit(stuId);
     xueWeikeJiaQuanPingJunStr = ExamRecordBLL.SumGXWAverageCredit(stuId);
 }
 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 initial(int Id)
 {
     studentBLL StudentBLL = new studentBLL();
     student Student = StudentBLL.GetModel(Id);
     try
     {
         stuIdTB.Text = Student.stuId;
         nameTB.Text = Student.name;
         sexDDL.SelectedValue = Student.sex;
         nationTB.Text = Student.nation;
         birthdayTB.Text = Student.birthday;
         certificateTypeTB.Text = Student.certificateType;
         certificateIdTB.Text = Student.certificateId;
         majorIdTB.Text = Student.majorId;
         majorNameTB.Text = Student.majorName;
         colleageTB.Text = Student.colleage;
         degreeTB.Text = Student.degree;
         classTypeTB.Text = Student.classType;
         typeTB.Text = Student.type;
         placeOfWorkTB.Text = Student.placeOfWork;
         workPhoneTB.Text = Student.workPhone;
         phoneTB.Text = Student.phone;
         emailTB.Text = Student.email;
         addressTB.Text = Student.address;
         zipCodeTB.Text = Student.zipCode;
         schoolYearTB.Text = Student.admissionDate;
     }
     catch
     {
         MessageBox.Show(this, "该学生不存在!");
         Response.Write("<script language=javascript>history.go(-2);</script>");
     }
     finally { };
     examrecordBLL ExamRecordBLL = new examrecordBLL();
     sumCreditStr = ExamRecordBLL.SumCredit(Session["StuId"].ToString().Trim());
     stuGXWCreditStr = ExamRecordBLL.SumGXWCredit(Session["StuId"].ToString().Trim());
     stuGXWAverageCreditStr = ExamRecordBLL.SumGXWAverageCredit(Session["StuId"].ToString().Trim());
 }
    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");
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     Tools.authentication(this, "1", "2");
     if (Session["type"].ToString().Equals("2")) Panel1.Visible = false;
     markUnder60();
     try
     {
         id = Convert.ToInt32(Request.QueryString["id"].ToString().Trim());
         ViewState["id"] = id;
         studentBLL StudentBLL = new studentBLL();
         Session["StuId"] = StudentBLL.GetModel(id).stuId;
     }
     catch
     {
         MessageBox.Show(this, "你查询的页面不存在!");
         Response.Write("<script language=javascript>history.go(-2);</script>");
     }
     finally { }
     if (!Page.IsPostBack)
     {
         id = Convert.ToInt32(ViewState["id"]);
         initial(id);
     }
 }