Ejemplo n.º 1
0
        void InputAuthorization(string path, string title, string message)
        {
            LoginDialogSettings settingsAuthorization = new LoginDialogSettings();

            settingsAuthorization.AnimateShow              = true;
            settingsAuthorization.UsernameWatermark        = "Имя пользователя";
            settingsAuthorization.PasswordWatermark        = "Пароль";
            settingsAuthorization.AffirmativeButtonText    = "Зарегистрировать";
            settingsAuthorization.NegativeButtonVisibility = Visibility.Visible;
            settingsAuthorization.ColorScheme              = MetroDialogColorScheme.Accented;
            settingsAuthorization.EnablePasswordPreview    = true;
            var result = this.ShowModalLoginExternal(title, message, settingsAuthorization);

            try {
                if (result.Password.Equals(string.Empty) || result.Username == null || result.Username.Equals(string.Empty))
                {
                    InputAuthorization(CreateDB.GetDataBasePath, title, message);
                }
            }
            catch
            {
                File.Delete(CreateDB.GetDataBasePath);
                Environment.Exit(0);
            }
            CreateDB.CreateDataBase(CreateDB.GetDataBasePath, result.Username.ToUpper(), result.Password);
        }
Ejemplo n.º 2
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            //путь  к базе данных
            string path = @"D:\\CompanyDB.db";


            if (!File.Exists(path))
            {
                CreateDB.GetDataBasePath = path;
                try {
                    SQLiteConnection.CreateFile(path);
                }
                catch { MessageBox.Show("Внимание!", "Диск защищен от записи! Выберите другую директорию для Базы данных");
                        Environment.Exit(0); };
                InputAuthorization(CreateDB.GetDataBasePath, "Создайте имя пользователя и пароль", "для учетной записи администратора...");
                Insert.InsertOnLoad();
            }
            else
            {
                CreateDB.GetDataBasePath = path;
            }
            try
            {
                if (CreateDB.CheckAdministrator())
                {
                    InputAuthentication(CreateDB.GetDataBasePath);
                }
            }
            catch
            {
                MessageBox.Show("Ошибка Базы дынных");
                this.Close();
            }
        }
Ejemplo n.º 3
0
        void InputAuthentication(string path)
        {
            LoginDialogSettings settingsAuthentication = new LoginDialogSettings();

            settingsAuthentication.AnimateShow              = true;
            settingsAuthentication.UsernameWatermark        = "Имя пользователя";
            settingsAuthentication.PasswordWatermark        = "Пароль";
            settingsAuthentication.AffirmativeButtonText    = "Войти";
            settingsAuthentication.NegativeButtonVisibility = Visibility.Visible;
            settingsAuthentication.ColorScheme              = MetroDialogColorScheme.Accented;
            settingsAuthentication.EnablePasswordPreview    = true;
            LoginDialogData result;

            if (Action.Acces)
            {
                result = this.ShowModalLoginExternal("Вход в систему", "Аутентификация пользователя...", settingsAuthentication);
            }
            else
            {
                result = this.ShowModalLoginExternal("Вход в систему", "Ошибка учетных данных", settingsAuthentication);
            }

            try
            {
                if (result.Password.Equals(string.Empty) || result.Username == null || result.Username.Equals(string.Empty))
                {
                    Action.Acces = false;
                    InputAuthentication(CreateDB.GetDataBasePath);
                }
                else
                {
                    string pass = Action.Encrypt(result.Password);

                    CreateDB.LogIn(CreateDB.GetDataBasePath, result.Username.ToUpper(), pass);
                    InteractionBD.Rights(result.Username.ToUpper());
                    dataGrid2.ItemsSource = InteractionBD.ShowWorker(result.Username.ToUpper());
                    LabelAccount.Content  = Action.AccountName;
                }
            }
            catch
            {
                Environment.Exit(0);
            }

            if (!CreateDB.Authentication)
            {
                Action.Acces = false;
                InputAuthentication(CreateDB.GetDataBasePath);
            }
        }