/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.poa.struts.action;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.hibernate.Session;
import com.poa.hibernate.Dao;
import com.poa.hibernate.HibernateSessionFactory;
import com.poa.po.Book;
import com.poa.po.Booktype;
import com.poa.po.Pay;
import com.poa.po.Paytype;
import com.poa.util.JsonUtil;
import com.poa.vo.Books;
import com.poa.vo.Pays;
/**
* MyEclipse Struts
* Creation date: 09-30-2009
*
* XDoclet definition:
* @struts.action parameter="method" validate="true"
*/
public class PayAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
Dao dao = new Dao();
public Dao getDao() {
return dao;
}
public void setDao(Dao dao) {
this.dao = dao;
}
public ActionForward findAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Session session = HibernateSessionFactory.getSession();
if(request.getSession().getAttribute("userId").toString() == ""){
return mapping.findForward("login");
}
String userId = request.getSession().getAttribute("userId").toString();
String jsonString = "";
List<Paytype> pt = new ArrayList<Paytype>();
pt = session.createQuery("from Paytype where userid = "+userId+" order by id asc").list();
if(pt!=null){
jsonString = JsonUtil.pageFromListWithoutConfig(0, pt.size(), pt);
}else{
jsonString ="{success:false,errors:{reason:'you didn't create payType!!'}}";
}
try {
response.setContentType("text/jsonString;charset=UTF-8");
response.getWriter().write(jsonString);
response.getWriter().flush();
response.getWriter().close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public ActionForward addType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if(request.getSession().getAttribute("userId").toString() == ""){
return mapping.findForward("login");
}
String title = request.getParameter("title");
String detail = request.getParameter("detail");
String json = "";
String userId = request.getSession().getAttribute("userId").toString();
Paytype bt = new Paytype();
bt.setDetail(detail);
bt.setTitle(title);
bt.setUserid(Long.parseLong(userId));
try{
dao.Save(bt);
json = "{success:true}";
response.setContentType("text/json;charset=UTF-8");
response.getWriter().write(json);
response.getWriter().flush();
response.getWriter().close();
}catch(Exception e){
try{
json = "{success:false}";
response.setContentType("text/json;charset=UTF-8");
response.getWriter().write(json);
response.getWriter().flush();
response.getWriter().close();
}catch(Exception e1){
e1.printStackTrace();
}
e.printStackTrace();
}
return null;
}
public ActionForward findpayTypeById(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception {
String id = request.getParameter("Id");
if(request.getSession().getAttribute("userId").toString() == ""){
return mapping.findForward("login");
}
String json = "";
String userId = request.getSession().getAttribute("userId").toString();
Paytype bt = new Paytype();
Map map = new HashMap();
map.put("id", id);
map.put("userid", userId);
bt = (Paytype) dao.findResult("Paytype", map);
if(bt!=null){
json = "{success:true,data:"+JsonUtil.getJsonFromBean(bt)+"}";
response.setContentType("text/json;charset=UTF-8");
response.getWriter().write(json);
response.getWriter().flush();
response.getWriter().close();
}else{
json = "{success:false}";
response.setContentType("text/json;charset=UTF-8");
response.getWriter().write(json);
response.getWriter().flush();
response.getWriter().close();
}
return null;
}
public ActionForward updatepayType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception {
if(request.getSession().getAttribute("userId").toString() == ""){
return mapping.findForward("login");
}
String title = request.getParameter("title");
String json="";
String detail = request.getParameter("detail");
String id = request.getParameter("id");
String userId = request.getSession().getAttribute("userId").toString();
Paytype bt = new Paytype();
Map map = new HashMap();
map.put("id", id);
map.put("userid", userId);
bt = (Paytype) dao.findResult("Paytype", map);
if(bt!=null){
bt.setDetail(detail);
bt.setTitle(title);
dao.Update(bt);
json = "{success:true,Id:'"+id+"'}";
response.setContentType("text/json;charset=UTF-8");
response.getWriter().write(json);
response.getWriter().flush();
response.getWriter().close();
}else{
json = "{success:false}";
response.setContentType("text/json;charset=UTF-8");
response.getWriter().write(json);
response.getWriter().flush();
response.getWriter().close();
}
return null;
}
public ActionForward deletePayType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if(request.getSession().getAttribute("userId").toString() == ""){
return mapping.findForward("login");
}
String id = request.getParameter("Id");
String json="";
Map map = new HashMap();
map.put("id", id);
Paytype bt = (Paytype) dao.findResult("Paytype", map);
dao.Delete(bt);
if(bt != null){
json = "{success:true}";
}else{
json = "{success:false}";
}
try {
response.setContentType("text/json;charset=UTF-8");
response.getWriter().write(json);
response.getWriter().flush();
response.getWriter().close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public ActionForward findAllpay(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if(request.getSession().getAttribute("userId").toString() == ""){
return mapping.findForward("login");
}
Session session=HibernateSessionFactory.getSession();
String userid="" ;
String jsonString = "";
try{
userid = String.valueOf(request.getSession().getAttribute("userId"));
}catch(Exception e){
userid = "";
}
List<Pays> ps = new ArrayList<Pays>();
List list = session.createSQLQuery("select p.id,pt.id, p.pay_name,p.author,p.brief,p.price,p.times,pt.title from pay p ,paytype pt where p.type_id = pt.id and p.userid = "+userid).list();
for (int i=0;i<list.size();i++){
Object[] obj = (Object[])list.get(i);
Pays p = new Pays();
p.setAuthor(obj[3].toString());
p.setBrief(obj[4].toString());
p.setId(Integer.parseInt(obj[0].toString()));
p.setPayName(obj[2].toString());
p.setPayTypeId(Integer.parseInt(obj[1].toString()));
p.setPrice(Integer.parseInt(o
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
EXTJS桌面系统-完整实例 (1022个子文件)
Pie3D.xml.bak 778B
PayAction.class 12KB
IntypeAction.class 12KB
FenxiAction.class 7KB
Dao.class 6KB
UserAction.class 6KB
JsonUtil.class 4KB
HibernateSessionFactory.class 2KB
Book.class 2KB
Pay.class 2KB
Books.class 2KB
Pays.class 2KB
Booktype.class 1KB
Paytype.class 1KB
Users.class 1KB
DateUtil.class 746B
Total.class 474B
.classpath 6KB
ext-all.css 78KB
desktop.css 16KB
grid.css 13KB
extjs.css 10KB
form.css 10KB
xtheme-gray.css 9KB
panel.css 8KB
tabs.css 7KB
tree.css 7KB
core.css 6KB
date-picker.css 5KB
toolbar.css 5KB
layout.css 5KB
window.css 4KB
button.css 4KB
resizable.css 4KB
qtips.css 3KB
menu.css 3KB
box.css 3KB
Style.css 2KB
slider.css 2KB
editor.css 2KB
dialog.css 2KB
dd.css 2KB
combo.css 1KB
borders.css 1KB
examples.css 1KB
progress.css 939B
login.css 909B
debug.css 862B
reset-min.css 471B
reset.css 471B
lib.css 306B
Thumbs.db 33KB
desktop.gif 331KB
desktop.gif 331KB
dlg-bg.gif 27KB
resizable.gif 7KB
data-view.gif 7KB
desktop.gif 6KB
border-layout.gif 6KB
panel.gif 6KB
air.gif 6KB
grid-paging.gif 6KB
chooser.gif 6KB
tasks.gif 6KB
combo-custom.gif 6KB
organizer.gif 6KB
tabs.gif 5KB
feeds.gif 5KB
grid-xml.gif 5KB
grid-plugins.gif 5KB
grid-edit.gif 5KB
tree-columns.gif 5KB
tool-sprites.gif 4KB
form-adv-vtypes.gif 4KB
portal.gif 4KB
dd-zones.gif 4KB
grid-array.gif 4KB
grid-from-markup.gif 4KB
tabs-adv.gif 4KB
form-custom.gif 4KB
grid-data-binding.gif 4KB
grid-filter.gif 4KB
tip-sprite.gif 4KB
form-dynamic.gif 4KB
form-xml.gif 4KB
locale-switch.gif 4KB
error-tip-corners.gif 4KB
tip-sprite.gif 4KB
window-layout.gif 4KB
tool-sprites.gif 4KB
templates.gif 4KB
form-grid-binding.gif 4KB
tip-sprite.gif 4KB
grid-summary.gif 4KB
toolbar-actions.gif 4KB
progress.gif 4KB
grid-grouping.gif 4KB
tree-two.gif 4KB
window.gif 4KB
ext.gif 4KB
共 1022 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
0o憨胖o0
- 粉丝: 86
- 资源: 36
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页