public DummyDbContext()
        {
            TaxRate = new AppVariable("TaxRate", "20");
            AppVariable dummyVariable = new AppVariable("Dummy", "variable");

            AppVariables = new[] { TaxRate, dummyVariable };
        }
        private void getStudent(long BaseId)
        {
            try
            {
                var query = GetAllStudentsAsync(BaseId);
                query.Wait();

                List <DataClass.DataTransferObjects.StudentsScoresDto> data = query.Result;

                if (data.Any())
                {
                    var res = data.GroupBy(x => new { x.StudentId })
                              .Select(x => new
                    {
                        x.Key.StudentId,
                        Name  = x.FirstOrDefault().Name,
                        LName = x.FirstOrDefault().LName,
                        FName = x.FirstOrDefault().FName,
                        Sum   = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
                    }).OrderByDescending(x => x.Sum).ToArray();

                    dataGrid.ItemsSource = res.ToList();
                }
                else
                {
                    dataGrid.ItemsSource = null;
                    MainWindow.main.showGrowlNotification(NotificationKEY: AppVariable.No_Data_KEY, param: "TopStudent");
                }
            }
            catch (Exception)
            {
            }
        }
Пример #3
0
        public MaterialCircular(string Row, string Title, string Category, string Type, string SubType, string Date, string Link)
        {
            InitializeComponent();
            DataContext      = this;
            Dlink            = Link;
            BorderColor      = AppVariable.GetBrush(FindElement.Settings.SkinCode ?? AppVariable.DEFAULT_BORDER_BRUSH);
            txtCategory.Text = Category;
            txtDate.Text     = Date;
            txtSubType.Text  = SubType;
            txtTitle.Text    = Title;
            txtType.Text     = Type;
            txtRow.Text      = Row;

            if (!System.IO.Directory.Exists(AppVariable.fileNameBakhsh + txtRow.Text + txtTitle.Text))
            {
                txtDown.Text = "دانلود";
            }
            else
            {
                txtDown.Text = "مطالعه";
                Style style = this.FindResource("WorkButton") as Style;
                btnSave.Style  = style;
                imgDown.Source = new BitmapImage(new Uri("pack://application:,,,/MoalemYar;component/Resources/pdf.png", UriKind.Absolute));
            }
        }
Пример #4
0
 public AddStudentView()
 {
     InitializeComponent();
     this.DataContext = this;
     main             = this;
     BorderColor      = AppVariable.GetBrush(MainWindow.main.BorderBrush.ToString());
 }
Пример #5
0
 public AddSchoolView()
 {
     InitializeComponent();
     this.DataContext = this;
     main             = this;
     BorderColor      = AppVariable.GetBrush(MainWindow.main.BorderBrush.ToString());
     GenerateEducateYear();
 }
Пример #6
0
 public AddQuestionsView()
 {
     InitializeComponent();
     this.DataContext = this;
     main             = this;
     BorderColor      = AppVariable.GetBrush(MainWindow.main.BorderBrush.ToString());
     strDate          = pc.GetYear(DateTime.Now).ToString("0000") + "/" + pc.GetMonth(DateTime.Now).ToString("00") + "/" + pc.GetDayOfMonth(DateTime.Now).ToString("00");
 }
Пример #7
0
 public About()
 {
     InitializeComponent();
     DataContext = this;
     History     = Properties.Resources.History;
     AppName     = AppVariable.getAppTitle;
     AppVersion  = AppVariable.getAppVersion;
     TimeColor   = AppVariable.GetBrush(MainWindow.main.BorderBrush.ToString());
 }
Пример #8
0
        public AddUser()
        {
            InitializeComponent();
            this.DataContext = this;
            main             = this;
            var color = (Color)ColorConverter.ConvertFromString(AppVariable.ReadSetting(AppVariable.SkinCode));
            var brush = new SolidColorBrush(color);

            BorderColor = brush;
        }
Пример #9
0
        public AttendancelistView()
        {
            InitializeComponent();

            this.DataContext = this;
            main             = this;
            strDate          = pc.GetYear(DateTime.Now).ToString("0000") + "/" + pc.GetMonth(DateTime.Now).ToString("00") + "/" + pc.GetDayOfMonth(DateTime.Now).ToString("00");
            txtDate.Text     = string.Format("تاریخ امروز : {0} ", strDate);
            BorderColor      = AppVariable.GetBrush(MainWindow.main.BorderBrush.ToString());
        }
Пример #10
0
        public void resetConfig()
        {
            string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\MoalemYar\config.json";

            if (System.IO.File.Exists(folder))
            {
                File.Delete(folder);
                AppVariable.InitializeSettings();
                MainWindow.main.DataResetDeletedNotification("تنظیمات برنامه");
            }
        }
