Skip to content

Commit

Permalink
Fix using forms when sign out & add frmPhanLop
Browse files Browse the repository at this point in the history
  • Loading branch information
18520339 committed Dec 17, 2020
1 parent 41d59b4 commit 2be0e33
Show file tree
Hide file tree
Showing 77 changed files with 1,201 additions and 77 deletions.
1 change: 1 addition & 0 deletions BUS/BUS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<Compile Include="KetQuaBUS.cs" />
<Compile Include="KhoiLopBUS.cs" />
<Compile Include="LoaiNguoiDungBUS.cs" />
<Compile Include="PhanLopBUS.cs" />
<Compile Include="Reports\KQHSCaNamBUS.cs" />
<Compile Include="Reports\KQHSMonHocBUS.cs" />
<Compile Include="LopBUS.cs" />
Expand Down
23 changes: 21 additions & 2 deletions BUS/HocSinhBUS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public void HienThi(
txtHoTenCha.DataBindings.Add("Text", bindingSource, "HoTenCha");

cmbNgheNghiepCha.DataBindings.Clear();
cmbNgheNghiepCha.DataBindings.Add("SelectedValue", bindingSource, "MaNNghiepCha");
cmbNgheNghiepCha.DataBindings.Add("SelectedValue", bindingSource, "MaNgheCha");

txtHoTenMe.DataBindings.Clear();
txtHoTenMe.DataBindings.Add("Text", bindingSource, "HoTenMe");

cmbNgheNghiepMe.DataBindings.Clear();
cmbNgheNghiepMe.DataBindings.Add("SelectedValue", bindingSource, "MaNNghiepMe");
cmbNgheNghiepMe.DataBindings.Add("SelectedValue", bindingSource, "MaNgheMe");

txtEmail.DataBindings.Clear();
txtEmail.DataBindings.Add("Text", bindingSource, "Email");
Expand All @@ -103,13 +103,32 @@ public void HienThiHocSinhTheoLop(
dataGridViewX.DataSource = bs;
}

public void HienThiHocSinhTheoLop(string namHoc, string khoiLop, string lop, ListViewEx listViewEx)
{
DataTable dataTable = HocSinhDAO.Instance.LayDanhSachHocSinhTheoLop(namHoc, khoiLop, lop);
listViewEx.Items.Clear();

foreach (DataRow Row in dataTable.Rows)
{
ListViewItem item = new ListViewItem();
item.Text = Row["MaHocSinh"].ToString();
item.SubItems.Add(Row["HoTen"].ToString());
listViewEx.Items.Add(item);
}
}

public void HienThiComboBox(string namHoc, string lop, ComboBoxEx comboBox)
{
comboBox.DataSource = HocSinhDAO.Instance.LayDanhSachHocSinh(namHoc, lop);
comboBox.DisplayMember = "HoTen";
comboBox.ValueMember = "MaHocSinh";
}

public DataTable LayDanhSachHocSinhTheoNamHoc(string namHoc)
{
return HocSinhDAO.Instance.LayDanhSachHocSinhTheoNamHoc(namHoc);
}

public IList<HocSinhDTO> Report()
{
DataTable dataTable = HocSinhDAO.Instance.LayDanhSachHocSinh();
Expand Down
8 changes: 8 additions & 0 deletions BUS/KhoiLopBUS.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DAO;
using DevComponents.DotNetBar.Controls;
using System;
using System.Data;
using System.Windows.Forms;

Expand Down Expand Up @@ -37,6 +38,13 @@ public void HienThiComboBox(ComboBoxEx comboBox)
comboBox.ValueMember = "MaKhoiLop";
}

public void HienThiComboBox(string khoiLop, ComboBoxEx comboBox)
{
comboBox.DataSource = KhoiLopDAO.Instance.LayDanhSachKhoiLop(khoiLop);
comboBox.DisplayMember = "TenKhoiLop";
comboBox.ValueMember = "MaKhoiLop";
}

public void HienThiDgvCmbCol(DataGridViewComboBoxColumn cmbColumn)
{
cmbColumn.DataSource = KhoiLopDAO.Instance.LayDanhSachKhoiLop();
Expand Down
7 changes: 7 additions & 0 deletions BUS/LopBUS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ public void HienThiComboBox(string namHoc, ComboBoxEx comboBox)
comboBox.ValueMember = "MaLop";
}

public void HienThiComboBox(string khoiLop, string namHoc, ComboBoxEx comboBox)
{
comboBox.DataSource = LopDAO.Instance.LayDanhSachLop(khoiLop, namHoc);
comboBox.DisplayMember = "TenLop";
comboBox.ValueMember = "MaLop";
}

public void HienThiDgvCmbCol(DataGridViewComboBoxColumn cmbColumn)
{
cmbColumn.DataSource = LopDAO.Instance.LayDanhSachLop();
Expand Down
4 changes: 2 additions & 2 deletions BUS/NgheNghiepBUS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void HienThiDgvCmbColCha(DataGridViewComboBoxColumn cmbColumn)
cmbColumn.DataSource = NgheNghiepDAO.Instance.LayDanhSachNgheNghiep();
cmbColumn.DisplayMember = "TenNghe";
cmbColumn.ValueMember = "MaNghe";
cmbColumn.DataPropertyName = "MaNNghiepCha";
cmbColumn.DataPropertyName = "MaNgheCha";
cmbColumn.HeaderText = "Nghề nghiệp cha";
}

Expand All @@ -51,7 +51,7 @@ public void HienThiDgvCmbColMe(DataGridViewComboBoxColumn cmbColumn)
cmbColumn.DataSource = NgheNghiepDAO.Instance.LayDanhSachNgheNghiep();
cmbColumn.DisplayMember = "TenNghe";
cmbColumn.ValueMember = "MaNghe";
cmbColumn.DataPropertyName = "MaNNghiepMe";
cmbColumn.DataPropertyName = "MaNgheMe";
cmbColumn.HeaderText = "Nghề nghiệp mẹ";
}

