示例#1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (parentMode == false)
            {
                lblTitle.Content = "Kind " + $"'{_firstName + " " + _lastName}'" + " niet gevonden.";

                var childList = VakacientjesDb.GetChildren();
                foreach (Child child in childList)
                {
                    cmbChild.Items.Add(child.FirstName + " " + child.LastName);
                }
            }
            else
            {
                this.Title             = "Selecteer ouder";
                lblTitle.Content       = "Ouder " + $"'{_firstName + " " + _lastName}'" + " niet gevonden.";
                lblDescription.Content = "Selecteer een bestaande ouder of voeg een nieuwe ouder toe.";

                var parentList = VakacientjesDb.GetParents();
                foreach (Parent parent in parentList)
                {
                    cmbChild.Items.Add(parent.FirstName + " " + parent.LastName);
                }
            }
        }
        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Trim() == "")
            {
                MessageBox.Show("Je hebt nog geen naam ingevuld.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (VakacientjesDb.AddFamily(txtName.Text, txtEmail.Text) == true)
            {
                DialogResult = true;
                Close();
            }
        }
        public AddChildWindow(string firstName, string lastName)
        {
            InitializeComponent();

            txtFirstName.Text = firstName.Trim();
            txtLastName.Text  = lastName.Trim();

            var familyList = VakacientjesDb.GetFamilies();

            foreach (Family family in familyList)
            {
                cmbFamily.Items.Add(family.Name);
            }
        }
        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            if (txtFirstName.Text.Trim() == "")
            {
                MessageBox.Show("Je hebt nog geen voornaam ingevuld.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (txtLastName.Text.Trim() == "")
            {
                MessageBox.Show("Je hebt nog geen familienaam ingevuld.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (cmbFamily.Text == "")
            {
                MessageBox.Show("Je hebt nog geen familie geselecteerd.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            Family family = VakacientjesDb.GetFamily(cmbFamily.Text);

            if (family.Id == -1)
            {
                MessageBox.Show($"Familie '{cmbFamily.Text}' niet gevonden.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (parentMode == false)
            {
                if (VakacientjesDb.AddChild(family.Id, txtFirstName.Text, txtLastName.Text) == true)
                {
                    DialogResult = true;
                    Close();
                }
            }
            else
            {
                if (VakacientjesDb.AddParent(family.Id, txtFirstName.Text, txtLastName.Text) == true)
                {
                    DialogResult = true;
                    Close();
                }
            }
        }
示例#5
0
        private void BtnAddChild_Click(object sender, RoutedEventArgs e)
        {
            AddChildWindow addChildWindow = new AddChildWindow(_firstName, _lastName);

            addChildWindow.parentMode = this.parentMode;
            var res = addChildWindow.ShowDialog();

            if (res == true)
            {
                if (parentMode == false)
                {
                    var childList     = VakacientjesDb.GetChildren();
                    int maxId         = -1;
                    int selectedIndex = -1;
                    cmbChild.Items.Clear();
                    foreach (Child child in childList)
                    {
                        if (child.Id > maxId)
                        {
                            maxId         = child.Id;
                            selectedIndex = childList.IndexOf(child);
                        }
                        cmbChild.Items.Add(child.FirstName + " " + child.LastName);
                    }
                    cmbChild.SelectedIndex = selectedIndex;
                }
                else
                {
                    var parentList    = VakacientjesDb.GetParents();
                    int maxId         = -1;
                    int selectedIndex = -1;
                    cmbChild.Items.Clear();
                    foreach (Parent parent in parentList)
                    {
                        if (parent.Id > maxId)
                        {
                            maxId         = parent.Id;
                            selectedIndex = parentList.IndexOf(parent);
                        }
                        cmbChild.Items.Add(parent.FirstName + " " + parent.LastName);
                    }
                    cmbChild.SelectedIndex = selectedIndex;
                }
            }
        }
        private void BtnAddFamily_Click(object sender, RoutedEventArgs e)
        {
            AddFamilyWindow addFamilyWindow = new AddFamilyWindow(txtLastName.Text);
            var             res             = addFamilyWindow.ShowDialog();

            if (res == true)
            {
                var familyList    = VakacientjesDb.GetFamilies();
                int maxId         = -1;
                int selectedIndex = -1;
                cmbFamily.Items.Clear();
                foreach (Family family in familyList)
                {
                    if (family.Id > maxId)
                    {
                        maxId         = family.Id;
                        selectedIndex = familyList.IndexOf(family);
                    }
                    cmbFamily.Items.Add(family.Name);
                }
                cmbFamily.SelectedIndex = selectedIndex;
            }
        }
        private bool AnalyzeData(List <FamilyActivity> familyActivityList, int weekNumber)
        {
            int tableNr = xlsxDataSet.Tables.IndexOf($"Week {weekNumber}");

            if (tableNr == -1)
            {
                return(false);
            }

            DataTable table = xlsxDataSet.Tables[tableNr];

            int  colMaandag      = -1;
            int  colDinsdag      = -1;
            int  colWoensdag     = -1;
            int  colDonderdag    = -1;
            int  colVrijdag      = -1;
            bool validDayColumns = false;
            bool abort           = false;

            foreach (DataRow row in table.Rows)
            {
                bool   child     = false;
                bool   parent    = false;
                string name      = "";
                string startTime = "";
                string endTime   = "";
                bool   newDay    = false;
                int    dayNumber = -1;
                bool   morning   = false;
                bool   afterNoon = false;

                for (int i = 0; i < table.Columns.Count; i++)
                {
                    string fieldValue = row.Field <String>(i);

                    if (String.IsNullOrWhiteSpace(fieldValue) == false)
                    {
                        if (validDayColumns == true)
                        {
                            if ((i == colMaandag) || (i == colDinsdag) || (i == colWoensdag) || (i == colDonderdag) || (i == colVrijdag))
                            {
                                newDay = true;
                            }

                            if (newDay)
                            {
                                child     = false;
                                parent    = false;
                                name      = "";
                                startTime = "";
                                endTime   = "";
                                newDay    = false;
                                morning   = false;
                                afterNoon = false;

                                if (i == colMaandag)
                                {
                                    dayNumber = 1;
                                }
                                if (i == colDinsdag)
                                {
                                    dayNumber = 2;
                                }
                                if (i == colWoensdag)
                                {
                                    dayNumber = 3;
                                }
                                if (i == colDonderdag)
                                {
                                    dayNumber = 4;
                                }
                                if (i == colVrijdag)
                                {
                                    dayNumber = 5;
                                }
                            }

                            if (fieldValue.StartsWith("Kind", StringComparison.InvariantCultureIgnoreCase) == true)
                            {
                                child = true;
                                continue;
                            }

                            if (fieldValue.StartsWith("Ouder", StringComparison.InvariantCultureIgnoreCase) == true)
                            {
                                parent = true;
                                continue;
                            }

                            if (((child == true) || (parent == true)) && (name == ""))
                            {
                                name = fieldValue.Trim();
                                continue;
                            }

                            if ((name != "") && (startTime == ""))
                            {
                                startTime = fieldValue.Trim();
                                continue;
                            }

                            if ((startTime != "") && (endTime == ""))
                            {
                                endTime = fieldValue.Trim();

                                //Determine morning and afternoon
                                string hourString = "";
                                int    p          = startTime.IndexOf("u", StringComparison.InvariantCultureIgnoreCase);
                                if (p == -1)
                                {
                                    p = startTime.IndexOf("h", StringComparison.InvariantCultureIgnoreCase);
                                }
                                if (p == -1)
                                {
                                    p = startTime.IndexOf(":", StringComparison.InvariantCultureIgnoreCase);
                                }
                                hourString = startTime.Substring(0, p);

                                int hour = 0;
                                if (String.IsNullOrWhiteSpace(hourString) == false)
                                {
                                    hour = Convert.ToInt32(hourString);
                                }

                                if (hour < 12)
                                {
                                    morning = true;
                                }

                                p = endTime.IndexOf("u", StringComparison.InvariantCultureIgnoreCase);
                                if (p == -1)
                                {
                                    p = endTime.IndexOf("h", StringComparison.InvariantCultureIgnoreCase);
                                }
                                if (p == -1)
                                {
                                    p = endTime.IndexOf(":", StringComparison.InvariantCultureIgnoreCase);
                                }
                                if (p == -1)
                                {
                                    p = endTime.IndexOf(".", StringComparison.InvariantCultureIgnoreCase);
                                }
                                hourString = endTime.Substring(0, p);
                                if (String.IsNullOrWhiteSpace(hourString) == false)
                                {
                                    hour = Convert.ToInt32(hourString);
                                }
                                else
                                {
                                    hour = 0;
                                }

                                if (hour > 13)
                                {
                                    afterNoon = true;
                                }

                                //
                                if (child)
                                {
                                    var child1 = VakacientjesDb.GetChild(name);
                                    if (child1.Id == -1)
                                    {
                                        string firstName;
                                        string lastName;
                                        GetFirstNameLastName(name, out firstName, out lastName);

                                        SelectChildWindow selectChildWindow = new SelectChildWindow(firstName, lastName);
                                        var res = selectChildWindow.ShowDialog();
                                        if (res == true)
                                        {
                                            child1 = VakacientjesDb.GetChild(selectChildWindow.cmbChild.Text);
                                            if (child1.Id == -1)
                                            {
                                                MessageBox.Show($"Onverwachte fout: kind '{selectChildWindow.cmbChild.Text}' toch niet gevonden." +
                                                                "\n\n De bewerking wordt afgebroken.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                                                abort = true;
                                            }
                                        }
                                        else
                                        {
                                            abort = selectChildWindow.abort;
                                        }
                                    }

                                    if (child1.Id != -1)
                                    {
                                        FamilyActivity familyActivity = familyActivityList.FirstOrDefault(a => a.FamilyId == child1.FamilyId);
                                        if (familyActivity == null)
                                        {
                                            familyActivity          = new FamilyActivity();
                                            familyActivity.FamilyId = child1.FamilyId;
                                            familyActivityList.Add(familyActivity);
                                        }

                                        if (morning == true)
                                        {
                                            PlayActivity playActivity = new PlayActivity();
                                            playActivity.PersonId   = child1.Id;
                                            playActivity.WeekNumber = weekNumber;
                                            playActivity.DayNumber  = dayNumber;
                                            playActivity.Morning    = true;
                                            familyActivity.ChildPlayActivities.Add(playActivity);
                                        }

                                        if (afterNoon == true)
                                        {
                                            PlayActivity playActivity = new PlayActivity();
                                            playActivity.PersonId   = child1.Id;
                                            playActivity.WeekNumber = weekNumber;
                                            playActivity.DayNumber  = dayNumber;
                                            playActivity.Morning    = false;
                                            familyActivity.ChildPlayActivities.Add(playActivity);
                                        }
                                    }
                                }
                                else
                                {
                                    var parent1 = VakacientjesDb.GetParent(name);
                                    if (parent1.Id == -1)
                                    {
                                        string firstName;
                                        string lastName;
                                        GetFirstNameLastName(name, out firstName, out lastName);

                                        SelectChildWindow selectChildWindow = new SelectChildWindow(firstName, lastName);
                                        selectChildWindow.parentMode = true;
                                        var res = selectChildWindow.ShowDialog();
                                        if (res == true)
                                        {
                                            parent1 = VakacientjesDb.GetParent(selectChildWindow.cmbChild.Text);
                                            if (parent1.Id == -1)
                                            {
                                                MessageBox.Show($"Onverwachte fout: ouder '{selectChildWindow.cmbChild.Text}' toch niet gevonden." +
                                                                "\n\n De bewerking wordt afgebroken.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                                                abort = true;
                                            }
                                        }
                                        else
                                        {
                                            abort = selectChildWindow.abort;
                                        }
                                    }

                                    if (parent1.Id != -1)
                                    {
                                        FamilyActivity familyActivity = familyActivityList.FirstOrDefault(a => a.FamilyId == parent1.FamilyId);
                                        if (familyActivity == null)
                                        {
                                            familyActivity          = new FamilyActivity();
                                            familyActivity.FamilyId = parent1.FamilyId;
                                            familyActivityList.Add(familyActivity);
                                        }

                                        if (morning == true)
                                        {
                                            PlayActivity playActivity = new PlayActivity();
                                            playActivity.PersonId   = parent1.Id;
                                            playActivity.WeekNumber = weekNumber;
                                            playActivity.DayNumber  = dayNumber;
                                            playActivity.Morning    = true;
                                            familyActivity.ParentPlayActivities.Add(playActivity);
                                        }

                                        if (afterNoon == true)
                                        {
                                            PlayActivity playActivity = new PlayActivity();
                                            playActivity.PersonId   = parent1.Id;
                                            playActivity.WeekNumber = weekNumber;
                                            playActivity.DayNumber  = dayNumber;
                                            playActivity.Morning    = false;
                                            familyActivity.ParentPlayActivities.Add(playActivity);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            //Find column with days
                            if (fieldValue.Equals("MAANDAG", StringComparison.InvariantCultureIgnoreCase) == true)
                            {
                                colMaandag = i;
                            }
                            if (fieldValue.Equals("DINSDAG", StringComparison.InvariantCultureIgnoreCase) == true)
                            {
                                colDinsdag = i;
                            }
                            if (fieldValue.Equals("WOENSDAG", StringComparison.InvariantCultureIgnoreCase) == true)
                            {
                                colWoensdag = i;
                            }
                            if (fieldValue.Equals("DONDERDAG", StringComparison.InvariantCultureIgnoreCase) == true)
                            {
                                colDonderdag = i;
                            }
                            if (fieldValue.Equals("VRIJDAG", StringComparison.InvariantCultureIgnoreCase) == true)
                            {
                                colVrijdag = i;
                            }
                        }
                    }

                    if (abort == true)
                    {
                        break;
                    }
                }

                if (abort == true)
                {
                    break;
                }

                if (validDayColumns == false)
                {
                    validDayColumns = ((colMaandag != -1) || (colDinsdag != -1) || (colWoensdag != -1) || (colDonderdag != -1) || (colVrijdag != -1));
                    if (validDayColumns == true)
                    {
                        validDayColumns = ((colMaandag != -1) && (colDinsdag != -1) && (colWoensdag != -1) && (colDonderdag != -1) && (colVrijdag != -1));
                        if (validDayColumns == false)
                        {
                            MessageBox.Show($"Niet alle dagen zijn gevonden in week {weekNumber}.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                            return(false);
                        }
                    }
                }
            }

            if (abort == false)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }