/// <summary> /// maakt het assignment object dat bij de student hoort /// </summary> public void makeAssignment(StageopdrachtViewModel vm2) { string query = "SELECT o.opdrachtnaam, o.omschrijving, o.opmerking, o.opdrachtgoed, o.toestemmingvoorlopig, o.toestemmingdefinitief, o.periode_periodenaam, b.naam, o.type FROM stageopdracht o JOIN stageopdracht_has_student s ON o.stagenr = s.stageopdracht_stagenr JOIN stagebedrijf b ON o.stagebedrijf_bedrijfnr = b.bedrijfnr WHERE s.student_studentnr = " + SelectedItem.StudentNo + ";"; MySqlCommand mycommand = new MySqlCommand(query); MySqlDataAdapter adapter = new MySqlDataAdapter(); DataTable data = new DataTable(); adapter = Database.getData(mycommand); adapter.Fill(data); if (data.Rows.Count != 0) { vm2.Student.Assignment = new Assignment { Name = data.Rows[0][0].ToString(), Description = data.Rows[0][1].ToString(), Comments = data.Rows[0][2].ToString(), Accepted = (bool)data.Rows[0][3], Permission = (bool)data.Rows[0][5], TempPermission = (bool)data.Rows[0][4], //Knowledge = data.Rows[0][5].ToString(), Period = data.Rows[0][6].ToString(), Company = data.Rows[0][7].ToString(), Type = data.Rows[0][8].ToString(), }; } else { vm2.Student.Assignment = null; } }
/// <summary> /// Returns the viewModel. It will be made if it doesn't exist yet. /// </summary> /// <param name="app">The applicationcontroller</param> /// <param name="name">Name of the viewModel to be returned</param> /// <returns>The requested viewModel or null if the value is wrong</returns> public static PropertyChangedBase getViewModel(IApplicationController app, string name) { switch (name) { case ("stageBedrijfViewModel"): if (_stageBedrijfView == null) _stageBedrijfView = new StageBedrijfViewModel(app); _mainWindowModel.Display = "Stage"; return _stageBedrijfView; case ("stageBedrijfOverzichtViewModel"): if (_stageBedrijfOverzichtView == null) _stageBedrijfOverzichtView = new StagebedrijfOverzichtViewModel(app); _stageBedrijfOverzichtView.FillCompanyTable(); _mainWindowModel.Display = "Bedrijven"; return _stageBedrijfOverzichtView; case ("docentKwalificatieViewModel"): if (_docentKwalificatieView == null) _docentKwalificatieView = new DocentKwalificatieViewModel(app); _mainWindowModel.Display = "Docenten"; return _docentKwalificatieView; case ("docentPersoonViewModel"): if (_docentPersoonView == null) _docentPersoonView = new DocentPersoonViewModel(app); _mainWindowModel.Display = "Docenten"; return _docentPersoonView; case ("docentViewModel"): if (_docentView == null) _docentView = new DocentViewModel(app); _docentView.fillTeacherTable(); _mainWindowModel.Display = "Docenten"; return _docentView; case ("gebruikerAccountViewModel"): if (_gebruikerAccountView == null) _gebruikerAccountView = new GebruikerAccountViewModel(app); _mainWindowModel.Display = "Gebruikers"; return _gebruikerAccountView; case ("gebruikerViewModel"): if (_gebruikerView == null) _gebruikerView = new GebruikerViewModel(app); _gebruikerView.fillUserTable(); _mainWindowModel.Display = "Gebruikers"; return _gebruikerView; case ("matchDetailsViewModel"): if (_matchDetailsView == null) _matchDetailsView = new MatchDetailsViewModel(app); _mainWindowModel.Display = "Matchen"; return _matchDetailsView; case ("matchInvoerViewModel"): if (_matchInvoerView == null) _matchInvoerView = new MatchInvoerViewModel(app); _mainWindowModel.Display = "Matchen"; _matchInvoerView.FillTable(); return _matchInvoerView; case ("matchGemaaktViewModel"): if (_matchGemaaktView == null) _matchGemaaktView = new MatchGemaaktViewModel(app); _mainWindowModel.Display = "Matchen"; _matchGemaaktView.FillTable(); return _matchGemaaktView; case ("matchMogelijkViewModel"): if (_matchMogelijkView == null) _matchMogelijkView = new MatchMogelijkViewModel(app); return _matchMogelijkView; case ("matchSuccesViewModel"): if (_matchSuccesView == null) _matchSuccesView = new MatchSuccesViewModel(app); _mainWindowModel.Display = "Matchen"; return _matchSuccesView; case ("stageViewModel"): if (_stageView == null) _stageView = new StageViewModel(app); _mainWindowModel.Display = "Stage"; return _stageView; case ("stageopdrachtViewModel"): if (_stageopdrachtView == null) _stageopdrachtView = new StageopdrachtViewModel(app); _mainWindowModel.Display = "Studenten"; return _stageopdrachtView; case ("studentPersoonViewModel"): if (_studentPersoonView == null) _studentPersoonView = new StudentPersoonViewModel(app); _mainWindowModel.Display = "Studenten"; return _studentPersoonView; case ("studentViewModel"): if (_studentView == null) _studentView = new StudentViewModel(app); _studentView.fillStudentTable(); _studentView.Filter(true); _mainWindowModel.Display = "Studenten"; return _studentView; case ("wachtwoordViewModel"): _wachtwoordViewModel = new WachtwoordViewModel(app); _wachtwoordView = new WachtwoordView(); _wachtwoordView.DataContext = _wachtwoordViewModel; _wachtwoordView.Show(); return _wachtwoordViewModel; case ("mainWindowModel"): if (_mainWindowModel == null) { _mainWindowModel = new MainWindowModel(app); _mainWindow = new MainWindow(); _mainWindow.DataContext = _mainWindowModel; _mainWindow.Closed += app.OnWindowClose; } if (_loginView != null) { _loginView.Hide(); } _mainWindow.Show(); return _mainWindowModel; case ("logInViewModel"): if (_logInViewModel == null) { _logInViewModel = new LogInViewModel(app); _loginView = new LogInView(); _loginView.DataContext = _logInViewModel; _loginView.Closed += app.OnWindowClose; _logInViewModel.PasswordBox = _loginView.PasswordBox; } if (_mainWindow != null) { _mainWindow.Hide(); } _loginView.Show(); return _logInViewModel; default: return null; } }