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 <RO> SelectAllResource(int resourceTypeId) { List <RO> rList = new List <RO>(); OpenConnection(); SqlCommand getR = new SqlCommand("SELECT * FROM Resource", myConnection); SqlDataReader reader = getR.ExecuteReader(); while (reader.Read()) { RO r = new RO(); r.Name = reader.GetString(1); r.ResourceID = reader.GetInt32(2); rList.Add(r); } CloseConnection(); return(rList); }
private static string GenerateJobName(JobO jobToBeScheduled) { UserO jobCreatedBy = DB.GetUser(jobToBeScheduled.CreatedUserID); RO jobResource = DB.GetResource(jobToBeScheduled.ResourceID); string resName; if (jobResource.Name.Length < 8) { resName = jobResource.Name; } else { resName = jobResource.Name.Substring(0, 8); } string jobname = jobCreatedBy.FirstName + resName + jobToBeScheduled.ExeTime.ToShortDateString() + rnd.Next(1000, 9999).ToString(); return(jobname); }
internal static RO GetResource(int resourceID) { RO r = new RO(); OpenConnection(); SqlCommand getR = new SqlCommand("SELECT * FROM Resource WHERE ResourceID=@ResourceID", myConnection); getR.Parameters.Add("@ResourceID", SqlDbType.Int); getR.Parameters["@ResourceID"].Value = resourceID; SqlDataReader reader = getR.ExecuteReader(); if (reader.Read()) { r.Name = reader.GetString(1); r.ResourceID = reader.GetInt32(2); } CloseConnection(); return(r); }
private void lbx_Resources_SelectionChanged(object sender, SelectionChangedEventArgs e) { ResourceID = (RO)lbx_Resources.SelectedItem; }
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; } }