private void btnCancel_Click(object sender, RoutedEventArgs e) { cookWindow = (CookWindow)this.Owner; cookWindow.btnSearch_Click(sender, e); cookWindow.readMeals(); this.Close(); }
private void btnLogIn_Click(object sender, RoutedEventArgs e) { String nameToFind = Regex.Match(cmbChooseAccount.SelectedItem.ToString(), @"Name: ([A-Za-z]+)").Value; //String nameToFind = Regex.Match(cmbChooseAccount.SelectedItem.ToString(), @"\bName\W+\s\w+\W+\s\b").Value; nameToFind = Regex.Replace(nameToFind, @"Name: ", ""); //MessageBox.Show("Name to find is " + nameToFind); Console.WriteLine("Name to find is " + nameToFind); if (accountToLogIn == 1) { Cook currentCook = new Cook(); foreach (Cook cook in dbAccess.CooksDB) { currentCook = dbAccess.CooksDB.Find(c => c.Name == nameToFind); } if (passwordBox.Password == SingletonDatabaseAccess.PasswordForAll) { CookWindow cookWindow = new CookWindow(currentCook); this.Close(); cookWindow.ShowDialog(); } else { MessageBox.Show("Please enter the valid password!"); } } else if (accountToLogIn == 2) { Eater currentEater = new Eater(); foreach (Eater eater in dbAccess.EatersDB) { currentEater = dbAccess.EatersDB.Find(eat => eat.Name == nameToFind); } if (passwordBox.Password == SingletonDatabaseAccess.PasswordForAll) { EaterWindow eaterWindow = new EaterWindow(currentEater); this.Close(); eaterWindow.ShowDialog(); } else { MessageBox.Show("Please enter the valid password!"); } } else if (accountToLogIn == 3) { Administrator currentAdmin = new Administrator(); foreach (Administrator admin in dbAccess.AdminsDB) { currentAdmin = dbAccess.AdminsDB.Find(a => a.Name == nameToFind); } if (passwordBox.Password == SingletonDatabaseAccess.PasswordForAll) { AdminWindow adminWindow = new AdminWindow(currentAdmin); this.Close(); adminWindow.ShowDialog(); } else { MessageBox.Show("Please enter the valid password!"); } } else { MessageBox.Show("Please select one of the accounts from above to Log In"); } }