Java代码增删查改完整流程

第一步编写表模型

package com.model;
/**
 * 案件受理表
 * @author LSY
 *
 */
//get set方法
public class AJSLB { private String id;//主键id private String ajly;//案件来源 private String afdw;//案发单位 private String yyzz;//营业执照 private String frdbr;//法人 private String frdbrzjhm;//法人证件号码 private String frdbrzjlx;//法人证件类型 private String dwmc;//单位名称 private String dz;//单位地址 private String tyshxydm;//统一社会信用代码 private String gszch;//工商注册号 private String zzjgdm;//组织机构代码 private String swdjh;//税务登记号 private String sydwzsh;//事业单位证书号 private String shzzdjzh;//社会组织登记证号 private String jyzxb;//经营者性别 private String jyzmz;//经营者民族 private String jyzdz;//经营者住址 private String lxdh;//经营者联系电话 private String zw;//经营者职务 private String slsj;//受理时间 private String ajzy;//案件摘要 private String jbrqm;//经办人签名 private String jbrqmsj;//经办人签名时间 private String fzryj;//负责人意见 private String fzrqm;//负责人签名 private String fzrqmsj;//负责人签名时间 private String state;//审核状态 private String delstate;//删除状态 private String cbr;//承办人 public String getId() { return id; } public String getCbr() { return cbr; } public void setCbr(String cbr) { this.cbr = cbr; } public void setId(String id) { this.id = id; } public String getAjly() { return ajly; } public void setAjly(String ajly) { this.ajly = ajly; } public String getAfdw() { return afdw; } public void setAfdw(String afdw) { this.afdw = afdw; } public String getSlsj() { return slsj; } public void setSlsj(String slsj) { this.slsj = slsj; } public String getYyzz() { return yyzz; } public void setYyzz(String yyzz) { this.yyzz = yyzz; } public String getFrdbr() { return frdbr; } public void setFrdbr(String frdbr) { this.frdbr = frdbr; } public String getFrdbrzjhm() { return frdbrzjhm; } public void setFrdbrzjhm(String frdbrzjhm) { this.frdbrzjhm = frdbrzjhm; } public String getFrdbrzjlx() { return frdbrzjlx; } public void setFrdbrzjlx(String frdbrzjlx) { this.frdbrzjlx = frdbrzjlx; } public String getDwmc() { return dwmc; } public void setDwmc(String dwmc) { this.dwmc = dwmc; } public String getDz() { return dz; } public void setDz(String dz) { this.dz = dz; } public String getTyshxydm() { return tyshxydm; } public void setTyshxydm(String tyshxydm) { this.tyshxydm = tyshxydm; } public String getGszch() { return gszch; } public void setGszch(String gszch) { this.gszch = gszch; } public String getZzjgdm() { return zzjgdm; } public void setZzjgdm(String zzjgdm) { this.zzjgdm = zzjgdm; } public String getSwdjh() { return swdjh; } public void setSwdjh(String swdjh) { this.swdjh = swdjh; } public String getSydwzsh() { return sydwzsh; } public void setSydwzsh(String sydwzsh) { this.sydwzsh = sydwzsh; } public String getShzzdjzh() { return shzzdjzh; } public void setShzzdjzh(String shzzdjzh) { this.shzzdjzh = shzzdjzh; } public String getJyzxb() { return jyzxb; } public void setJyzxb(String jyzxb) { this.jyzxb = jyzxb; } public String getJyzmz() { return jyzmz; } public void setJyzmz(String jyzmz) { this.jyzmz = jyzmz; } public String getJyzdz() { return jyzdz; } public void setJyzdz(String jyzdz) { this.jyzdz = jyzdz; } public String getLxdh() { return lxdh; } public void setLxdh(String lxdh) { this.lxdh = lxdh; } public String getZw() { return zw; } public void setZw(String zw) { this.zw = zw; } public String getAjzy() { return ajzy; } public void setAjzy(String ajzy) { this.ajzy = ajzy; } public String getJbrqm() { return jbrqm; } public void setJbrqm(String jbrqm) { this.jbrqm = jbrqm; } public String getFzryj() { return fzryj; } public void setFzryj(String fzryj) { this.fzryj = fzryj; } public String getFzrqm() { return fzrqm; } public void setFzrqm(String fzrqm) { this.fzrqm = fzrqm; } public String getFzrqmsj() { return fzrqmsj; } public void setFzrqmsj(String fzrqmsj) { this.fzrqmsj = fzrqmsj; } public String getState() { return state; } public void setState(String state) { this.state = state; } public String getDelstate() { return delstate; } public void setDelstate(String delstate) { this.delstate = delstate; } public String getJbrqmsj() { return jbrqmsj; } public void setJbrqmsj(String jbrqmsj) { this.jbrqmsj = jbrqmsj; } public AJSLB() { } public AJSLB(String id, String ajly, String afdw, String yyzz, String frdbr, String frdbrzjhm, String frdbrzjlx, String dwmc, String dz, String tyshxydm, String gszch, String zzjgdm, String swdjh, String sydwzsh, String shzzdjzh, String jyzxb, String jyzmz, String jyzdz, String lxdh, String zw, String slsj, String ajzy, String jbrqm,String jbrqmsj, String fzryj, String fzrqm, String fzrqmsj, String state, String delstate, String cbr) { this.id = id; this.ajly = ajly; this.afdw = afdw; this.yyzz = yyzz; this.frdbr = frdbr; this.frdbrzjhm = frdbrzjhm; this.frdbrzjlx = frdbrzjlx; this.dwmc = dwmc; this.dz = dz; this.tyshxydm = tyshxydm; this.gszch = gszch; this.zzjgdm = zzjgdm; this.swdjh = swdjh; this.sydwzsh = sydwzsh; this.shzzdjzh = shzzdjzh; this.jyzxb = jyzxb; this.jyzmz = jyzmz; this.jyzdz = jyzdz; this.lxdh = lxdh; this.zw = zw; this.slsj = slsj; this.ajzy = ajzy; this.jbrqm = jbrqm; this.jbrqmsj=jbrqmsj; this.fzryj = fzryj; this.fzrqm = fzrqm; this.fzrqmsj = fzrqmsj; this.state = state; this.delstate = delstate; this.cbr = cbr; } }

第二步编写增删查改方法

package com.dao;
//结案报告
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.model.Jabg;
import com.tool.SuperUtil;

public class JabgDao {
    Connection conn = null;
    PreparedStatement ptmt = null;
    ResultSet rs = null;
    //根据id查询单个的案件
    public List<Jabg> selectMsg1(String id) {
        List<Jabg> list = new ArrayList<Jabg>();
        String sql = " ";
        sql = "select * from Jabg  where jabgid='"+id+"'";
        
            try {conn = SuperUtil.getConnection();
            ptmt = conn.prepareStatement(sql);
            rs = ptmt.executeQuery();
            while (rs.next()) {
                Jabg u = new Jabg();
                u.setA_id(rs.getString("a_id"));
                u.setJabgid(rs.getString("Jabgid"));
                u.setDsr(rs.getString("dsr"));
                u.setAy(rs.getString("ay"));
                u.setLarq(rs.getString("larq"));
                u.setCfjdswh(rs.getString("cfjdswh"));
                u.setCfnr(rs.getString("cfnr"));
                u.setZxfs(rs.getString("zxfs"));
                u.setZxrq(rs.getString("zxrq"));
                u.setZxjg(rs.getString("zxjg"));
                u.setByxzcfdly(rs.getString("byxzcfdly"));
                u.setCbrqm(rs.getString("cbrqm"));                
                u.setCbrqmsj(rs.getString("cbrqmsj"));                
                u.setFzrspyj(rs.getString("fzrspyj"));                
                u.setFzrqm(rs.getString("fzrqm"));
                u.setFzrqmsj(rs.getString("fzrqmsj"));
                u.setState(rs.getString("state"));    
                u.setDelstate(rs.getString("delstate"));
                list.add(u);
            }
            SuperUtil.release(conn, ptmt, rs);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return list;

    }
    //根据aid查询单个的案件
        public List<Jabg> selectall(String jarq,String yyzz,String sfz,String ay,String jarq2,int curPage,int pageSize) {
            int start=(curPage-1)*pageSize;
            List<Jabg> list = new ArrayList<Jabg>();
            String sql = " ";
            sql = "select j.a_id,a.frdbr,a.frdbrzjhm,a.dwmc,a.tyshxydm,a.frdbrzjlx,j.cfjdswh,j.larq,j.ay,x.wftk,x.cfyj,x.wfss,x.clyj,x.gzsj,j.fzrqmsj  from jabg j,ajslb a,xzcfjds x where j.a_id=x.a_id and x.a_id=a.id and j.a_id=a.id and j.state=2";
         
            if (jarq!= null && jarq.length() != 0) {
                sql += " and j.fzrqmsj >='" +jarq + "'";
            }
            if (jarq2!= null && jarq2.length() != 0) {
                sql += " and j.fzrqmsj <='" +jarq2 + "'";
            }if (yyzz!= null && yyzz.length() != 0) {
                sql += " and a.yyzz ='" +yyzz + "'";
            }if (sfz!= null && sfz.length() != 0) {
                sql += " and a.frdbrzjhm like'%" +sfz + "%'";
            }if (ay!= null && ay.length() != 0) {
                sql += " and j.ay like'%" +ay + "%'";
            }
            sql+=" limit "+start+","+pageSize+"";
            //System.out.println(sql);
                try {conn = SuperUtil.getConnection();
                ptmt = conn.prepareStatement(sql);
                rs = ptmt.executeQuery();
                while (rs.next()) {
                    Jabg u = new Jabg();
                    u.setA_id(rs.getString("a_id"));
                    //u.setJabgid(rs.getString("Jabgid"));
                    //u.setDsr(rs.getString("dsr"));
                    u.setAy(rs.getString("ay"));
                    u.setLarq(rs.getString("larq"));
                    u.setCfjdswh(rs.getString("cfjdswh"));
                    //u.setCfnr(rs.getString("cfnr"));
                    //u.setZxfs(rs.getString("zxfs"));
                    //u.setZxrq(rs.getString("zxrq"));
                //    u.setZxjg(rs.getString("zxjg"));
                    //u.setByxzcfdly(rs.getString("byxzcfdly"));
                //    u.setCbrqm(rs.getString("cbrqm"));                
                //    u.setCbrqmsj(rs.getString("cbrqmsj"));                
                //    u.setFzrspyj(rs.getString("fzrspyj"));                
                //    u.setFzrqm(rs.getString("fzrqm"));
                    u.setFzrqmsj(rs.getString("fzrqmsj"));
                    //u.setState(rs.getString("state"));    
                //    u.setDelstate(rs.getString("delstate"));
                    u.setWftk(rs.getString("wftk"));
                    u.setCfyj(rs.getString("cfyj"));
                    u.setWfss(rs.getString("wfss"));
                    u.setClyj(rs.getString("clyj"));
                    u.setGzsj(rs.getString("gzsj"));
                    u.setFrdbr(rs.getString("frdbr"));
                    u.setFrdbrzjhm(rs.getString("frdbrzjhm"));
                    u.setDwmc(rs.getString("dwmc"));
                    u.setTyshxydm(rs.getString("tyshxydm"));
                    u.setFrdbrzjlx(rs.getString("frdbrzjlx"));
                    list.add(u);
                }
                SuperUtil.release(conn, ptmt, rs);
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return list;

        }
        //cx
        public List<Jabg> selectall2(String jarq,String yyzz,String sfz,String ay,String jarq2) {
            List<Jabg> list = new ArrayList<Jabg>();
            String sql = " ";
            sql = "select j.a_id,a.frdbr,a.frdbrzjhm,a.dwmc,a.tyshxydm,a.frdbrzjlx,j.cfjdswh,j.larq,j.ay,x.wftk,x.cfyj,x.wfss,x.clyj,x.gzsj,j.fzrqmsj  from jabg j,ajslb a,xzcfjds x where j.a_id=x.a_id and x.a_id=a.id and j.a_id=a.id and j.state=2";
         
            if (jarq!= null && jarq.length() != 0) {
                sql += " and j.fzrqmsj >='" +jarq + "'";
            }
            if (jarq2!= null && jarq2.length() != 0) {
                sql += " and j.fzrqmsj <='" +jarq2 + "'";
            }if (yyzz!= null && yyzz.length() != 0) {
                sql += " and a.yyzz ='" +yyzz + "'";
            }if (sfz!= null && sfz.length() != 0) {
                sql += " and a.frdbrzjhm like'%" +sfz + "%'";
            }if (ay!= null && ay.length() != 0) {
                sql += " and j.ay like'%" +ay + "%'";
            }
                try {conn = SuperUtil.getConnection();
                ptmt = conn.prepareStatement(sql);
                rs = ptmt.executeQuery();
                while (rs.next()) {
                    Jabg u = new Jabg();
                    u.setA_id(rs.getString("a_id"));
                    //u.setJabgid(rs.getString("Jabgid"));
                    //u.setDsr(rs.getString("dsr"));
                    u.setAy(rs.getString("ay"));
                    u.setLarq(rs.getString("larq"));
                    u.setCfjdswh(rs.getString("cfjdswh"));
                    //u.setCfnr(rs.getString("cfnr"));
                    //u.setZxfs(rs.getString("zxfs"));
                    //u.setZxrq(rs.getString("zxrq"));
                //    u.setZxjg(rs.getString("zxjg"));
                    //u.setByxzcfdly(rs.getString("byxzcfdly"));
                //    u.setCbrqm(rs.getString("cbrqm"));                
                //    u.setCbrqmsj(rs.getString("cbrqmsj"));                
                //    u.setFzrspyj(rs.getString("fzrspyj"));                
                //    u.setFzrqm(rs.getString("fzrqm"));
                    u.setFzrqmsj(rs.getString("fzrqmsj"));
                    //u.setState(rs.getString("state"));    
                //    u.setDelstate(rs.getString("delstate"));
                    u.setWftk(rs.getString("wftk"));
                    u.setCfyj(rs.getString("cfyj"));
                    u.setWfss(rs.getString("wfss"));
                    u.setClyj(rs.getString("clyj"));
                    u.setGzsj(rs.getString("gzsj"));
                    u.setFrdbr(rs.getString("frdbr"));
                    u.setFrdbrzjhm(rs.getString("frdbrzjhm"));
                    u.setDwmc(rs.getString("dwmc"));
                    u.setTyshxydm(rs.getString("tyshxydm"));
                    u.setFrdbrzjlx(rs.getString("frdbrzjlx"));
                    list.add(u);
                }
                SuperUtil.release(conn, ptmt, rs);
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return list;

        }
    //分页查询
        public List<Jabg> selectJabgFy(String state,String fzrqmsj,int curPage,int pageSize ) {
            int start=(curPage-1)*pageSize;
            List<Jabg> list = new ArrayList<Jabg>();
            String sql ="";
            sql="SELECT * FROM  Jabg WHERE 1=1 and delstate>=0";
            if (state!= null && state.length() != 0) {
                sql += " and state ='" +state + "'";
            }
            if (fzrqmsj!= null && fzrqmsj.length() != 0) {
                sql += " and fzrqmsj ='" +fzrqmsj + "'";
            }
        sql+="limit "+start+","+pageSize+"";
        // System.out.println(sql);
        try {
            rs = SuperUtil.executeQuery(sql);
                while (rs.next()) {
                    Jabg u = new Jabg();
                    u.setA_id(rs.getString("a_id"));
                    u.setJabgid(rs.getString("Jabgid"));
                    u.setDsr(rs.getString("dsr"));
                    u.setAy(rs.getString("ay"));
                    u.setLarq(rs.getString("larq"));
                    u.setCfjdswh(rs.getString("cfjdswh"));
                    u.setCfnr(rs.getString("cfnr"));
                    u.setZxfs(rs.getString("zxfs"));
                    u.setZxrq(rs.getString("zxrq"));
                    u.setZxjg(rs.getString("zxjg"));
                    u.setByxzcfdly(rs.getString("byxzcfdly"));
                    u.setCbrqm(rs.getString("cbrqm"));                
                    u.setCbrqmsj(rs.getString("cbrqmsj"));                
                    u.setFzrspyj(rs.getString("fzrspyj"));                
                    u.setFzrqm(rs.getString("fzrqm"));
                    u.setFzrqmsj(rs.getString("fzrqmsj"));
                    u.setDelstate(rs.getString("delstate"));
                    u.setState(rs.getString("state"));                
                    list.add(u);
                }
                SuperUtil.release(conn, ptmt, rs);
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return list;
        }
        
        //查询总条数
        public int selectJabgNum(String state,String fzrqmsj) {
            int a = 0;
            String sql ="";
            sql = "select count(jabgid) totalCount from Jabg WHERE 1=1 and delstate>=0";
            if (state!= null && state.length() != 0) {
                sql += " and state ='" +state + "'";
            }
            if (fzrqmsj!= null && fzrqmsj.length() != 0) {
                sql += " and fzrqmsj ='" +fzrqmsj + "'";
            }
            //System.out.println(sql);
                try {
                    rs = SuperUtil.executeQuery(sql);

                while (rs.next()) {
                    a=rs.getInt("totalCount"); 
                }
                SuperUtil.release(conn, ptmt, rs);
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return a;

        }
        //查询all的总条数
                public int selectAllNum(String jarq,String yyzz,String sfz,String ay,String jarq2) {
                    int a = 0;
                    String sql ="";
                    sql = "select count(j.a_id) totalCount   from jabg j,ajslb a,xzcfjds x where j.a_id=x.a_id and x.a_id=a.id and j.a_id=a.id and j.state=2";
                    if (jarq!= null && jarq.length() != 0) {
                        sql += " and j.fzrqmsj >='" +jarq + "'";
                    }
                    if (jarq2!= null && jarq2.length() != 0) {
                        sql += " and j.fzrqmsj <='" +jarq2 + "'";
                    }if (yyzz!= null && yyzz.length() != 0) {
                        sql += " and a.yyzz ='" +yyzz + "'";
                    }if (sfz!= null && sfz.length() != 0) {
                        sql += " and a.frdbrzjhm like'%" +sfz + "%'";
                    }if (ay!= null && ay.length() != 0) {
                        sql += " and j.ay like'%" +ay + "%'";
                    }
                    // System.out.println(sql);
                        try {
                            rs = SuperUtil.executeQuery(sql);

                        while (rs.next()) {
                            a=rs.getInt("totalCount"); 
                        }
                        SuperUtil.release(conn, ptmt, rs);
                    } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return a;

                }
    public int addMsg(Jabg msg) {//添加行政处罚决定书表信息

        int a = 0;
        String sql = "insert into Jabg values(UUID(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            try {
            conn = SuperUtil.getConnection();
            ptmt = conn.prepareStatement(sql);
            ptmt.setString(1, msg.getA_id());
            ptmt.setString(2, msg.getDsr());
            ptmt.setString(3, msg.getAy());
            ptmt.setString(4, msg.getLarq());
            ptmt.setString(5, msg.getCfjdswh());
            ptmt.setString(6, msg.getCfnr());
            ptmt.setString(7, msg.getZxfs());
            ptmt.setString(8, msg.getZxrq());
            ptmt.setString(9, msg.getZxjg());
            ptmt.setString(10, msg.getByxzcfdly());
            ptmt.setString(11, msg.getCbrqm());
            ptmt.setString(12, msg.getCbrqmsj());
            ptmt.setString(13, msg.getFzrspyj());
            ptmt.setString(14, msg.getFzrqm());
            ptmt.setString(15, msg.getFzrqmsj());
            ptmt.setString(16, msg.getState());
            ptmt.setString(17, msg.getDelstate());

            a = ptmt.executeUpdate();
            SuperUtil.release(conn, ptmt, rs);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return a;
    }    
//    public int deleteMsg(String id) {//删除用户(意思是修改状态,假删除)
//
//        int a = 0;
//        String sql = "update Jabg set delstate='-1'  where id='"+id+"' ";
//        //System.out.println(sql);
//            try {
//            conn = SuperUtil.getConnection();
//            ptmt = conn.prepareStatement(sql);
//            a = ptmt.executeUpdate();
//            SuperUtil.release(conn, ptmt, rs);
//        } catch (SQLException e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
//        return a;
//    }    
    public int tj(String id) {//提交到负责人进行审核

        int a = 0;
        String sql = "update Jabg set state='1'  where Jabgid='"+id+"' ";
        //System.out.println(sql);
            try {
            conn = SuperUtil.getConnection();
            ptmt = conn.prepareStatement(sql);
            a = ptmt.executeUpdate();
            SuperUtil.release(conn, ptmt, rs);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return a;
    }    
    public int bj(  String dsr, String ay, String larq, String cfjdswh, String cfnr,
            String zxfs, String zxrq, String zxjg, String byxzcfdly, String cbrqm, String cbrqmsj, String Jabgid ) {//修改信息时

        int a = 0;
        String sql = "update Jabg set dsr=?,ay=?,larq=?,cfjdswh=?,cfnr=?,zxfs=?,\r\n" + 
                "                 zxrq=?,zxjg=?,byxzcfdly=?,cbrqm=?,cbrqmsj=? where Jabgid=? ";
        //System.out.println(sql);
            try {
            conn = SuperUtil.getConnection();
            ptmt = conn.prepareStatement(sql);
            ptmt.setString(1, dsr);
            ptmt.setString(2, ay);
            ptmt.setString(3, larq);
            ptmt.setString(4, cfjdswh);
            ptmt.setString(5, cfnr);
            ptmt.setString(6, zxfs);
            ptmt.setString(7, zxrq);
            ptmt.setString(8, zxjg);
            ptmt.setString(9, byxzcfdly);
            ptmt.setString(10, cbrqm);
            ptmt.setString(11, cbrqmsj);
            ptmt.setString(12, Jabgid);
            a = ptmt.executeUpdate();
            SuperUtil.release(conn, ptmt, rs);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return a;
    }    
    public int fzrsh(String fzrspyj,String fzrqm,String fzrqmsj,String state,String id) {//分管所领导审核,填写审核意见

        int a = 0;
        String sql = "update jabg set fzrspyj=?,fzrqm=?,fzrqmsj=?,state=? where jabgid=? ";
        // System.out.println(sql);
            try {
            conn = SuperUtil.getConnection();
            ptmt = conn.prepareStatement(sql);
            ptmt.setString(1,fzrspyj);
            ptmt.setString(2, fzrqm);
            ptmt.setString(3, fzrqmsj);
            ptmt.setString(4, state);
            ptmt.setString(5, id);
            a = ptmt.executeUpdate();
            SuperUtil.release(conn, ptmt, rs);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return a;
    }
}

第三步编写独立方法

增加方法

package com.ajsljl.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//案件记录表添加记录
import com.dao.AJSLBDao;
import com.model.AJSLB;

import net.sf.json.JSONObject;

public class AJsljlAdd extends HttpServlet{
    AJSLBDao ajsldao=new AJSLBDao();
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        String id="";
        String ajly = request.getParameter("ajly");    
        String afdw = request.getParameter("afdw");    
        String slsj = request.getParameter("slsj");    
        String zzjgdm = request.getParameter("zzjgdm");    
        String dwmc = request.getParameter("dwmc");    
        String dz = request.getParameter("dz");    
        String ajzy = request.getParameter("ajzy");    
        String jbrqm = request.getParameter("jbrqm");    
        String jbrqmsj = request.getParameter("jbrqmsj");    
        String frdbrzjlx = request.getParameter("frdbrzjlx");    
        String sydwzsh = request.getParameter("sydwzsh");    
        String swdjh = request.getParameter("swdjh");    
        String fzryj = request.getParameter("fzryj");    
        String fzrqm = request.getParameter("fzrqm");    
        String fzrqmsj = request.getParameter("fzrqmsj");    
        String yyzz = request.getParameter("yyzz");    
        String frdbr = request.getParameter("frdbr");    
        String frdbrzjhm = request.getParameter("frdbrzjhm");    
        String state = request.getParameter("state");    
        String delstate = request.getParameter("delstate");        
        String tyshxydm = request.getParameter("tyshxydm");    
        String gszch = request.getParameter("gszch");        
        String zw = request.getParameter("zw");    
        String lxdh = request.getParameter("lxdh");        
        String jyzmz = request.getParameter("jyzmz");    
        String jyzxb = request.getParameter("jyzxb");        
        String jyzdz = request.getParameter("jyzdz");    
        String cbr = request.getParameter("cbr");    
        String shzzdjzh = request.getParameter("shzzdjzh");    
        AJSLB aj=new AJSLB(id,ajly,afdw,yyzz,frdbr,frdbrzjhm,frdbrzjlx,
                 dwmc,dz,tyshxydm,gszch,zzjgdm,swdjh,sydwzsh,
                 shzzdjzh,jyzxb,jyzmz,jyzdz,lxdh,zw,slsj,ajzy,
                 jbrqm, jbrqmsj,  fzryj,  fzrqm,  fzrqmsj,state,delstate,cbr);
        if (ajsldao.addMsg(aj)>0) {
            JSONObject jsonarray = new JSONObject();
            jsonarray.put("status", 1);
            jsonarray.put("msg", "提交成功");
            jsonarray.put("data", aj);
            PrintWriter out = response.getWriter();
            out.write(jsonarray.toString());
        
            } else {
                JSONObject jsonarray = new JSONObject();
                jsonarray.put("status", 0);
                jsonarray.put("msg", "提交失败!");
                PrintWriter out = response.getWriter();
                out.write(jsonarray.toString());
                
        }
        
        
    }
}

编辑方法

package com.ajsljl.controller;
//编辑详情
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.dao.AJSLBDao;

import net.sf.json.JSONObject;

public class AJsljlBJ extends HttpServlet{
    AJSLBDao ajsldao=new AJSLBDao();
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        
        String id = request.getParameter("id1");    
        String ajly = request.getParameter("ajly");    
        String afdw = request.getParameter("afdw");    
        String slsj = request.getParameter("slsj");    
        String zzjgdm = request.getParameter("zzjgdm");    
        String dwmc = request.getParameter("dwmc");    
        String dz = request.getParameter("dz");    
        String ajzy = request.getParameter("ajzy");    
        String jbrqm = request.getParameter("jbrqm");    
        String jbrqmsj = request.getParameter("jbrqmsj");    
        String frdbrzjlx = request.getParameter("frdbrzjlx");    
        String sydwzsh = request.getParameter("sydwzsh");    
        String swdjh = request.getParameter("swdjh");        
        String yyzz = request.getParameter("yyzz");    
        String frdbr = request.getParameter("frdbr");    
        String frdbrzjhm = request.getParameter("frdbrzjhm");    
        String tyshxydm = request.getParameter("tyshxydm");    
        String gszch = request.getParameter("gszch");        
        String zw = request.getParameter("zw");    
        String lxdh = request.getParameter("lxdh");        
        String jyzmz = request.getParameter("jyzmz");    
        String jyzxb = request.getParameter("jyzxb");        
        String jyzdz = request.getParameter("jyzdz");    
        String shzzdjzh = request.getParameter("shzzdjzh");    
        int aj=ajsldao.bj(ajly, afdw, yyzz, frdbr, frdbrzjhm, frdbrzjlx, dwmc, dz, tyshxydm, gszch, zzjgdm, swdjh, sydwzsh, shzzdjzh, jyzxb, jyzmz, jyzdz, lxdh, zw, slsj, ajzy, jbrqm, jbrqmsj, id);
        if (aj>0) {
            JSONObject jsonarray = new JSONObject();
            jsonarray.put("status", 1);
            jsonarray.put("msg", "编辑成功");
            jsonarray.put("data", aj);
            PrintWriter out = response.getWriter();
            out.write(jsonarray.toString());
        
            } else {
                JSONObject jsonarray = new JSONObject();
                jsonarray.put("status", 0);
                jsonarray.put("msg", "编辑失败!");
                PrintWriter out = response.getWriter();
                out.write(jsonarray.toString());
                
        }
        
        
    }
}

删除方法

package com.ajsljl.controller;
//删除
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//案件记录表查询总条数
import com.dao.AJSLBDao;

import net.sf.json.JSONObject;

public class AJsljlDel extends HttpServlet{
    AJSLBDao ajsldao=new AJSLBDao();
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        
        String id = request.getParameter("id");    
        int aj=ajsldao.deleteMsg(id);
        if (aj>0) {
            JSONObject jsonarray = new JSONObject();
            jsonarray.put("status", 1);
            jsonarray.put("msg", "删除成功");
            jsonarray.put("data", aj);
            PrintWriter out = response.getWriter();
            out.write(jsonarray.toString());
        
            } else {
                JSONObject jsonarray = new JSONObject();
                jsonarray.put("status", 0);
                jsonarray.put("msg", "删除失败!");
                PrintWriter out = response.getWriter();
                out.write(jsonarray.toString());
                
        }
        
        
    }
}

分页查询方法

package com.ajsljl.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//案件记录表分页查询
import com.dao.AJSLBDao;
import com.model.AJSLB;

import net.sf.json.JSONObject;

public class AJsljlFy extends HttpServlet{
    AJSLBDao ajsldao=new AJSLBDao();
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        String frdbrzjhm = request.getParameter("frdbrzjhm");    
        String ajly = request.getParameter("ajly");    
        String state = request.getParameter("state");    
        String yyzz = request.getParameter("yyzz");    
        String slsj = request.getParameter("slsj");            
        int curPage= Integer.parseInt(request.getParameter("curPage"));
        int pageSize= Integer.parseInt(request.getParameter("pageSize"));
        List<AJSLB> uu =ajsldao.selectAJSLBFy(state, slsj, ajly, yyzz, frdbrzjhm, curPage, pageSize);
                if (uu.size()>0) {
            JSONObject jsonarray = new JSONObject();
            jsonarray.put("status", 1);
            jsonarray.put("msg", "查询成功");
            jsonarray.put("data", uu);
            PrintWriter out = response.getWriter();
            out.write(jsonarray.toString());
        
            } else {
                JSONObject jsonarray = new JSONObject();
                jsonarray.put("status", 0);
                jsonarray.put("msg", "查询失败!");
                PrintWriter out = response.getWriter();
                out.write(jsonarray.toString());
                
        }
        
        
    }
}

提交方法

package com.ajsljl.controller;
//提交给负责人
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.dao.AJSLBDao;

import net.sf.json.JSONObject;

public class AJsljlTJ extends HttpServlet{
    AJSLBDao ajsldao=new AJSLBDao();
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type");
        response.setHeader("Access-Control-Allow-Credentials", "true");
        
        String id = request.getParameter("id");    
        int aj=ajsldao.tj(id);
        if (aj>0) {
            JSONObject jsonarray = new JSONObject();
            jsonarray.put("status", 1);
            jsonarray.put("msg", "提交成功");
            jsonarray.put("data", aj);
            PrintWriter out = response.getWriter();
            out.write(jsonarray.toString());
        
            } else {
                JSONObject jsonarray = new JSONObject();
                jsonarray.put("status", 0);
                jsonarray.put("msg", "提交失败!");
                PrintWriter out = response.getWriter();
                out.write(jsonarray.toString());
                
        }
        
        
    }
}

 

 

posted @ 2020-05-07 10:55  逐梦武威  阅读(1873)  评论(0编辑  收藏  举报