Пример #1
0
        public void Back()
        {
            AuthView t = new AuthView();

            t.Show();
            Close();
        }
Пример #2
0
        private void Logout()
        {
            AuthView _win = new AuthView();

            _win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            _win.Show();
            Close();
        }
Пример #3
0
        public void Back()
        {
            AuthView t = new AuthView();

            Close();
            Thread myThread = new Thread(new ThreadStart(DB.DB.ShowLoader));

            myThread.SetApartmentState(ApartmentState.STA);
            myThread.Start();
            Thread.Sleep(1000);
            myThread.Abort();
            t.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            t.Show();
        }
Пример #4
0
        public void RegisterCommand()
        {
            try
            {
                ErrorMes = "";
                flag     = true;
                login   += " ";
                int x1 = login.Length - 1;
                login = login.Substring(0, x1);
                bool fl = true;

                if (password.Length < 8)
                {
                    ErrorMes = Properties.Resources.charac;
                }
                if (password == String.Empty || password == null || lastname == String.Empty || lastname == null || gender == null || gender == String.Empty ||
                    purpose_of_use == String.Empty || purpose_of_use == null || age == null || age == String.Empty || height == null || height == String.Empty ||
                    activity == String.Empty || activity == null || firstname == null || firstname == String.Empty)
                {
                    fl       = false;
                    ErrorMes = Properties.Resources.emptyfield;
                }

                bool IsDone = true;
                if (fl && canreg)
                {
                    DataBaseUser spam = new DataBaseUser();
                    string       Pass = DB.DB.Hash(password).ToString();
                    IsDone = spam.AddUser(login, Pass, firstname, lastname, purpose_of_use, gender, age, height, weight, activity, daily_calories);
                    if (IsDone)
                    {
                        AuthView t = new AuthView();
                        t.Show();
                        Close();
                    }
                }

                if (!IsDone)
                {
                    ErrorMes = Properties.Resources.existserr;
                    login    = "";
                }
                canreg = true;
                flag   = false;
            }
            catch (SystemException)
            {
                ErrorMes = Properties.Resources.errordata;
            }
        }
Пример #5
0
 public void Changeacc()
 {
     if (MessageBox.Show($"Вы уверенны, что вы хотите выйти?",
                         "Подтвердите", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
     {
         AuthView t = new AuthView();
         Close();
         Thread myThread = new Thread(new ThreadStart(DB.DB.ShowLoader));
         myThread.SetApartmentState(ApartmentState.STA);
         myThread.Start();
         Thread.Sleep(1000);
         myThread.Abort();
         t.WindowStartupLocation = WindowStartupLocation.CenterScreen;
         t.Show();
     }
 }
Пример #6
0
        public void RegisterCommand()
        {
            using (MyDbContext db = new MyDbContext())
            {
                bool Registration = true;
                ErrorMes = "";
                try
                {
                    SqlParameter param = new SqlParameter("@Login", Login);
                    var          users = db.Database.SqlQuery <User>("SELECT * FROM Users WHERE Login LIKE @Login", param);
                    foreach (var user in users)
                    {
                        if (user.Login == Login)
                        {
                            Registration = false;
                        }
                    }
                    if (Registration)
                    {
                        user           = new User();
                        user.FirstName = FirstName;
                        user.Surname   = Surname;
                        user.BDay      = BDay;

                        user.Gender   = Gender;
                        user.Login    = Login;
                        user.Password = Password;


                        db.Users.Add(user);
                        db.SaveChanges();

                        AuthView t = new AuthView();
                        t.Show();
                        Close();
                    }
                    else
                    {
                        ErrorMes = "Такой логин уже существует";
                        Login    = "";
                    }
                }
                catch (Exception ex) {}
            }
        }