private void prepareDropdown() { Bibliothek.Projekt_Alle().ForEach(delegate(Projekt projekt) { ComboBox_ProjektBezeichnung.Items.Add(projekt.Name); }); Bibliothek.Mitarbeiter_Alle().ForEach(delegate(Mitarbeiter mitarbeiter) { ComboBox_Mitarbeiter.Items.Add(mitarbeiter.Name + " " + mitarbeiter.Vorname); }); }
public listProject() { InitializeComponent(); List <Projekt> projList = Bibliothek.Projekt_Alle(); for (var i = 0; i < projList.Count(); i++) { ListBoxItem proj = new ListBoxItem(); proj.Tag = projList[i].ID; proj.Content = projList[i].Name; proj.Background = Brushes.White; proj.MouseDoubleClick += this.lsProj_Handler; this.projListBox.Items.Add(proj); } }
/// <summary> /// Diese Methode liest alle Projekte und schreibt Sie in eine ComboBox /// damit Einsätze anderen Projekten zugeteilt werden können. /// </summary> private void setProjektBox() { List <String> projektNamen = new List <string>(); foreach (Projekt projekt in Bibliothek.Projekt_Alle()) { // Für jedes Projekt wird der Name in eine Liste gespeichert projektNamen.Add(projekt.Name); } // Dann wird diese Liste als Quelle für die ComboBox der Projekte angegeben this.projekt.ItemsSource = projektNamen; // Wenn der Einsatz sbereits existiert, wird das Projekt als Standart gesezt zudem der Einsatz gehört. // Falls dies ein neuer Einsatz ist, wird einfach das erste Projekt als Standart gesezt. if (Neu) { this.projekt.SelectedIndex = 1; } else { this.projekt.SelectedIndex = einsatz.Projekt.ID - 1; } }
public newJob() { InitializeComponent(); if (Application.Current.Properties["job_edit_id"] == null) // not in edit mode { // Fill list of mitarbeiters var listMitarbeiter = Bibliothek.Mitarbeiter_Alle(); for (var i = 0; i < listMitarbeiter.Count(); i++) { ComboboxItem mitarbeiter = new ComboboxItem(); // Defined own combobox object (defined below) to save name & id mitarbeiter.Text = listMitarbeiter[i].Name; mitarbeiter.Value = listMitarbeiter[i].ID; jobMit.Items.Add(mitarbeiter); } jobMit.SelectedIndex = 0; // Fill list of projects var listProjekte = Bibliothek.Projekt_Alle(); for (var i = 0; i < listProjekte.Count(); i++) { ComboboxItem projekt = new ComboboxItem(); // Defined own combobox object (defined below) to save name & id projekt.Text = listProjekte[i].Name; projekt.Value = listProjekte[i].ID; jobProj.Items.Add(projekt); } jobProj.SelectedIndex = 0; } // Edit Employee auto fill form if (Application.Current.Properties["job_edit_id"] != null) { int job_id; var bool5 = Int32.TryParse(Application.Current.Properties["job_edit_id"].ToString(), out job_id); Einsatz job = Bibliothek.Einsatz_nach_ID(job_id); this.jobName.Text = job.Name; // Fill list of mitarbeiters var listMit = Bibliothek.Mitarbeiter_Alle(); var index1 = 0; for (var i = 0; i < listMit.Count(); i++) { ComboboxItem mitarbeiter = new ComboboxItem(); // Defined own combobox object (defined below) to save name & id mitarbeiter.Text = listMit[i].Name; mitarbeiter.Value = listMit[i].ID; jobMit.Items.Add(mitarbeiter); if (job.Mitarbeiter.ID == listMit[i].ID) { jobMit.SelectedIndex = index1; } else { index1 += 1; } } // Fill list of projects var listProj = Bibliothek.Projekt_Alle(); var index2 = 0; for (var i = 0; i < listProj.Count(); i++) { ComboboxItem projekt = new ComboboxItem(); // Defined own combobox object (defined below) to save name & id projekt.Text = listProj[i].Name; projekt.Value = listProj[i].ID; jobProj.Items.Add(projekt); if (job.Projekt.ID == listProj[i].ID) { jobProj.SelectedIndex = index2; } else { index2 += 1; } } this.jobStart.SelectedDate = job.Start; this.jobEnd.SelectedDate = job.Ende; this.jobSubmit.Tag = "edit"; // Create hidden button to save employee id this.btnID.Tag = job_id.ToString(); // Edit window opened and loaded.. reset trigger property Application.Current.Properties["job_edit_id"] = null; } }