package com.docs.controller;
//import java.awt.List;不支持泛型
import java.util.ArrayList;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.docs.dao.DianBiaoDao;
import com.docs.dao.XiaoQuDao;
import com.docs.dao.YeZhuDao;
import com.docs.dao.YuanGongDao;
import com.docs.javabean.*;
public class Manage extends HttpServlet {
private static final long serialVersionUID = 1L;
public Manage() {
super();
}
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doPost(req, res);
}
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
if (req.getSession().getAttribute("userName")!=null) {
req.setCharacterEncoding("utf-8");
String url = null;
// TODO Auto-generated method stub
if (req.getParameter("manage").equals("XiaoQu")) {
// 查看小区信息
if (req.getParameter("manageType").equals("query")) {
url = "manager/XiaoQuManage.jsp";
}
// 添加小区处理
else if (req.getParameter("manageType").equals("add")) {
XiaoQu xq = new XiaoQu();
xq.setNum(Integer.valueOf(req.getParameter("Num")));
xq.setSName(req.getParameter("shortName"));
xq.setName(req.getParameter("Name"));
if (addXiaoQu(xq)) {
url = "manager/XiaoQuManage.jsp";
} else {
req.setAttribute("errorMessage","添加失败,请检查是否小区已存在或者小区编号已被占用!");
url = "add/AddXiaoQu.jsp";
}
}
// 删除小区处理
else if (req.getParameter("manageType").equals("delete")) {
String xiaoqu_num = req.getParameter("xiaoqu_num");
String xiaoqu_sName = req.getParameter("xiaoqu_sName");
if (deleteXiaoQu(xiaoqu_num, xiaoqu_sName)) {
url = "manager/XiaoQuManage.jsp";
}
}
/*
* 从数据库中获取小区信息
*/
setXiaoQu(req);
req.getRequestDispatcher(url).forward(req, res);
}
// TODO Auto-generated method stub
// 电表
else if (req.getParameter("manage").equals("DianBiao")) {
String xiaoqu_short = req.getParameter("xiaoqu_short");
// 查看xiaoqu_short下的电表
if (req.getParameter("manageType").equals("query")) {
url = "manager/DianBiaoManage.jsp";
}
// 为xiaoqu_short添加电表
else if (req.getParameter("manageType").equals("add")) {
DianBiao db = new DianBiao();
db.setDb_num(Integer.valueOf(req.getParameter("Num")));
db.setType(req.getParameter("Type"));
db.setWork(req.getParameter("Work"));
db.setUsed(req.getParameter("Used"));
if (addDianBiao(db, xiaoqu_short)) {
url = "manager/DianBiaoManage.jsp";
} else {
req.setAttribute("errorMessage",
"添加失败,请检查是否电表已存在或者电表编号已被占用!");
url = "add/AddDianBiao.jsp";
}
} else if (req.getParameter("manageType").equals("delete")) {
String db_num = req.getParameter("dianbiao_num");
if (deleteDianBiao(db_num, xiaoqu_short)) {
url = "manager/DianBiaoManage.jsp";
}
}
// 小区信息
setXiaoQu(req);
req.setAttribute("xiaoqu_short", xiaoqu_short);
// 小区电表信息
DianBiaoDao dianbiao_dao = new DianBiaoDao();
ArrayList<DianBiao> dianbiao = dianbiao_dao.getDianBiaoList(
xiaoqu_short, "");
req.setAttribute("dianbiaoList", dianbiao);
req.getRequestDispatcher(url).forward(req, res);//
}
// TODO Auto-generated method stub
// 员工
else if (req.getParameter("manage").equals("YuanGong")) {
if (req.getParameter("manageType").equals("query")) {
url = "manager/YuanGongManage.jsp";
} else if (req.getParameter("manageType").equals("add")) {
YuanGong yg = new YuanGong();
yg.setNum(Integer.valueOf(req.getParameter("Num")));
yg.setName(req.getParameter("Name"));
yg.setBumen(req.getParameter("Bumen"));
yg.setTel(Long.valueOf(req.getParameter("Tel")));
yg.setPower(Integer.valueOf(req.getParameter("Power")));
yg.setPwd(req.getParameter("Pwd"));
if (addYuanGong(yg)) {
url = "manager/YuanGongManage.jsp";
} else {
req.setAttribute("errorMessage",
"添加失败,请检查是否员工已存在或者员工编号已被占用!");
url = "add/AddYuanGong.jsp";
}
} else if (req.getParameter("manageType").equals("delete")) {
String yg_num = req.getParameter("yuangong_num");
if (deleteYuanGong(yg_num)) {
url = "manager/YuanGongManage.jsp";
}
}
YuanGongDao yuangong_dao = new YuanGongDao();
ArrayList<YuanGong> yuangong = yuangong_dao.getYuanGongList();
req.setAttribute("yuangongList", yuangong);
req.getRequestDispatcher(url).forward(req, res);
}
// TODO Auto-generated method stub
// 业主
else if (req.getParameter("manage").equals("YeZhu")) {
String xiaoqu_short = req.getParameter("xiaoqu_short");
if (req.getParameter("manageType").equals("query")) {
url = "manager/YeZhuManage.jsp";
} else if (req.getParameter("manageType").equals("add")) {
YeZhu yz = new YeZhu();
yz.setYz_num(req.getParameter("Num"));
yz.setYz_name(req.getParameter("Name"));
yz.setID(req.getParameter("ID"));
yz.setTel(Long.valueOf(req.getParameter("Tel")));
yz.setCompany(req.getParameter("Company"));
yz.setDb_num(Integer.valueOf(req.getParameter("DianBiao")));
if (addYeZhu(yz, xiaoqu_short)) {
url = "manager/YeZhuManage.jsp";
} else {
req.setAttribute("errorMessage",
"添加失败,请检查是否业主已存在或者业主编号已被占用!");
url = "add/AddYuanGong.jsp";
}
} else if (req.getParameter("manageType").equals("delete")) {
String yz_num = req.getParameter("yezhu_num");
String db_num = req.getParameter("dianbiao_num");
if (deleteYeZhu(yz_num, xiaoqu_short, db_num)) {
url = "manager/YeZhuManage.jsp";
}
}
// 小区信息
setXiaoQu(req);
req.setAttribute("xiaoqu_short", xiaoqu_short);
// 小区业主信息
YeZhuDao yezhu_dao = new YeZhuDao();
ArrayList<YeZhu> yezhu = yezhu_dao.getYeZhuList(xiaoqu_short);
req.setAttribute("yezhuList", yezhu);
req.getRequestDispatcher(url).forward(req, res);
}
}
else{
req.getRequestDispatcher("Login.jsp").forward(req, res);
}
}
/*
* 小区处理--从小区表删除记录,并删除其表-业主表与电表表
*/
private boolean deleteXiaoQu(String xiaoqu_num, String xiaoqu_sName) {
XiaoQuDao xiaoqu_dao = new XiaoQuDao();
return xiaoqu_dao.deleteXiaoQu(xiaoqu_num, xiaoqu_sName);
}
// 获取
private static void setXiaoQu(HttpServletRequest req) {
XiaoQuDao xiaoqu_dao = new XiaoQuDao();
req.setAttribute("xiaoquList", xiaoqu_dao.getXiaoQuList());
}
// 添加
private static boolean addXiaoQu(XiaoQu xq) {
String sql = "insert into xiaoqu values(" + xq.getNum() + ",'"
+ xq.getSName() + "','" + xq.getName() + "');";
XiaoQuDao xiaoqu_dao = new XiaoQuDao();
return xiaoqu_dao.addXiaoQu(sql, xq.getSName());
}
// TODO Auto-generated method stub
/*
* 电表处理
*/
// 添加
private static boolean addDianBiao(DianBiao db, String xiaoqu_short) {
String sql = "insert into " + xiaoqu_short + "_dianbiao values("
+ db.getDb_num() + ",'" + db.getType() + "','" + db.getWork()
+ "','" + db.getUsed() + "');";
System.out.println(sql);
DianBiaoDao dianbiao_dao = new DianBiaoDao();
return dianbiao_dao.addDianBiao(sql);
}
// 删除
private boolean deleteDianBiao(String db_num, String xiaoqu_short) {
String sql = "delete from " + xiaoqu_short + "_dianbiao where db_num="
+ db_num + " and used='未使用';";
System.out.println(sql);
DianBiaoDao dianbiao_dao = new DianBia
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
电力公司电费管理系统(以小区为例)Java语言 MYSQL数据库(数据库暂未打包,下载后留言留下邮箱即发送) (128个子文件)
Manage.class 9KB
JiFeiDao.class 7KB
XiaoQuDao.class 4KB
ForgetPwd.class 4KB
YuanGongDao.class 4KB
AndroidGetData.class 4KB
MakeJSON.class 4KB
System_DB.class 4KB
Login.class 3KB
YeZhuDao.class 3KB
AndroidLogin.class 3KB
XQTable.class 3KB
JiFei.class 3KB
DianBiaoDao.class 3KB
AndroidSendData.class 3KB
Finance.class 3KB
ResetPwd.class 2KB
ChangePwd.class 2KB
AndroidGetYGInfo.class 2KB
GetUnusedDianBiao.class 2KB
YeZhu.class 2KB
Exit.class 2KB
YuanGong.class 1KB
ForGetPwdUser.class 1KB
DianBiao.class 1KB
Price.class 1KB
XiaoQu.class 940B
YeZhuMsg.class 715B
.classpath 948B
org.eclipse.wst.common.component 494B
org.eclipse.wst.jsdt.ui.superType.container 49B
ManagerLeft.css 3KB
finance_left.css 2KB
jiFeiManager.css 782B
login.css 457B
managerHead.css 289B
finance.css 19B
menu_bg2.gif 4KB
menu_bgs.gif 2KB
menu_bg1.gif 1KB
menu_topline.gif 1KB
header01.gif 1KB
out.gif 859B
center0.gif 242B
center.gif 242B
03.gif 225B
header_bei.gif 198B
02.gif 76B
01.gif 74B
left01_right.gif 66B
left02_right.gif 66B
left02_left.gif 65B
left01_left.gif 65B
04.gif 54B
04.gif 54B
left01_bei.gif 52B
left02_bei.gif 52B
test.html 3KB
mysql-connector-java-5.1.25-bin.jar 829KB
org.json.jar 117KB
servlet.jar 78KB
Manage.java 10KB
JiFeiDao.java 4KB
XiaoQuDao.java 4KB
System_DB.java 3KB
YuanGongDao.java 3KB
ForgetPwd.java 3KB
AndroidGetData.java 3KB
Login.java 3KB
AndroidLogin.java 2KB
YeZhuDao.java 2KB
JiFei.java 2KB
MakeJSON.java 2KB
XQTable.java 2KB
AndroidSendData.java 2KB
Finance.java 2KB
ResetPwd.java 2KB
ChangePwd.java 2KB
DianBiaoDao.java 2KB
GetUnusedDianBiao.java 1KB
Exit.java 1KB
AndroidGetYGInfo.java 1KB
YeZhu.java 983B
YuanGong.java 919B
Price.java 694B
DianBiao.java 598B
ForGetPwdUser.java 590B
XiaoQu.java 469B
YeZhuMsg.java 386B
highcharts.js 84KB
jquery.js 71KB
.jsdtscope 503B
ManagerLeft.jsp 7KB
ManagerLeft.jsp 7KB
XQTable.jsp 5KB
BaoBiaoManage.jsp 4KB
YeZhuManage.jsp 3KB
DianBiaoManage.jsp 3KB
FinanceLeft.jsp 3KB
YuanGongManage.jsp 2KB
共 128 条
- 1
- 2
资源评论
- jgx19922021-11-102063293868@qq.com,求个数据库,感谢!
- ccbwx2014-10-20这个数据库是mssql,我需要mysql,不知道谁会改,求求你们了zengzeng_HK2014-11-10不过是跟我代码配套的zengzeng_HK2014-11-10我有,邮箱
zengzeng_HK
- 粉丝: 7
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- IT桔子:中国智能电视市场研究报告
- [MICCAI'24]“BGF-YOLO通过多尺度注意力特征融合增强型YOLOv8用于脑肿瘤检测”的官方实现 .zip
- CB Insights:智能汽车才是未来-信息图
- 安卓项目-记事本的实现
- Yolo(实时物体检测)模型训练教程,基于深度学习神经网络.zip
- 网络爬虫基础 & HTML解析基础-课件
- Java基础语法与高级特性的全面讲解
- YOLO(You Only Look Once)的 Keras 实现统一的实时对象检测.zip
- YOLO(You Only Look Once)物体检测机制在 Tensorflow 中的实现.zip
- H3m-Blog项目源代码文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功