-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLopHocPhan_BLL.cs
191 lines (170 loc) · 6.57 KB
/
LopHocPhan_BLL.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using DAL;
using DTO;
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
namespace BLL
{
public class LopHocPhan_BLL
{
private static LopHocPhan_BLL _Instance;
public static LopHocPhan_BLL Instance
{
get
{
if (_Instance == null)
_Instance = new LopHocPhan_BLL();
return _Instance;
}
}
public int GetNumberOfStudentInClass(string MaLopHP)
{
return LopHocPhan_DAL.Instance.GetNumberOfStudentInClass(MaLopHP);
}
#region Xử lí bên giao diện sinh viên
/*public int GetKiHocHienTai(string MSSV)
{
return LopHocPhan_DAL.Instance.GetKiHocHienTai(MSSV);
}*/
/*public List<LopHocPhan_DTO> GetDailySchoolSchedule(string MSSV, string Thu, int KiHoc, int NamHoc)
{
List<LopHocPhan_DTO> li = LopHocPhan_DAL.Instance.GetListHocPhanOfStudent(MSSV, KiHoc, NamHoc);
List<LopHocPhan_DTO> res = new List<LopHocPhan_DTO>();
foreach (LopHocPhan_DTO lhp in li)
{
if (lhp.tkb != null && lhp.tkb.Thu == Thu)
res.Add(lhp);
}
return res;
}*/
/*public List<LopHocPhan_DTO> GetWeeklySchoolSchedule(string MSSV, int KiHoc, int NamHoc)
{
return LopHocPhan_DAL.Instance.GetListHocPhanOfStudent(MSSV, KiHoc, NamHoc);
}*/
#endregion
/// <summary>
/// Trả về các thông tin cần như: mã HP, tênHP,SoTC,MaGV,HoGV,KiHoc,NamHoc,Thu,TietBD,TietKT
/// </summary>
/// <param name="MaHP"></param>
/// <returns></returns>
public LopHocPhan_AdminEdit GetLopHocPhanByMaHP(string MaHP)
{
return LopHocPhan_DAL.Instance.GetHocPhanByMaHP(MaHP);
}
public List<SinhVienLHP_View> GetSinhVienInLHP(string MaHP)
{
List<SinhVienLHP_View> li = LopHocPhan_DAL.Instance.GetSinhVienInLHP(MaHP);
int stt = 1;
foreach (var sv in li)
sv.STT = stt++;
return li;
}
public bool UpdateSoTC(string MaHP, int SoTC)
{
return LopHocPhan_DAL.Instance.UpdateSoTC(MaHP, SoTC);
}
/// <summary>
/// Hàm này trả về 3 trường hợp:
/// null -> không va chạm;
/// not null nhưng Count == 0 -> sv này đã được thêm vào lớp HP.
/// Và trường hợp còn lại là va chạm lịch học
/// </summary>
/// <param name="MaHP"></param>
/// <param name="MaSV"></param>
/// <param name="KiHoc"></param>
/// <param name="Thu"></param>
/// <param name="TietBD"></param>
/// <param name="TietKT"></param>
/// <returns></returns>
public List<LopHocPhan_AdminEdit> GetListHocPhanConflictOfStudent(string MaHP, string MaSV, int KiHoc,
string Thu, int TietBD, int TietKT)
{
List<LopHocPhan_AdminEdit> li = LopHocPhan_DAL.Instance.GetListHocPhanOfStudent_AddSV(MaSV, KiHoc);
List<LopHocPhan_AdminEdit> conflict = null;
foreach (LopHocPhan_AdminEdit lhp in li)
{
if (lhp.MaHP == MaHP)
{
//Thể hiện là đã có sinh viên này trong lớp HP
return new List<LopHocPhan_AdminEdit>();
}
if (lhp.Thu == Thu && !(TietKT < lhp.TietBD || TietBD > lhp.TietKT))
{
//Đã xảy ra va chạm lịch
if (conflict == null)
conflict = new List<LopHocPhan_AdminEdit>();
conflict.Add(lhp);
}
}
//Trả về danh sách các lớp HP bị va chạm
return conflict;
}
public void AddStudentIntoClass(string MaHP, string MaSV)
{
LopHocPhan_DAL.Instance.AddStudentIntoClass(MaHP, MaSV);
}
public bool DeleteStudent(string MaHP, List<string> liMSSV)
{
return LopHocPhan_DAL.Instance.DeleteStudent(MaHP, liMSSV);
}
public string GetMaKhoaOfLHP(string MaHP)
{
return LopHocPhan_DAL.Instance.GetMaKhoaOfLHP(MaHP);
}
#region các hàm dùng trong việc add,delete lớp học phần
public int InsertModuleClass(LopHocPhan_AdminEdit lhp)
{
bool CheckIsExist = GetLopHocPhanByMaHP(lhp.MaHP) != null;
if (!CheckIsExist)
{
LOP_HOC_PHAN NewModuleClass = new LOP_HOC_PHAN()
{
MaMH = lhp.MaMH,
MaLopHP = lhp.MaHP,
NamHoc = lhp.NamHoc,
KiHoc = lhp.KiHoc,
SoLuongToiDa = lhp.SoLuongMax
};
//1: thêm thành công, 0: thêm thất bại
if (LopHocPhan_DAL.Instance.InsertModuleClass(NewModuleClass))
return 1;
return 0;
}
//Đã có lớp học phần này rồi
return -1;
}
#endregion
public List<InformationClass_DTO> GetInformationClasses()
{
return LopHocPhan_DAL.Instance.GetInformationClasses();
}
public int CountMoudleClass()
{
return LopHocPhan_DAL.Instance.CountModuleClass();
}
public List<ThongBao_DTO> GetNotificationsInSpecificBound(string MaSV, DateTime StartDateFilter)
{
return LopHocPhan_DAL.Instance.GetNotificationsInSpecificBound(MaSV, StartDateFilter);
}
public bool DeleteMoudleClass(string idClass)
{
return LopHocPhan_DAL.Instance.DeleteModuleClass(idClass);
}
public List<InformationSubject_DTO> getListSubjects()
{
return LopHocPhan_DAL.Instance.getListSubjects();
}
public List<string> getListStudent(string maKhoa, string maLHP)
{
return LopHocPhan_DAL.Instance.getListStudent(maKhoa, maLHP);
}
public LopHocPhan_DTO GetTenMonHocByMaLHP(string MaLHP)
{
return LopHocPhan_DAL.Instance.GetInfoLopHocPhanByMaLHP(MaLHP);
}
public List<KeyValuePair<string, string>> GetListStundent_v2(string maKhoa, string maLHP)
{
return LopHocPhan_DAL.Instance.GetListStundent_v2(maKhoa, maLHP);
}
}
}