Esempio n. 1
0
        private void OnRegisterClick(object sender, RoutedEventArgs e)
        {
            User newUser = new User
            {
                Name       = NameTextBox.Text,
                Surname    = SurnameTextBox.Text,
                MiddleName = MiddleNameTextBox.Text,
                Position   = PositionTextBox.Text
            };

            using (CarServiceContext db = new CarServiceContext())
            {
                db.Users.Add(newUser);
                db.SaveChanges();
            }

            Close();
        }
Esempio n. 2
0
        public MainWindow(User currentUser)
        {
            InitializeComponent();
            DataContext = currentUser;

            db = new CarServiceContext();
            db.Clients.Load();
            db.Cars.Load();

            clientsGrid.ItemsSource = db.Clients.Local.ToBindingList();
            carGrid.ItemsSource     = db.Cars.Local.ToBindingList();

            foreach (var attribute in attributesClientsField)
            {
                SearchFieldClients.Items.Add(attribute);
            }
            foreach (var attribute in attributesCarsField)
            {
                SearchFieldCars.Items.Add(attribute);
            }
        }
Esempio n. 3
0
        private void OnLoginClick(object sender, RoutedEventArgs e)
        {
            if (TextBoxID.Text == string.Empty)
            {
                new MessageWindow("Введіть свій унікальний код", "Error").Show();
            }

            User loginUser;
            int  inputLogin = Convert.ToInt32(TextBoxID.Text);

            using (CarServiceContext db = new CarServiceContext())
                loginUser = db.Users.FirstOrDefault(user => user.Id == inputLogin);
            if (loginUser != null)
            {
                new MainWindow(loginUser).Show();
                Close();
            }
            else
            {
                new MessageWindow("Робітника з таким кодом не знайдено", "Error").Show();
            }
        }