private void Button_Click_7(object sender, RoutedEventArgs e)
        {
            ILogic adminService = new AdminService();

            if ((adminService.ActivUser(employerIdSearch.Text)))
            {
                List <Mechanic> DeklareraLista = adminService.GetMechanic(employerIdSearch.Text);
                foreach (var item in DeklareraLista)
                {
                    firstName.Text = item.FirstNameOfMechanic;
                    lastname.Text  = item.LastNameOfMechanic;
                    DateTime Birth  = item.BirthdayOfMechanic;
                    DateTime employ = item.DateOfEmploymentOfMechanic;
                    employerId.Text     = employerIdSearch.Text;
                    Motor.IsChecked     = item.Engine;
                    Däck.IsChecked      = item.Tire;
                    vindrutor.IsChecked = item.Window;
                    Bromsar.IsChecked   = item.Brakes;
                    Kaross.IsChecked    = item.Kaross;

                    dateOfBirth.Text      = Birth.ToString("yyyy-MM-dd");
                    dateOfEmployment.Text = employ.ToString("yyyy-MM-dd");
                }
            }
            else
            {
                MessageBox.Show(StringTools._inputError, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Пример #2
0
        private void Button_Click_7(object sender, RoutedEventArgs e)
        {
            ILogic adminService = new AdminService();

            if (RemoveUser.Text != String.Empty && adminService.ActivUser(RemoveUser.Text))
            {
                adminService.DeletLogin(RemoveUser.Text);
                MessageBox.Show("Användarekonto är nu borttaget!", "", MessageBoxButton.OK);
                ChangeUserAccount changeUserAccount = new ChangeUserAccount();
                this.NavigationService.Navigate(changeUserAccount);
            }
            else
            {
                MessageBox.Show(StringTools._inputError, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        //----------------------------------------------------------------Sök efter Anställd, koppla till konto eller ta bort, koppla till textbo samt koppla kompetens till radiobuttom.


        private void Button_Click_8(object sender, RoutedEventArgs e)
        {
            ILogic adminService = new AdminService();

            if ((adminService.ActivUser(employerIdSearch.Text)))
            {
                if (MessageBox.Show("Är du säker på att du vill ta bort anställd!", "", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    adminService.DeleteMechanic(employerIdSearch.Text);
                }
            }
            else
            {
                MessageBox.Show(StringTools._inputError, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            ChangeEmployer changeEmployer = new ChangeEmployer();

            this.NavigationService.Navigate(changeEmployer);
        }
        private void Button_Click_9(object sender, RoutedEventArgs e)
        {
            List <Mechanic> mechanics    = new List <Mechanic>();
            ILogic          adminService = new AdminService();


            if (adminService.ValidMechanic(firstName.Text, lastname.Text, dateOfBirth.Text, dateOfEmployment.Text, employerId.Text))
            {
                if ((adminService.ActivUser(employerIdSearch.Text)))
                {
                    adminService.DeleteMechanic(employerIdSearch.Text);

                    mechanics.Add(new Mechanic(firstName.Text, lastname.Text,
                                               DateTime.Parse(dateOfBirth.Text), DateTime.Parse(dateOfEmployment.Text),
                                               (bool)Motor.IsChecked, (bool)Däck.IsChecked, (bool)vindrutor.IsChecked,
                                               (bool)Bromsar.IsChecked, (bool)Kaross.IsChecked, mechanic.ActiveOrders));



                    string id = employerId.Text;
                    adminService.NewMechanic(id, mechanics);
                    MessageBox.Show("Mekaniker är nu ändrad!", "", MessageBoxButton.OK);
                }
                else
                {
                    MessageBox.Show("Kontrollera att allt är ifyllt korrekt!\n Datum ska anges i formatet(yyyy-mm-dd)", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            else
            {
                MessageBox.Show("Kontrollera att allt är ifyllt korrekt!\n Datum ska anges i formatet(yyyy-mm-dd)", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            ChangeEmployer changeEmployer = new ChangeEmployer();

            this.NavigationService.Navigate(changeEmployer);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ILogic adminService = new AdminService();

            if (adminService.ValidLogin(NewUser.Text.ToLower(), CreatPassword.Password, MatchPassword.Password, userId.Text) && (adminService.ActivUser(userId.Text)))
            {
                //Kolla om användare finns Lägg till i samma dic som  användare
                adminService.NewUser(NewUser.Text.ToLower(), CreatPassword.Password, userId.Text);
                MessageBox.Show("Användarekonto är nu tillagt!", "", MessageBoxButton.OK);
            }
            else
            {
                MessageBox.Show(StringTools._inputError, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }