package com.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.*;
import java.util.Date;
import javax.servlet.*;
import javax.servlet.http.*;
import com.model.*;
public class PaymentDealler extends HttpServlet {
/**
* Created by Light on 20141210
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
// 获取session,保障安全登录
HttpSession hs = request.getSession();
Users sessionUser = (Users) hs.getAttribute("loginUser");
String loginName = null;
if (sessionUser == null) {
request.getRequestDispatcher("/Send2LoginPage").forward(request,response);
return;
} else {
loginName = ((Users) hs.getAttribute("loginUser")).getLoginName();
}
//获取请求类型
String qryType = request.getParameter("type");
//创建service对象
PaymentService paymentService = new PaymentService();
if("delete".equals(qryType))
{
//获取需要删除的paymentId
String paymentId = request.getParameter("paymentId");
//调用PaymentService删除方法 delPaymentRecord
boolean b = paymentService.delPaymentRecord(paymentId);
//判断状态
if(b)
{
request.getRequestDispatcher("/DealOK").forward(request, response);
return;
}else{
request.getRequestDispatcher("/DealErr").forward(request, response);
return;
}
}else if("add".equals(qryType)){
//接受表单数据
String paymentId = request.getParameter("paymentId");
String payUser = request.getParameter("payUser");
//接受付费类型并返回枚举值
CfgEnumService ces1 = new CfgEnumService();
int payType = ces1.getEnumValue("UM", "UM_PAYMENT", "PAYMENT_TYPE", request.getParameter("payType").toUpperCase());
String payDate = request.getParameter("payDate");
float payAmount = Float.parseFloat(request.getParameter("payAmount"))*100;
//接受是否打印发票并返回枚举值
CfgEnumService ces2 = new CfgEnumService();
int isPrintInvoice = ces2.getEnumValue("UM", "UM_PAYMENT","IS_PRINT_INVOICE",request.getParameter("isPrintInvoice").toUpperCase());
String remark = request.getParameter("remark");
//转化表单值
Date _payDate = null ;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
_payDate = sdf.parse(payDate) ;
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //默认当前时间
//System.out.println("PaymentDealler-->payDate: "+payDate);
//System.out.println("PaymentDealler-->_payDate: "+_payDate);
//封装为Payment对象
UsersService userService = new UsersService();
Payment p = new Payment(Integer.parseInt(paymentId), userService.getIdByLoginName(loginName), payType, _payDate, payAmount, isPrintInvoice, remark);
//调用PaymentService.addPaymentRecord(Payment p)
boolean addStatus = paymentService.addPaymentRecord(p);
if(addStatus)
{
request.getRequestDispatcher("/DealOK").forward(request, response);
return;
}else{
request.getRequestDispatcher("/DealErr").forward(request, response);
return;
}
}else if("updateView".equals(qryType)){
//跳转到修改页面去操作
request.getRequestDispatcher("/PaymentModifyView").forward(request, response);
return;
}else if("update".equals(qryType)){
//out.println("已经接受修改了!");
//获取隐藏参数
int userId = Integer.parseInt(request.getParameter("userId"));
//接受表单数据
String paymentId = request.getParameter("paymentId");
String payUser = request.getParameter("payUser");
//接受付费类型并返回枚举值
CfgEnumService ces1 = new CfgEnumService();
int payType = ces1.getEnumValue("UM", "UM_PAYMENT", "PAYMENT_TYPE", request.getParameter("payType").toUpperCase());
String payDate = request.getParameter("payDate");
float payAmount = Float.parseFloat(request.getParameter("payAmount"))*100;
//接受是否打印发票并返回枚举值
CfgEnumService ces2 = new CfgEnumService();
int isPrintInvoice = ces2.getEnumValue("UM", "UM_PAYMENT","IS_PRINT_INVOICE",request.getParameter("isPrintInvoice").toUpperCase());
String remark = request.getParameter("remark");
//转化表单值
Date _payDate = null ;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
_payDate = sdf.parse(payDate) ;
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //默认当前时间
//System.out.println("PaymentDealler-->payDate: "+payDate);
//System.out.println("PaymentDealler-->_payDate: "+_payDate);
//TEST
System.out.println("paymentId="+paymentId);
System.out.println("userId="+userId);
System.out.println("payType="+payType);
System.out.println("_payDate="+_payDate);
System.out.println("payAmount="+payAmount);
System.out.println("isPrintInvoice="+isPrintInvoice);
System.out.println("remark="+remark);
Payment p = new Payment(Integer.parseInt(paymentId), userId, payType, _payDate, payAmount, isPrintInvoice, remark);
//调用PaymentService.addPaymentRecord(Payment p)
boolean modifyStatus = paymentService.modifyPaymentRecord(p);
if(modifyStatus)
{
request.getRequestDispatcher("/DealOK").forward(request, response);
return;
}else{
request.getRequestDispatcher("/DealErr").forward(request, response);
return;
}
}else{
request.getRequestDispatcher("/DealErr").forward(request, response);
return;
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
实现的功能点: 1.登录用户名、密码和验证码验证; 2.第二次登录自动记住用户名; 3.欢迎页面提示上次登录时间; 4.消费信息查询页面分页; 5.新增、删除、修改消费记录; 6.防止盗连(非登录页面直接登录校验提示); 本web应用的页面是纯servlet的,用到的Java web技术: 1.Jdbc; 2.Servlet; 3.一点点cookie; 4.一点点session; 其他知识点: 1.一点点Javascript ; 2.简单的手写MVC三层开发模式;
资源推荐
资源详情
资源评论
收起资源包目录
MoneyManager.rar (47个子文件)
MoneyManager
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 414B
org.eclipse.wst.common.component 497B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 522B
org.eclipse.jdt.core.prefs 364B
src
com
model
UsersService.java 4KB
PaymentService.java 6KB
Users.java 2KB
Payment.java 3KB
CfgEnumService.java 2KB
view
PaymentInfo.java 4KB
Send2LoginPage.java 911B
Login.java 2KB
PaymentModifyView.java 3KB
AddPaymentView.java 4KB
DealErr.java 815B
DealOK.java 2KB
Welcome.java 3KB
controller
PaymentDealler.java 6KB
LoginDealler.java 3KB
util
CreateCheckCode.java 2KB
SqlHelper.java 4KB
.project 1KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 4KB
classes
com
model
UsersService.class 4KB
CfgEnumService.class 3KB
Payment.class 3KB
PaymentService.class 7KB
Users.class 2KB
view
Welcome.class 3KB
AddPaymentView.class 5KB
DealOK.class 1KB
PaymentModifyView.class 4KB
DealErr.class 1KB
PaymentInfo.class 5KB
Send2LoginPage.class 1KB
Login.class 2KB
controller
LoginDealler.class 3KB
PaymentDealler.class 5KB
util
CreateCheckCode.class 3KB
SqlHelper.class 4KB
lib
ojdbc14.jar 1.47MB
index.jsp 834B
imges
UMhead.gjf 29KB
.classpath 1KB
共 47 条
- 1
码上行动_Light
- 粉丝: 10
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页