public void ImportDataFromExcel() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Excel file (*.xlsx)|*.xlsx"; if ((bool)openFileDialog.ShowDialog()) { try { ExcelConnection.ExcelConnect excelConnect = new ExcelConnection.ExcelConnect(); List <EventAttendeesDtoExcel> eventAttendeesDtoExcels = excelConnect.ImportExcel <EventAttendeesDtoExcel>(openFileDialog.FileName); EventAttendeesDao eventAttendeesDao = new EventAttendeesDao(); eventAttendeesDao.MakeConnection(Properties.Resources.strConnection); foreach (EventAttendeesDtoExcel eventAttendeesDtoExcel in eventAttendeesDtoExcels) { EventAttendeesDto eventAttendeesDto = new EventAttendeesDto(); eventAttendeesDto.Name = eventAttendeesDtoExcel.Name; eventAttendeesDto.Email = eventAttendeesDtoExcel.Email; eventAttendeesDto.Other = eventAttendeesDtoExcel.Other; eventAttendeesDto.GroupID = memberWindow.Id; eventAttendeesDao.Create(eventAttendeesDto); } } catch (Exception e) { MessageBox.Show(e.ToString()); } } }
public void RemoveEventAttendees() { EventAttendeesDao eventAttendeesDao = new EventAttendeesDao(); eventAttendeesDao.MakeConnection(Properties.Resources.strConnection); List <EventAttendeesDto> eventAttendeesDtos = (List <EventAttendeesDto>)memberWindow.DefaulData; eventAttendeesDao.DeleteById(eventAttendeesDtos[memberWindow.SelectedIndex].Id); }
public void LoadMemberGroup() { EventAttendeesDao eventAttendeesDao = new EventAttendeesDao(); eventAttendeesDao.MakeConnection(Properties.Resources.strConnection); memberWindow.DefaulData = eventAttendeesDao.ReadData(memberWindow.Id, memberWindow.Search); List <dynamic> eventAttendeesShowList = new List <dynamic>(); int count = 1; foreach (EventAttendeesDto eventAttendeesDto in eventAttendeesDao.ReadData(memberWindow.Id, memberWindow.Search)) { eventAttendeesShowList.Add(new { NO = count, Name = eventAttendeesDto.Name, Email = eventAttendeesDto.Email, Other = eventAttendeesDto.Other }); count++; } memberWindow.ShowData = eventAttendeesShowList; }
public bool AddEvent() { if (addEventWindow.EventName.Length == 0) { addEventWindow.Status = "Event name is empty"; return(false); } if (addEventWindow.EventName.Length > 50) { addEventWindow.Status = "Event name have length lower than 50"; return(false); } EventDao eventDao = new EventDao(); eventDao.MakeConnection(Properties.Resources.strConnection); if (eventDao.Create(new EventDto(addEventWindow.EventName, addEventWindow.Desciption, "", ((App)Application.Current).UserName))) { List <CheckBox> groupShowList = (List <CheckBox>)addEventWindow.Group; int index = 0; foreach (CheckBox checkBox in groupShowList) { if ((bool)checkBox.IsChecked) { EventAttendeesDao eventAttendeesDao = new EventAttendeesDao(); List <GroupDto> groupDtos = (List <GroupDto>)addEventWindow.GroupData; eventAttendeesDao.MakeConnection(Properties.Resources.strConnection); List <EventAttendeesDto> eventAttendeesDtos = eventAttendeesDao.ReadData(groupDtos[index].Id, ""); foreach (EventAttendeesDto eventAttendeesDto in eventAttendeesDtos) { CheckInDao checkInDao = new CheckInDao(); checkInDao.MakeConnection(Properties.Resources.strConnection); CheckInDto checkInDto = new CheckInDto(); checkInDto.EventID = eventDao.GetLastId(); checkInDto.Name = eventAttendeesDto.Name; checkInDto.Email = eventAttendeesDto.Email; checkInDto.Other = eventAttendeesDto.Other; checkInDao.Create(checkInDto); } } index++; } } return(true); }
public bool UpdateMemberInGroup() { if (detailMemberWindow.DataName.Length == 0) { detailMemberWindow.Status = "Member name is empty"; return(false); } if (!IsValidEmail(detailMemberWindow.Email)) { detailMemberWindow.Status = "Email invalidate"; return(false); } EventAttendeesDao eventAttendeesDao = new EventAttendeesDao(); eventAttendeesDao.MakeConnection(Properties.Resources.strConnection); EventAttendeesDto eventAttendeesDto = new EventAttendeesDto(); eventAttendeesDto.Name = detailMemberWindow.DataName; eventAttendeesDto.Email = detailMemberWindow.Email; eventAttendeesDto.Other = detailMemberWindow.Other; eventAttendeesDto.Id = detailMemberWindow.Id; return(eventAttendeesDao.Update(eventAttendeesDto)); }