public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { string SessionGroupName = (string)values[0]; string TeamName = (string)values[1]; SessionGroupDAL sgd = new SessionGroupDAL(); SessionGroup sg = sgd.FindAll(x => x.Semester.IsActive && x.SessionGroupName == SessionGroupName).FirstOrDefault(); if (sg == null) { return(new SolidColorBrush(Colors.Red)); } TeamDAL td = new TeamDAL(); Team t = td.FindAll(x => x.TeamName == TeamName && x.SessionGroupID == sg.ID).FirstOrDefault(); if (t == null) { return(new SolidColorBrush(Colors.Red)); } return(new SolidColorBrush(Colors.Black)); }
private void DeleteSemester(object param) { Semester selectedSemester = (Semester)((DataGrid)param).SelectedItem; SessionGroupDAL sessionGroupDal = new SessionGroupDAL(); if (selectedSemester.IsActive == true) { MessageBox.Show("Aktív szemeszter nem törölhető!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else if (sessionGroupDal.FindAll(x => x.SemesterID == selectedSemester.ID).FirstOrDefault() != null) { MessageBox.Show("A félévhez tartozik csoport, ezért nem törölhető!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { MessageBoxResult messageBoxResult = MessageBox.Show("Valóban törli?", "Törlés megerősítése", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { SemesterList.Remove(selectedSemester); ((TeacherDAL)_contextDal).DeleteSemester(selectedSemester); } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { UsersDAL ud = new UsersDAL(); if (value.GetType() == typeof(Users)) { Users val = (Users)value; Users existingUser = new Users(); switch (parameter) { case "Email": existingUser = ud.FindAll(x => x.Email == val.Email).FirstOrDefault(); break; case "Neptun": existingUser = ud.FindAll(x => x.NEPTUN == val.NEPTUN).FirstOrDefault(); break; } if (existingUser == null) { return(new SolidColorBrush(Colors.Black)); } return(new SolidColorBrush(Colors.Red)); } else { string paramString = parameter as string; string SessionGroupName = (string)value; SessionGroupDAL sgd = new SessionGroupDAL(); SessionGroup sg = sgd.FindAll(x => x.Semester.IsActive && x.SessionGroupName == SessionGroupName).FirstOrDefault(); if (sg == null) { return(new SolidColorBrush(Colors.Red)); } return(new SolidColorBrush(Colors.Black)); } }
private void ImportStudents() { bool duplicateError = false; bool sessionGroupMissing = false; bool teamMissing = false; List <Users> userList = new List <Users>(); foreach (DataRow item in Table.Rows) { userList.Add((Users)item["User"]); } var NEPTUNDuplicates = userList.GroupBy(x => x.NEPTUN).Select(c => new { Key = c.Key, total = c.Count() }); var MailDuplicates = userList.GroupBy(x => x.Email).Select(c => new { Key = c.Key, total = c.Count() }); foreach (var item in NEPTUNDuplicates) { if (item.total > 1) { duplicateError = true; break; } } foreach (var item in MailDuplicates) { if (item.total > 1) { duplicateError = true; break; } } UsersDAL ud = new UsersDAL(); SessionGroupDAL sgd = new SessionGroupDAL(); TeamDAL td = new TeamDAL(); foreach (DataRow item in Table.Rows) { Users rowUser = ((Users)item["User"]); string sessiongroupName = (string)item["SessionGroup"]; string teamName = (string)item["Team"]; duplicateError = duplicateError || ud.FindAll().Exists(x => x.Email == rowUser.Email); duplicateError = duplicateError || ud.FindAll().Exists(x => x.Email == rowUser.NEPTUN); SessionGroup sg = sgd.FindAll(x => x.Semester.IsActive && x.SessionGroupName == sessiongroupName).FirstOrDefault(); sessionGroupMissing = sessionGroupMissing || (sg == null); teamMissing = teamMissing || sessionGroupMissing; if (!teamMissing) { Team t = td.FindAll(x => x.SessionGroupID == sg.ID && x.TeamName == teamName).FirstOrDefault(); teamMissing = teamMissing || (t == null); } } string errorMessage = ""; if (duplicateError) { errorMessage += "\nAz állományban több azonos, vagy a rendszerben már szereplő E-mail cím vagy NEPTUN kód szerepel!"; } if (sessionGroupMissing) { errorMessage += "\nAz állományban nem létező csoport szerepel!"; } if (teamMissing) { errorMessage += "\nAz állományban nem létező csapat szerepel!"; } if (!String.IsNullOrEmpty(errorMessage)) { MessageBox.Show("Hiba az importált adatokban!" + errorMessage, "Hiba", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { foreach (DataRow item in Table.Rows) { string sessionGroupName = (string)item["SessionGroup"]; string teamName = (string)item["Team"]; SessionGroup sg = sgd.FindAll(x => x.Semester.IsActive && x.SessionGroupName == sessionGroupName).FirstOrDefault(); Team t = td.FindAll(x => x.SessionGroupID == sg.ID && x.TeamName == teamName).FirstOrDefault(); Student st = new Student() { TeamID = t.ID }; Users u = (Users)item["User"]; u.IsPasswordChangeRequired = true; ud.Create(u); st.UserID = u.ID; u.Student.Add(st); ud.Update(u); MailSender.SendMail(u.Email); } MessageBox.Show("Sikeres importálás!", "", MessageBoxButton.OK); this.Close(); } }