Exemplo n.º 1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            //  Validation
            if (AnyFieldsEmpty())
            {
                new NotificationForm("All fields must be filled.").ShowDialog();
                return;
            }
            if (!ValidatorHelper.IsEmailValid(inEmail.Text))
            {
                new NotificationForm("Invalid Email.").ShowDialog();
                return;
            }
            if (!ValidatorHelper.IsValidPPSN(inPPSN.Text))
            {
                new NotificationForm("Invalid PPSN. Must be 7 numbers, followed by a letter, and finally a letter or a space e.g. 1234567AW").ShowDialog();
                return;
            }

            Student tmp = new Student(inID.Text, (inGradStatus.SelectedIndex == 0 ? GradStatus.Undergrad : GradStatus.Postgrad), inPPSN.Text, inName.Text, inAddress.Text, inPhone.Text, inEmail.Text);

            if (College.Instance.Contains(tmp))
            {
                new NotificationForm("This person already exists in the system (PPSN).").ShowDialog();
                return;
            }
            College.Instance.Add(tmp);
            listener.NotifyPersonAdded();
            this.Close();
        }
Exemplo n.º 2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (AnyFieldsEmpty())
            {
                new NotificationForm("All fields must be filled.").ShowDialog();
                return;
            }
            else if (!ValidatorHelper.MeetsSlimlinedISBNRequirements(inISBN.Text))
            {
                new NotificationForm("Invalid ISBN. Must be at least 10 digits long, and contain only numbers, hyphons, or spaces").ShowDialog();
                return;
            }

            Book b = new Book(inISBN.Text, inTitle.Text, inAuthor.Text, inPublisher.Text, inCategory.Text, (int)inQuantity.Value);

            College.Instance.Library.AddBook(b);
            listener.NotifyBookAdded();
            this.Close();
        }
Exemplo n.º 3
0
        private void addButton_Click(object sender, EventArgs e)
        {
            //  Validation
            if (AnyFieldsEmpty())
            {
                new NotificationForm("All fields must be filled.").ShowDialog();
                return;
            }
            if (!ValidatorHelper.IsEmailValid(inEmail.Text))
            {
                new NotificationForm("Invalid Email.").ShowDialog();
                return;
            }
            if (!ValidatorHelper.IsValidPPSN(inPPSN.Text))
            {
                new NotificationForm("Invalid PPSN. Must be 7 numbers, followed by a letter, and finally a letter or a space e.g. 1234567AW").ShowDialog();
                return;
            }

            decimal tmpSal;

            if (!decimal.TryParse(inSalary.Text, out tmpSal))
            {
                new NotificationForm("Salary must be a decimal value.").ShowDialog();
                return;
            }
            Lecturer tmp = new Lecturer(inID.Text, tmpSal, inPPSN.Text, inName.Text, inAddress.Text, inPhone.Text, inEmail.Text);

            if (College.Instance.Contains(tmp))
            {
                new NotificationForm("This person already exists in the system (PPSN).").ShowDialog();
                return;
            }

            College.Instance.Add(tmp);
            listener.NotifyPersonAdded();
            this.Close();
        }