Пример #11
0
        public void getTopStudent(long BaseId)
        {
            using (var db = new DataClass.myDbContext())
            {
                var query = db.Scores.Join(
                    db.Students,
                    c => c.StudentId,
                    v => v.Id,
                    (c, v) => new DataClass.DataTransferObjects.StudentsScoresDto {
                    Id = c.Id, BaseId = v.BaseId, StudentId = v.Id, Name = v.Name, LName = v.LName, FName = v.FName, Scores = c.Scores
                }
                    ).OrderBy(x => x.Scores).Where(x => x.BaseId == BaseId).ToList();


                var res = query.GroupBy(x => new { x.StudentId })
                          .Select(x => new
                {
                    x.Key.StudentId,
                    Name  = x.FirstOrDefault().Name,
                    LName = x.FirstOrDefault().LName,
                    FName = x.FirstOrDefault().FName,
                    Sum   = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
                }).OrderByDescending(x => x.Sum).Take(6).ToArray();

                foreach (var item in res)
                {
                    Arthas.Controls.Metro.MetroProgressBar metroProgressBar;
                    TextBlock textBlock;
                    Control   _currentUser;
                    metroProgressBar = new Arthas.Controls.Metro.MetroProgressBar()
                    {
                        FlowDirection = FlowDirection.LeftToRight,
                        Background    = AppVariable.GetBrush("#15a4fa"),
                        CornerRadius  = new CornerRadius(0),
                        Value         = item.Sum
                    };
                    textBlock = new TextBlock()
                    {
                        Opacity  = .4,
                        Margin   = new Thickness(0, 5, 0, 0),
                        FontSize = 15,
                        Text     = item.Name + " " + item.LName
                    };


                    _currentUser = metroProgressBar;
                    stkDash.Children.Add(textBlock);

                    stkDash.Children.Add(_currentUser);
                }
            }
        }
Пример #12
0
        //get Scores to double[]
        private double[] getScoreArray(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();

            return(score.Select(x => Convert.ToDouble(x.Sum)).ToArray());
        }
Пример #13
0
        public About()
        {
            InitializeComponent();
            DataContext = this;

            History    = Properties.Resources.History;
            AppName    = AppVariable.getAppTitle;
            AppVersion = AppVariable.getAppVersion;
            var color = (Color)ColorConverter.ConvertFromString(AppVariable.ReadSetting(AppVariable.SkinCode));
            var brush = new SolidColorBrush(color);

            TimeColor = brush;
        }
 public async Task InitializeData()
 {
     _dbContext.Database.EnsureDeleted();
     if (_dbContext.Database.EnsureCreated())
     {
         // Seed database
         AppVariable taxRate = new AppVariable("TaxRate", "20");
         _dbContext.AppVariables.Add(taxRate);
         _dbContext.SaveChanges();
         // Seed users
         await InitializeUsers();
     }
 }
Пример #15
0
        public IActionResult Index()
        {
            AppVariable taxRate = _appVariableRepository.GetBy("TaxRate");

            try
            {
                ViewBag.CurrentTaxRate = Convert.ToDouble(taxRate.Value);
            }
            catch (Exception e)
            {
                // do something
            }
            return(View());
        }
Пример #16
0
        private List <DataClass.DataTransferObjects.myChartTemplate> getDataList(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();

            return(score.Select(x => new DataClass.DataTransferObjects.myChartTemplate {
                Book = x.Book, Caption = x.Date, Scores = x.Sum, StudentId = x.StudentId
            }).ToList());
        }
Пример #17
0
        //get Score Average to string
        private string getAverage(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();
            var dCount = score.Select(x => x.Date).Count();
            var sum    = score.Sum(x => x.Sum);

            return(decimal.Divide(sum, dCount).ToString("0.00"));
        }
 public IActionResult Result(double amount, string eventType)
 {
     try
     {
         AppVariable taxRateVariable = _appVariableRepository.GetBy("TaxRate");
         double      taxRate         = Convert.ToDouble(taxRateVariable.Value);
         var         result          = CalculateDeductableAmount(taxRate, amount, eventType);
         ViewData["amount"] = result;
     }
     catch (Exception e)
     {
         // do something?
     }
     return(View());
 }
        public void IndexPost_ValidForm_SavesChanges()
        {
            // mock usermanager?
            _appVariableRepository.Setup(m => m.GetBy("TaxRate")).Returns(_dummyContext.TaxRate); // not needed (taxrate not shown)
            var taxrateViewModel = new TaxRateViewModel()
            {
                TaxRate = 25
            };

            _controller.Index(taxrateViewModel);

            AppVariable taxRate = _dummyContext.TaxRate;

            Assert.Equal("25", taxRate.Value);
            _appVariableRepository.Verify(m => m.SaveChanges(), Times.Once());
        }
