示例#1
0
  // 插入销售退货记录
  public void insertSalesReturnOrder(SalesReturnOrder order) throws SalesDaoException {
    Connection con = null;
    PreparedStatement ps = null;

    try {
      // 获取数据库连接
      con = DBConnection.getConnection();
      // 设置手动提交事务
      con.setAutoCommit(false);
      ps =
          con.prepareStatement(
              "insert into tb_salesReturnOrder values(?,to_date(?,'yyyy-mm-dd'),?,?,?,?)");
      // 动态传值
      ps.setString(1, order.getSalesReturnId());
      ps.setString(2, order.getTime());
      ps.setString(3, order.getHandle());
      ps.setString(4, order.getCurName());
      ps.setString(5, order.getPayMent());
      ps.setDouble(6, order.getSum());
      // 执行sql语句,添加销售退货记录
      ps.executeUpdate();
      // 添加销售退货详单记录
      insertSalesReturnDetailOrder(con, order.getSalesReturnDetailOrders());
      // 更新库存
      updateStock(con, order.getSalesReturnDetailOrders());
      // 提交事务
      con.commit();
    } catch (SQLException e) {
      try {
        // 事务回滚
        con.rollback();
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
      e.printStackTrace();
      throw new SalesDaoException(e.getMessage());
    } catch (SalesDaoException e) {
      try {
        // 事务回滚
        con.rollback();
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
      e.printStackTrace();
      throw new SalesDaoException(e.getMessage());
    } finally {
      // 关闭资源
      try {
        DBConnection.close(con, ps);
      } catch (SQLException e) {
        e.printStackTrace();
        throw new SalesDaoException(e.getMessage());
      }
    }
  }
示例#2
0
  // 根据销售退货票号查询销售退货详单
  public Vector<Vector<String>> querySalesReturnDetailOrderBySid(String salesReturnId)
      throws SalesDaoException {
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      // 获取数据库连接
      con = DBConnection.getConnection();
      ps = con.prepareStatement("select * from v_salesReturnDetailInfo where salesReturnId=?");
      // 动态传值
      ps.setString(1, salesReturnId);
      // 执行sql语句
      rs = ps.executeQuery();
      // 销售退货详单集合
      Vector<Vector<String>> details = new Vector<Vector<String>>();
      // 遍历结果集
      while (rs.next()) {
        Vector<String> d = new Vector<String>();
        d.add(String.valueOf(rs.getLong("PROID")));
        d.add(rs.getString("proName"));
        d.add(rs.getString("genre"));
        d.add(String.valueOf(rs.getDouble("price")));
        d.add(String.valueOf(rs.getInt("amount")));
        d.add(rs.getString("specific"));
        d.add(rs.getString("madeIn"));
        d.add(rs.getString("remarks"));
        details.add(d);
      }
      return details;
    } catch (SQLException e) {
      e.printStackTrace();
      throw new SalesDaoException(e.getMessage());
    } finally {
      // 关闭资源
      try {
        DBConnection.close(con, ps, rs);
      } catch (SQLException e) {
        e.printStackTrace();
        throw new SalesDaoException(e.getMessage());
      }
    }
  }
示例#3
0
  // 根据销售退货票号查询销售退货单
  public Vector<Vector<String>> querySalesReturnOrderBySid(String salesReturnId)
      throws SalesDaoException {
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      // 获取数据库连接
      con = DBConnection.getConnection();
      ps = con.prepareStatement("select * from tb_salesReturnOrder where id=?");
      // 动态传值
      ps.setString(1, salesReturnId);
      // 执行sql语句
      rs = ps.executeQuery();
      // 销售退货单集合
      Vector<Vector<String>> orders = new Vector<Vector<String>>();

      // 遍历结果集
      while (rs.next()) {
        Vector<String> o = new Vector<String>();
        o.add(rs.getString("id"));
        o.add(rs.getString("customerName"));
        o.add(rs.getString("handle"));
        o.add((rs.getDate("time")).toString());
        o.add(rs.getString("payMent"));
        o.add(String.valueOf(rs.getDouble("sum")));
        orders.add(o);
      }
      return orders;
    } catch (SQLException e) {
      e.printStackTrace();
      throw new SalesDaoException(e.getMessage());
    } finally {
      // 关闭资源
      try {
        DBConnection.close(con, ps, rs);
      } catch (SQLException e) {
        e.printStackTrace();
        throw new SalesDaoException(e.getMessage());
      }
    }
  }