示例#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
        public newProject()
        {
            InitializeComponent();


            // Edit Employee auto fill form
            if (Application.Current.Properties["proj_edit_id"] != null)
            {
                int     proj_id;
                var     bool5 = Int32.TryParse(Application.Current.Properties["proj_edit_id"].ToString(), out proj_id);
                Projekt proj  = Bibliothek.Projekt_nach_ID(proj_id);
                this.projName.Text = proj.Name;

                this.projOffene.Text     = proj.OffeneZeitStunden.ToString();
                this.projGesamt.Text     = proj.GesamtZeitStunden.ToString();
                this.projAktiv.IsChecked = proj.IstAktiv;

                this.projStart.SelectedDate = proj.StartDatum;
                this.projEnd.SelectedDate   = proj.EndDatum;

                this.projSubmit.Tag = "edit";
                // Create hidden button to save employee id
                this.btnID.Tag = proj_id.ToString();

                // Edit window opened and loaded.. reset trigger property
                Application.Current.Properties["proj_edit_id"] = null;
            }
        }
示例#3
0
 /// <summary>
 /// Diese Methode nimmt die Werte die der Benutzer einegegeben hat und speichert sie in einen Einsatz,
 /// </summary>
 /// <param name="e">Einsatz der mit den Werten vom Benutzer gefüllt werden soll</param>
 private void setzeEinsatz(Einsatz e)
 {
     e.ID          = einsatz.ID;
     e.Mitarbeiter = Bibliothek.Mitarbeiter_nach_ID(this.mitarbeiter.SelectedIndex + 1);
     e.Projekt     = Bibliothek.Projekt_nach_ID(this.projekt.SelectedIndex + 1);
     e.Farbe       = (farbe.Background as SolidColorBrush).Color;
     setzeDatum(e);
 }
示例#4
0
        private void btnProj_Handler(object sender, RoutedEventArgs e)
        {
            Button myButton = (Button)sender;

            // Create new Project
            if (myButton.Tag.ToString() == "new")
            {
                Projekt newProj = new Projekt();
                int     id;
                var     bool4 = Int32.TryParse(Application.Current.Properties["proj_id"].ToString(), out id); // saved max id to increment
                newProj.ID = id += 1;
                Application.Current.Properties["proj_id"] = (id += 1).ToString();
                newProj.Name = this.projName.Text;

                int offen;
                var bool1 = Int32.TryParse(projOffene.Text, out offen);
                int gesamt;
                var bool2 = Int32.TryParse(projGesamt.Text, out gesamt);
                newProj.OffeneZeitStunden = offen;
                newProj.GesamtZeitStunden = gesamt;

                newProj.IstAktiv = projAktiv.IsChecked.Value;

                newProj.StartDatum = this.projStart.SelectedDate.Value;
                newProj.EndDatum   = this.projEnd.SelectedDate.Value;
                Bibliothek.Projekt_Neu(newProj);

                // Project Created - show success and reset form
                this.projName.Text          = "";
                this.projOffene.Text        = "";
                this.projGesamt.Text        = "";
                this.projStart.SelectedDate = null;
                this.projEnd.SelectedDate   = null;
                this.projAktiv.IsChecked    = false;

                this.success.Text       = "Projekt erfolgrichlich erstellt";
                this.success.Visibility = Visibility.Visible;
            }

            // Edit Project
            if (myButton.Tag.ToString() == "edit")
            {
                int     id;
                var     bool6 = Int32.TryParse(this.btnID.Tag.ToString(), out id);
                Projekt proj  = Bibliothek.Projekt_nach_ID(id);
                proj.Name = this.projName.Text;

                int offen;
                var bool1 = Int32.TryParse(projOffene.Text, out offen);
                int gesamt;
                var bool2 = Int32.TryParse(projGesamt.Text, out gesamt);
                proj.OffeneZeitStunden = offen;
                proj.GesamtZeitStunden = gesamt;

                proj.IstAktiv = projAktiv.IsChecked.Value;

                proj.StartDatum = this.projStart.SelectedDate.Value;
                proj.EndDatum   = this.projEnd.SelectedDate.Value;
                this.btnID.Tag  = ""; // reset edit job id holder

                // Project Edited - show success and reset form
                this.projName.Text          = "";
                this.projOffene.Text        = "";
                this.projGesamt.Text        = "";
                this.projStart.SelectedDate = null;
                this.projEnd.SelectedDate   = null;
                this.projAktiv.IsChecked    = false;

                this.success.Text       = "Projekt erfolgrichlich gearbeitet";
                this.success.Visibility = Visibility.Visible;
            }
        }
        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;
                }
            }
        }