Exemplo 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());
                }
            }
        }
Exemplo n.º 2
0
        public bool AddMemberInGroup()
        {
            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.GroupID = detailMemberWindow.Id;
            return(eventAttendeesDao.Create(eventAttendeesDto));
        }