仓库管理系统
---恢复内容开始---
1.web文件
add.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>增加</title> <script type="text/javascript""> function validate() { var Name=document.forms[0].Name.value; var Maker=document.forms[0].Maker.value; var Type=document.forms[0].Type.value; var Size=document.forms[0].Size.value; if(Name.length<=0){ alert("产品名称不能为空,请输入商品名称!"); return false; } else if(Maker.length<=0){ alert("制造商不能为空,请输入制造商名称!"); return false; } else if(Type<=0){ alert("类型不能为空,请输入类型名称!"); return false; } else if(Size.length<=0){ alert("规格不能为空,请输入规格名称!"); return false; } else{ return true; } //document.getElementById("form").submit(); } </script> </head> <body> <form action="addresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <table border="1"> <caption>入库信息</caption> <tr> <td>商品名称:</td> <td><input type="text" name="Name"title="商品名称不能为空"></input><br></td> </tr> <tr> <td>生产商:</td> <td><input type="text" name="Maker"title="生产商名称不能为空"></input><br></td> </tr> <tr> <td>型号:</td> <td><input type="text" name="Type"title="型号不能为空"></input><br></td> </tr> <tr> <td>规格:</td> <td><input type="text" name="Size"title="规格不能为空"></input><br></td> </tr> <tr> <td>数量:</td> <td><input type="text" name="Number"title="数量不能为空"></input><br></td> </tr> <tr> <td>日期:</td> <td><input type="text" name="Date"title="日期不能为空"></input><br></td> </tr> <tr> <td>时间:</td> <td><input type="text" name="Time"title="时间不能为空"></input><br></td> </tr> <tr> <td>存放单位:</td> <td><input type="text" name="Danwei"title="存放单位不能为空"></input><br></td> </tr> <tr> <td>负责人:</td> <td><input type="text" name="Person"title="负责人不能为空"></input><br></td> </tr> <tr> <td> </td> <td><input type="submit" value="提交"/></td> </tr> </table> </form> </body> </html>
addone.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>增加</title> <script type="text/javascript""> function validate() { var Name=document.forms[0].Name.value; var Maker=document.forms[0].Maker.value; var Type=document.forms[0].Type.value; var Size=document.forms[0].Size.value; if(Name.length<=0){ alert("产品名称不能为空,请输入商品名称!"); return false; } else if(Maker.length<=0){ alert("制造商不能为空,请输入制造商名称!"); return false; } else if(Type<=0){ alert("类型不能为空,请输入类型名称!"); return false; } else if(Size.length<=0){ alert("规格不能为空,请输入规格名称!"); return false; } else{ return true; } //document.getElementById("form").submit(); } </script> </head> <body> <form action="addresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <table border="1"> <caption>入库信息</caption> <tr> <td>商品名称:</td> <td><input type="text" name="Name"title="商品名称不能为空"></input><br></td> </tr> <tr> <td>生产商:</td> <td><input type="text" name="Maker"title="生产商名称不能为空"></input><br></td> </tr> <tr> <td>型号:</td> <td><input type="text" name="Type"title="型号不能为空"></input><br></td> </tr> <tr> <td>规格:</td> <td><input type="text" name="Size"title="规格不能为空"></input><br></td> </tr> <tr> <td>数量:</td> <td><input type="text" name="Number"title="数量不能为空"></input><br></td> </tr> <tr> <td>日期:</td> <td><input type="text" name="Date"title="日期不能为空"></input><br></td> </tr> <tr> <td>时间:</td> <td><input type="text" name="Time"title="时间不能为空"></input><br></td> </tr> <tr> <td>存放单位:</td> <td><input type="text" name="Danwei"title="存放单位不能为空"></input><br></td> </tr> <tr> <td>负责人:</td> <td><input type="text" name="Person"title="负责人不能为空"></input><br></td> </tr> <tr> <td> </td> <td><input type="submit" value="提交"/></td> </tr> </table> </form> </body> </html>
addoneresult.jsp
<%@page import="Ke.Test2"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加结果</title> </head> <body> <% if(Test2.addone(request.getParameter("Name"),request.getParameter("Maker"),request.getParameter("Type"),request.getParameter("Size"))==1) { { out.print("<script language = 'javascript'>alert('添加成功');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); } } else{ out.print("<script language = 'javascript'>alert('添加失败');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); //out.println("添加失败"); } %> </body> </html>
addresult.jsp
<%@page import="Ke.Test2"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加结果</title> </head> <body> <% if(Test2.addone(request.getParameter("Name"),request.getParameter("Maker"),request.getParameter("Type"),request.getParameter("Size"))==1) { { out.print("<script language = 'javascript'>alert('添加成功');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); } } else{ out.print("<script language = 'javascript'>alert('添加失败');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); //out.println("添加失败"); } %> </body> </html>
Choice.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <a href="add.jsp" target="right">入库</a><br> <a href="update.jsp" target="right">出库</a><br> <a href="addone.jsp" target="right">添加商品信息</a><br> <a href="deleteone.jsp" target="right">删除商品信息</a><br> <a href="updateone.jsp" target="right">修改商品信息</a><br> <a href="search.jsp" target="right">查看商品信息</a> <a href="Choicetwo.jsp" target="right">查看库存信息</a> <a href="delete.jsp" target="right">删除库存信息</a> </body> </html>
choicethree.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <a href="search.jsp" target="right">按商品名称查询</a><br> </body> </html>
choicetwo.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <a href="find.jsp" target="right">按商品名称查询</a><br> <a href="findtwo.jsp" target="right">按入库日期查询</a> </body> </html>
delete.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>删除界面</title> </head> <body> <form action="deleteresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <h4> 商品名称:<input type="text" name="Name"title="商品名称不能为空"></input><br></h4> <input type="submit" value="完成"/> </form> </body> </html>
deleteone.jsp
<%@page import="Ke.Test2"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>删除界面</title> </head> <body> <form action="deleteoneresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <h4> 商品名称:<input type="text" name="Name"title="商品名称不能为空"></input><br></h4> <input type="submit" value="完成"/> </form> </body> </html>
deleteoneresult.jsp
<%@page import="Ke.Test2"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>删除结果</title> </head> <body> <% if(Test2.delete(request.getParameter("Name"))==1) { { out.print("<script language = 'javascript'>alert('删除成功');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); } } else{ out.print("<script language = 'javascript'>alert('删除失败');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); //out.println("添加失败"); } %> </body> </html>
deleteresult.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>删除结果</title> </head> <body> <% if(Test.delete(request.getParameter("Name"))==1) { { out.print("<script language = 'javascript'>alert('删除成功');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); } } else{ out.print("<script language = 'javascript'>alert('删除失败');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); //out.println("添加失败"); } %> </body> </html>
find.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>查找界面</title> <script type="text/javascript""> function validate() { var Name=document.forms[0].Name.value; var Maker=document.forms[0].Maker.value; var Type=document.forms[0].Type.value; var Size=document.forms[0].Size.value; //document.getElementById("form").submit(); } </script> </head> <body> <form action="findresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <h4> 商品名称:<input type="text" name="Name"></input><br></h4> <input type="submit" value="完成"/> </form> </body> </html>
findresult.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>查找结果</title> </head> <body> <% Test.find(request.getParameter("Name")); out.println("商品名称:"+Test.a_Name()); out.println("制造商:"+Test.a_Maker()); out.println("型号:"+Test.a_Type()); out.println("规格:"+Test.a_Size()); out.println("数量:"+Test.a_Number()); out.println("日期:"+Test.a_Date()); out.println("时间:"+Test.a_Time()); out.println("入库单位:"+Test.a_Danwei()); out.println("负责人:"+Test.a_Person()); %> </body> </html>
findtwo.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>查找界面</title> <script type="text/javascript""> function validate() { var Name=document.forms[0].Name.value; var Maker=document.forms[0].Maker.value; var Type=document.forms[0].Type.value; var Size=document.forms[0].Size.value; var Date=document.forms[0].Date.value; //document.getElementById("form").submit(); } </script> </head> <body> <form action="findtworesult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <h4> 入库日期:<input type="text" name="Date"></input><br></h4> <input type="submit" value="完成"/> </form> </body> </html>
findtworesult.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>查找结果</title> </head> <body> <% Test.findtwo(request.getParameter("Date")); out.println("商品名称:"+Test.a_Name()); out.println("制造商:"+Test.a_Maker()); out.println("型号:"+Test.a_Type()); out.println("规格:"+Test.a_Size()); out.println("数量:"+Test.a_Number()); out.println("日期:"+Test.a_Date()); out.println("时间:"+Test.a_Time()); out.println("入库单位:"+Test.a_Danwei()); out.println("负责人:"+Test.a_Person()); %> </body> </html>
search.jsp
<%@page import="Ke.Test2"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>查找界面</title> <script type="text/javascript""> function validate() { var Name=document.forms[0].Name.value; var Maker=document.forms[0].Maker.value; var Type=document.forms[0].Type.value; var Size=document.forms[0].Size.value; //document.getElementById("form").submit(); } </script> </head> <body> <form action="searchresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <h4> 商品名称:<input type="text" name="Name"></input><br></h4> <input type="submit" value="完成"/> </form> </body> </html>
searchresult.jsp
<%@page import="Ke.Test2"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>查找结果</title> </head> <body> <% Test2.search(request.getParameter("Name")); out.println("商品名称:"+Test2.a_Name()); out.println("制造商:"+Test2.a_Maker()); out.println("型号:"+Test2.a_Type()); out.println("规格:"+Test2.a_Size()); %> </body> </html>
Top.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <h1>仓库信息管理系统</h1> </body> </html>
update.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>修改界面</title> <script type="text/javascript""> function validate() { var Name=document.forms[0].Name.value; var Maker=document.forms[0].Maker.value; var Type=document.forms[0].Type.value; var Size=document.forms[0].Size.value; if(Name.length<=0){ alert("产品名称不能为空,请输入产品名称!"); return false; } else if(Maker.length<=0){ alert("制造商不能为空,请输入制造商名称!"); return false; } else if(Type<=0){ alert("类型不能为空,请输入类型!"); return false; } else if(Size.length<=0){ alert("规格不能为空,请输入规格!"); return false; } else{ return true; } //document.getElementById("form").submit(); } </script> </head> <body> <form action="uqdateresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <table border="1"> <caption>出库信息</caption> <tr> <td>商品名称:</td> <td><input type="text" name="Name"title="商品名称不能为空"></input><br></td> </tr> <tr> <td>生产商:</td> <td><input type="text" name="Maker"title="生产商名称不能为空"></input><br></td> </tr> <tr> <td>型号:</td> <td><input type="text" name="Type"title="型号不能为空"></input><br></td> </tr> <tr> <td>规格:</td> <td><input type="text" name="Size"title="规格不能为空"></input><br></td> </tr> <tr> <td>数量:</td> <td><input type="text" name="Number"title="数量不能为空"></input><br></td> </tr> <tr> <td>日期:</td> <td><input type="text" name="Date"title="日期不能为空"></input><br></td> </tr> <tr> <td>时间:</td> <td><input type="text" name="Time"title="时间不能为空"></input><br></td> </tr> <tr> <td>存放单位:</td> <td><input type="text" name="Danwei"title="存放单位不能为空"></input><br></td> </tr> <tr> <td>负责人:</td> <td><input type="text" name="Person"title="负责人不能为空"></input><br></td> </tr> <tr> <td> </td> <td><input type="submit" value="提交"/></td> </tr> </table> </form> </body> </html>
updateone.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>修改界面</title> <script type="text/javascript""> function validate() { var Name=document.forms[0].Name.value; var Maker=document.forms[0].Maker.value; var Type=document.forms[0].Type.value; var Size=document.forms[0].Size.value; if(Name.length<=0){ alert("产品名称不能为空,请输入产品名称!"); return false; } else if(Maker.length<=0){ alert("制造商不能为空,请输入制造商名称!"); return false; } else if(Type<=0){ alert("类型不能为空,请输入类型!"); return false; } else if(Size.length<=0){ alert("规格不能为空,请输入规格!"); return false; } else{ return true; } //document.getElementById("form").submit(); } </script> </head> <body> <form action="uqdateresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <table border="1"> <caption>出库信息</caption> <tr> <td>商品名称:</td> <td><input type="text" name="Name"title="商品名称不能为空"></input><br></td> </tr> <tr> <td>生产商:</td> <td><input type="text" name="Maker"title="生产商名称不能为空"></input><br></td> </tr> <tr> <td>型号:</td> <td><input type="text" name="Type"title="型号不能为空"></input><br></td> </tr> <tr> <td>规格:</td> <td><input type="text" name="Size"title="规格不能为空"></input><br></td> </tr> <tr> <td>数量:</td> <td><input type="text" name="Number"title="数量不能为空"></input><br></td> </tr> <tr> <td>日期:</td> <td><input type="text" name="Date"title="日期不能为空"></input><br></td> </tr> <tr> <td>时间:</td> <td><input type="text" name="Time"title="时间不能为空"></input><br></td> </tr> <tr> <td>存放单位:</td> <td><input type="text" name="Danwei"title="存放单位不能为空"></input><br></td> </tr> <tr> <td>负责人:</td> <td><input type="text" name="Person"title="负责人不能为空"></input><br></td> </tr> <tr> <td> </td> <td><input type="submit" value="提交"/></td> </tr> </table> </form> </body> </html>
updateoneresult.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>修改界面</title> <script type="text/javascript""> function validate() { var Name=document.forms[0].Name.value; var Maker=document.forms[0].Maker.value; var Type=document.forms[0].Type.value; var Size=document.forms[0].Size.value; if(Name.length<=0){ alert("产品名称不能为空,请输入产品名称!"); return false; } else if(Maker.length<=0){ alert("制造商不能为空,请输入制造商名称!"); return false; } else if(Type<=0){ alert("类型不能为空,请输入类型!"); return false; } else if(Size.length<=0){ alert("规格不能为空,请输入规格!"); return false; } else{ return true; } //document.getElementById("form").submit(); } </script> </head> <body> <form action="uqdateresult.jsp" method="post" id="form" onSubmit="return validate()" > <input type="hidden" name="methodName" value="0"/> <table border="1"> <caption>出库信息</caption> <tr> <td>商品名称:</td> <td><input type="text" name="Name"title="商品名称不能为空"></input><br></td> </tr> <tr> <td>生产商:</td> <td><input type="text" name="Maker"title="生产商名称不能为空"></input><br></td> </tr> <tr> <td>型号:</td> <td><input type="text" name="Type"title="型号不能为空"></input><br></td> </tr> <tr> <td>规格:</td> <td><input type="text" name="Size"title="规格不能为空"></input><br></td> </tr> <tr> <td>数量:</td> <td><input type="text" name="Number"title="数量不能为空"></input><br></td> </tr> <tr> <td>日期:</td> <td><input type="text" name="Date"title="日期不能为空"></input><br></td> </tr> <tr> <td>时间:</td> <td><input type="text" name="Time"title="时间不能为空"></input><br></td> </tr> <tr> <td>存放单位:</td> <td><input type="text" name="Danwei"title="存放单位不能为空"></input><br></td> </tr> <tr> <td>负责人:</td> <td><input type="text" name="Person"title="负责人不能为空"></input><br></td> </tr> <tr> <td> </td> <td><input type="submit" value="提交"/></td> </tr> </table> </form> </body> </html>
updateresult.jsp
<%@page import="Ke.Test"%> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>修改结果</title> </head> <body> <% if(Test.uqdate(request.getParameter("Name"),request.getParameter("Maker"),request.getParameter("Type"),request.getParameter("Size"),request.getParameter("Number"),request.getParameter("Date"),request.getParameter("Time"),request.getParameter("Danwei"),request.getParameter("Person"))==1) { { out.print("<script language = 'javascript'>alert('修改成功');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); } } else{ out.print("<script language = 'javascript'>alert('修改失败');</script>"); response.setHeader("refresh", "0;url=Zhu.jsp"); //out.println("添加失败"); } %> </body> </html>
Zhu.jsp
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <frameset rows="100,*"> <frame name="top" src="Top.jsp"> <frameset cols="120,*"> <frame name="left" src="Choice.jsp"> <frame name="right" src="add.jsp"> </frameset> </html>
2.java文件
Test.java
package Ke;
import Ke.util;
import java.sql.*;
import java.util.Scanner;
public class Test {
static Connection conn;
static PreparedStatement ps = null;
static ResultSet rs;
static String sql = "select * from Ke_c";
static util ut= new util();
static Scanner in = new Scanner(System.in);
static String Name;
static String Maker;
static String Type;
static String Size;
static String Number;
static String Date;
static String Time;
static String Danwei;
static String Person;
public static String a_Name() {
return Name;
}
public static String a_Maker() {
return Maker;
}
public static String a_Type() {
return Type;
}
public static String a_Size() {
return Size;
}
public static String a_Date() {
return Date;
}
public static String a_Time() {
return Time;
}
public static String a_Danwei() {
return Danwei;
}
public static String String() {
return Person;
}
public static String a_Number() {
return Number;
}
public static String a_Person() {
return Person;
}
public static int add(String Name,String Maker,String Type,String Size,String Number,String Date,String Time,String Danwei,String Person)
{
conn= ut.getConn();
String sql="insert into Ke_c values(?,?,?,?,?,?,?,?,?)";
int b=0;
try {
ps=conn.prepareStatement(sql);
ps.setString(1,Name);
ps.setString(2, Maker);
ps.setString(3, Type);
ps.setString(4, Size);
ps.setString(5, Number);
ps.setString(6, Date);
ps.setString(7, Time);
ps.setString(8, Danwei);
ps.setString(9, Person);
int a=ps.executeUpdate();
if(a>0) {
b++;
System.out.println("添加成功");
}
else {
System.out.println("添加失败");
}
}catch(Exception e) {
e.printStackTrace();
}
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
return b;
}
public static int uqdate(String name,String maker,String type,String size,String number,String date,String time,String danwei,String person) {
int b=0;
conn=ut.getConn();
ps=null;
sql="update Ke_c set Maker=?,Type=?,Size=?,Number=?,Date=?,Time=?,Person=?,Danwei=? where Name=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1, maker);
ps.setString(2, type);
ps.setString(3, size);
ps.setString(4, number);
ps.setString(5, date);
ps.setString(6, time);
ps.setString(7, person);
ps.setString(8, danwei);
ps.setString(9, name);
int a=ps.executeUpdate();
if(a>0) {
b++;
System.out.println("修改成功");
}
else {
System.out.println("修改失败");
}
}catch(Exception e) {
e.printStackTrace();
}
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
return b;
}
public static int delete(String Name) {
int b=0;
conn=ut.getConn();
ps=null;
sql="delete from Ke_c where Name=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1, Name);
int a=ps.executeUpdate();
if(a>0) {
b++;
System.out.println("删除成功");
}
else {
System.out.println("删除失败");
}
}catch(Exception e) {
e.printStackTrace();
}
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
return b;
}
public static void find(String a) {
conn=ut.getConn();
ps=null;
ResultSet rs=null;
String id;
sql="select * from Ke_c where Name=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1, a);
rs=ps.executeQuery();
if(rs.next()) {
Name = rs.getString("Name");
Maker = rs.getString("Maker");
Type = rs.getString("Type");
Size = rs.getString("Size");
Number = rs.getString("Number");
Date = rs.getString("Date");
Time = rs.getString("Time");
Danwei = rs.getString("Danwei");
Person = rs.getString("Person");
}
}catch(SQLException e) {
e.printStackTrace();
}finally {
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
}
}
public static void findtwo(String a) {
conn=ut.getConn();
ps=null;
ResultSet rs=null;
String id;
sql="select * from Ke_c where Date=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1, a);
rs=ps.executeQuery();
if(rs.next()) {
Date = rs.getString("Date");
Name = rs.getString("Name");
Maker = rs.getString("Maker");
Type = rs.getString("Type");
Size = rs.getString("Size");
Number = rs.getString("Number");
Time = rs.getString("Time");
Danwei = rs.getString("Danwei");
Person = rs.getString("Person");
}
}catch(SQLException e) {
e.printStackTrace();
}finally {
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
}
}
public static void main(String[] args) {
//System.out.println("请输入要删除课程");
//System.out.println("请输入查找课程:");
//String a;
//Scanner scan=new Scanner(System.in);
//a=scan.next();
//delete(a);
//findtwo(a);
uqdate("computer","2","2","2","1","1","1","1","1");
}
}
Test2.java
package Ke;
import Ke.util;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;
public class Test2{
static Connection conn;
static PreparedStatement ps = null;
static ResultSet rs;
static String sql = "select * from Ke_c_copy";
static util ut= new util();
static Scanner in = new Scanner(System.in);
static String Name;
static String Maker;
static String Type;
static String Size;
public static String a_Name() {
return Name;
}
public static String a_Maker() {
return Maker;
}
public static String a_Type() {
return Type;
}
public static String a_Size() {
return Size;
}
public static int addone(String Name,String Maker,String Type,String Size)
{
conn= ut.getConn();
String sql="insert into Ke_c_copy values(?,?,?,?)";
int b=0;
try {
ps=conn.prepareStatement(sql);
ps.setString(1,Name);
ps.setString(2, Maker);
ps.setString(3, Type);
ps.setString(4, Size);
int a=ps.executeUpdate();
if(a>0) {
b++;
System.out.println("添加成功");
}
else {
System.out.println("添加失败");
}
}catch(Exception e) {
e.printStackTrace();
}
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
return b;
}
public static void search(String a) {
conn=ut.getConn();
ps=null;
ResultSet rs=null;
String id;
sql="select * from Ke_c_copy where Name=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1, a);
rs=ps.executeQuery();
if(rs.next()) {
Name = rs.getString("Name");
Maker = rs.getString("Maker");
Type = rs.getString("Type");
Size = rs.getString("Size");
}
}catch(SQLException e) {
e.printStackTrace();
}finally {
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
}
}
public static int delete(String Name) {
int b=0;
conn=ut.getConn();
ps=null;
sql="delete from Ke_c_copy where Name=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1, Name);
int a=ps.executeUpdate();
if(a>0) {
b++;
System.out.println("删除成功");
}
else {
System.out.println("删除失败");
}
}catch(Exception e) {
e.printStackTrace();
}
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
return b;
}
public static int uqdate(String name,String maker,String type,String size) {
int b=0;
conn=ut.getConn();
ps=null;
sql="update Ke_c_copy set Maker=?,Type=?,Size=?where Name=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1, maker);
ps.setString(2, type);
ps.setString(3, size);
ps.setString(9, name);
int a=ps.executeUpdate();
if(a>0) {
b++;
System.out.println("修改成功");
}
else {
System.out.println("修改失败");
}
}catch(Exception e) {
e.printStackTrace();
}
try {
if(ps!=null)ps.close();
if(conn!=null)conn.close();
}catch(Exception e2) {
e2.printStackTrace();
}
return b;
}
}
util.java
package Ke;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class util {
String user="sa";
String password="364624";
String url="jdbc:sqlserver://localhost:1433;DatabaseName=XVQIU";
public Connection getConn(){
Connection conn=null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
conn=DriverManager.getConnection(url, user, password);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
public void close(ResultSet rs, Statement state, Connection conn) {
if(rs!=null)
{
try
{
rs.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
if(state!=null)
{
try
{
state.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
if(conn!=null)
{
try
{
conn.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}