Example #1
0
 public Profile()
 {
     InitializeComponent();
     using (USERContext y = new USERContext())
     {
         log.Content = App.CurrentUser.username;
         lvl.Content = App.CurrentUser.lvl == 1 ? "Продвинутый" : "Новичок";
         IEnumerable <Generator> Ryads = from p in y.Ryads
                                         where p.USERusername == App.CurrentUser.username
                                         select p;
         nryads.Content = Ryads.Count().ToString();
         int avgr = 0;
         IEnumerable <Test> Tests = from p in y.Tests
                                    where p.USERusername == App.CurrentUser.username
                                    select p;
         foreach (Test r in Tests)
         {
             avgr += r.Mark;
         }
         if (Tests.Count() != 0)
         {
             avg.Content = (avgr / Tests.Count()).ToString();
         }
         else
         {
             avg.Content = "---";
         }
         tests.Content = Tests.Count().ToString();
     }
 }
Example #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (USERContext T = new USERContext())
         {
             if (Pass.Password != Pass1.Password)
             {
                 throw new Exception();
             }
             T.Users.Find(App.CurrentUser.username).password = Pass.Password.GetHashCode().ToString();
             MessageBox.Show("Вы успешно сменили свой пароль!");
             T.SaveChanges();
             this.Close();
         }
     }
     catch
     {
         Pass.BorderBrush  = new SolidColorBrush(Colors.Red);
         Pass1.BorderBrush = new SolidColorBrush(Colors.Red);
         err.Visibility    = Visibility.Visible;
     }
 }
Example #3
0
 private void ButReg_Click(object sender, RoutedEventArgs e)
 {
     using (USERContext Users = new USERContext())
     {
         if (validate(this, null))
         {
             USER check = Users.Users.Find(Log.Text);
             if (check == null)
             {
                 USER T = new USER(Log.Text, (Pass.Password).GetHashCode().ToString(), (bool)IsAlter.IsChecked ? 1 : 0);
                 Users.Users.Add(T);
                 Users.SaveChanges();
                 auth auth = new auth();
                 auth.Show();
                 this.Close();
             }
             else
             {
                 LoginCheck.Opacity = 1;
                 Log.BorderBrush    = new SolidColorBrush(Colors.Red);
             }
         }
     }
 }
Example #4
0
        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            MessageBoxResult t = MessageBox.Show("Вы уверены?", "Предупреждение", MessageBoxButton.YesNo);

            if (t == MessageBoxResult.Yes)
            {
                App.newbee = new MainWindow();

                App.newbee.Resources.Add("CurrentUser", App.CurrentUser.username);
                using (USERContext m = new USERContext())
                {
                    m.Users.Find(App.CurrentUser.username).lvl = 0;

                    m.SaveChanges();
                }
                App.CurrentUser.lvl = 0;
                App.newbee.Show();
                this.Close();
            }
            else if (t == MessageBoxResult.No)
            {
                // Do something else
            }
        }
Example #5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool pass = false;

            foreach (CheckBox m in T)
            {
                if ((bool)m.IsChecked)
                {
                    ansss[stage] = Convert.ToInt32(m.Name.ToString().Substring(2, 1));
                    pass         = true;
                }
                m.IsChecked = false;
            }
            if (pass)
            {
                if (stage == 9)
                {
                    Test t = new Test(App.CurrentUser, DateTime.Today, ansss);
                    using (TestContext T = new TestContext())
                    {
                        T.Tests.Add(t);
                        T.SaveChanges();
                    }
                    if (t.Mark >= 8)
                    {
                        MessageBox.Show("Поздравляем, вы набрали " + t.Mark + " баллов из 10!");
                        App.normal = new normal();

                        App.normal.Resources.Add("CurrentUser", App.CurrentUser.username);
                        using (USERContext m = new USERContext())
                        {
                            m.Users.Find(App.CurrentUser.username).lvl = 1;
                            App.CurrentUser.lvl = 1;
                            m.SaveChanges();
                        }
                        App.normal.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("К сожалению, вы набрали " + t.Mark + " баллов из 10 и не смогли повысить свой уровень :(");
                        App.newbee = new MainWindow();
                        App.newbee.Resources.Add("CurrentUser", App.CurrentUser.username);

                        App.newbee.Show();
                        this.Close();
                    }
                    this.Close();
                    return;
                }
                stage++;
                asktext.Text = asks[stage];
                var1.Content = vars1[stage];
                var2.Content = vars2[stage];
                var3.Content = vars3[stage];
                var4.Content = vars4[stage];
            }
            else
            {
                MessageBox.Show("Вы должны принять решение! ");
            }
        }
 public USERRepository(USERContext M)
 {
     this.Users = M;
 }