Пример #20
0
 public IActionResult Index(TaxRateViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             AppVariable taxRate = _appVariableRepository.GetBy("TaxRate");
             MapTaxRateViewModelToAppVariable(model, taxRate);
             _appVariableRepository.SaveChanges();
             ViewBag.CurrentTaxRate = model.TaxRate;
         }
         catch (Exception e)
         {
             // do something?
         }
     }
     return(View(model));
 }
Пример #21
0
        private string getAverageStatus(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();

            var sum = score.Sum(x => x.Sum);

            var dCount = score.Select(x => x.Date).Count();

            var Avg = decimal.Divide(sum, dCount).ToString("0.00");

            var one   = decimal.Divide(dCount * 4, 1).ToString("0.00");
            var sec   = decimal.Divide(dCount * 4, 2).ToString("0.00");
            var thi   = decimal.Divide(dCount * 4, 3).ToString("0.00");
            var forth = decimal.Divide(dCount * 4, 4).ToString("0.00");

            string status = string.Empty;

            if (Convert.ToDecimal(Avg) >= Convert.ToDecimal(sec))
            {
                status = "خیلی خوب";
            }
            else if (Convert.ToDecimal(Avg) < Convert.ToDecimal(one) && Convert.ToDecimal(Avg) >= Convert.ToDecimal(thi))
            {
                status = "خوب";
            }
            else if (Convert.ToDecimal(Avg) < Convert.ToDecimal(sec) && Convert.ToDecimal(Avg) >= Convert.ToDecimal(forth))
            {
                status = "قابل قبول";
            }
            else if (Convert.ToDecimal(Avg) < Convert.ToDecimal(forth))
            {
                status = "نیاز به تلاش بیشتر";
            }

            return(status);
        }
Пример #22
0
        private string getAverageStatus(string Book)
        {
            var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                        .Select(x => new
            {
                x.Key.StudentId,
                x.Key.Book,
                x.Key.Date,
                Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
            }).Where(x => x.Book == Book).ToArray();

            var sum = score.Sum(x => x.Sum);

            var dCount = score.Select(x => x.Date).Count();

            var TotalScore = Convert.ToDecimal(dCount * 4);
            var HalfScore  = Convert.ToDecimal(decimal.Divide(dCount * 4, 2).ToString("0.00"));
            var ThirdScore = Convert.ToDecimal(decimal.Divide(dCount * 4, 3).ToString("0.00"));
            var ForthScore = Convert.ToDecimal(decimal.Divide(dCount * 4, 4).ToString("0.00"));

            string status = string.Empty;

            if (sum == TotalScore || (TotalScore - sum) <= 1)
            {
                status = "خیلی خوب";
            }
            else if (sum >= HalfScore && sum < TotalScore)
            {
                status = "خوب";
            }
            else if (sum >= ThirdScore && sum < HalfScore)
            {
                status = "قابل قبول";
            }
            else if (sum >= ForthScore && sum < ThirdScore || sum <= ForthScore)
            {
                status = "نیاز به تلاش بیشتر";
            }

            return(status);
        }
Пример #23
0
        private void LoadSettings()
        {
            if (AppVariable.ReadBoolSetting(AppVariable.CredentialLogin))
            {
                swLogin.IsChecked = true;
            }
            else
            {
                swLogin.IsChecked = false;
            }

            if (AppVariable.ReadBoolSetting(AppVariable.Autorun))
            {
                swAutoStart.IsChecked = true;
            }
            else
            {
                swAutoStart.IsChecked = false;
            }

            if (AppVariable.ReadBoolSetting(AppVariable.AutoSendReport))
            {
                swAutoReport.IsChecked = true;
            }
            else
            {
                swAutoReport.IsChecked = false;
            }

            var hb_Menu = AppVariable.ReadBoolSetting(AppVariable.HamburgerMenu);

            Hamborger_Menu.IsChecked = hb_Menu;

            var color = (Color)ColorConverter.ConvertFromString(AppVariable.ReadSetting(AppVariable.SkinCode));
            var brush = new SolidColorBrush(color);

            color1.Background = brush;
        }
Пример #24
0
 private void swLogin_Unchecked(object sender, RoutedEventArgs e)
 {
     AppVariable.AddUpdateAppSettings(AppVariable.CredentialLogin, false);
 }
