public void LoadData() { using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities()) { SucChua = (from dd in db.DIADIEMTOCHUCs where dd.IDDD == HoiNghi.IDDD select dd).First().SUCCHUA; var ListUser = db.USERs; this.ListDangKyUser = new ObservableCollection <XacNhanDangKyUser>(); foreach (var user in ListUser) { foreach (var dangKy in db.DANGKITHAMGIAs) { if (dangKy.IDUSER == user.IDUSER && dangKy.IDHN == HoiNghi.IDHN) { if (user.HINHANH != string.Empty) { user.HINHANH = Path.GetFullPath(user.HINHANH); } else { user.HINHANH = Path.GetFullPath("Images/user_example.png"); } XacNhanDangKyUser capQuyenUser = new XacNhanDangKyUser(user, dangKy, HoiNghi, SucChua); ListDangKyUser.Add(capQuyenUser); } } } } }
public void LoadDataByNameAndEmail(string name, string email) { using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities()) { string sql = "select* from [QuanLiHoiNghi].[dbo].[USER] "; string sqlName = $" freetext(TENUSER, N'%{name}%')"; string sqlEmail = $" EMAIL like N'%{email}%'"; if (name != "" && email != "") { sql += "where" + sqlName + "and" + sqlEmail; } else if (name != "") { sql += "where" + sqlName; } else if (email != "") { sql += "where" + sqlEmail; } var ListUser = db.USERs.SqlQuery(sql); this.ListDangKyUser = new ObservableCollection <XacNhanDangKyUser>(); foreach (var user in ListUser) { foreach (var dangKy in db.DANGKITHAMGIAs) { if (dangKy.IDUSER == user.IDUSER && dangKy.IDHN == HoiNghi.IDHN) { if (user.HINHANH != string.Empty) { user.HINHANH = Path.GetFullPath(user.HINHANH); } else { user.HINHANH = Path.GetFullPath("Images/user_example.png"); } XacNhanDangKyUser capQuyenUser = new XacNhanDangKyUser(user, dangKy, HoiNghi, SucChua); ListDangKyUser.Add(capQuyenUser); } } } } }