当前位置:文档之家› 个人信息管理系统

个人信息管理系统

个人信息管理系统1、登录界面代码实现public Boolean login(User user) throws SQLException{Connection con=DB.connection();boolean temp=true;String sql="select * from user where userName='"+user.getUserNa me()+"'";PreparedStatement ps=DB.prepar(sql, con);ResultSet rs=null;rs=ps.executeQuery();if(rs.next()){sql="select * from user where password='"+user.getPassword()+"'"; ps=DB.prepar(sql, con);rs=ps.executeQuery();if(rs.next()){temp=true;}else{temp=false;}}else{temp=false;}DB.Close(con);DB.Close(rs);return temp;}public String register(User user){String temp="sucess";Connection con=DB.connection();String sql="select * from user where userName='"+user.getUserNa me()+"'";PreparedStatement ps1=DB.prepar(sql,con);ResultSet rs=null;try {rs=ps1.executeQuery();if(rs.next()){temp="error";}sql="insert into user values (?,?,?,?,?)";PreparedStatement ps2=DB.prepar(sql, con);ps2.setString(1, user.getUserName());ps2.setString(2, user.getPassword());ps2.setString(3, user.getSex());ps2.setString(4, user.getBirth());ps2.setString(5, user.getPhone());ps2.executeUpdate();DB.Close(ps2);} catch (SQLException e1) {e1.printStackTrace();}DB.Close(con);DB.Close(ps1);return temp;}2、主页面3、个人信息界面代码实现:Xml:<action name="gerenAdd"class="gerenAction"method="gerenAdd"> </action><action name="gerenDel"class="gerenAction"method="gerenDel"> </action><action name="gerenMana"class="gerenAction"method="gerenMana"> <result name="success">/admin/geren/gerenMana.jsp</result> </action><action name="gerenEditPre"class="gerenAction"method="gerenEditPre"><result name="success">/admin/geren/gerenEditPre.jsp</result> </action><action name="gerenEdit"class="gerenAction"method="gerenEdit"></action>public String gerenMana(){String sql="from TXuyuan where xuyuanDel='no'";ListxuyuanList=xuyuanDAO.getHibernateTemplate().find(sql);Maprequest=(Map)ServletActionContext.getContext().get("request");request.put("xuyuanList", xuyuanList);return ActionSupport.SUCCESS;}代码实现:public String gerenAdd(){TGeren geren=new TGeren();geren.setGerenBianhao(geren Bianhao);geren.setGerenName(geren Name);geren.setGerenJianjie(geren Jianjie);geren.setGerenDel("no");geren DAO.save(geren);this.setMessage("添加成功");this.setPath("geren Mana.action");return"succeed";}4、通讯录xml:<action name="tongxunAdd"class="tongxunAction"method="tongxunAdd"></action><action name="tongxunMana"class="tongxunAction" method="tongxunMana"><resultname="success">/admin/tongxunlu/tongxunMana.jsp</result> </action><action name="tongxunDel"class="tongxunAction" method="tongxunDel"></action>代码实现:public String tongxunAdd(){TTongxun tongxun=new TTongxun();tongxun.setTongxunren(tongxunren);tongxun.setTongxunzhuti(tongxunzhuti);tongxun.setTongxunzongzhi(tongxunzongzhi);tongxun.setTongxunneirong(tongxunneirong);tongxun.setTongxunshijian(tongxunshijian);tongxun.setTongxundidian(tongxundidian);tongxun.setCanjiarenyuan(canjiarenyuan);tongxun.setDel("no");tongxunDAO.save(tongxun);this.setMessage("添加成功");this.setPath("tongxunMana.action");return"succeed";}public String tongxunDel(){TTongxun tongxun=tongxunDAO.findById(id);tongxun.setDel("yes");T ongxunDAO.attachDirty(tongxun);this.setMessage("删除成功");this.setPath("tongxunMana.action");return"succeed";}5、文件上传Xml:<action name="folderMana"class="folderAction"method="folderMana"><result name="success">/admin/folder/folderMana.jsp</result> </action><action name="folderAdd"class="folderAction"method="folderAdd"></action><action name="folderDel"class="folderAction"method="folderDel"></action><action name="folderByStu"class="folderAction"method="folderByStu"><result name="success">/atea/folder/folderByStu.jsp</result> </action>代码实现:public String folderAdd(){TFolder folder=new TFolder();folder.setFolderName(folderName);folder.setFolderFaburiqi(new Date().toLocaleString());folder.setFolderType("folderByAdmin");if(folderFujianFileName==null || folderFujianFileName.equals("")){System.out.println("");folder.setFolderFujian("0");}else{System.out.println("");String newFile1Name=newDate().getTime()+folderFujianFileName.substring(folderFujianFi leName.indexOf("."));String dstPath =ServletActionContext.getServletContext().getRealPath("uploadPa th")+ "\\" + newFile1Name;File dstFile = new File(dstPath);copy(this.getFolderFujian(),dstFile);folder.setFolderFujian("/uploadPath/"+newFile1Name);folder.setFolderFujianleixing(folderFujianContentType);folder.setFolderFujianyuanshiming(folderFujianFileName);}folderDAO.save(folder);this.setMessage("文件上传成功");this.setPath("folderMana.action");return"succeed";}public String folderByStu(){String sql="from TFolder where folderType='folderByAdmin' order by folderId desc";ListfolderList=folderDAO.getHibernateTemplate().find(sql);Maprequest=(Map)ServletActionContext.getContext().get("request");request.put("folderList", folderList);return ActionSupport.SUCCESS;}public String folderMana(){String sql="from TFolder where folderType='folderByAdmin' order by folderId desc";ListfolderList=folderDAO.getHibernateTemplate().find(sql);Maprequest=(Map)ServletActionContext.getContext().get("request");request.put("folderList", folderList);return ActionSupport.SUCCESS;}public String folderDel(){TFolder folder=folderDAO.findById(folderId);folderDAO.delete(folder);this.setMessage("删除成功");this.setPath("folderMana.action");return"succeed";}。

相关主题