private void DeleteEmployeeButton_Click(object sender, RoutedEventArgs e) { using (CarentContext db = new CarentContext()) { Employee employee = db.Employees.Find(CurrentId); db.Employees.Remove(employee); db.SaveChanges(); } AdminEmployees ae = new AdminEmployees(); NavigationService.Navigate(ae); }
private void EditEmployeeButton_Click(object sender, RoutedEventArgs e) { using (CarentContext db = new CarentContext()) { Employee employee = db.Employees.Find(CurrentId); employee.FIO = EmployeeFIOTextBox.Text; employee.Experience = int.Parse(EmployeeExpTextBox.Text); db.SaveChanges(); } AdminEmployees ae = new AdminEmployees(); NavigationService.Navigate(ae); }
public EditEmployee(int id) { InitializeComponent(); CurrentId = id; using (CarentContext db = new CarentContext()) { var employees = db.Employees; foreach (Employee employee in employees) { if (CurrentId == employee.Id) { EmployeeFIOTextBox.Text = employee.FIO; EmployeeExpTextBox.Text = Convert.ToString(employee.Experience); } } } }
private void TryToRegistrButton_Click(object sender, RoutedEventArgs e) { if (LogInTextBox.Text == "" || RegistrPasswordBox.Text == "" || TelephoneNumberTextBox.Text == "") { ErrorTextBox.Visibility = Visibility.Visible; } else { using (CarentContext db = new CarentContext()) { User user = new User { Login = LogInTextBox.Text, Password = RegistrPasswordBox.Text, TelephoneNumber = TelephoneNumberTextBox.Text, Status = "user" }; db.Users.Add(user); db.SaveChanges(); } AppWindow app = new AppWindow("user"); app.Show(); Application.Current.MainWindow.Close(); } }
private void TryToLogInButton_Click(object sender, RoutedEventArgs e) { using (CarentContext user_db = new CarentContext()) { var users = user_db.Users; foreach (User u in users) { if (u.Login == LogInTextBox.Text) { if (u.Password == LogInPasswordBox.Password) { AppWindow app = new AppWindow(u.Status); app.Show(); Application.Current.MainWindow.Close(); } } else { ErrorTextBox.Text = "Вы ввели неверный логин или пароль"; } } } }
public CarsList(string carClass) { InitializeComponent(); using (CarentContext db = new CarentContext()) { IEnumerable <Car> selectedCars = null; var Allcars = db.Cars; if (carClass == "Эконом") { var cars = from c in Allcars where c.Class == "Эконом" select c; selectedCars = cars; } if (carClass == "Средний") { var cars = from c in Allcars where c.Class == "Средний" select c; selectedCars = cars; } if (carClass == "Премиум") { var cars = from c in Allcars where c.Class == "Премиум" select c; selectedCars = cars; } List <Car> crs = new List <Car>(); foreach (Car c in selectedCars) { crs.Add(c); } carsList.ItemsSource = crs; } }