コード例 #1
0
        private void ButtonUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //I have to add this here, because struct doesnt work with data binding
                newAdress.street = this.textBoxStreet.Text;

                if (Int32.TryParse(this.textBoxApart.Text, out toInt))
                {
                    newAdress.houseNumber = toInt;
                }
                else
                {
                    throw new Exception("מספר הבית אינו תקין");
                }

                newAdress.city = this.textBoxCity.Text;

                traineeToUpdate._adressOfTrainee = newAdress;

                //Just if everithing is correct and legal, will implemet the update
                bl.updateDetailsTrainee(traineeToUpdate);

                //This continue if there isnt excemption
                this.Close();

                optionsToTrainee opTrainee = new optionsToTrainee();
                opTrainee.receiveTrainee(traineeToUpdate);
                opTrainee.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void ButtonToEnter_Click(object sender, RoutedEventArgs e)
        {
            bl = BL.factoryBL.getBL();

            currentTesters  = bl.testersList();
            currentTrainees = bl.traineesList();

            myTester  = new BE.Tester();
            myTrainee = new BE.Trainee();

            try
            {
                //To check the ID
                if (Int64.TryParse(this.textBoxID.Text, out toLong))
                {
                    ID = toLong;
                }
                else
                {
                    throw new Exception("ת.ז אינו תקין");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //To check the password;
            password = passwordBox.Password;

            foreach (Tester testerItem in currentTesters)
            {
                if (testerItem._ID == ID && testerItem._password == password)
                {
                    myTester = new BE.Tester(testerItem);
                    optionsToTester opTester = new optionsToTester();
                    opTester.receiveTester(myTester);
                    opTester.Show();

                    return;
                }
            }

            foreach (Trainee traineeItem in currentTrainees)
            {
                if (traineeItem._ID == ID && traineeItem._password == password)
                {
                    myTrainee = new BE.Trainee(traineeItem);
                    optionsToTrainee opTrainee = new optionsToTrainee();
                    opTrainee.receiveTrainee(myTrainee);
                    opTrainee.Show();

                    return;
                }
            }

            try
            {
                //If we arrive here throw that we didnt find
                throw new Exception("אחד או יותר מהפרטים אינם תקינים");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }