private void User() { try { WindowUser window = new WindowUser(EventsBase.GetInstance().GetControlEvents(OpcServer.OpcList.Rbu)); window.Show(); } catch (Exception) { MessageBox.Show("Нет связи с базой данных", "Предупреждение"); } }
private void btnlog_Click(object sender, RoutedEventArgs e) { var user = Ent.context.Worker.ToList(). Where(i => i.Login == tblog.Text && i.Password == pbpas.Password).FirstOrDefault(); if (user != null) { UserData.worker = user; switch (user.RoleId) { case 1: WindowAdmin winad = new WindowAdmin(); Hide(); winad.ShowDialog(); Close(); break; case 2: WindowUser winuser = new WindowUser(); Hide(); winuser.ShowDialog(); Close(); break; case 3: WindowManager winmanager = new WindowManager(); Hide(); winmanager.ShowDialog(); Close(); break; default: break; } } else { MessageBox.Show("Пользователь не найден", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }