Example #1
0
        private void EnterClick(object sender, RoutedEventArgs e)
        {
            Accaunt acc = new Accaunt {
                Login = Log.Text, Password = Pass.Password
            };

            acc = DB.Accaunts.FirstOrDefault(c => c.Login == acc.Login && c.Password == acc.Password);
            if (acc == null)
            {
                Pass.Password = "";
                Log.Text      = "";
                System.Windows.MessageBox.Show("Не верный логин или пароль");
            }
            else
            {
                //DB.Wokers.ToList();

                System.Console.WriteLine("here");
                if (acc.Woker == null)
                {
                    new AdminWindow();
                    this.Close();
                }
                else
                {
                    new UserWindow(acc.Woker);
                    this.Close();
                }
            }
        } //авторизация
Example #2
0
        public App()   //при запуске ели нет БД оздаем ее и добавляем аккант админа
        {
            Accaunt a = new Accaunt {
                Login = "******", Password = "******"
            };

            this.InitializeComponent();

            using (var db = new WokerContext())
            {
                db.Database.Migrate();
                if (db.Accaunts.Count() == 0)
                {
                    db.Accaunts.Add(a);
                    db.SaveChanges();
                }
            }
        }
Example #3
0
        private void Add_woker(object sender, RoutedEventArgs e)
        {
            Accaunt newAccaunt = new Accaunt {
                Login = loginBox.Text, Password = passwordBox.Text
            };

            DB.Accaunts.Add(newAccaunt);
            DB.SaveChanges();

            Woker newWoker = new Woker
            {
                Name      = nameBox.Text,
                Surname   = surnameBox.Text,
                Rate      = System.Convert.ToInt32(rateBox.Text),
                Type      = typeCombo.SelectedItem.ToString(),
                Begin     = Convert.ToDateTime(beginBox.Text),
                AccauntId = newAccaunt.Id,
                Accaunt   = newAccaunt
            };

            DB.Wokers.Add(newWoker);
            DB.SaveChanges();
            RefreshAll();
        }    //добавление работника в базу данных