daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public ArrayList<OfflineStatistic> getDonHangOffline()
  2.     {
  3.         ArrayList<OfflineStatistic> loff = new ArrayList<>();
  4.         try{
  5.             PreparedStatement ps = conn.prepareStatement("SELECT TOP 1000 [DonHangID]\n" +
  6. "      ,[NhanvienID]\n" +
  7. "  FROM [httql].[dbo].[DonHangOffline]");
  8.             ResultSet rs = ps.executeQuery();
  9.             OfflineStatistic off = new OfflineStatistic();
  10.             while(rs.next())
  11.             {
  12.                 off.setDhid(rs.getInt("DonHangID"));
  13.                 System.out.println(rs.getInt("DonHangID"));
  14.                 PreparedStatement st1 = conn.prepareStatement("SELECT TOP 1000 [ID]\n" +
  15. "      ,[ngaydathang]\n" +
  16. "      ,[ChiNhanhID]\n" +
  17. "      ,[MaGiamGiaID]\n" +
  18. "  FROM [httql].[dbo].[DonHang] WHERE ID = ?");
  19.                 st1.setInt(1, off.getDhid());
  20.                 System.out.println(off.getDhid());
  21.                
  22.                 ResultSet rs1 = st1.executeQuery();
  23.                 rs1.next();
  24.                 off.setDate(rs1.getString("ngaydathang"));
  25.                 ps = conn.prepareStatement("SELECT [STT]\n" +
  26. "       , [ID]\n" +
  27. "      ,[soluong]\n" +
  28. "      ,[SanphamID]\n" +
  29. "      ,[DonHangID]\n" +
  30. "      ,[gia]\n" +
  31. "     ,[tensp]\n" +
  32. "  FROM [httql].[dbo].[ChiTietDonHang], [httql].[dbo].[Sanpham] WHERE [SanphamID] = [ID] AND [DonHangID] = ?");
  33.                
  34.                         ps.setInt(1, off.getDhid());
  35.                         ResultSet rs2 = ps.executeQuery();
  36.                 while(rs2.next())
  37.                 {
  38.                     SanPham sp = new SanPham();
  39.                     sp.setId(rs2.getInt("SanphamID"));
  40.                     sp.setTen(rs2.getString("tensp"));
  41.                     sp.setGia(rs2.getInt("gia"));
  42.                     sp.setSoluong(rs2.getInt("soluong"));
  43.                     off.getLsp().add(sp);
  44.                 }
  45.                 loff.add(off);
  46.             }
  47.            
  48.         }catch(Exception e){
  49.             System.out.println(e);
  50.         }
  51.            return loff;
  52.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top