This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from kennex666/add-demo-Bao
Add lib, add demo file, add entities
- Loading branch information
Showing
21 changed files
with
908 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package bus; | ||
|
||
import java.util.ArrayList; | ||
|
||
import dao.DanhMuc_DAO; | ||
import entities.DanhMuc; | ||
import interfaces.IDanhMuc; | ||
|
||
public class DanhMuc_BUS implements IDanhMuc{ | ||
private DanhMuc_DAO danhMuc_DAO; | ||
|
||
@Override | ||
public boolean addDanhMuc(DanhMuc x) { | ||
// TODO Auto-generated method stub | ||
return false; | ||
} | ||
@Override | ||
public boolean editDanhMuc(DanhMuc x) { | ||
// TODO Auto-generated method stub | ||
return false; | ||
} | ||
@Override | ||
public ArrayList<DanhMuc> getAllDanhMuc() { | ||
// TODO Auto-generated method stub | ||
return danhMuc_DAO.getAllDanhMuc(); | ||
} | ||
@Override | ||
public ArrayList<DanhMuc> getDanhMucTheoID(String x) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
|
||
public DanhMuc_BUS() { | ||
super(); | ||
danhMuc_DAO = new DanhMuc_DAO(); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package bus; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
|
||
import dao.HoaDon_DAO; | ||
import entities.HoaDon; | ||
import interfaces.IHoaDon; | ||
|
||
public class HoaDon_BUS implements IHoaDon{ | ||
private HoaDon_DAO hoaDon_DAO; | ||
|
||
|
||
public HoaDon_BUS() { | ||
super(); | ||
hoaDon_DAO = new HoaDon_DAO(); | ||
} | ||
|
||
@Override | ||
public boolean createHoaDon(HoaDon x) { | ||
// TODO Auto-generated method stub | ||
return hoaDon_DAO.createHoaDon(x); | ||
} | ||
|
||
@Override | ||
public ArrayList<HoaDon> getDanhSachHoaDon() { | ||
// TODO Auto-generated method stub | ||
return hoaDon_DAO.getDanhSachHoaDon(); | ||
} | ||
|
||
@Override | ||
public ArrayList<HoaDon> getDanhSachHoaDonTheoThoiGian(Date batDau, Date ketThuc) { | ||
// TODO Auto-generated method stub | ||
return getDanhSachHoaDonTheoThoiGian(batDau, ketThuc); | ||
} | ||
|
||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package dao; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.util.ArrayList; | ||
|
||
import connectDB.ConnectDB; | ||
import entities.DanhMuc; | ||
import interfaces.IDanhMuc; | ||
|
||
public class DanhMuc_DAO implements IDanhMuc{ | ||
|
||
private Connection conn; | ||
|
||
@Override | ||
public boolean addDanhMuc(DanhMuc x) { | ||
// TODO Auto-generated method stub | ||
return false; | ||
} | ||
@Override | ||
public boolean editDanhMuc(DanhMuc x) { | ||
// TODO Auto-generated method stub | ||
return false; | ||
} | ||
@Override | ||
public ArrayList<DanhMuc> getAllDanhMuc() { | ||
ArrayList<DanhMuc> list = new ArrayList<DanhMuc>(); | ||
|
||
try { | ||
Statement stm = conn.createStatement(); | ||
|
||
String query = "SELECT * FROM DanhMuc"; | ||
|
||
ResultSet rs = stm.executeQuery(query); | ||
|
||
while (rs.next()) { | ||
try { | ||
DanhMuc danhMuc = new DanhMuc(rs.getInt("danhmucid"), rs.getString("tendanhmuc")); | ||
list.add(danhMuc); | ||
} catch (Exception e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
return list; | ||
} | ||
} | ||
|
||
|
||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
return list; | ||
} | ||
|
||
return list; | ||
} | ||
@Override | ||
public ArrayList<DanhMuc> getDanhMucTheoID(String x) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
public DanhMuc_DAO() { | ||
// TODO Auto-generated constructor stub | ||
conn = ConnectDB.getConnection(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package dao; | ||
|
||
import java.sql.Connection; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
|
||
import connectDB.ConnectDB; | ||
import entities.HoaDon; | ||
import interfaces.IHoaDon; | ||
|
||
public class HoaDon_DAO implements IHoaDon{ | ||
private Connection conn; | ||
|
||
public HoaDon_DAO() { | ||
// TODO Auto-generated constructor stub | ||
conn = ConnectDB.getConnection(); | ||
} | ||
|
||
@Override | ||
public boolean createHoaDon(HoaDon x) { | ||
// TODO Auto-generated method stub | ||
|
||
return false; | ||
} | ||
@Override | ||
public ArrayList<HoaDon> getDanhSachHoaDon() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
@Override | ||
public ArrayList<HoaDon> getDanhSachHoaDonTheoThoiGian(Date batDau, Date ketThuc) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package entities; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* | ||
* @author: Dương Thái Bảo | ||
* @lastUpdate: 24/10/2023 | ||
* | ||
*/ | ||
|
||
public class DanhMuc { | ||
private int danhMucID; | ||
private String tenDanhMuc; | ||
public int getDanhMucID() { | ||
return danhMucID; | ||
} | ||
public void setDanhMucID(int danhMucID) { | ||
this.danhMucID = danhMucID; | ||
} | ||
public String getTenDanhMuc() { | ||
return tenDanhMuc; | ||
} | ||
public void setTenDanhMuc(String tenDanhMuc) throws Exception{ | ||
if (tenDanhMuc.trim().isBlank() || tenDanhMuc.trim().isEmpty()) | ||
throw new Exception("Tên danh mục không được để trống!"); | ||
this.tenDanhMuc = tenDanhMuc; | ||
} | ||
public DanhMuc(int danhMucID, String tenDanhMuc) throws Exception{ | ||
super(); | ||
setDanhMucID(danhMucID); | ||
setTenDanhMuc(tenDanhMuc); | ||
} | ||
public DanhMuc() { | ||
super(); | ||
} | ||
|
||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(danhMucID); | ||
} | ||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
DanhMuc other = (DanhMuc) obj; | ||
return danhMucID == other.danhMucID; | ||
} | ||
@Override | ||
public String toString() { | ||
return tenDanhMuc; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.