1 概述
燃气服务评价综合管理系统,其开发主要包括后台数据库的建立和维护以及应用程序的开发两个方面。对于数据库要求建立起数据一致性和完整性强、数据安全性好的数据库,而对于后者则要求应用程序功能完备,易使用等特点。该燃气服务评价综合系统实现的功能有:系统管理、燃气产品管理、客户管理、服务信息管理、电话咨询管理。
本系统采用B/S模式,主要实现的功能如下:
系统管理:该模块实现的功能有系统属性、管理员维护、修改密码。主要是对系统的维护信息的分析;
燃气产品管理:该模块实现的功能有产品分类、添加分类、燃气产品管理、添加产品。产品分类主要是对分类管理的添加、删除修改;燃气产品管理主要是对产品信息进行添加、删除、修改等,如类别、名称、产地、单位 、规格等;
客户管理:该模块实现的功能有客户管理、添加客户。主要是对客户信息的添加、删除、修改,如姓名、性别、年龄、联系电话、住址;
服务管理:该模块实现的功能有故障维修登记、服务登记、故障量统计。故障维修管理主要是对服务信息的添加、删除、修改。如单据号、故障维修时间、总金额、经手人、明细等;服务登记主要是对服务登记信息的添加、删除、修改,如单据号、登记者时间、总金额等;故障量统计主要是对故障信息的统计,如产品名称、统计数量;
电话咨询管理:该模块实现的功能有电话咨询管理、添加电话咨询。电话咨询管理主要是对电话咨询信息进行添加、删除、修改,如电话咨询产品、到期时间、电话咨询费用、支付方式、顾客姓名等;
2 数据库表
实体描述:
管理员信息:说明、编号、名称、密码、类型;
分类信息:说明、编号、名称、介绍
服务信息:说明、编号、单据号、时间、价格、经手人、备注
服务明细信息:说明、编号、服务编号、商品编号、数量、备注
电话咨询信息:说明、编号、咨询内容、地址、联系人、电话、QQ、座机、邮箱
燃气信息:说明、编号、分类编号、词典、单位 、规格、备注、图片
客户信息:说明、编号、名称、性别、年龄、电话、地址、职务
3 关键代码
package com.action;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import com.dao.DB;
import com.orm.TAdmin;
import com.orm.zhixun;
public class zhixun_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("zhixunMana"))
{
zhixunMana(req, res);
}
if(type.endsWith("zhixunAdd"))
{
zhixunAdd(req, res);
}
if(type.endsWith("zhixunDel"))
{
zhixunDel(req, res);
}
if(type.endsWith("zhixunEdit"))
{
zhixunEdit(req, res);
}
/* if(type.endsWith("zhixunSearch"))
{
zhixunSearch(req, res);
}*/
if(type.endsWith("zhixunXinxi"))
{
zhixunXinxi(req, res);
}
}
public void zhixunAdd(HttpServletRequest req,HttpServletResponse res)
{
String mingcheng=req.getParameter("mingcheng");
String dizhi=req.getParameter("dizhi");
String lianxiren=req.getParameter("lianxiren");
String dianhua=req.getParameter("dianhua");
String youbian=req.getParameter("youbian");
String chuanzhen=req.getParameter("chuanzhen");
String youxiang=req.getParameter("youxiang");
String sql="insert into t_zhixun (`mingcheng`, `dizhi`, `lianxiren`, `dianhua`, `youbian`, `chuanzhen`, `youxiang`, `kahuhang`, `zhanghao`, `type`, `del`) values(?,?,?,?,?,?,?,?,?,?,?)";
Object[] params={mingcheng,dizhi,lianxiren,dianhua,youbian,chuanzhen,youxiang,"","","zhixun","no"};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "zhixun?type=zhixunMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void zhixunEdit(HttpServletRequest req,HttpServletResponse res)
{
String mingcheng=req.getParameter("mingcheng");
String dizhi=req.getParameter("dizhi");
String lianxiren=req.getParameter("lianxiren");
String dianhua=req.getParameter("dianhua");
String youbian=req.getParameter("youbian");
String chuanzhen=req.getParameter("chuanzhen");
String youxiang=req.getParameter("youxiang");
String sql="update t_zhixun set mingcheng='"+mingcheng+"',dizhi='"+dizhi+"',lianxiren='"+lianxiren+"',dianhua='"+dianhua+"',youbian='"+youbian+"',chuanzhen='"+chuanzhen+"',youxiang='"+youxiang+"' where id="+Integer.parseInt(req.getParameter("id"));
Object[] params={};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "zhixun?type=zhixunMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void zhixunMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String page1=req.getParameter("page");
if(page1==null){
page1="1";
}
//分页设置
int EVERYPAGENUM=10;//每页条数
int page=Integer.parseInt(page1); //传递过来的当前页
int cou = 1;//得到信息总数
int pagecount=1; //总页数
String sql1="select count(*) as cou from t_zhixun where type='zhixun' and del='no'";
if(req.getParameter("mingcheng")!=null) sql1+=" and mingcheng like '%"+req.getParameter("mingcheng").trim()+"%'";
Object[] params1={};
DB mydb1=new DB();
try
{
mydb1.doPstm(sql1, params1);
ResultSet rs=mydb1.getRs();
while(rs.next())
{
cou= rs.getInt("cou");
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb1.closed();
if (cou % EVERYPAGENUM == 0) {
pagecount= cou / EVERYPAGENUM;
} else {
pagecount=cou / EVERYPAGENUM + 1;
}
req.setAttribute("EVERYPAGENUM", EVERYPAGENUM);
req.setAttribute("page", page);
req.setAttribute("cou", cou);
req.setAttribute("pagecount", pagecount);
List zhixunList=new ArrayList();
String sql="select * from t_zhixun where type='zhixun' and del='no'";
if(req.getParameter("mingcheng")!=null) sql+=" and mingcheng like '%"+req.getParameter("mingcheng").trim()+"%'";Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
rs.next();
}
for (int t = 0; t < EVERYPAGENUM; t++) {
if (rs.next()) {
zhixun zhixun=new zhixun();
zhixun.setId(rs.getInt("id"));
zhixun.setMingcheng(rs.getString("mingcheng"));
zhixun.setDizhi(rs.getString("dizhi"));
zhixun.setLianxiren(rs.getString("lianxiren"));
zhixun.setDianhua(rs.getString("dianhua"));
zhixun.setYoubian(rs.getString("youbian"));
zhixun.setChuanzhen(rs.getString("chuanzhen"));
zhixun.setYouxiang(rs.getString("youxiang"));
zhixunList.add(zhixun);
} else {
break; //减少空循环的时间
}
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("zhixunList", zhixunList);
req.getRequestDispatcher("admin/zhixun/zhixunMana.jsp").forward(req, res);
}
public void zhixunDel(HttpServletRequest req,HttpServletResponse res)
{
int id=Integer.parseInt(req.getParameter("id"));
String sql="update t_zhixun set del='yes' where id=?";
Object[] params={id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "zhixun?type=zhixunMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
/*public void zhixunEdit(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
int id=Integer.parseInt(req.getParameter("id"));
String sql="update t_zhixun set mingcheng=?,dizhi=?,lianxiren=?,dianhua=?,youbian=?,chuanzhen=?,youxiang=? where id="+id;
String mingcheng=req.getParameter("mingcheng");
String dizhi=req.getParameter("dizhi");
String lianxiren=req.getParameter("lianxiren");
String dianhua=req.getParameter("dianhua");
String youbian=req.getParameter("youbian");
String chuanzhen=req.getParameter("chuanzhen");
String youxiang=req.getParameter("youxiang");
Object[] params={mingcheng,dizhi,lianxiren,dianhua,youbian,chuanzhen,youxiang};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "zhixun?type=zhixunMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void zhixunSearch(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List zhixunList=new ArrayList();
String sql="select * from t_zhixun where type='zhixun' and del='no' and mingcheng like '%"+req.getParameter("mingcheng").trim()+"%'";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
zhixun zhixun=new zhixun();
zhixun.setId(rs.getInt("id"));
zhixun.setMingcheng(rs.getString("mingcheng"));
zhixun.setDizhi(rs.getString("dizhi"));
zhixun.setLianxiren(rs.getString("lianxiren"));
zhixun.setDianhua(rs.getString("dianhua"));
zhixun.setYoubian(rs.getString("youbian"));
zhixun.setChuanzhen(rs.getString("chuanzhen"));
zhixun.setYouxiang(rs.getString("youxiang"));
zhixunList.add(zhixun);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("zhixunList", zhixunList);
req.getRequestDispatcher("admin/zhixun/zhixunMana.jsp").forward(req, res);
}
*/
public void zhixunXinxi(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{System.out.println("%%%%");
List zhixunList=new ArrayList();
int id=Integer.parseInt(req.getParameter("id"));
String sql="select * from t_zhixun where id="+id;
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
zhixun zhixun=new zhixun();
zhixun.setId(rs.getInt("id"));
zhixun.setMingcheng(rs.getString("mingcheng"));
zhixun.setDizhi(rs.getString("dizhi"));
zhixun.setLianxiren(rs.getString("lianxiren"));
zhixun.setDianhua(rs.getString("dianhua"));
zhixun.setYoubian(rs.getString("youbian"));
zhixun.setChuanzhen(rs.getString("chuanzhen"));
zhixun.setYouxiang(rs.getString("youxiang"));
zhixunList.add(zhixun);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("zhixunList", zhixunList);
req.getRequestDispatcher("admin/zhixun/zhixunXinxi.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
4 效果演示
idea或eclipse开发,mysql数据库