package com.custmannage.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import org.apache.struts2.ServletActionContext;
import java.util.List;
import com.custmannage.dao.ClassInfoDAO;
import com.custmannage.dao.StudentDAO;
import com.custmannage.domain.ClassInfo;
import com.custmannage.domain.Student;
import com.custmannage.test.TestUtil;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class StudentAction extends ActionSupport {
/*图片字段studentPhoto参数接收*/
private File studentPhotoFile;
private String studentPhotoFileFileName;
private String studentPhotoFileContentType;
public File getStudentPhotoFile() {
return studentPhotoFile;
}
public void setStudentPhotoFile(File studentPhotoFile) {
this.studentPhotoFile = studentPhotoFile;
}
public String getStudentPhotoFileFileName() {
return studentPhotoFileFileName;
}
public void setStudentPhotoFileFileName(String studentPhotoFileFileName) {
this.studentPhotoFileFileName = studentPhotoFileFileName;
}
public String getStudentPhotoFileContentType() {
return studentPhotoFileContentType;
}
public void setStudentPhotoFileContentType(String studentPhotoFileContentType) {
this.studentPhotoFileContentType = studentPhotoFileContentType;
}
/*界面层需要查询的属性: 学号*/
private String studentNumber;
public void setStudentNumber(String studentNumber) {
this.studentNumber = studentNumber;
}
public String getStudentNumber() {
return this.studentNumber;
}
/*界面层需要查询的属性: 姓名*/
private String studentName;
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public String getStudentName() {
return this.studentName;
}
/*界面层需要查询的属性: 所在班级*/
private ClassInfo studentClassNumber;
public void setStudentClassNumber(ClassInfo studentClassNumber) {
this.studentClassNumber = studentClassNumber;
}
public ClassInfo getStudentClassNumber() {
return this.studentClassNumber;
}
/*界面层需要查询的属性: 出生日期*/
private String studentBirthday;
public void setStudentBirthday(String studentBirthday) {
this.studentBirthday = studentBirthday;
}
public String getStudentBirthday() {
return this.studentBirthday;
}
/*当前第几页*/
private int currentPage;
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getCurrentPage() {
return currentPage;
}
/*一共多少页*/
private int totalPage;
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getTotalPage() {
return totalPage;
}
/*当前查询的总记录数目*/
private int recordNumber;
public void setRecordNumber(int recordNumber) {
this.recordNumber = recordNumber;
}
public int getRecordNumber() {
return recordNumber;
}
/*业务层对象*/
StudentDAO studentDAO = new StudentDAO();
/*待操作的Student对象*/
private Student student;
public void setStudent(Student student) {
this.student = student;
}
public Student getStudent() {
return this.student;
}
/*跳转到添加Student视图*/
public String AddView() {
ActionContext ctx = ActionContext.getContext();
/*查询所有的ClassInfo信息*/
ClassInfoDAO classInfoDAO = new ClassInfoDAO();
List<ClassInfo> classInfoList = classInfoDAO.QueryAllClassInfoInfo();
ctx.put("classInfoList", classInfoList);
return "add_view";
}
/*添加Student信息*/
@SuppressWarnings("deprecation")
public String AddStudent() {
ActionContext ctx = ActionContext.getContext();
/*验证学号是否已经存在*/
String studentNumber = student.getStudentNumber();
Student db_Student = studentDAO.GetStudentByStudentNumber(studentNumber);
if(null != db_Student) {
ctx.put("error", java.net.URLEncoder.encode("该学号已经存在!"));
return "error";
}
try {
if(true) {
ClassInfoDAO classInfoDAO = new ClassInfoDAO();
ClassInfo studentClassNumber = classInfoDAO.GetClassInfoByClassNumber(student.getStudentClassNumber().getClassNumber());
student.setStudentClassNumber(studentClassNumber);
}
String path = ServletActionContext.getServletContext().getRealPath("/upload");
/*处理图片上传*/
String studentPhotoFileName = "";
if(studentPhotoFile != null) {
InputStream is = new FileInputStream(studentPhotoFile);
String fileContentType = this.getStudentPhotoFileContentType();
if(fileContentType.equals("image/jpeg") || fileContentType.equals("image/pjpeg"))
studentPhotoFileName = UUID.randomUUID().toString() + ".jpg";
else if(fileContentType.equals("image/gif"))
studentPhotoFileName = UUID.randomUUID().toString() + ".gif";
else {
ctx.put("error", java.net.URLEncoder.encode("上传图片格式不正确!"));
return "error";
}
File file = new File(path, studentPhotoFileName);
OutputStream os = new FileOutputStream(file);
byte[] b = new byte[1024];
int bs = 0;
while ((bs = is.read(b)) > 0) {
os.write(b, 0, bs);
}
is.close();
os.close();
}
if(studentPhotoFile != null)
student.setStudentPhoto("upload/" + studentPhotoFileName);
else
student.setStudentPhoto("upload/NoImage.jpg");
studentDAO.AddStudent(student);
ctx.put("message", java.net.URLEncoder.encode("Student添加成功!"));
return "add_success";
} catch (Exception e) {
e.printStackTrace();
ctx.put("error", java.net.URLEncoder.encode("Student添加失败!"));
return "error";
}
}
/*查询Student信息*/
public String QueryStudent() {
if(currentPage == 0) currentPage = 1;
if(studentNumber == null) studentNumber = "";
if(studentName == null) studentName = "";
if(studentBirthday == null) studentBirthday = "";
List<Student> StudentList = studentDAO.QueryStudentInfo(studentNumber, studentName, studentClassNumber, studentBirthday, currentPage);
/*计算总的页数和总的记录数*/
studentDAO.CalculateTotalPageAndRecordNumber(studentNumber, studentName, studentClassNumber, studentBirthday);
/*获取到总的页码数目*/
totalPage = studentDAO.getTotalPage();
/*当前查询条件下总记录数*/
recordNumber = studentDAO.getRecordNumber();
ActionContext ctx = ActionContext.getContext();
ctx.put("StudentList", StudentList);
ctx.put("totalPage", totalPage);
ctx.put("recordNumber", recordNumber);
ctx.put("currentPage", currentPage);
ctx.put("studentNumber", studentNumber);
ctx.put("studentName", studentName);
ctx.put("studentClassNumber", studentClassNumber);
ClassInfoDAO classInfoDAO = new ClassInfoDAO();
List<ClassInfo> classInfoList = classInfoDAO.QueryAllClassInfoInfo();
ctx.put("classInfoList", classInfoList);
ctx.put("studentBirthday", studentBirthday);
return "query_view";
}
/*前台查询Student信息*/
public String FrontQueryStudent() {
if(currentPage == 0) currentPage = 1;
if(studentNumber == null) studentNumber = "";
if(studentName == null) s
没有合适的资源?快使用搜索试试~ 我知道了~
edu_system.rar_教务_教务 选课_教务管理系统
共311个文件
gif:86个
jsp:57个
java:36个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 169 浏览量
2022-09-20
21:29:51
上传
评论
收藏 14.88MB RAR 举报
温馨提示
这是一个教务管理系统,用户登录后可以进行选课、成绩管理、个人信息的编辑等操作
资源推荐
资源详情
资源评论
收起资源包目录
edu_system.rar_教务_教务 选课_教务管理系统 (311个子文件)
StudentAction.class 9KB
TeacherAction.class 8KB
NewsAction.class 7KB
StudentSelectCourseInfoAction.class 7KB
SpecialFieldInfoAction.class 7KB
ScoreInfoAction.class 7KB
ClassInfoAction.class 7KB
CourseInfoAction.class 6KB
StudentDAO.class 6KB
SpecialFieldInfoDAO.class 6KB
StudentSelectCourseInfoDAO.class 5KB
ClassInfoDAO.class 5KB
CourseInfoDAO.class 5KB
TeacherDAO.class 5KB
ScoreInfoDAO.class 5KB
NewsDAO.class 5KB
CollegeInfoAction.class 4KB
CollegeInfoDAO.class 4KB
Student.class 3KB
Teacher.class 3KB
CardIdFieldValidator.class 2KB
HibernateUtil.class 2KB
ChangePasswordAction.class 2KB
AdminDAO.class 2KB
FrontLoginAction.class 2KB
SpecialFieldInfo.class 2KB
ClassInfo.class 2KB
CourseInfo.class 2KB
ScoreInfo.class 2KB
CollegeInfo.class 2KB
LoginAction.class 2KB
News.class 1KB
StudentSelectCourseInfo.class 1KB
TestUtil.class 1KB
Admin.class 742B
UserAction.class 416B
.classpath 3KB
org.eclipse.wst.common.component 480B
org.eclipse.wst.jsdt.ui.superType.container 49B
index.css 2KB
style.css 2KB
desk.css 841B
alert.css 51B
Thumbs.db 54KB
Thumbs.db 26KB
edumanage 852KB
frontlogin.gif 356KB
logo.gif 66KB
login_03.gif 59KB
login_08.gif 25KB
login_03 - 副本.gif 19KB
login_05.gif 7KB
login_07.gif 5KB
main_30.gif 3KB
main_40.gif 3KB
main_03.gif 3KB
main_32.gif 2KB
main_04.gif 2KB
main_29.gif 2KB
main_22.gif 2KB
main_47.gif 2KB
main_48.gif 2KB
login_06.gif 2KB
error_b.gif 1KB
main_20.gif 1KB
main_18.gif 1KB
main_12.gif 1KB
main_11.gif 1KB
main_14.gif 1KB
main_16.gif 1KB
tab_17.gif 924B
tab_17.gif 924B
main_58.gif 804B
tab_20.gif 770B
tab_20.gif 770B
tab_07.gif 752B
tab_07.gif 752B
back.gif 749B
back.gif 749B
next.gif 745B
next.gif 745B
last.gif 741B
last.gif 741B
first.gif 736B
go.gif 736B
first.gif 736B
go.gif 736B
tab_18.gif 715B
tab_18.gif 715B
main_07.gif 701B
tab_03.gif 699B
tab_03.gif 699B
main_37.gif 661B
main_05.gif 640B
tb.gif 585B
tb.gif 585B
main_31.gif 552B
tab_19.gif 420B
tab_19.gif 420B
dl.gif 377B
共 311 条
- 1
- 2
- 3
- 4
资源评论
四散
- 粉丝: 50
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功