public ArrayList<NhanVien> getTatCaNhanVien() { this.listNhanVien = new ArrayList<NhanVien>(); try { con = SQLConnection.getConnection(); pstmt = con.prepareStatement(sqlGetTatCaNhanVien); rs = pstmt.executeQuery(); while (rs.next()) { this.nhanVien = new NhanVien( rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5)); this.listNhanVien.add(this.nhanVien); } } catch (SQLException e) { e.printStackTrace(); } finally { SQLConnection.closeConnection(this.con); SQLConnection.closePrepareStatement(pstmt); SQLConnection.closeResultSet(rs); } return this.listNhanVien; }
public NhanVien getNhanVienTheoTenDangNhapVaMatKhau(String tenDangNhap, String matKhau) { this.nhanVien = null; try { con = SQLConnection.getConnection(); pstmt = con.prepareStatement(sqlGetNhanVienTheoTenDangNhapVaMatKhau); pstmt.setString(1, tenDangNhap); pstmt.setString(2, matKhau); rs = pstmt.executeQuery(); if (rs.next()) { this.nhanVien = new NhanVien( rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5)); } } catch (SQLException e) { e.printStackTrace(); } finally { SQLConnection.closeConnection(this.con); SQLConnection.closePrepareStatement(pstmt); SQLConnection.closeResultSet(rs); } return this.nhanVien; }
public int deleteNhanVien(int maNhanVien) { int result = 0; try { con = SQLConnection.getConnection(); pstmt = con.prepareStatement(sqlDeleteNhanVien); pstmt.setInt(1, maNhanVien); result = pstmt.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { SQLConnection.closeConnection(this.con); SQLConnection.closePrepareStatement(pstmt); } return result; }
public int addLoaiSanPham(LoaiSanPham lsp) { int result = 0; try { con = SQLConnection.getConnection(); pstmt = con.prepareStatement(sqlAddLoaiSanPham); pstmt.setString(1, lsp.getTen()); pstmt.setString(2, lsp.getMoTa()); result = pstmt.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { SQLConnection.closeConnection(this.con); SQLConnection.closePrepareStatement(pstmt); } return result; }
public int addNhanVien(NhanVien nv) { int result = 0; try { con = SQLConnection.getConnection(); pstmt = con.prepareStatement(sqlAddNhanVien); pstmt.setString(1, nv.getTen()); pstmt.setString(2, nv.getTenDangNhap()); pstmt.setString(3, nv.getMatKhau()); pstmt.setString(4, nv.getGhiChu()); result = pstmt.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { SQLConnection.closeConnection(this.con); SQLConnection.closePrepareStatement(pstmt); } return result; }
public LoaiSanPham getLoaiSanPhamTheoMa(int maLoaiSanPham) { this.loaiSanPham = null; try { con = SQLConnection.getConnection(); pstmt = con.prepareStatement(sqlGetLoaiSanPhamTheoMa); pstmt.setInt(1, maLoaiSanPham); rs = pstmt.executeQuery(); if (rs.next()) { this.loaiSanPham = new LoaiSanPham(rs.getInt(1), rs.getString(2), rs.getString(3)); } } catch (SQLException e) { e.printStackTrace(); } finally { SQLConnection.closeConnection(this.con); SQLConnection.closePrepareStatement(pstmt); SQLConnection.closeResultSet(rs); } return this.loaiSanPham; }
public ArrayList<LoaiSanPham> getTatCaLoaiSanPham() { this.listLoaiSanPham = new ArrayList<LoaiSanPham>(); try { con = SQLConnection.getConnection(); pstmt = con.prepareStatement(sqlGetTatCaLoaiSanPham); rs = pstmt.executeQuery(); while (rs.next()) { this.loaiSanPham = new LoaiSanPham(rs.getInt(1), rs.getString(2), rs.getString(3)); this.listLoaiSanPham.add(this.loaiSanPham); } } catch (SQLException e) { e.printStackTrace(); } finally { SQLConnection.closeConnection(this.con); SQLConnection.closePrepareStatement(pstmt); SQLConnection.closeResultSet(rs); } return this.listLoaiSanPham; }