Exemple #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";
 }
Exemple #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("Внимание!", "Вы делаете что-то неправильно!");
     }
 }
Exemple #3
0
 private void comboBoxGroup_DropDownOpened(object sender, EventArgs e)
 {
     combobox.SelectedItems.Clear();
     comboboxChief.SelectedItems.Clear();
     comboBoxGroup.ItemsSource      = Insert.GetSplitGroup();
     SplitRate.ItemsSource          = Insert.GetSplitRate();
     SplitPercent.ItemsSource       = Insert.GetSplitPercent();
     SplitPercentWorker.ItemsSource = Insert.GetSplitPercentWorker();
     combobox.ItemsSource           = InteractionBD.GetWorkers();
     comboboxChief.ItemsSource      = InteractionBD.GetWorkersChief();
 }
Exemple #4
0
 private void comboBoxGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     SplitRate.SelectedValue          = InteractionBD.GetRate(comboBoxGroup.SelectedValue.ToString());
     SplitPercent.SelectedValue       = InteractionBD.GetPercent(comboBoxGroup.SelectedValue.ToString());
     SplitPercentWorker.SelectedValue = InteractionBD.GetPercentWorker(comboBoxGroup.SelectedValue.ToString());
     //SplitChief.IsEnabled = SplitGroup.SelectedValue.ToString() == "Administrator" ? false:true ;
     SplitRate.IsEnabled          = comboBoxGroup.SelectedValue.ToString() == "Administrator" ? false : true;
     SplitPercent.IsEnabled       = comboBoxGroup.SelectedValue.ToString() == "Administrator" ? false : true;
     SplitPercentWorker.IsEnabled = comboBoxGroup.SelectedValue.ToString() == "Administrator" ? false : true;
     combobox.IsEnabled           = ((comboBoxGroup.SelectedValue.ToString() == "Administrator") || (comboBoxGroup.SelectedValue.ToString() == "Employee")) ? false : true;
     comboboxChief.IsEnabled      = comboBoxGroup.SelectedValue.ToString() == "Administrator" ? false : true;
     // combobox.IsEnabled = comboBoxGroup.SelectedValue.ToString() == "Employee" ? false : true;
 }
Exemple #5
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);
            }
        }
Exemple #6
0
        private void dataGrid2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                labelStatus.Content = "";
                var ci = new DataGridCellInfo(dataGrid2.Items[dataGrid2.SelectedIndex], dataGrid2.Columns[0]);

                var content = ci.Column.GetCellContent(ci.Item) as TextBlock;

                textBoxDel.Text               = content.Text;
                textBoxEditFio.Text           = content.Text;
                comboboxSubEdit.ItemsSource   = InteractionBD.GetWorkersSubEdit(textBoxEditFio.Text);
                comboboxChiefEdit.ItemsSource = InteractionBD.GetWorkersChiefEdit(textBoxEditFio.Text);
            }
            catch { };
        }