private void bDeleteAssignment4_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cbSerialNbr4.Text))
            {
                MessageBox.Show("Es wurde kein Simulator ausgewählt.", "Löschen nicht möglich", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            string simId      = cbSerialNbr4.Text;
            var    assignment = SimulatorAssignmentsManager.GetAssignmentForSimulatorById(simId);

            if (assignment != null)
            {
                if (SimulatorAssignmentsManager.DeleteAssignment(assignment))
                {
                    cbSerialNbr4.SelectedIndex = cbPosition4.SelectedIndex = cbMattress4.SelectedIndex = cbDeviceAssignment4.SelectedIndex = 0;
                    MessageBox.Show("Die Zuweisung von Simulator " + simId + " wurde erfolgreich gelöscht.", "Löschen erfolgreich", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        /// <summary>
        /// Validates and saves the assignments.
        /// </summary>
        private void bSave_Click(object sender, EventArgs e)
        {
            #region Validation
            //only 1 simulator may have the pressure mapping assignment
            int pressureMappingCnt = 0;
            if ((string)cbDeviceAssignment1.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung.ToString() || (string)cbDeviceAssignment1.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung_und_Simulation_Kaltschaum.ToString() || (string)cbDeviceAssignment1.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung_und_Simulation_NaturLatex.ToString())
            {
                pressureMappingCnt++;
            }
            if ((string)cbDeviceAssignment2.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung.ToString() || (string)cbDeviceAssignment2.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung_und_Simulation_Kaltschaum.ToString() || (string)cbDeviceAssignment2.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung_und_Simulation_NaturLatex.ToString())
            {
                pressureMappingCnt++;
            }
            if ((string)cbDeviceAssignment3.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung.ToString() || (string)cbDeviceAssignment3.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung_und_Simulation_Kaltschaum.ToString() || (string)cbDeviceAssignment3.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung_und_Simulation_NaturLatex.ToString())
            {
                pressureMappingCnt++;
            }
            if ((string)cbDeviceAssignment4.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung.ToString() || (string)cbDeviceAssignment4.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung_und_Simulation_Kaltschaum.ToString() || (string)cbDeviceAssignment4.Text == SimulatorAssignmentsManager.SimulatorAssignments.Druckmessung_und_Simulation_NaturLatex.ToString())
            {
                pressureMappingCnt++;
            }

            if (pressureMappingCnt != 1 && pressureMappingCnt != 2)
            {
                MessageBox.Show("Bitte weisen Sie maximal zwei Simulatoren die Funktion \"Druckmessung\" bzw. \"Druckmessung_und_Simulation_Kaltschaum\" und \"Druckmessung_und_Simulation_NaturLatex\" zu!", "Zuweisungen nicht korrekt", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            //check if a simulator has been assigned multiple times
            List <string> simulatorSerialNbrs = new List <string>()
            {
                (string)cbSerialNbr1.Text, (string)cbSerialNbr2.Text, (string)cbSerialNbr3.Text, (string)cbSerialNbr4.Text
            };

            //delete any "Nicht verwendet" selections
            simulatorSerialNbrs = simulatorSerialNbrs.Where(s => s != COMBOBOX_ITEM_NOT_USED).ToList();

            if (simulatorSerialNbrs.Count != simulatorSerialNbrs.Distinct().Count())
            {
                MessageBox.Show("Es wurde mindestens ein Simulator doppelt eingerichtet. Bitte stellen Sie sicher, dass jede Seriennummer nur einmal verwendet wird!", "Simulator doppelt", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            //if a serial number was selected, all other settings have to be made as well
            #endregion

            #region Save assignments
            bool success = true;

            List <SimulatorAssignment> unchangedAssignments = SimulatorAssignmentsManager.GetSimulatorAssignments();

            if (cbSerialNbr1.SelectedIndex > 0)
            {
                string simId = cbSerialNbr1.Text;
                SimulatorAssignmentsManager.SimulatorAssignments assignment = (SimulatorAssignmentsManager.SimulatorAssignments)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulatorAssignments), cbDeviceAssignment1.Text);
                SimulatorAssignmentsManager.SimulatorPositions   position   = (SimulatorAssignmentsManager.SimulatorPositions)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulatorPositions), cbPosition1.Text);
                SimulatorAssignmentsManager.SimulationMattresses mattress   = (SimulatorAssignmentsManager.SimulationMattresses)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulationMattresses), cbMattress1.Text);
                string customName = tbCustomName1.Text;

                SimulatorAssignment newAssignment = new SimulatorAssignment(simId, assignment, position, mattress, customName);

                success &= SimulatorAssignmentsManager.AddOrUpdateAssignment(newAssignment);

                if (unchangedAssignments.Where(a => a.SimulatorId == cbSerialNbr1.Text).Count() == 1) //remove the assignment from the list if it was existing before
                {
                    unchangedAssignments.Remove(unchangedAssignments.Where(a => a.SimulatorId == cbSerialNbr1.Text).FirstOrDefault());
                }
            }

            if (cbSerialNbr2.SelectedIndex > 0)
            {
                string simId = cbSerialNbr2.Text;
                SimulatorAssignmentsManager.SimulatorAssignments assignment = (SimulatorAssignmentsManager.SimulatorAssignments)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulatorAssignments), cbDeviceAssignment2.Text);
                SimulatorAssignmentsManager.SimulatorPositions   position   = (SimulatorAssignmentsManager.SimulatorPositions)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulatorPositions), cbPosition2.Text);
                SimulatorAssignmentsManager.SimulationMattresses mattress   = (SimulatorAssignmentsManager.SimulationMattresses)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulationMattresses), cbMattress2.Text);
                string customName = tbCustomName2.Text;

                SimulatorAssignment newAssignment = new SimulatorAssignment(simId, assignment, position, mattress, customName);

                success &= SimulatorAssignmentsManager.AddOrUpdateAssignment(newAssignment);

                if (unchangedAssignments.Where(a => a.SimulatorId == cbSerialNbr2.Text).Count() == 1) //remove the assignment from the list if it was existing before
                {
                    unchangedAssignments.Remove(unchangedAssignments.Where(a => a.SimulatorId == cbSerialNbr2.Text).FirstOrDefault());
                }
            }

            if (cbSerialNbr3.SelectedIndex > 0)
            {
                string simId = cbSerialNbr3.Text;
                SimulatorAssignmentsManager.SimulatorAssignments assignment = (SimulatorAssignmentsManager.SimulatorAssignments)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulatorAssignments), cbDeviceAssignment3.Text);
                SimulatorAssignmentsManager.SimulatorPositions   position   = (SimulatorAssignmentsManager.SimulatorPositions)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulatorPositions), cbPosition3.Text);
                SimulatorAssignmentsManager.SimulationMattresses mattress   = (SimulatorAssignmentsManager.SimulationMattresses)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulationMattresses), cbMattress3.Text);
                string customName = tbCustomName3.Text;

                SimulatorAssignment newAssignment = new SimulatorAssignment(simId, assignment, position, mattress, customName);

                success &= SimulatorAssignmentsManager.AddOrUpdateAssignment(newAssignment);

                if (unchangedAssignments.Where(a => a.SimulatorId == cbSerialNbr3.Text).Count() == 1) //remove the assignment from the list if it was existing before
                {
                    unchangedAssignments.Remove(unchangedAssignments.Where(a => a.SimulatorId == cbSerialNbr3.Text).FirstOrDefault());
                }
            }

            if (cbSerialNbr4.SelectedIndex > 0)
            {
                string simId = cbSerialNbr4.Text;
                SimulatorAssignmentsManager.SimulatorAssignments assignment = (SimulatorAssignmentsManager.SimulatorAssignments)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulatorAssignments), cbDeviceAssignment4.Text);
                SimulatorAssignmentsManager.SimulatorPositions   position   = (SimulatorAssignmentsManager.SimulatorPositions)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulatorPositions), cbPosition4.Text);
                SimulatorAssignmentsManager.SimulationMattresses mattress   = (SimulatorAssignmentsManager.SimulationMattresses)Enum.Parse(typeof(SimulatorAssignmentsManager.SimulationMattresses), cbMattress4.Text);
                string customName = tbCustomName4.Text;

                SimulatorAssignment newAssignment = new SimulatorAssignment(simId, assignment, position, mattress, customName);

                success &= SimulatorAssignmentsManager.AddOrUpdateAssignment(newAssignment);

                if (unchangedAssignments.Where(a => a.SimulatorId == cbSerialNbr4.Text).Count() == 1) //remove the assignment from the list if it was existing before
                {
                    unchangedAssignments.Remove(unchangedAssignments.Where(a => a.SimulatorId == cbSerialNbr4.Text).FirstOrDefault());
                }
            }

            if (success)
            {
                //check if an assignment has been deleted
                if (unchangedAssignments.Count > 0) //if there are assignments left in this list it means that the user selected "Nicht verwendet" combobox item --> delete these assignments
                {
                    foreach (var assignment in unchangedAssignments)
                    {
                        SimulatorAssignmentsManager.DeleteAssignment(assignment);
                    }
                }

                MessageBox.Show("Die Simulatorzuweisungen wurden erfolgreich übernommen.", "Erfolg", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Fehler beim Speichern der Simulatorzuweisungen!", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            #endregion
        }