Exemplo n.º 1
0
        private void btnBack_Copy1_Click(object sender, RoutedEventArgs e)
        {
            Window TesterM1 = new TesterMenu();

            TesterM1.Show();
            this.Close();
        }
Exemplo n.º 2
0
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            TesterMenu menu = new TesterMenu();

            this.Close();
            menu.Show();
        }
Exemplo n.º 3
0
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            Window MenuWindow = new TesterMenu();

            MenuWindow.Show();
            this.Close();
        }
Exemplo n.º 4
0
        private void BtnTesters_Click(object sender, RoutedEventArgs e)//go to testers menu
        {
            TesterMenu MytesterMenu = new TesterMenu();

            this.Close();
            MytesterMenu.Show();
        }
Exemplo n.º 5
0
        private void BtnOk_Click(object sender, RoutedEventArgs e)
        {
            TesterMenu myTesterMenu = new TesterMenu();

            // try
            //{

            if ((string)btnOk.Content == "Add")
            {
                int numId = Convert.ToInt32(txtid.Text);
                if (numId < 100000000 || numId > 999999999)    //check if id is legal
                {
                    throw new Exception("Non-valid Id. Please enter a valid Id.");
                }

                if ((txtfirstName.Text == "") || (txtCity.Text == "") || (txtBuilding.Text == "") || (txtMaxtests.Text == "") ||
                    (txtExperience.Text == "") || (txtlastName.Text == "") || (txtStreet.Text == "") ||
                    (txtphone.Text == "") || (txtmaxDistance.Text == "") || (cmbGearbox.Text == "") || (cmbKindV.Text == "") ||
                    (cmbTesterGender.Text == ""))       //chech the texts box are not empty
                {
                    throw new Exception("Not all fields are filled in.");
                }

                if (TesterBirth.SelectedDate < DateTime.Today)
                {
                    throw new Exception("Please, enter a passed date");
                }
                //fill in the tester's scheduleMatrix the days he works according to the values he chose in checkbox
                if (chkSun9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[0, 0] = true;
                }
                if (chkSun14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[0, 5] = true;
                }
                if (chkSun13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[0, 4] = true;
                }
                if (chkSun12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[0, 3] = true;
                }
                if (chkSun11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[0, 2] = true;
                }
                if (chkSun10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[0, 1] = true;
                }
                //filled Sunday
                if (chkMon9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 0] = true;
                }
                if (chkMon14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 5] = true;
                }
                if (chkMon13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 4] = true;
                }
                if (chkMon12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 3] = true;
                }
                if (chkMon11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 2] = true;
                }
                if (chkMon10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 1] = true;
                }
                //filled Monday
                if (chkTu9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 0] = true;
                }
                if (chkTu14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 5] = true;
                }
                if (chkTu13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 4] = true;
                }
                if (chkTu12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 3] = true;
                }
                if (chkTu11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 2] = true;
                }
                if (chkTu10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 1] = true;
                }
                //filled Tuesday
                if (chkWen9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 0] = true;
                }
                if (chkWen14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 5] = true;
                }
                if (chkWen13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 4] = true;
                }
                if (chkWen12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 3] = true;
                }
                if (chkWen11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 2] = true;
                }
                if (chkWen10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 1] = true;
                }
                //filled Wensday
                if (chkThe9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 0] = true;
                }
                if (chkThe14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 5] = true;
                }
                if (chkThe13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 4] = true;
                }
                if (chkThe12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 3] = true;
                }
                if (chkThe11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 2] = true;
                }
                if (chkThe10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 1] = true;
                }
                //filled Thursday

                bl.addTester(MyTester);
                MyTester = new Tester();
                //this.DataContext = MyTester;
                this.Close();
                myTesterMenu.Show();
            }
            else if ((string)btnOk.Content == "Remove")
            {
                var mbResult = MessageBox.Show("Are you sure you want to remove this tester?", "", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Yes);
                if (mbResult == MessageBoxResult.OK)
                {
                    bl.deleteTester(MyTester);
                    MyTester         = new Tester();//clean the datacontext
                    this.DataContext = MyTester;
                    this.Close();
                    MessageBox.Show("Tester removed");
                    myTesterMenu.Show();
                }
            }
            else if ((string)btnOk.Content == "Update")
            {
                MyTester.ScheduleMatrix[0, 0] = chkSun9.IsChecked.Value;
                MyTester.ScheduleMatrix[0, 5] = chkSun14.IsChecked.Value;
                MyTester.ScheduleMatrix[0, 4] = chkSun13.IsChecked.Value;
                MyTester.ScheduleMatrix[0, 3] = chkSun12.IsChecked.Value;
                MyTester.ScheduleMatrix[0, 2] = chkSun11.IsChecked.Value;
                MyTester.ScheduleMatrix[0, 1] = chkSun10.IsChecked.Value;
                //filled Sunday
                if (chkMon9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 0] = true;
                }
                if (chkMon14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 5] = true;
                }
                if (chkMon13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 4] = true;
                }
                if (chkMon12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 3] = true;
                }
                if (chkMon11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 2] = true;
                }
                if (chkMon10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[1, 1] = true;
                }
                //filled Monday
                if (chkTu9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 0] = true;
                }
                if (chkTu14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 5] = true;
                }
                if (chkTu13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 4] = true;
                }
                if (chkTu12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 3] = true;
                }
                if (chkTu11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 2] = true;
                }
                if (chkTu10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[2, 1] = true;
                }
                //filled Tuesday
                if (chkWen9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 0] = true;
                }
                if (chkWen14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 5] = true;
                }
                if (chkWen13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 4] = true;
                }
                if (chkWen12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 3] = true;
                }
                if (chkWen11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 2] = true;
                }
                if (chkWen10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[3, 1] = true;
                }
                //filled Wensday
                if (chkThe9.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 0] = true;
                }
                if (chkThe14.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 5] = true;
                }
                if (chkThe13.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 4] = true;
                }
                if (chkThe12.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 3] = true;
                }
                if (chkThe11.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 2] = true;
                }
                if (chkThe10.IsChecked == true)
                {
                    MyTester.ScheduleMatrix[4, 1] = true;
                }



                if (chkMon9.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[1, 0] = false;
                }
                if (chkMon14.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[1, 5] = false;
                }
                if (chkMon13.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[1, 4] = false;
                }
                if (chkMon12.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[1, 3] = false;
                }
                if (chkMon11.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[1, 2] = false;
                }
                if (chkMon10.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[1, 1] = false;
                }
                //filled Monday
                if (chkTu9.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[2, 0] = false;
                }
                if (chkTu14.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[2, 5] = false;
                }
                if (chkTu13.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[2, 4] = false;
                }
                if (chkTu12.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[2, 3] = false;
                }
                if (chkTu11.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[2, 2] = false;
                }
                if (chkTu10.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[2, 1] = false;
                }
                //filled Tuesday
                if (chkWen9.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[3, 0] = false;
                }
                if (chkWen14.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[3, 5] = false;
                }
                if (chkWen13.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[3, 4] = false;
                }
                if (chkWen12.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[3, 3] = false;
                }
                if (chkWen11.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[3, 2] = false;
                }
                if (chkWen10.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[3, 1] = false;
                }
                //filled Wensday
                if (chkThe9.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[4, 0] = false;
                }
                if (chkThe14.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[4, 5] = false;
                }
                if (chkThe13.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[4, 4] = false;
                }
                if (chkThe12.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[4, 3] = false;
                }
                if (chkThe11.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[4, 2] = false;
                }
                if (chkThe10.IsChecked == false)
                {
                    MyTester.ScheduleMatrix[4, 1] = false;
                }



                var mbResult = MessageBox.Show("Are you sure you want to update this tester?", "", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Yes);
                if (mbResult == MessageBoxResult.OK)
                {
                    bl.updateTester(MyTester);
                    MyTester         = new Tester();
                    this.DataContext = MyTester;
                    this.Close();
                    MessageBox.Show("Tester updated");
                    myTesterMenu.Show();
                }
                else
                {
                    this.Close();
                    myTesterMenu.Show();
                }
            }
            else
            {
                MyTester         = new Tester();
                this.DataContext = MyTester;
                this.Close();
                myTesterMenu.Show();
            }
            // }


            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }