⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin1111bean.java

📁 1.简单缩减版的教务管理系统 2.Struts+SQLServer2000 3.包含数据库(含表格说明)和源代码 4.主页源自厦门大学教务处首页 5.完整实现其中第一个功能模块
💻 JAVA
字号:
package cn.edu.yuyh.admin.bean;import java.sql.*;import java.util.ArrayList;import java.util.HashMap;import javax.servlet.http.*;import cn.edu.yuyh.admin.actionform.*;import cn.edu.yuyh.tools.*;public class Admin1111Bean{  public void doInitOfQuery(Admin1111ActionForm myForm,HttpServletRequest httpServletRequest,Connection conn)                 throws Exception{    try {      this.doInitOptionsCollection(myForm,httpServletRequest,conn);      myForm.reset();     }    catch (Exception e) {      throw e;    }  }  public void doInitOptionsCollection(Admin1111ActionForm myForm,HttpServletRequest httpServletRequest,Connection conn)                 throws Exception  {    PublicFunction function = new PublicFunction();    try    {      myForm.setOcdeptno(function.initOcdeptno(httpServletRequest,conn));      myForm.setOcspecialno(function.initOcspecialno(httpServletRequest,conn));      myForm.setOcsclass(function.initOcsclass(httpServletRequest,conn));    }    catch (Exception e)    {      throw e;    }  }  public Boolean doQueryInfo(Admin1111ActionForm myForm,HttpServletRequest httpServletRequest,Connection conn)                 throws Exception{    PublicFunction function = new PublicFunction();    String sno = function.trim(myForm.getSno());    String sname = function.trim(myForm.getSname());    String id_card = function.trim(myForm.getId_card());    String deptno = function.trim(myForm.getDeptno());    String specialno = function.trim(myForm.getSpecialno());    String sclass = function.trim(myForm.getSclass());    StringBuffer sql = new StringBuffer();    sql.append("select Sno,Sname,ID_Card,b.DeptName Dept,c.SpecialName Special,Class");    sql.append(" from Student a,Department b,Special c");    sql.append(" where a.DeptNo = b.DeptNo and a.SpecialNo = c.SpecialNo");    if (!"".equals(sno))    {      sql.append(" and a.Sno='" + sno + "'");    }    if (!"".equals(sname))    {      sql.append(" and a.Sname='" + sname + "'");    }    if (!"".equals(id_card))    {      sql.append(" and a.ID_Card='" + id_card + "'");    }    if (!"all".equals(deptno))    {      sql.append(" and a.DeptNo='" + deptno + "'");    }    if (!"all".equals(specialno))    {      sql.append(" and a.SpecialNo='" + specialno + "'");    }    if (!"all".equals(sclass))    {      sql.append(" and a.Class='" + sclass + "'");    }    try {      ArrayList rows = function.queryArrayList(sql.toString(), conn);      if (rows.isEmpty())      {        doInitOptionsCollection(myForm,httpServletRequest,conn);        return Boolean.FALSE;      }      else      {        myForm.setRows(rows);        myForm.setNumber(""+rows.size());      }      doInitOptionsCollection(myForm,httpServletRequest,conn);    }    catch (Exception e) {      e.printStackTrace();      throw e;    }    return Boolean.TRUE;  }  public Boolean doDeleteInfo(Admin1111ActionForm myForm,HttpServletRequest httpServletRequest,Connection conn)                 throws Exception{    String aSno[] = httpServletRequest.getParameterValues("cbFlag");    String strSno = "";    int lengthOfaSno = aSno.length;    for(int i=0;i<lengthOfaSno;i++){      strSno = strSno + "'"+aSno[i]+"'";      if(i!=lengthOfaSno-1){        strSno = strSno + ",";      }    }    StringBuffer sql = new StringBuffer();    sql.append("delete from Student");    sql.append(" where sno in ("+strSno+")");    PreparedStatement pstmt = conn.prepareStatement(sql.toString());    try {      int number = pstmt.executeUpdate();      if (number == 0)      {        doInitOptionsCollection(myForm,httpServletRequest,conn);        return Boolean.FALSE;      }      else      {        doInitOptionsCollection(myForm,httpServletRequest,conn);      }    }    catch (Exception e) {      e.printStackTrace();      throw e;    }    return Boolean.TRUE;  }  public Boolean doInitOfModify(Admin1111ActionForm myForm,HttpServletRequest httpServletRequest,Connection conn)                 throws Exception{    PublicFunction function = new PublicFunction();    String sno = function.trim(httpServletRequest.getParameter("sno"));    StringBuffer sql = new StringBuffer();    sql.append("select Sno,Password,Sname,ID_Card,a.DeptNo,a.SpecialNo,Class, ");    sql.append(" b.DeptName Dept,c.SpecialName Special");    sql.append(" from Student a,Department b,Special c");    sql.append(" where a.DeptNo = b.DeptNo and a.SpecialNo = c.SpecialNo");    sql.append(" and a.Sno='" + sno + "'");    try {      ArrayList rows = function.queryArrayList(sql.toString(), conn);      myForm.setOcdeptno(function.initOcdeptno(httpServletRequest,conn));      myForm.setOcspecialno(function.initOcspecialno(httpServletRequest,conn));      if(rows.isEmpty())      {        return Boolean.FALSE;      }      else{        myForm.setSno(((HashMap)rows.get(0)).get("Sno").toString());        myForm.setPassword(((HashMap)rows.get(0)).get("Password").toString());        myForm.setSname(((HashMap)rows.get(0)).get("Sname").toString());        myForm.setId_card(((HashMap)rows.get(0)).get("ID_Card").toString());        myForm.setDeptno(((HashMap)rows.get(0)).get("DeptNo").toString());        myForm.setSpecialno(((HashMap)rows.get(0)).get("SpecialNo").toString());        myForm.setSclass1(((HashMap)rows.get(0)).get("Class").toString().substring(0,2));        myForm.setSclass2(((HashMap)rows.get(0)).get("Class").toString().substring(2,3));        myForm.setRows(rows);      }    }    catch (Exception e) {      e.printStackTrace();      throw e;    }    return Boolean.TRUE;  }  public Boolean doModifyInfo(Admin1111ActionForm myForm,HttpServletRequest httpServletRequest,Connection conn)                 throws Exception{    PublicFunction function = new PublicFunction();    String sno = function.trim(myForm.getSno());    String sname = function.trans2iso8859(function.trim(myForm.getSname()));    String password = function.trim(myForm.getPassword());    String id_card = function.trim(myForm.getId_card());    String deptno = function.trim(myForm.getDeptno());    String specialno = function.trim(myForm.getSpecialno());    String sclass = function.trim(myForm.getSclass1())+function.trim(myForm.getSclass2());    StringBuffer sql = new StringBuffer();    sql.append("update Student");    sql.append(" set Sname='"+sname+"',");    sql.append(" Password='"+password+"',");    sql.append(" ID_Card='"+id_card+"',");    sql.append(" DeptNo='"+deptno+"',");    sql.append(" SpecialNo='"+specialno+"',");    sql.append(" Class='"+sclass+"'");    sql.append(" where Sno ='"+sno+"'");    PreparedStatement pstmt = conn.prepareStatement(sql.toString());    try {      int number = pstmt.executeUpdate();      if (number == 0)      {        return Boolean.FALSE;      }    }    catch (Exception e) {      e.printStackTrace();      throw e;    }    return Boolean.TRUE;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -