public async Task <IActionResult> Index(int currentYear, string action)
        {
            {
                List <int> years = _context.Indicators
                                   .OrderByDescending(f => f.Year)
                                   .Select(f => f.Year)
                                   .ToList();
                years.Insert(0, currentYear); years.Insert(0, currentYear + 1);
                var ListYears         = new SelectList(years.Distinct(), currentYear);
                var indicators        = _context.Indicators.Where(t => t.Year == currentYear).ToList();
                var achievementsCount = _context.Achievements.Where(m => m.Year == currentYear).Count();

                switch (action)
                {
                case "FillDataFromLastYear":
                    if (indicators.Count() == 0)
                    {
                        var indicatorsLastYear = _context.Indicators
                                                 .Where(y => y.Year == (currentYear - 1));
                        foreach (var ind in indicatorsLastYear)
                        {
                            ind.Year        = currentYear;
                            ind.IndicatorId = 0;
                            indicators.Add(ind);
                        }
                        _context.AddRange(indicators);
                        await _context.SaveChangesAsync();
                    }
                    else
                    {
                        return(View("Message", "Для текущего года уже загружены данные!"));
                    }
                    break;

                case "FillDataForUniversities":
                    //Загрузка набора показателей дл¤ университетов на заданный год
                    string resultPublishIndicatorsForUniversities = await PublishIndicatorsForUniversities(currentYear);

                    if (resultPublishIndicatorsForUniversities == "")
                    {
                        return(Redirect("~/Admin/Achievements/Index"));
                    }
                    else
                    {
                        return(View("Message", resultPublishIndicatorsForUniversities));
                    }

                default:
                    break;
                }
                IndicatorsViewModel indicatorsViewModel = new IndicatorsViewModel()
                {
                    ListYears         = new SelectList(years.Distinct(), currentYear),
                    AchievementsCount = achievementsCount
                };
                return(View(indicatorsViewModel));
            }
        }
        public CheckBox MakeCheckBox(IndicatorsViewModel ivm, string bulletType)
        {
            var checkbox = new CheckBox
            {
                Style = MakeCheckBoxStyle(ivm, bulletType)
            };

            return(checkbox);
        }
        public DataGrid Make_ColumnHeaderAware_DataGrid(IndicatorsViewModel ivm)
        {
            indicatorsViewModel = ivm;

            var dg = new DataGrid();

            dg.ColumnHeaderStyle = MakeDataGridColumnHeaderStyle();

            return(dg);
        }
        public Button Make_Button(IndicatorsViewModel ivm, object content)
        {
            indicatorsViewModel = ivm;

            var butt = new Button
            {
                Content = content,
                Style   = MakeButtonStyle1()
            };

            return(butt);
        }
Пример #5
0
        public ActionResult Indicators()
        {
            var model = new IndicatorsViewModel();
            List <SelectListItem> items = new List <SelectListItem>();

            GGs.ForEach(g => items.Add(new SelectListItem {
                Text = g, Value = g
            }));
            model.Generators        = items;
            model.TemperatureValues = new List <Temperature>();

            return(View(model));
        }
Пример #6
0
        public Button Make_Button(IndicatorsViewModel ivm, bool isFlashy)
        {
            indicatorsViewModel = ivm;

            var butt = new Button
            {
                Style = MakeButtonStyle1()
            };

            if (isFlashy)
            {
                AddFlashyTemplate(butt);
                // Add the Attached Property Binding to the button
                butt.SetBinding(AttachedProperties.IsHighlightedProperty, new Binding {
                    Source = ivm, Path = new PropertyPath("IsConfirmed")
                });
            }

            return(butt);
        }
        // GET: Indicators
        public IActionResult Index(int?currentYear)
        {
            int        currYear = currentYear ?? DateTime.Now.Year;
            List <int> years    = _context.Indicators
                                  .OrderByDescending(f => f.Year)
                                  .Select(f => f.Year)
                                  .ToList();

            years.Insert(0, currYear); years.Insert(0, currYear + 1);
            var ListYears         = new SelectList(years.Distinct(), currYear);
            var achievementsCount = _context.Achievements.Where(m => m.Year == currYear).Count();

            IndicatorsViewModel indicators = new IndicatorsViewModel()
            {
                ListYears         = new SelectList(years.Distinct(), currYear),
                AchievementsCount = achievementsCount
            };

            return(View(indicators));
        }
        // GET: Indicators
        public IActionResult Index(int?currentYear, bool?disableForEdition)
        {
            bool       enableForEdition = !(disableForEdition ?? true);
            int        currYear         = currentYear ?? DateTime.Now.Year;
            List <int> years            = _context.Indicators
                                          .OrderByDescending(f => f.Year)
                                          .Select(f => f.Year)
                                          .ToList();

            years.Insert(0, currYear); years.Insert(0, currYear + 1);
            var ListYears         = new SelectList(years.Distinct(), currYear);
            var achievementsCount = _context.Achievements.Where(m => m.Year == currYear).Count();

            IndicatorsViewModel indicators = new IndicatorsViewModel()
            {
                Indicators        = _context.Indicators.Where(t => t.Year == currYear).OrderBy(s => s.IndicatorCode).ToList(),
                ListYears         = new SelectList(years.Distinct(), currYear),
                EnableForEdition  = enableForEdition,
                AchievementsCount = achievementsCount
            };

            return(View(indicators));
        }
Пример #9
0
        // GET: Indicators
        public IActionResult Index(int?currentYear, bool?disableForEdition, int page = 1)
        {
            int pageSize = 20;


            bool       enableForEdition = !(disableForEdition ?? true);
            int        currYear         = currentYear ?? DateTime.Now.Year;
            List <int> years            = _context.Indicators
                                          .OrderByDescending(f => f.Year)
                                          .Select(f => f.Year)
                                          .ToList();

            years.Insert(0, currYear); years.Insert(0, currYear + 1);
            var ListYears = new SelectList(years.Distinct(), currYear);

            var achievementsCount = _context.Achievements.Where(m => m.Year == currYear).Count();

            IQueryable <Indicator> Indicatorsc = _context.Indicators.Where(t => t.Year == currYear).OrderBy(s => s.IndicatorId1).OrderBy(s => s.IndicatorId2).OrderBy(s => s.IndicatorId3);


            var count = Indicatorsc.Count();
            var items = Indicatorsc.Skip((page - 1) * pageSize).Take(pageSize);

            PageViewModel pageViewModel = new PageViewModel(count, page, pageSize);


            IndicatorsViewModel indicators = new IndicatorsViewModel()
            {
                PageViewModel     = pageViewModel,
                Indicators        = items,
                ListYears         = new SelectList(years.Distinct(), currYear),
                EnableForEdition  = enableForEdition,
                AchievementsCount = achievementsCount
            };

            return(View(indicators));
        }
        private System.Windows.Style MakeCheckBoxStyle(IndicatorsViewModel ivm, string bulletType)
        {
            var template = new ControlTemplate {
                TargetType = typeof(CheckBox)
            };

            var bChrome = new FrameworkElementFactory(typeof(Microsoft.Windows.Themes.BulletChrome));

            bChrome.SetValue(Control.BorderBrushProperty, new TemplateBindingExtension(Control.BorderBrushProperty)); // Tested in MainWindow.xaml.cs
            bChrome.SetValue(Control.BackgroundProperty, new TemplateBindingExtension(Control.BackgroundProperty));
            bChrome.SetValue(Microsoft.Windows.Themes.BulletChrome.RenderMouseOverProperty, new TemplateBindingExtension(UIElement.IsMouseOverProperty));
            bChrome.SetValue(Microsoft.Windows.Themes.BulletChrome.RenderPressedProperty, new TemplateBindingExtension(ButtonBase.IsPressedProperty));
            bChrome.SetValue(ToggleButton.IsCheckedProperty, new TemplateBindingExtension(ToggleButton.IsCheckedProperty));

            var contentPresenter = new FrameworkElementFactory(typeof(ContentPresenter));

            contentPresenter.SetValue(FrameworkElement.HorizontalAlignmentProperty, new TemplateBindingExtension(Control.HorizontalContentAlignmentProperty));
            contentPresenter.SetValue(FrameworkElement.MarginProperty, new TemplateBindingExtension(Control.PaddingProperty));
            contentPresenter.SetValue(ContentPresenter.RecognizesAccessKeyProperty, true);
            contentPresenter.SetValue(UIElement.SnapsToDevicePixelsProperty, new TemplateBindingExtension(UIElement.SnapsToDevicePixelsProperty));
            contentPresenter.SetValue(FrameworkElement.VerticalAlignmentProperty, new TemplateBindingExtension(Control.VerticalContentAlignmentProperty));

            var t1 = new Trigger {
                Property = ContentControl.HasContentProperty, Value = true
            };

            t1.Setters.Add(new Setter(FrameworkElement.FocusVisualStyleProperty, new DynamicResourceExtension("CheckRadioFocusVisual")));
            //This is related to Content, if this setter is wrong, you won't know till you use Content property
            t1.Setters.Add(new Setter(Control.PaddingProperty, new Thickness(4, 0, 0, 0)));

            var t2 = new Trigger {
                Property = ContentControl.IsEnabledProperty, Value = false
            };

            t2.Setters.Add(new Setter(Control.ForegroundProperty, new DynamicResourceExtension(SystemColors.GrayTextBrushKey))); // Not DynamicResource as in xaml

            template.Triggers.Add(t1);
            template.Triggers.Add(t2);

            var bDecorator = new FrameworkElementFactory(typeof(BulletDecoratorByCode));

            bDecorator.SetValue(Control.BackgroundProperty, Brushes.Transparent);
            bDecorator.SetValue(UIElement.SnapsToDevicePixelsProperty, true);

            // Bullet Issue
            // http://msdn.microsoft.com/en-us/library/system.windows.frameworkelementfactory.aspx
            // not all of the template functionality is available when you create a template using this class. The recommended way to programmatically create a template is to load XAML from a string or a memory stream using the Load method of the XamlReader class.

            //bDecorator.SetValue(BulletDecorator.BulletProperty, cChrome);  // Bullet property is CLI, not DependancyProperty
            //
            bDecorator.SetValue(BulletDecoratorByCode.ActualBulletProperty, bulletType);

            //bDecorator.AppendChild(bChrome);
            bDecorator.AppendChild(contentPresenter);
            template.VisualTree = bDecorator;

            var style = new Style {
                TargetType = typeof(CheckBox)
            };

            style.Setters.Add(new Setter(Control.ForegroundProperty, new DynamicResourceExtension(SystemColors.ControlTextBrushKey)));
            style.Setters.Add(new Setter(Control.BackgroundProperty, new DynamicResourceExtension("ButtonNormalBackground")));
            style.Setters.Add(new Setter(Control.BorderBrushProperty, new DynamicResourceExtension("ButtonNormalBorder")));
            style.Setters.Add(new Setter(Control.BorderThicknessProperty, new Thickness(1)));
            style.Setters.Add(new Setter(FrameworkElement.FocusVisualStyleProperty, new DynamicResourceExtension("EmptyCheckBoxFocusVisual")));
            style.Setters.Add(new Setter(Control.TemplateProperty, template));

            return(style);
        }