Expand Down
42 changes: 42 additions & 0 deletions BUS/PhanLopBUS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using DAO;
using DevComponents.DotNetBar.Controls;
using DTO;
using System.Windows.Forms;

namespace BUS
{
public class PhanLopBUS
{
private static PhanLopBUS instance;

private PhanLopBUS() { }

public static PhanLopBUS Instance
{
get
{
if (instance == null) instance = new PhanLopBUS();
return instance;
}
private set => instance = value;
}

public void LuuHocSinhVaoBangPhanLop(string namHoc, string khoiLop, string lop, ListViewEx listViewEx)
{
foreach (ListViewItem item in listViewEx.Items)
{
PhanLopDTO phanLop = new PhanLopDTO(namHoc, khoiLop, lop, item.SubItems[0].Text.ToString());
PhanLopDAO.Instance.LuuHocSinhVaoBangPhanLop(phanLop);
}
}

public void XoaHocSinhKhoiBangPhanLop(string namHoc, string khoiLop, string lop, ListViewEx listViewEx)
{
foreach (ListViewItem item in listViewEx.Items)
{
PhanLopDTO phanLop = new PhanLopDTO(namHoc, khoiLop, lop, item.SubItems[0].Text.ToString());
PhanLopDAO.Instance.XoaHocSinhKhoiBangPhanLop(phanLop);
}
}
}
}
Binary file modified BUS/bin/Debug/BUS.dll
Binary file not shown.
Binary file modified BUS/bin/Debug/BUS.pdb
Binary file not shown.
Binary file modified BUS/bin/Debug/DAO.dll
Binary file not shown.
Binary file modified BUS/bin/Debug/DAO.pdb
Binary file not shown.
Binary file modified BUS/bin/Debug/DTO.dll
Binary file not shown.
Binary file modified BUS/bin/Debug/DTO.pdb
Binary file not shown.
Binary file modified BUS/bin/Release/BUS.dll
Binary file not shown.
Binary file modified BUS/bin/Release/BUS.pdb
Binary file not shown.
Binary file modified BUS/bin/Release/DAO.dll
Binary file not shown.
Binary file modified BUS/bin/Release/DAO.pdb
Binary file not shown.
Binary file modified BUS/bin/Release/DTO.dll
Binary file not shown.
Binary file modified BUS/bin/Release/DTO.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions DAO/DAO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Compile Include="KetQuaDAO.cs" />
<Compile Include="KhoiLopDAO.cs" />
<Compile Include="LoaiNguoiDungDAO.cs" />
<Compile Include="PhanLopDAO.cs" />
<Compile Include="Reports\KQHSCaNamDAO.cs" />
<Compile Include="Reports\KQHSMonHocDAO.cs" />
<Compile Include="LopDAO.cs" />
Expand Down
16 changes: 16 additions & 0 deletions DAO/HocSinhDAO.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DTO;
using System;
using System.Data;

