private void allLogins_SelectionChanged(object sender, SelectionChangedEventArgs e) { using (Model2 db = new Model2()) { logHistory.ItemsSource = null; string f = allLogins.SelectedValue.ToString(); var query = from b in db.users where b.login.Equals(f) select new { Login = b.login, LastEnter = b.lastenter, Ip = b.ip }; logHistory.ItemsSource = query.ToList(); } }
public BookherWindow(int id) { InitializeComponent(); using (Model2 db = new Model2()) { var a = from b in db.users where b.id.Equals(id) select b; if (a.Count() != 0) { foreach (var i in a) { nameUser.Content = i.name; } } } }
public void Update() { using (Model2 db = new Model2()) { var a = from b in db.users select new { Login = b.login, LastEnter = b.lastenter, Ip = b.ip }; logHistory.ItemsSource = a.ToList(); foreach (var i in a) { allLogins.Items.Add(i.Login); } } }
private void dateFilter_SelectedDateChanged(object sender, SelectionChangedEventArgs e) { using (Model2 db = new Model2()) { logHistory.ItemsSource = null; DateTime dates = dateFilter.SelectedDate.Value; int day = dates.Date.Day; int month = dates.Date.Month; int year = dates.Date.Year; string data = $"{day}/{month}/{year}"; var query = from b in db.users where b.lastenter.Equals(data) select new { Login = b.login, LastEnter = b.lastenter, Ip = b.ip }; logHistory.ItemsSource = query.ToList(); } }
public ResearcherWindow(int id) { InitializeComponent(); dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); using (Model2 db = new Model2()) { var a = from b in db.users where b.id.Equals(id) select b; if (a.Count() != 0) { foreach (var i in a) { nameUser.Content = i.name; } } } }
private void okay_Click(object sender, RoutedEventArgs e) { try { if (loginUser.Text.Length == 0 && passUser.Password.Length == 0) { MessageBox.Show("Нужно ввести данные"); } else if (loginUser.Text.Length != 0 && passUser.Password.Length == 0) { MessageBox.Show("Нужно ввести данные"); } else if (loginUser.Text.Length == 0 && passUser.Password.Length != 0) { MessageBox.Show("Нужно ввести данные"); } else if (loginUser.Text.Length != 0 && passUser.Password.Length != 0) { using (Model2 db = new Model2()) { var a = from b in db.users where b.login.Equals(loginUser.Text) && b.password.Equals(passUser.Password) select b; if (a.Count() != 0) { foreach (var ister in a) { if (ister.type == 1) { LaborantWindow laborant = new LaborantWindow(ister.id); laborant.Show(); Close(); } else if (ister.type == 2) { BookherWindow bookher = new BookherWindow(ister.id); bookher.Show(); Close(); } else if (ister.type == 3) { ResearcherWindow researcher = new ResearcherWindow(ister.id); researcher.Show(); Close(); } else if (ister.type == 4) { AdminWindow admin = new AdminWindow(ister.id); admin.Show(); Close(); } } } else { Captcha captcha = new Captcha(); captcha.ShowDialog(); Close(); } } } } catch (Exception er) { MessageBox.Show(er.Message); } }