Esempio n. 1
0
 private void ButtonDel_Click(object sender, RoutedEventArgs e)
 {
     InteractionBD.DeleteWorker(textBoxDel.Text);
     dataGrid2.ItemsSource  = InteractionBD.ShowWorker();
     labelStatus.Foreground = Brushes.Green;
     labelStatus.Content    = "Success";
 }
Esempio n. 2
0
 private void ButtonAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (InteractionBD.CheckName(textBoxAddFIO.Text))
         {
             InteractionBD.AddInDataBase(textBoxAddFIO.Text, comboBoxGroup.SelectedValue.ToString(), DatePickerAddDate.Text, textBoxAddPassword.Text, combobox.SelectedItems.Cast <Worker>().ToList(), comboboxChief.SelectedItems.Cast <Worker>().ToList());
             dataGrid2.ItemsSource = InteractionBD.ShowWorker();
             textBoxAddFIO.Clear();
             textBoxAddPassword.Clear();
             label1.Content                 = "Суммарная зарплата всех сотрудников  =  " + InteractionBD.TotalSalary();
             textBoxAddFIO.BorderBrush      = Brushes.Black;
             textBoxAddPassword.BorderBrush = Brushes.Black;
             DatePickerAddDate.BorderBrush  = Brushes.Black;
             comboBoxGroup.BorderBrush      = Brushes.Black;
         }
         else
         {
             this.ShowMessageAsync("Внимание!", "Такой пользователь существует!");
         }
     }
     catch
     {
         textBoxAddFIO.BorderBrush      = Brushes.Red;
         textBoxAddPassword.BorderBrush = Brushes.Red;
         DatePickerAddDate.BorderBrush  = Brushes.Red;
         comboBoxGroup.BorderBrush      = Brushes.Red;
         this.ShowMessageAsync("Внимание!", "Вы делаете что-то неправильно!");
     }
 }
Esempio 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);
            }
        }