Esempio n. 1
0
        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 ExportReportToExcel()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "Excel file (*.xlsx)|*.xlsx";
            if ((bool)saveFileDialog.ShowDialog())
            {
                try
                {
                    ExcelConnection.ExcelConnect excelConnect = new ExcelConnection.ExcelConnect();
                    CheckInDao checkInDao = new CheckInDao();
                    checkInDao.MakeConnection(Properties.Resources.strConnection);
                    List <EventDto>   events      = (List <EventDto>)mainWindow.OldEventData;
                    List <CheckInDto> checkInDtos = checkInDao.ReadData(events[mainWindow.SelectIndexOldEvent].Id, "");
                    List <EventAttendeesDtoToExportReport> eventAttendeesDtoToExportReports = new List <EventAttendeesDtoToExportReport>();
                    foreach (CheckInDto checkInDto in checkInDtos)
                    {
                        EventAttendeesDtoToExportReport eventAttendeesDtoToExportReport = new EventAttendeesDtoToExportReport();
                        eventAttendeesDtoToExportReport.Name      = checkInDto.Name;
                        eventAttendeesDtoToExportReport.Email     = checkInDto.Email;
                        eventAttendeesDtoToExportReport.Other     = checkInDto.Other;
                        eventAttendeesDtoToExportReport.IsChecked = checkInDto.Check;
                        eventAttendeesDtoToExportReports.Add(eventAttendeesDtoToExportReport);
                    }
                    excelConnect.ExportExcel(eventAttendeesDtoToExportReports, saveFileDialog.FileName);
                }
                catch (Exception e)
                {
                }
            }
        }