餐饮管理系统(核心代码)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

餐饮管理系统教学单位长春工业大学姓名岳继武学号20093561年级093306专业软件工程指导教师刘寒梅职称副教授2013年03月01日一、数据库连接类构建(文件DBconn.java)packagecom;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;publicclassDBconn{privateConnectioncon;privateStringclassname=com.microsoft.jdbc.sqlserver.SQLServerDriver;privateStringurl=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=canyin;publicConnectiongetCon(){try{Class.forName(classname);con=DriverManager.getConnection(url,sa,);}catch(Exceptione){e.printStackTrace(System.err);con=null;}returncon;}publicvoidclosed(){try{if(con!=null)con.close();}catch(Exceptione){e.printStackTrace();}}//用于注册,添加publicintGetCount(StringSQL){try{ConnectionCon=getCon();StatementSmt=Con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);intcounts=Smt.executeUpdate(SQL);returncounts;}catch(SQLExceptione){System.out.println(失败!);return0;}}//用于查询,登陆publicResultSetGetRs(StringSQL){try{ConnectionCon=getCon();StatementSmt=Con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);ResultSetRs=Smt.executeQuery(SQL);returnRs;}catch(SQLExceptione){System.out.println(失败!);returnnull;}}//修改和删除publicbooleanexecuteUpdate(Stringsql){if(con==null){getCon();}try{Statementstmt=con.createStatement();intiCount=stmt.executeUpdate(sql);System.out.println(操作成功,所影响的记录数为+String.valueOf(iCount));}catch(SQLExceptione){System.out.println(e.getMessage());System.out.println(executeUpdaterError!);}returntrue;}}二、中文字符处理类(文件Char.java)packagecom;importjava.io.UnsupportedEncodingException;publicclassChar{publicChar(){}/***对字符进行转码处理*@paramstr要转码的字符串*@return编码后的字符串*/publicStringtoString(Stringstr){//转换字符Stringtext=;//判断要转码的字符串是否有效if(str!=null&&!.equals(str)){try{//将字符串进行编码处理text=newString(str.getBytes(iso8859-1),GB18030);}catch(UnsupportedEncodingExceptione){e.printStackTrace();}}//返回后的字符串returntext;}}三、字符串过滤类(文件DoString.java)packagecom;publicclassDoString{privateStringgetstr;privateStringcheckstr;publicDoString(){}publicvoidsetGetstr(Stringgetstr){this.getstr=getstr;dostring();}publicStringgetGetstr(){returnthis.getstr;}publicStringgetCheckstr(){returnthis.checkstr;}publicvoiddostring(){this.checkstr=this.getstr;this.checkstr=this.checkstr.replaceAll(&,&);this.checkstr=this.checkstr.replaceAll(;,);this.checkstr=this.checkstr.replaceAll(',);this.checkstr=this.checkstr.replaceAll(,<);this.checkstr=this.checkstr.replaceAll(,>);this.checkstr=this.checkstr.replaceAll(--,);this.checkstr=this.checkstr.replaceAll(\\,");this.checkstr=this.checkstr.replaceAll(/,);this.checkstr=this.checkstr.replaceAll(%,);}}四、提示信息类(文件PopDialog.java)packagecom;publicclassPopDialog{/******************************功能:返回弹出提示对话框并重定向网页到指定页面的字符串*message:指定要显示的提示信息*url:指定重定向到的页面******************************/publicStringmessageBox(Stringmessage,Stringurl){Stringstr=scriptlanguage='javascript'alert('+message+');;str=str+window.location.href='+url+';/script;returnstr;}}五、时间函数类(文件Shijian.java)packagecom;importjava.text.DateFormat;importjava.util.Date;publicclassShijian{publicStringshowTodayTime(){Datedate=newDate();returnDateFormat.getDateInstance().format(date);}}六、CSS样式表(文件style.css)body,td,th{font-size:12px;}body{background-image:url(../image/dw.gif);margin-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;}body{font-size:12px;color:#000000;}a:link{font-size:12px;color:#000000;text-decoration:none;}a:visited{font-size:12px;color:#000000;text-decoration:none;}a:hover{font-size:12px;color:#0000FF;}.style7{color:#FFFFE1}七、系统登录界面(login.jsp和login_chuli.jsp)核心代码:scriptlanguage=javascriptfunctioncheck(){//判断用户名是否为空if(form1.username.value==){alert(请输入用户名!);form1.username.focus();returnfalse;}//判断密码是否为空if(form1.password.value==){alert(请输入密码!);form1.password.focus();returnfalse;}}/scripttablewidth=800height=388border=0align=centercellpadding=0cellspacing=0trtdvalign=topbackground=image/login.jpgformid=form1name=form1method=postaction=login_chuli.jsponSubmit=returncheck()tablewidth=800border=0cellspacing=0cellpadding=0trtdheight=127colspan=2 /td/trtrtdwidth=320height=20align=right账号:/tdtdwidth=480height=25align=leftinputname=usernametype=textid=username//td/trtrtdheight=20align=right密码:/tdtdheight=25align=leftinputname=passwordtype=passwordid=password//td/trtrtdheight=25align=right权限:/tdtdheight=25align=leftselectname=quanxianid=quanxianoptionvalue=员工selected=selected员工/optionoptionvalue=管理员管理员/option/select/td/trtrtdheight=30align=right /tdtdheight=30align=leftinputtype=submitname=Submitvalue=登陆/ inputtype=buttonname=Submit2value=注册onclick=location.href='zhuce.jsp'//td/tr/table/form/td/tr/table后台处理:%@pagelanguage=javacontentType=text/html;charset=GB18030pageEncoding=GB18030import=java.sql.*%jsp:useBeanid=Login_chuliclass=com.DBconnscope=page/jsp:useBeanid=popDialogscope=pageclass=com.PopDialog/jsp:useBeanid=mystringclass=com.DoStri

1 / 30
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功