protected void Button2_Click(object sender, EventArgs e) { studentBLL StudentBLL = new studentBLL(); examrecordBLL ExamRecordBLL = new examrecordBLL(); studentloginlogBLL StudentLoginLogBLL = new studentloginlogBLL(); try { ExamRecordBLL.Delete(Session["StuId"].ToString().Trim()); StudentLoginLogBLL.Delete(Session["StuId"].ToString().Trim()); StudentBLL.Delete(id); } catch { MessageBox.Show(this, "删除失败!"); } MessageBox.ShowAndRedirect(this, "删除成功!", "student.aspx"); }
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"); }