示例#1
0
        private void demoDatenEinsaetze()
        {
            Einsatz e1 = new Einsatz();
            e1.ID = 1;
            e1.Mitarbeiter = Bibliothek.Mitarbeiter_nach_ID(1);
            e1.Projekt = Bibliothek.Projekt_nach_ID(1);
            e1.Start = new DateTime(2016, 6, 7, 8, 0, 0);
            e1.Ende = new DateTime(2016, 6, 7, 15, 0, 0);
            Bibliothek.EinsatzNeu(e1);

            Einsatz e2 = new Einsatz();
            e1.ID = 2;
            e2.Mitarbeiter = Bibliothek.Mitarbeiter_nach_ID(1);
            e2.Projekt = Bibliothek.Projekt_nach_ID(2);
            e2.Start = new DateTime(2016, 6, 10, 11, 0, 0);
            e2.Ende = new DateTime(2016, 6, 10, 18, 0, 0);
            Bibliothek.EinsatzNeu(e2);

            Einsatz e3 = new Einsatz();
            e1.ID = 3;
            e3.Mitarbeiter = Bibliothek.Mitarbeiter_nach_ID(2);
            e3.Projekt = Bibliothek.Projekt_nach_ID(1);
            e3.Start = new DateTime(2016, 6, 14, 10, 0, 0);
            e3.Ende = new DateTime(2016, 6, 14, 14, 0, 0);
            Bibliothek.EinsatzNeu(e3);

            Einsatz e4 = new Einsatz();
            e1.ID = 4;
            e4.Mitarbeiter = Bibliothek.Mitarbeiter_nach_ID(2);
            e4.Projekt = Bibliothek.Projekt_nach_ID(1);
            e4.Start = new DateTime(2016, 6, 15, 10, 0, 0);
            e4.Ende = new DateTime(2016, 6, 15, 14, 0, 0);
            Bibliothek.EinsatzNeu(e4);
        }
示例#2
0
 /// <summary>
 /// Wenn auf den Knopf Speicher geklickt wird, werden die Benutzereingaben überprüft
 /// sowie dass keine Zeitüberschneidungen bestehen. Falls beides in Ordnung ist, wird der Einsatz erstellt oder geändert
 /// und das Fenster wird geschlossen.
 /// </summary>
 /// <param name="sender">Button Objekt</param>
 /// <param name="e">Event Parameter</param>
 private void speichern_Click(object sender, RoutedEventArgs e)
 {
     if (ueberpruefeEingaben() && ueberpruefeZeit())
     {
         setzeEinsatz(this.einsatz);
         if (Neu)
         {
             Bibliothek.EinsatzNeu(this.einsatz);
         }
         this.Close();
     }
 }
        private void btnJob_Handler(object sender, RoutedEventArgs e)
        {
            Button myButton = (Button)sender;

            // Create new Job
            if (myButton.Tag.ToString() == "new")
            {
                Einsatz newJob = new Einsatz();
                int     id;
                var     bool4 = Int32.TryParse(Application.Current.Properties["job_id"].ToString(), out id); // saved max id to increment
                newJob.ID = id += 1;
                Application.Current.Properties["job_id"] = (id += 1).ToString();
                newJob.Name = this.jobName.Text;

                // Get Mitarbeiter und Projekte ID
                int mit_id;
                var bool1 = Int32.TryParse((jobMit.SelectedItem as ComboboxItem).Value.ToString(), out mit_id);
                int proj_id;
                var bool2 = Int32.TryParse((jobProj.SelectedItem as ComboboxItem).Value.ToString(), out proj_id);

                newJob.Mitarbeiter = Bibliothek.Mitarbeiter_nach_ID(mit_id); // Tag has id and save Bibliotek get from id
                newJob.Projekt     = Bibliothek.Projekt_nach_ID(proj_id);
                newJob.Start       = this.jobStart.SelectedDate.Value;
                newJob.Ende        = this.jobEnd.SelectedDate.Value;

                // check validity
                bool valid = isValid(newJob, new Einsatz(), false);

                if (valid == true)
                {
                    // Create New Job
                    Bibliothek.EinsatzNeu(newJob);

                    // Job Created - show success and reset form
                    this.jobName.Text          = "";
                    this.jobMit.SelectedIndex  = 1;
                    this.jobProj.SelectedIndex = 1;
                    this.jobStart.SelectedDate = null;
                    this.jobEnd.SelectedDate   = null;

                    this.success.Text       = "Einsatz erfolgrichlich erstellt";
                    this.success.Background = Brushes.LimeGreen;
                    this.success.Visibility = Visibility.Visible;
                }
            }

            // Edit Job
            if (myButton.Tag.ToString() == "edit")
            {
                int id;
                var bool6 = Int32.TryParse(this.btnID.Tag.ToString(), out id);

                // Einsatz job = Bibliothek.Einsatz_nach_ID(id);
                Einsatz job = new Einsatz();

                job.Name = this.jobName.Text;

                // Get Mitarbeiter und Projekte ID
                int mit_id;
                var bool1 = Int32.TryParse((jobMit.SelectedItem as ComboboxItem).Value.ToString(), out mit_id);
                int proj_id;
                var bool2 = Int32.TryParse((jobProj.SelectedItem as ComboboxItem).Value.ToString(), out proj_id);

                job.Mitarbeiter = Bibliothek.Mitarbeiter_nach_ID(mit_id); // Tag has id and save Bibliotek get from id
                job.Projekt     = Bibliothek.Projekt_nach_ID(proj_id);
                job.Start       = this.jobStart.SelectedDate.Value;
                job.Ende        = this.jobEnd.SelectedDate.Value;

                bool valid = isValid(job, Bibliothek.Einsatz_nach_ID(id), true);
                if (valid == true)
                {
                    Einsatz original_job = Bibliothek.Einsatz_nach_ID(id);
                    original_job.Name = this.jobName.Text;

                    // Get Mitarbeiter und Projekte ID
                    int _mit_id;
                    var _bool1 = Int32.TryParse((jobMit.SelectedItem as ComboboxItem).Value.ToString(), out _mit_id);
                    int _proj_id;
                    var _bool2 = Int32.TryParse((jobProj.SelectedItem as ComboboxItem).Value.ToString(), out _proj_id);

                    original_job.Mitarbeiter = Bibliothek.Mitarbeiter_nach_ID(_mit_id); // Tag has id and save Bibliotek get from id
                    original_job.Projekt     = Bibliothek.Projekt_nach_ID(_proj_id);
                    original_job.Start       = this.jobStart.SelectedDate.Value;
                    original_job.Ende        = this.jobEnd.SelectedDate.Value;

                    this.btnID.Tag = ""; // reset edit job id holder

                    // Job Edited - show success and reset form
                    this.jobName.Text          = "";
                    this.jobMit.SelectedIndex  = 1;
                    this.jobProj.SelectedIndex = 1;
                    this.jobStart.SelectedDate = null;
                    this.jobEnd.SelectedDate   = null;

                    this.success.Text       = "Einsatz erfolgrichlich gearbeitet";
                    this.success.Background = Brushes.LimeGreen;
                    this.success.Visibility = Visibility.Visible;
                }
            }
        }