package com.tian.foodserver;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.tian.userclass.MysqlConnection;
public class AdminOrder extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
public AdminOrder() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("gb2312");
response.setContentType("text/html; charset=gb2312");
PrintWriter out = response.getWriter();
Statement stmt =null;
ResultSet rs =null;
Connection conn = null;
String sql =null;
String adminStr = request.getParameter("load");
String userStr = request.getParameter("regist");
try{
conn =MysqlConnection.getConntion();
stmt = conn.createStatement();
/*显示用户信息*/
if(userStr !=null){
out.println("<html><head><title>用户信息</title></head><body bgcolor='#B5E6E8' " +
" background='display3.jpg'>" +
" <center> <table width ='20' border='5' cellpadding='5' bordercolor='#7777E3'> " +
"<br><br><tr> <td nowrap><font size ='5'> <b> 用户信息 </b><font ></td></td></table><p></p><br><br>" +
"<table border='0' cellpadding='3'> <tr bgcolor='#DDB7F4'>" +
"<td nowrap><font>电话</font></td>" +
"<td nowrap><font>姓名</font></td>" +
"<td nowrap><font>地址</font></td>" +
"<td nowrap><font>权限</font></td>" +
"<td nowrap><font>密码</font></td>" +
"</tr>");
sql = "select * from user " ;
rs = stmt.executeQuery(sql);
while(rs.next()){
String phone = rs.getString("uphone");
String name = rs.getString("uname");
String address = rs.getString("uaddress");
int rootid = rs.getInt("rootid");
String password = rs.getString("upassword");
out.println("<tr>" +
"<td nowrap><center>" + phone +
"</center>" +
"</td> <td nowrap><center>" + name +
"</center></td> <td nowrap><center>" + address +
"</center></td> <td nowrap><center>" + rootid +
"</center></td> <td nowrap><center>" + password +
"</center></td>" +
"</tr>");
}
out.println("</table><br><center>" +
"<br><br><a href= './AdminPage.html'>返回管理页面</a> <a href= './Exit.html'>退出系统</a>" +
"</center></body></html>");
}
else{
out.println("<html><head><title>总订单管理</title></head><body bgcolor='#B5E6E8'" +
"background='display3.jpg'>" +
" <center> <table width ='20' border='5' cellpadding='5' bordercolor='#7777E3'> " +
"<br><br><tr> <td nowrap><font size ='5'> <b> 订单管理 </b><font ></td></td></table><p></p><br><br>" +
"<table border='0' cellpadding='3'> <tr bgcolor='#DDB7F4'>" +
"<td nowrap><font>电话</font></td>" +
"<td nowrap align='center'><font>菜名</font></td>" +
"<td nowrap><font>数量</font></td>" +
"<td nowrap><font>价格</font></td>" +
"<td nowrap><font>交易完成</font></td>" +
"<td nowrap><font>清零</font></td>" +
"</tr>");
/*查询数据库order表*/
sql = "select * from uorder " ;
rs = stmt.executeQuery(sql);
while(rs.next()){
String phone = rs.getString("phone");
String menu = rs.getString("menu");
int amount = rs.getInt("amount");
float price = rs.getFloat("price");
String yorn =rs.getString("yorn");
out.println("<tr>" +
"<td nowrap><center>" + phone +
"</center>" +
"</td> <td nowrap><center>" + menu +
"</center></td> <td nowrap><center>" + amount +
"</center></td> <td nowrap><center>" + price +
"</center></td> <td nowrap><center>" + yorn +
"</center></td><td nowrap align='center'><form method ='post' action =ClearZero>" +
"<input type='hidden' name='menu' value='" + menu +
"'><input type='submit' name= 'update' value='zero'" +
"></form></td>" +
"</tr>");
}
out.println("</table><br><center>" +
"<br><br><a href= './AdminPage.html'>返回管理页面</a>" +
" <a href= './Exit.html'>退出系统</a>" +
"</center></body></html>");
}
rs.close();
conn.close();
stmt.close();
}catch(SQLException ex){
ex.printStackTrace();
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request, response);
}
}
评论7