hs2586258吧 关注:142贴子:1,258
总算是做出了个能看的鬼=-=


1楼2015-08-13 11:08回复
    package dao;
    import java.sql.*;
    public class BaseDao {
    private static final String DRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
    private static final String URL="jdbc:sqlserver://localhost:1433;databaseName=ymw";
    private static final String USBR="hs";
    private static final String PWD="123";
    public static Connection con;
    public static PreparedStatement ps;
    public static ResultSet rs;
    public static CallableStatement cs;
    public static Connection getCon(){
    try {
    Class.forName(DRIVER);
    con=DriverManager.getConnection(URL,USBR,PWD);
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    return con;
    }
    public void closeAll(Connection con,CallableStatement cs,ResultSet rs){
    try {
    if(null!=rs){
    rs.close();
    }if(null!=ps){
    ps.close();
    }if(null!=con){
    con.close();
    }
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }
    }


    2楼2015-08-13 11:11
    回复
      2025-08-13 06:30:05
      广告
      不感兴趣
      开通SVIP免广告

      package dao;
      import entity.EBOD;
      public interface IEBODDao {
      public int insert(EBOD ebod);
      }


      3楼2015-08-13 11:11
      回复

        package dao;
        import java.util.ArrayList;
        import entity.EBPC;
        public interface IEBPCDao {
        public int insert_info(EBPC ebpc);
        public int update_info(EBPC ebpc);
        public int delete_info(int id);
        public ArrayList<EBPC> sel_by_parentid(int parent_id);
        }


        4楼2015-08-13 11:11
        回复

          package dao;
          import java.util.ArrayList;
          import entity.EBP;
          public interface IEBPDao {
          public int insert_info(EBP ebp);
          public int delete_info(int id);
          public int update_info(EBP ebp);
          //查询全部;根据父标签id查;根据子标签id查;
          public ArrayList<EBP> sel_info(EBP ebp);
          public EBP sel_info(int id);
          }


          5楼2015-08-13 11:12
          回复

            package dao;
            import entity.order;
            public interface IorderDao {
            public int insert_info(order ord);
            }


            6楼2015-08-13 11:12
            回复

              package entity;
              public class EBOD {
              private int eod_id;
              private int eo_id;
              private int ep_id;
              private int eod_quantity;
              private double eod_cost;
              public int getEod_id() {
              return eod_id;
              }
              public void setEod_id(int eodId) {
              eod_id = eodId;
              }
              public int getEo_id() {
              return eo_id;
              }
              public void setEo_id(int eoId) {
              eo_id = eoId;
              }
              public int getEp_id() {
              return ep_id;
              }
              public void setEp_id(int epId) {
              ep_id = epId;
              }
              public int getEod_quantity() {
              return eod_quantity;
              }
              public void setEod_quantity(int eodQuantity) {
              eod_quantity = eodQuantity;
              }
              public double getEod_cost() {
              return eod_cost;
              }
              public void setEod_cost(double eodCost) {
              eod_cost = eodCost;
              }
              }


              7楼2015-08-13 11:13
              回复
                package entity;
                public class EBP {
                private int id;
                private String name;
                private String description;
                private double price;
                private int stopk;//库存
                private int epc_id;//对应的:父商品分类id
                private int child_id;//对应的:子商品分类id
                private String file_name;//图片地址
                //工具列:
                private int ep_num;//商品数量;
                public int getId() {
                return id;
                }
                public void setId(int id) {
                this.id = id;
                }
                public String getName() {
                return name;
                }
                public void setName(String name) {
                this.name = name;
                }
                public String getDescription() {
                return description;
                }
                public void setDescription(String description) {
                this.description = description;
                }
                public double getPrice() {
                return price;
                }
                public void setPrice(double price) {
                this.price = price;
                }
                public int getStopk() {
                return stopk;
                }
                public void setStopk(int stopk) {
                this.stopk = stopk;
                }
                public int getEpc_id() {
                return epc_id;
                }
                public void setEpc_id(int epcId) {
                epc_id = epcId;
                }
                public int getChild_id() {
                return child_id;
                }
                public void setChild_id(int childId) {
                child_id = childId;
                }
                public String getFile_name() {
                return file_name;
                }
                public void setFile_name(String fileName) {
                file_name = fileName;
                }
                public int getEp_num() {
                return ep_num;
                }
                public void setEp_num(int epNum) {
                ep_num = epNum;
                }
                }


                8楼2015-08-13 11:13
                回复
                  2025-08-13 06:24:05
                  广告
                  不感兴趣
                  开通SVIP免广告

                  package entity;
                  public class EBPC {
                  private int id;
                  private String name;
                  private int parent_id;
                  public int getId() {
                  return id;
                  }
                  public void setId(int id) {
                  this.id = id;
                  }
                  public String getName() {
                  return name;
                  }
                  public void setName(String name) {
                  this.name = name;
                  }
                  public int getParent_id() {
                  return parent_id;
                  }
                  public void setParent_id(int parentId) {
                  parent_id = parentId;
                  }
                  }


                  9楼2015-08-13 11:14
                  回复

                    package entity;
                    public class order {
                    private int eo_id;
                    private String eo_user_id;
                    private String eo_user_name;
                    private String eo_user_address;
                    private String eo_create_time;
                    private double eo_cost;
                    private int eo_status;
                    private String eo_No;
                    private String eu_mobile;
                    public String getEu_mobile() {
                    return eu_mobile;
                    }
                    public void setEu_mobile(String euMobile) {
                    eu_mobile = euMobile;
                    }
                    public int getEo_id() {
                    return eo_id;
                    }
                    public void setEo_id(int eoId) {
                    eo_id = eoId;
                    }
                    public String getEo_user_id() {
                    return eo_user_id;
                    }
                    public void setEo_user_id(String eoUserId) {
                    eo_user_id = eoUserId;
                    }
                    public String getEo_user_name() {
                    return eo_user_name;
                    }
                    public void setEo_user_name(String eoUserName) {
                    eo_user_name = eoUserName;
                    }
                    public String getEo_user_address() {
                    return eo_user_address;
                    }
                    public void setEo_user_address(String eoUserAddress) {
                    eo_user_address = eoUserAddress;
                    }
                    public String getEo_create_time() {
                    return eo_create_time;
                    }
                    public void setEo_create_time(String eoCreateTime) {
                    eo_create_time = eoCreateTime;
                    }
                    public double getEo_cost() {
                    return eo_cost;
                    }
                    public void setEo_cost(double eoCost) {
                    eo_cost = eoCost;
                    }
                    public int getEo_status() {
                    return eo_status;
                    }
                    public void setEo_status(int eoStatus) {
                    eo_status = eoStatus;
                    }
                    public String getEo_No() {
                    return eo_No;
                    }
                    public void setEo_No(String eoNo) {
                    eo_No = eoNo;
                    }
                    }


                    10楼2015-08-13 11:14
                    回复

                      package dao.impl;
                      import java.sql.SQLException;
                      import dao.BaseDao;
                      import dao.IEBODDao;
                      import entity.EBOD;
                      public class EBODDaoImpl extends BaseDao implements IEBODDao {
                      public int insert(EBOD ebod) {
                      int i=0;
                      String sql="insert into dbo.easybuy_order_detail values(?,?,?,?)";
                      try {
                      ps=getCon().prepareStatement(sql);
                      ps.setInt(1, ebod.getEo_id());
                      ps.setInt(2, ebod.getEp_id());
                      ps.setInt(3, ebod.getEod_quantity());
                      ps.setDouble(4, ebod.getEod_cost());
                      i=ps.executeUpdate();
                      } catch (SQLException e) {
                      e.printStackTrace();
                      }finally{
                      this.closeAll(con, cs, rs);
                      }
                      return i;
                      }
                      }


                      11楼2015-08-13 11:14
                      回复

                        package dao.impl;
                        import java.sql.SQLException;
                        import java.util.ArrayList;
                        import dao.BaseDao;
                        import dao.IEBPCDao;
                        import entity.EBPC;
                        public class EBPCDaoImpl extends BaseDao implements IEBPCDao {
                        public ArrayList<EBPC> sel_by_parentid(int parentId) {
                        ArrayList<EBPC> list=new ArrayList<EBPC>();
                        String sql="select * from easybuy_product_category where epc_parent_id=?";
                        try {
                        ps=getCon().prepareStatement(sql);
                        ps.setInt(1,parentId);
                        rs=ps.executeQuery();
                        while(rs.next()){
                        EBPC ebpc=new EBPC();
                        ebpc.setId(rs.getInt(1));
                        ebpc.setName(rs.getString(2));
                        ebpc.setParent_id(rs.getInt(3));
                        list.add(ebpc);
                        }
                        } catch (SQLException e) {
                        e.printStackTrace();
                        }
                        return list;
                        }
                        public int delete_info(int id) {
                        // TODO Auto-generated method stub
                        return 0;
                        }
                        public int insert_info(EBPC ebpc) {
                        // TODO Auto-generated method stub
                        return 0;
                        }
                        public int update_info(EBPC ebpc) {
                        // TODO Auto-generated method stub
                        return 0;
                        }
                        }


                        12楼2015-08-13 11:15
                        回复

                          package dao.impl;
                          import java.sql.SQLException;
                          import java.util.ArrayList;
                          import dao.BaseDao;
                          import dao.IEBPDao;
                          import entity.EBP;
                          public class EBPDaoImpl extends BaseDao implements IEBPDao {
                          public int delete_info(int id) {
                          // TODO Auto-generated method stub
                          return 0;
                          }
                          public int insert_info(EBP ebp) {
                          // TODO Auto-generated method stub
                          return 0;
                          }
                          public ArrayList<EBP> sel_info(EBP ebp) {
                          ArrayList<EBP> list=new ArrayList<EBP>();
                          String sql="select * from dbo.easybuy_product";
                          if(null!=ebp && ebp.getChild_id()!=0){
                          sql=sql+" where epc_child_id="+ebp.getChild_id();
                          }
                          try {
                          ps=getCon().prepareStatement(sql);
                          rs=ps.executeQuery();
                          while(rs.next()){
                          EBP eb=new EBP();
                          eb.setId(rs.getInt("ep_id"));
                          eb.setName(rs.getString("ep_name"));
                          eb.setDescription(rs.getString("ep_description"));
                          eb.setPrice(rs.getDouble("ep_price"));
                          eb.setStopk(rs.getInt("ep_stopk"));
                          eb.setEpc_id(rs.getInt("epc_id"));
                          eb.setChild_id(rs.getInt("epc_child_id"));
                          eb.setFile_name(rs.getString("ep_file_name"));
                          eb.setEp_num(rs.getInt("ep_num"));
                          list.add(eb);
                          }
                          } catch (SQLException e) {
                          e.printStackTrace();
                          }finally{
                          this.closeAll(con, cs, rs);
                          }
                          return list;
                          }
                          public int update_info(EBP ebp) {
                          // TODO Auto-generated method stub
                          return 0;
                          }
                          public EBP sel_info(int id) {
                          EBP eb=new EBP();
                          String sql="select * from easybuy_product where ep_id=?";
                          try {
                          ps=getCon().prepareStatement(sql);
                          ps.setInt(1,id);
                          rs=ps.executeQuery();
                          if(rs.next()){
                          eb.setId(rs.getInt("ep_id"));
                          eb.setName(rs.getString("ep_name"));
                          eb.setDescription(rs.getString("ep_description"));
                          eb.setPrice(rs.getDouble("ep_price"));
                          eb.setStopk(rs.getInt("ep_stopk"));
                          eb.setEpc_id(rs.getInt("epc_id"));
                          eb.setChild_id(rs.getInt("epc_child_id"));
                          eb.setFile_name(rs.getString("ep_file_name"));
                          eb.setEp_num(rs.getInt("ep_num"));
                          }
                          } catch (SQLException e) {
                          e.printStackTrace();
                          }finally{
                          this.closeAll(con, cs, rs);
                          }
                          return eb;
                          }
                          }


                          13楼2015-08-13 11:15
                          回复

                            package dao.impl;
                            import java.sql.SQLException;
                            import java.sql.Types;
                            import dao.BaseDao;
                            import dao.IorderDao;
                            import entity.order;
                            public class OrderDaoImpl extends BaseDao implements IorderDao {
                            public int insert_info(order ord) {
                            String sql="{call insert_order_info(?,?,?,?,?,?)}";
                            int i=0;
                            try {
                            cs=getCon().prepareCall(sql);
                            cs.setString(1, ord.getEo_user_name());
                            cs.setString(2, ord.getEo_user_address());
                            cs.setDouble(3, ord.getEo_cost());
                            cs.setString(4, ord.getEo_No());
                            cs.setString(5, ord.getEu_mobile());
                            cs.registerOutParameter(6, Types.INTEGER);
                            int j = cs.executeUpdate();
                            System.out.println("j:"+j);
                            if(j>0){
                            System.out.println("id:"+cs.getInt(6));
                            i=cs.getInt(6);
                            }
                            } catch (SQLException e) {
                            e.printStackTrace();
                            } finally{
                            this.closeAll(con, cs, rs);
                            }
                            //输出订单编号:
                            return i;
                            }
                            }


                            14楼2015-08-13 11:15
                            回复
                              2025-08-13 06:18:05
                              广告
                              不感兴趣
                              开通SVIP免广告

                              package servlet;
                              import java.io.IOException;
                              import java.io.PrintWriter;
                              import java.util.ArrayList;
                              import javax.servlet.ServletException;
                              import javax.servlet.http.HttpServlet;
                              import javax.servlet.http.HttpServletRequest;
                              import javax.servlet.http.HttpServletResponse;
                              import entity.EBP;
                              public class Del_Pro_Servlet extends HttpServlet {
                              /**
                              * Constructor of the object.
                              */
                              public Del_Pro_Servlet() {
                              super();
                              }
                              /**
                              * Destruction of the servlet. <br>
                              */
                              public void destroy() {
                              super.destroy(); // Just puts "destroy" string in log
                              // Put your code here
                              }
                              /**
                              * The doGet method of the servlet. <br>
                              *
                              * This method is called when a form has its tag value method equals to get.
                              *
                              * @param request the request send by the client to the server
                              * @param response the response send by the server to the client
                              * @throws ServletException if an error occurred
                              * @throws IOException if an error occurred
                              */
                              public void doGet(HttpServletRequest request, HttpServletResponse response)
                              throws ServletException, IOException {
                              request.setCharacterEncoding("utf-8");
                              Integer id=Integer.parseInt(request.getParameter("id"));
                              ArrayList<EBP> list_ebps=
                              (ArrayList<EBP>)request.getSession().getAttribute("list_GWC");
                              for(int i=0;i<list_ebps.size();i++){
                              if(id==list_ebps.get(i).getId()){
                              list_ebps.remove(i);
                              }
                              }
                              response.sendRedirect("GWC.jsp");
                              }
                              /**
                              * The doPost method of the servlet. <br>
                              *
                              * This method is called when a form has its tag value method equals to post.
                              *
                              * @param request the request send by the client to the server
                              * @param response the response send by the server to the client
                              * @throws ServletException if an error occurred
                              * @throws IOException if an error occurred
                              */
                              public void doPost(HttpServletRequest request, HttpServletResponse response)
                              throws ServletException, IOException {
                              response.setContentType("text/html");
                              PrintWriter out = response.getWriter();
                              out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
                              out.println("<HTML>");
                              out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
                              out.println(" <BODY>");
                              out.print(" This is ");
                              out.print(this.getClass());
                              out.println(", using the POST method");
                              out.println(" </BODY>");
                              out.println("</HTML>");
                              out.flush();
                              out.close();
                              }
                              /**
                              * Initialization of the servlet. <br>
                              *
                              * @throws ServletException if an error occurs
                              */
                              public void init() throws ServletException {
                              // Put your code here
                              }
                              }


                              15楼2015-08-13 11:16
                              回复