Пример #25
0
 private void swAutoReport_Unchecked(object sender, RoutedEventArgs e)
 {
     AppVariable.AddUpdateAppSettings(AppVariable.AutoSendReport, false);
     MainWindow.main.LogifyCrashReport();
 }
Пример #26
0
 private void MapTaxRateViewModelToAppVariable(TaxRateViewModel taxRateViewModel, AppVariable appVariable)
 {
     appVariable.Value = taxRateViewModel.TaxRate.ToString();
 }
Пример #27
0
 private void color1_close()
 {
     AppVariable.AddUpdateAppSettings(AppVariable.SkinCode, color1.CurrentColor.OpaqueSolidColorBrush.ToString());
     MainWindow.main.RestartNotification();
 }
Пример #28
0
        public Attendancelist()
        {
            InitializeComponent();

            this.DataContext = this;
            main             = this;
            strDate          = pc.GetYear(DateTime.Now).ToString("0000") + "/" + pc.GetMonth(DateTime.Now).ToString("00") + "/" + pc.GetDayOfMonth(DateTime.Now).ToString("00");
            txtDate.Text     = string.Format("تاریخ امروز : {0} ", strDate);

            var color = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(AppVariable.ReadSetting(AppVariable.SkinCode));
            var brush = new SolidColorBrush(color);

            BorderColor = brush;
        }
Пример #29
0
 private void swAutoStart_Unchecked(object sender, RoutedEventArgs e)
 {
     AppVariable.AddUpdateAppSettings(AppVariable.Autorun, false);
     AppVariable.RegisterInStartup(false);
 }
Пример #30
0
        private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                dynamic selectedItem = dataGrid.SelectedItems[0];

                waterfallFlow.Children.Clear();

                getStudentScore(selectedItem.Id); // get Student scores

                //get scores merge duplicates and replace string to int
                var score = _initialCollection.GroupBy(x => new { x.Book, x.Date, x.StudentId })
                            .Select(x => new
                {
                    x.Key.StudentId,
                    x.Key.Book,
                    x.Key.Date,
                    Sum = x.Sum(y => AppVariable.EnumToNumber(y.Scores))
                }).ToArray();

                //get Book Count for generate chart
                var bookCount = score.GroupBy(x => new { x.Book })
                                .Select(g => new
                {
                    g.Key.Book
                }).ToList();

                //generate chart based on count of books
                foreach (var item in bookCount)
                {
                    Mapper = Mappers.Xy <DataClass.DataTransferObjects.myChartTemplate>()
                             .X((myData, index) => index)
                             .Y(myData => myData.Scores);

                    var records = getDataList(item.Book).OrderByDescending(x => x.Caption).ToArray();

                    Results = records.AsChartValues();

                    Labels = new ObservableCollection <string>(records.Select(x => x.Caption));

                    var chart = new CartesianChart();

                    var series = new SeriesCollection
                    {
                        new ColumnSeries {
                            Title         = item.Book + Environment.NewLine + getAverageStatus(item.Book) + Environment.NewLine + "میانگین: " + getAverage(item.Book),
                            Configuration = Mapper, Values = Results, DataLabels = true, FontFamily = TryFindResource("TeacherYar.Fonts.IRANSans") as FontFamily,
                            Fill          = TryFindResource("PrimaryBrush") as Brush
                        }
                    };
                    chart.Margin         = new System.Windows.Thickness(5);
                    chart.Series         = series;
                    chart.LegendLocation = LegendLocation.Top;
                    chart.AxisX.Add(new Axis
                    {
                        FontFamily     = TryFindResource("TeacherYar.Fonts.IRANSans") as FontFamily,
                        Labels         = Labels,
                        LabelsRotation = -20,
                        Separator      = new LiveCharts.Wpf.Separator {
                            Step = 1
                        }
                    });
                    chart.AxisY.Add(new Axis {
                        FontFamily = TryFindResource("TeacherYar.Fonts.IRANSans") as FontFamily
                    });
                    chart.DataTooltip.Background = TryFindResource("SecondaryRegionBrush") as Brush;
                    var mainBorder = new Border();
                    mainBorder.Width        = 300;
                    mainBorder.Height       = 320;
                    mainBorder.Effect       = TryFindResource("EffectShadow3") as Effect;
                    mainBorder.CornerRadius = new System.Windows.CornerRadius(5);
                    mainBorder.Margin       = new System.Windows.Thickness(10);
                    mainBorder.Background   = TryFindResource("RegionBrush") as Brush;
                    mainBorder.Child        = chart;

                    waterfallFlow.Children.Add(mainBorder);
                }
            }
            catch (ArgumentNullException) { }
            catch (NullReferenceException)
            {
            }
        }