Example #1
0
 /// <summary>
 /// cmdInsertRow.Execute
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void InsertRowCmdExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     CompGroups.Add(new GroupItemLocalWorkbook(SelectedComp)
     {
         StartDate = SelectedComp.StartDate,
         EndDate   = SelectedComp.EndDate,
         SheetName = SheetNames.FirstOrDefault(),
         PersonalDataColumnIndex = 1,
         TeamColumnIndex         = 2,
         YoBColumnIndex          = 3,
         GradeColumnIndex        = 4
     });
 }
Example #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            descriptionViewSource        = ((CollectionViewSource)(this.FindResource("descriptionViewSource")));
            descriptionCollection        = new ObservableCollectionEx <description>(Entities.description);
            descriptionViewSource.Source = descriptionCollection;

            descriptionCollection.CollectionChanged += descriptionCollection_CollectionChanged;

            //groupsViewSource = ((CollectionViewSource)(this.FindResource("groupsViewSource")));
            //groupsViewSource.Source = Entities.groups;

            // Формируем запрос для вывода его в queryResultsDataGrid
            queryResults = from Desc in Entities.description
                           join Group in Entities.groups on Desc.id_desc equals Group.desc into CompGroups
                           from CompGroup in CompGroups.DefaultIfEmpty()
                           select new {
                desc_name = Desc.name,
                Desc.start_date,
                Desc.end_date,
                group_name = CompGroup.name,
                CompGroup.start_year,
                CompGroup.end_year
            };

            queryResultsCollection.AddRange(queryResults);

            queryResultsViewSource = new CollectionViewSource();
            (queryResultsViewSource as ISupportInitialize).BeginInit();
            queryResultsViewSource.CollectionViewType = typeof(ListCollectionView);
            queryResultsViewSource.Source             = queryResultsCollection;
            (queryResultsViewSource as ISupportInitialize).EndInit();

            Binding myBinding = new Binding()
            {
                Source = queryResultsViewSource
            };

            BindingOperations.SetBinding(queryResultsDataGrid, DataGrid.ItemsSourceProperty, myBinding);
        }
Example #3
0
        private bool CheckSettings()
        {
            if (cmbComp.SelectedItem == null)
            {
                MessageBox.Show(this, Properties.Resources.resNoSelectedComp, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (CompGroups.Count == 0)
            {
                MessageBox.Show(this, Properties.Resources.resNoGroupsInComp, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if ((from gr in CompGroups
                 group gr by gr.WorkbookName into groupNames
                 where groupNames.Count() > 1
                 select groupNames.Key)
                .Any())
            {
                MessageBox.Show(this, Properties.Resources.resDuplicateWorkbookNames, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (CompGroups.Any(
                    arg =>
                    (string.IsNullOrWhiteSpace(arg.WorkbookName) ||
                     arg.WorkbookName.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) != -1)))
            {
                MessageBox.Show(this,
                                string.Format(Properties.Resources.resfmtInvalidWorkbookNames, string.Join(", ", System.IO.Path.GetInvalidFileNameChars())),
                                Title,
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return(false);
            }

            if (!File.Exists(SelectedComp.SourceWorkbookName) &&
                System.IO.Path.GetExtension(SelectedComp.SourceWorkbookName) != GlobalDefines.MAIN_WBK_EXTENSION &&
                System.IO.Path.GetExtension(SelectedComp.SourceWorkbookName) != GlobalDefines.XLS_EXTENSION &&
                System.IO.Path.GetExtension(SelectedComp.SourceWorkbookName) != GlobalDefines.XLSX_EXTENSION)
            {
                MessageBox.Show(this, Properties.Resources.resInvalidSourceWorkbookName, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (CompGroups.Any(arg =>
                               string.IsNullOrWhiteSpace(arg.SheetName) ||
                               string.IsNullOrWhiteSpace(arg.TLCell) ||
                               string.IsNullOrWhiteSpace(arg.BRCell) ||
                               arg.PersonalDataColumnIndex <= 0 ||
                               arg.TeamColumnIndex <= 0 ||
                               arg.YoBColumnIndex <= 0 ||
                               arg.GradeColumnIndex <= 0))
            {
                MessageBox.Show(this, Properties.Resources.resInvalidSourceRangeForExporting, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (CompGroups.Any(arg =>
                               arg.EndYear.HasValue &&
                               arg.EndYear != (int)enEndYearSpecVals.AndElder &&
                               arg.EndYear != (int)enEndYearSpecVals.AndYounger &&
                               arg.StartYear >= arg.EndYear))
            {
                MessageBox.Show(this, Properties.Resources.resInvalidGroupYears, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (CompGroups.Any(arg =>
                               arg.EndDate.HasValue &&
                               arg.StartDate != arg.EndDate))
            {
                MessageBox.Show(this, Properties.Resources.resInvalidGroupDates, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (string.IsNullOrEmpty(SelectedComp.DestCompFolder) ||
                (SelectedComp.DestCompFolder.IndexOfAny(System.IO.Path.GetInvalidPathChars()) != -1))
            {
                MessageBox.Show(this, Properties.Resources.resInvalidDestCompFolder, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!Directory.Exists(DBManagerApp.m_AppSettings.m_Settings.WorkbookTemplateFolder))
            {
                MessageBox.Show(this, Properties.Resources.resInvalidWorkbookTemplateFolder, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            string WorkbookTemplateFullPath = System.IO.Path.Combine(DBManagerApp.m_AppSettings.m_Settings.WorkbookTemplateFolder,
                                                                     DBManagerApp.m_AppSettings.m_Settings.WorkbookTemplateName);

            if (!File.Exists(WorkbookTemplateFullPath))
            {
                MessageBox.Show(this,
                                string.Format(Properties.Resources.resfmtInvalidWorkbookTemplateName, WorkbookTemplateFullPath),
                                Title,
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return(false);
            }

            return(true);
        }
Example #4
0
 /// <summary>
 /// cmdDelRow.Execute
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DelRowCmdExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     CompGroups.RemoveAt(lstvGroups.SelectedIndex);
 }