Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 private void Btn_Edit_Click(object sender, RoutedEventArgs e)
 {
     if ((string)lbl_Title.Content == "Job")
     {
         Job.Editing = true;
         Job chosenJob = new Job();
         chosenJob.EditJobShow(SelectedTemp.ChosenJob.JobID, SelectedTemp.ChosenJob.CreatedUserID);
         Job.EditingJobID     = SelectedTemp.ChosenJob.JobID;
         Job.EditingJobUserID = SelectedTemp.ChosenJob.CreatedUserID;
     }
     // done
     else if ((string)lbl_Title.Content == "User")
     {
         User.Editing = true;
         User  chosenUser   = new User();
         UserO selectedUser = SelectedTemp.ChosenUser;
         chosenUser.EditUserShow(selectedUser.UserID);
         User.EditUserID = selectedUser.UserID;
     }
     else if ((string)lbl_Title.Content == "Tarif")
     {
         Tarif.editing        = true;
         Tarif.editingTarifID = SelectedTemp.ChosenTarif.TarifID;
         Tarif.EditShow(SelectedTemp.ChosenTarif.Cost, SelectedTemp.ChosenTarif.StartTime, SelectedTemp.ChosenTarif.EndTime, SelectedTemp.ChosenTarif.TarifID);
     }
     else if ((string)lbl_Title.Content == "ESP")
     {
         ESP.editing      = true;
         ESP.editingESPID = SelectedTemp.ChosenESP.ESP_ID;
         ESP.EditShow(SelectedTemp.ChosenESP.ESP_ID);
     }
     else if ((string)lbl_Title.Content == "Resource")
     {
         Resource.EditResourceShow(SelectedTemp.ChosenR.ResourceID);
         Resource.editing           = true;
         Resource.editingResourceID = SelectedTemp.ChosenR.ResourceID;
     }
     else if ((string)lbl_Title.Content == "Resource type")
     {
         ResourceType.EditShow(SelectedTemp.ChosenRT.ResourceTypeID);
         ResourceType.editing            = true;
         ResourceType.EditResourceTypeID = SelectedTemp.ChosenRT.ResourceTypeID;
     }
 }
Ejemplo n.º 4
0
        public static List <UserO> SelectAllUsers()
        {
            List <UserO> uList = new List <UserO>();

            OpenConnection();
            SqlCommand    getU   = new SqlCommand("SELECT * FROM [User]", myConnection);
            SqlDataReader reader = getU.ExecuteReader();

            while (reader.Read())
            {
                UserO u = new UserO();
                u.FirstName = reader.GetString(3);
                u.SurName   = reader.GetString(4);
                u.UserName  = reader.GetString(1);
                u.IsAdmin   = reader.GetBoolean(5);
                u.Password  = reader.GetString(2);
                u.UserID    = reader.GetInt32(0);
                uList.Add(u);
            }
            CloseConnection();
            return(uList);
        }
Ejemplo n.º 5
0
        internal static UserO GetUser(int createdUserID)
        {
            UserO u = new UserO();

            OpenConnection();
            SqlCommand getU = new SqlCommand("SELECT * FROM [User] WHERE UserID=@UserId", myConnection);

            getU.Parameters.Add("@UserID", SqlDbType.Int);
            getU.Parameters["@UserID"].Value = createdUserID;
            SqlDataReader reader = getU.ExecuteReader();

            if (reader.Read())
            {
                u.FirstName = reader.GetString(3);
                u.SurName   = reader.GetString(4);
                u.UserName  = reader.GetString(1);
                u.IsAdmin   = reader.GetBoolean(5);
                u.Password  = reader.GetString(2);
                u.UserID    = reader.GetInt32(0);
            }
            CloseConnection();
            return(u);
        }
Ejemplo n.º 6
0
        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;
            }
        }