namespace DAO
Expand Down Expand Up @@ -32,6 +33,21 @@ public DataTable LayDanhSachHocSinh(string namHoc, string lop, bool tatCaCot = f
return DataProvider.Instance.ExecuteQuery(query, parameters);
}

public DataTable LayDanhSachHocSinhTheoLop(string namHoc, string khoiLop, string lop)
{
string query = "EXEC LayDanhSachHocSinhTheoLop @maNamHoc , @maKhoiLop , @maLop";
object[] parameters = new object[] { namHoc, khoiLop, lop };
return DataProvider.Instance.ExecuteQuery(query, parameters);
}

public DataTable LayDanhSachHocSinhTheoNamHoc(string namHoc)
{
string query = "EXEC LayDanhSachHocSinhTheoNamHoc @maNamHoc";
object[] parameters = new object[] { namHoc };
return DataProvider.Instance.ExecuteQuery(query, parameters);
}


public void CapNhatHocSinh(DataTable dataTable)
{
DataProvider.Instance.UpdateTable(dataTable, "HOCSINH");
Expand Down
11 changes: 10 additions & 1 deletion DAO/KhoiLopDAO.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Data;
using System;
using System.Data;

namespace DAO
{
Expand All @@ -24,6 +25,14 @@ public DataTable LayDanhSachKhoiLop()
return DataProvider.Instance.ExecuteQuery(query);
}

public DataTable LayDanhSachKhoiLop(string khoiLop)
{
string query = $"SELECT * FROM KHOILOP WHERE MaKhoiLop = '{khoiLop}'";
if (khoiLop == "KHOI10") query += "OR MaKhoiLop = 'KHOI11'";
else if (khoiLop == "KHOI11") query += "OR MaKhoiLop = 'KHOI12'";
return DataProvider.Instance.ExecuteQuery(query);
}

public void CapNhatKhoiLop(DataTable dataTable)
{
DataProvider.Instance.UpdateTable(dataTable, "KHOILOP");
Expand Down
6 changes: 6 additions & 0 deletions DAO/LopDAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public DataTable LayDanhSachLop(string namHoc)
return DataProvider.Instance.ExecuteQuery(query);
}

public DataTable LayDanhSachLop(string khoiLop, string namHoc)
{
string query = $"SELECT * FROM LOP WHERE MaKhoiLop = '{khoiLop}' AND MaNamHoc = '{namHoc}'";
return DataProvider.Instance.ExecuteQuery(query);
}

public int LaySiSo(string maLop)
{
string query = $"SELECT SiSo FROM LOP WHERE MaLop = '{maLop}'";
Expand Down
36 changes: 36 additions & 0 deletions DAO/PhanLopDAO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using DTO;
using System.Data;

namespace DAO
{
public class PhanLopDAO
{
private static PhanLopDAO instance;

private PhanLopDAO() { }

public static PhanLopDAO Instance
{
get
{
if (instance == null) instance = new PhanLopDAO();
return instance;
}
private set => instance = value;
}

public void LuuHocSinhVaoBangPhanLop(PhanLopDTO phanLop)
{
string query = "EXEC LuuHocSinhVaoBangPhanLop @maNamHoc , @maKhoiLop , @maLop , @maHocSinh";
object[] parameters = new object[] { phanLop.MaNamHoc, phanLop.MaKhoiLop, phanLop.MaLop, phanLop.MaHocSinh };
DataProvider.Instance.ExecuteNonQuery(query, parameters);
}

public void XoaHocSinhKhoiBangPhanLop(PhanLopDTO phanLop)
{
string query = "EXEC XoaHocSinhKhoiBangPhanLop @maNamHoc , @maKhoiLop , @maLop , @maHocSinh";
object[] parameters = new object[] { phanLop.MaNamHoc, phanLop.MaKhoiLop, phanLop.MaLop, phanLop.MaHocSinh };
DataProvider.Instance.ExecuteNonQuery(query, parameters);
}
}
}
Binary file modified DAO/bin/Debug/DAO.dll
Binary file not shown.
Binary file modified DAO/bin/Debug/DAO.pdb
Binary file not shown.
Binary file modified DAO/bin/Debug/DTO.dll
Binary file not shown.
Binary file modified DAO/bin/Debug/DTO.pdb
Binary file not shown.
Binary file modified DAO/bin/Release/DAO.dll
Binary file not shown.
Binary file modified DAO/bin/Release/DAO.pdb
Binary file not shown.
Binary file modified DAO/bin/Release/DTO.dll
Binary file not shown.
Binary file modified DAO/bin/Release/DTO.pdb
Binary file not shown.
52 changes: 52 additions & 0 deletions DATABASE/Procedures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ BEGIN
END
GO

CREATE PROCEDURE LayDanhSachHocSinhTheoNamHoc @maNamHoc VARCHAR(6)
AS
BEGIN
SELECT PL.MaHocSinh, HS.HoTen, LOP.TenLop FROM HOCSINH HS
INNER JOIN PHANLOP PL ON HS.MaHocSinh = PL.MaHocSinh
INNER JOIN LOP ON LOP.MaLop = PL.MaLop
WHERE PL.MaNamHoc = @maNamHoc
END
GO

CREATE PROCEDURE LayDanhSachHocSinhTheoLop
@maNamHoc VARCHAR(6),
@maKhoiLop VARCHAR(10),
@maLop VARCHAR(10)
AS
BEGIN
SELECT PL.MaHocSinh, HS.HoTen, LOP.TenLop FROM HOCSINH HS
INNER JOIN PHANLOP PL ON HS.MaHocSinh = PL.MaHocSinh
INNER JOIN KHOILOP KL ON KL.MaKhoiLop = PL.MaKhoiLop
INNER JOIN LOP ON LOP.MaLop = PL.MaLop
WHERE PL.MaNamHoc = @maNamHoc AND PL.MaKhoiLop = @maKhoiLop AND PL.MaLop = @maLop
END
GO

CREATE PROCEDURE ThemHocSinh
@maHocSinh VARCHAR(6),
@hoTen NVARCHAR(30),
Expand All @@ -57,6 +81,34 @@ GO

--===================================================================================================================================================

CREATE PROCEDURE LuuHocSinhVaoBangPhanLop
@maNamHoc VARCHAR(6),
@maKhoiLop VARCHAR(6),
@maLop VARCHAR(10),
@maHocSinh VARCHAR(6)
AS
BEGIN
INSERT INTO PHANLOP VALUES(@maNamHoc, @maKhoiLop, @maLop, @maHocSinh)
END
GO

CREATE PROCEDURE XoaHocSinhKhoiBangPhanLop
@maNamHoc VARCHAR(6),
@maKhoiLop VARCHAR(6),
@maLop VARCHAR(10),
@maHocSinh VARCHAR(6)
AS
BEGIN
DELETE FROM PHANLOP
WHERE MaNamHoc = @maNamHoc
AND MaKhoiLop = @maKhoiLop
AND MaLop = @maLop
AND MaHocSinh = @maHocSinh
END
GO

--===================================================================================================================================================

CREATE PROCEDURE LayDanhSachDiem
@maHocSinh VARCHAR(6),
@maMonHoc VARCHAR(6),
Expand Down
10 changes: 5 additions & 5 deletions DATABASE/Tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CREATE TABLE LOAINGUOIDUNG
)

INSERT INTO LOAINGUOIDUNG VALUES('LND001', N'Ban giám hiệu')
INSERT INTO LOAINGUOIDUNG VALUES('LND002', N'Giáo viện')
INSERT INTO LOAINGUOIDUNG VALUES('LND002', N'Giáo viên')
INSERT INTO LOAINGUOIDUNG VALUES('LND003', N'Nhân viên giáo vụ')

--===================================================================================================================================================
Expand Down Expand Up @@ -213,15 +213,15 @@ CREATE TABLE HOCSINH
MaDanToc VARCHAR(6) NOT NULL,
MaTonGiao VARCHAR(6) NOT NULL,
HoTenCha NVARCHAR(30) NOT NULL,
MaNNghiepCha VARCHAR(6) NOT NULL,
MaNgheCha VARCHAR(6) NOT NULL,
HoTenMe NVARCHAR(30) NOT NULL,
MaNNghiepMe VARCHAR(6) NOT NULL,
MaNgheMe VARCHAR(6) NOT NULL,
Email NVARCHAR(50) NOT NULL UNIQUE,

CONSTRAINT FK_HOCSINH_DANTOC FOREIGN KEY(MaDanToc) REFERENCES DANTOC(MaDanToc),
CONSTRAINT FK_HOCSINH_TONGIAO FOREIGN KEY(MaTonGiao) REFERENCES TONGIAO(MaTonGiao),
CONSTRAINT FK_HOCSINH_NGHENGHIEPCHA FOREIGN KEY(MaNNghiepCha) REFERENCES NGHENGHIEP(MaNghe),
CONSTRAINT FK_HOCSINH_NGHENGHIEPME FOREIGN KEY(MaNNghiepMe) REFERENCES NGHENGHIEP(MaNghe)
CONSTRAINT FK_HOCSINH_NGHENGHIEPCHA FOREIGN KEY(MaNgheCha) REFERENCES NGHENGHIEP(MaNghe),
CONSTRAINT FK_HOCSINH_NGHENGHIEPME FOREIGN KEY(MaNgheMe) REFERENCES NGHENGHIEP(MaNghe)
)

