private void listbox_Show_SelectionChanged(object sender, SelectionChangedEventArgs e) { if ((string)lbl_Title.Content == "Jobs") { JobO chosenJob = (JobO)listbox_Show.SelectedItem; SelectedTemp.ChosenJob = chosenJob; ShowDetails sdJ = new ShowDetails((string)lbl_Title.Content); sdJ.Show(); this.Close(); } else if ((string)lbl_Title.Content == "Users") { UserO chosenUser = (UserO)listbox_Show.SelectedItem; SelectedTemp.ChosenUser = chosenUser; ShowDetails sdU = new ShowDetails((string)lbl_Title.Content); sdU.Show(); this.Close(); } else if ((string)lbl_Title.Content == "Tarif") { TO chosenTarif = (TO)listbox_Show.SelectedItem; SelectedTemp.ChosenTarif = chosenTarif; ShowDetails sdT = new ShowDetails((string)lbl_Title.Content); sdT.Show(); this.Close(); } else if ((string)lbl_Title.Content == "ESPs") { ESPO chosenESP = (ESPO)listbox_Show.SelectedItem; SelectedTemp.ChosenESP = chosenESP; ShowDetails sdESP = new ShowDetails((string)lbl_Title.Content); sdESP.Show(); this.Close(); } else if ((string)lbl_Title.Content == "Resources") { RO chosenR = (RO)listbox_Show.SelectedItem; SelectedTemp.ChosenR = chosenR; ShowDetails sdR = new ShowDetails((string)lbl_Title.Content); sdR.Show(); this.Close(); } else if ((string)lbl_Title.Content == "ResourceTypes") { RTO chosenRT = (RTO)listbox_Show.SelectedItem; SelectedTemp.ChosenRT = chosenRT; ShowDetails sdRT = new ShowDetails((string)lbl_Title.Content); sdRT.Show(); this.Close(); } }
public static List <RTO> SelectAllResourceTypes() { List <RTO> rtList = new List <RTO>(); OpenConnection(); SqlCommand getRT = new SqlCommand("SELECT * FROM ResourceType", myConnection); SqlDataReader reader = getRT.ExecuteReader(); while (reader.Read()) { RTO rt = new RTO(); rt.Name = reader.GetString(1); rt.ResourceTypeID = reader.GetInt32(0); rtList.Add(rt); } CloseConnection(); return(rtList); }
public ShowDetails(string subject) { InitializeComponent(); if (CurrentUser.IsAdmin == false) { btn_Delete.IsEnabled = false; btn_Edit.IsEnabled = false; } if (subject == "Jobs") { lbl_Title.Content = "Job"; JobO chosenJob = SelectedTemp.ChosenJob; lbl_CreatedFill.Content = chosenJob.Created; lbl_DeadlineFill.Content = chosenJob.Deadline; UserO createdBy = DB.GetUser(chosenJob.CreatedUserID); lbl_CreatedByFill.Content = (createdBy.FirstName + "" + createdBy.SurName); lbl_NameFill.Content = chosenJob.JobName; lbl_PriorityFill.Content = chosenJob.Priority; } else if (subject == "Users") { lbl_Title.Content = "User"; UserO chosenUser = SelectedTemp.ChosenUser; lbl_NameTitle.Content = ("Username: "******"Fornavn: "); lbl_CreatedTitle.Content = ("Efternavn: "); lbl_DeadlineTitle.Content = ("Password: "******"Is User admin:"); lbl_NameFill.Content = chosenUser.UserName; lbl_CreatedByFill.Content = chosenUser.FirstName; lbl_CreatedFill.Content = chosenUser.SurName; lbl_DeadlineFill.Content = chosenUser.Password; lbl_PriorityFill.Content = chosenUser.IsAdmin; } else if (subject == "Tarif") { lbl_Title.Content = "Tarif"; TO chosenTarif = SelectedTemp.ChosenTarif; lbl_NameTitle.Content = ("Price: "); lbl_CreatedByTitle.Content = ("Start: "); lbl_CreatedTitle.Content = ("End: "); lbl_DeadlineTitle.Content = (""); lbl_PriorityTitle.Content = (""); lbl_NameFill.Content = chosenTarif.Cost; lbl_CreatedByFill.Content = chosenTarif.StartTime; lbl_CreatedFill.Content = chosenTarif.EndTime; } else if (subject == "ESPs") { lbl_Title.Content = "ESP"; ESPO chosenESP = SelectedTemp.ChosenESP; lbl_NameTitle.Content = ("Energy Surplus: "); lbl_CreatedByTitle.Content = ("Start date: "); lbl_CreatedTitle.Content = ("End date: "); lbl_DeadlineTitle.Content = ("start time: "); lbl_PriorityTitle.Content = ("End time: "); lbl_NameFill.Content = chosenESP.EnergySurplus; lbl_CreatedByFill.Content = chosenESP.StartDate; lbl_CreatedFill.Content = chosenESP.EndDate; lbl_DeadlineFill.Content = chosenESP.StartTime; lbl_PriorityFill.Content = chosenESP.EndTime; } else if (subject == "Resources") { RO chosenR = SelectedTemp.ChosenR; lbl_Title.Content = "Resource"; lbl_NameTitle.Content = ("Name: "); lbl_CreatedByTitle.Content = (""); lbl_CreatedTitle.Content = (""); lbl_DeadlineTitle.Content = (""); lbl_PriorityTitle.Content = (""); lbl_NameFill.Content = chosenR.Name; } else if (subject == "ResourceTypes") { RTO chosenRT = SelectedTemp.ChosenRT; lbl_Title.Content = "Resource type"; lbl_NameTitle.Content = ("Name: "); lbl_CreatedByTitle.Content = (""); lbl_CreatedTitle.Content = (""); lbl_DeadlineTitle.Content = (""); lbl_PriorityTitle.Content = (""); lbl_NameFill.Content = chosenRT.Name; } }