public NewDoctorWindow(HeadPhysician sessionDoctor, WorkingWindow window) { InitializeComponent(); this.window = window; this.sessionDoctor = sessionDoctor; NewDocViewModel viewModel = new NewDocViewModel(sessionDoctor); this.DataContext = viewModel; viewModel.addDocCompleted += AddNewDocView; }
public static ObservableCollection <HeadPhysician> LoadHeadPhyses() { string query = "SELECT id FROM Worker WHERE retired = 0 and post = 2"; List <Dictionary <int, object> > doctorsDB = DBConnector.queryExecuteMultiResult(query); ObservableCollection <HeadPhysician> doctors = new ObservableCollection <HeadPhysician>(); foreach (Dictionary <int, object> data in doctorsDB) { HeadPhysician headPhysician = new HeadPhysician(); ((IDatabaseCommutable)headPhysician).LoadFromDb(Convert.ToInt32(data[0])); doctors.Add(headPhysician); } return(doctors); }
public NewDocViewModel(HeadPhysician sessionDoctor) { try { ((IDatabaseCommutable)sessionDoctor).LoadFromDb(sessionDoctor.Id); } catch (KeyNotFoundException) { ErrorWindow errorWindow = new ErrorWindow("A database error occured"); errorWindow.ShowDialog(); } catch (HaveBeenFiredException e) { ErrorWindow errorWindow = new ErrorWindow(e); errorWindow.ShowDialog(); } CurrentDoc = sessionDoctor; }
private void LoginFunction(object sender, RoutedEventArgs e) { string login = LoginField.Text; string password = PasswordField.Password; string query = "SELECT password, retired, post from Worker where cast(id as TEXT) = @login"; Dictionary <string, object> parameters = new Dictionary <string, object> { { "login", login } }; Dictionary <int, object> reader = DBConnector.queryExecuteSingleResult(query, parameters); if (reader.Count != 0 && password == Convert.ToString(reader[0]) && Convert.ToInt32(reader[1]) == 0) { int post = Convert.ToInt32(reader[2]); Nurse sessionDoctor; if (post == 1) { sessionDoctor = new Doctor(); } else if (post == 2) { sessionDoctor = new HeadPhysician(); } else { sessionDoctor = new Nurse(); } ((IDatabaseCommutable)sessionDoctor).LoadFromDb(Int32.Parse(login)); WorkingWindow workingWindow = new WorkingWindow(sessionDoctor); workingWindow.Show(); this.Close(); } else { wrongDataText.Visibility = Visibility.Visible; LoginField.Foreground = Brushes.Red; PasswordField.Foreground = Brushes.Red; } }