INSERT INTO HOCSINH VALUES('HS0001', N'Nguyễn Văn Tú', '0', '01/02/2005', N'Long Xuyên', 'DT0001', 'TG0005', N'Biết chết liền', 'NN0005', N'Biết chết liền', 'NN0002', '[email protected]')
Expand Down
1 change: 1 addition & 0 deletions DTO/DTO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<Compile Include="HocLucDTO.cs" />
<Compile Include="HocSinhDTO.cs" />
<Compile Include="KetQuaDTO.cs" />
<Compile Include="PhanLopDTO.cs" />
<Compile Include="Reports\KQHSCaNamDTO.cs" />
<Compile Include="Reports\KQHSMonHocDTO.cs" />
<Compile Include="LopDTO.cs" />
Expand Down
23 changes: 23 additions & 0 deletions DTO/PhanLopDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace DTO
{
public class PhanLopDTO
{
private string maNamHoc;
private string maKhoiLop;
private string maLop;
private string maHocSinh;

public PhanLopDTO(string maNamHoc, string maKhoiLop, string maLop, string maHocSinh)
{
this.maNamHoc = maNamHoc;
this.maKhoiLop = maKhoiLop;
this.maLop = maLop;
this.maHocSinh = maHocSinh;
}

public string MaNamHoc { get => maNamHoc; set => maNamHoc = value; }
public string MaKhoiLop { get => maKhoiLop; set => maKhoiLop = value; }
public string MaLop { get => maLop; set => maLop = value; }
public string MaHocSinh { get => maHocSinh; set => maHocSinh = value; }
}
}
Binary file modified DTO/bin/Debug/DTO.dll
Binary file not shown.
Binary file modified DTO/bin/Debug/DTO.pdb
Binary file not shown.
Binary file modified DTO/bin/Release/DTO.dll
Binary file not shown.
Binary file modified DTO/bin/Release/DTO.pdb
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions QuanLyHocSinh/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyVersion("1.0.3")]
[assembly: AssemblyFileVersion("1.0.3")]
Loading

0 comments on commit 2be0e33

Please sign in to comment.