Exemplo n.º 1
0
        private void TeacherForm_Load(object sender, EventArgs e)
        {
            clsTeacher objTeacher = new clsTeacher();

            ComboBox[] cmb = new ComboBox[] { cmbSuburbID, cmbSuburbName, cmbPostCode, cmbSkill };
            objTeacher.Load(cmb);
            objTeacher.ViewAll(dgvTeacher);
        }
Exemplo n.º 2
0
        private void mnuDelete_Click(object sender, EventArgs e)
        {
            if (!clsValidation.ValidateTextBoxForNumeric(txtTeacherID))
            {
                txtTeacherID.Focus();
                return;
            }
            clsTeacher objTeacher = new clsTeacher(Convert.ToInt32(txtTeacherID.Text));

            objTeacher.Delete();
            MessageBox.Show("Teacher record successfully deleted");
            objTeacher.ViewAll(dgvTeacher);
        }
Exemplo n.º 3
0
        private void mnuViewAll_Click(object sender, EventArgs e)
        {
            clsTeacher objTeacher = new clsTeacher();

            objTeacher.ViewAll(dgvTeacher);
        }
Exemplo n.º 4
0
        private void mnuAdd_Click(object sender, EventArgs e)
        {
            #region ValidationArea
            if (!clsValidation.ValidateTextBox(txtTeacherFirstName))
            {
                txtTeacherFirstName.Focus();
                return;
            }
            if (!clsValidation.ValidateForAlphabet(txtTeacherFirstName))
            {
                txtTeacherFirstName.Focus();
                return;
            }
            if (!clsValidation.ValidateNameFormat(txtTeacherFirstName))
            {
                txtTeacherFirstName.Focus();
                return;
            }
            if (!clsValidation.ValidateTextBox(txtTeacherLastName))
            {
                txtTeacherLastName.Focus();
                return;
            }
            if (!clsValidation.ValidateForAlphabet(txtTeacherLastName))
            {
                txtTeacherLastName.Focus();
                return;
            }
            if (!clsValidation.ValidateNameFormat(txtTeacherLastName))
            {
                txtTeacherLastName.Focus();
                return;
            }
            if (!clsValidation.ValidateDate(dtpDateOfBirth))
            {
                return;
            }
            if (!clsValidation.ValidateRadioButton(rdbMale, rdbFemale))
            {
                return;
            }
            if (!clsValidation.ValidateTextBox(txtTeacherStreetAddress))
            {
                txtTeacherStreetAddress.Focus();
                return;
            }
            if (!clsValidation.ValidateStreetAddress(txtTeacherStreetAddress))
            {
                txtTeacherStreetAddress.Focus();
                return;
            }
            if (!clsValidation.ValidateComboBox(cmbSuburbName))
            {
                return;
            }
            //if (!clsValidation.ValidateTextBox(txtTeacherPostCode))
            //{
            //    txtTeacherPostCode.Focus();
            //    return;
            //}
            //if (!clsValidation.ValidateTextBoxForNumeric(txtTeacherPostCode))
            //{
            //    txtTeacherPostCode.Focus();
            //    return;
            //}
            //if (!clsValidation.ValidatePostCode(txtTeacherPostCode.Text))
            //{
            //    txtTeacherPostCode.Focus();
            //    return;
            //}
            if (!clsValidation.ValidateTextBox(txtTeacherPhoneNum))
            {
                txtTeacherPhoneNum.Focus();
                return;
            }
            if (!clsValidation.ValidatePhoneNumber(txtTeacherPhoneNum))
            {
                txtTeacherPhoneNum.Focus();
                return;
            }
            if (!clsValidation.ValidateTextBox(txtTeacherEmail))
            {
                txtTeacherEmail.Focus();
                return;
            }
            if (!clsValidation.ValidateEmail(txtTeacherEmail))
            {
                txtTeacherEmail.Focus();
                return;
            }
            if (!clsValidation.ValidateDate(dtpCommencementDate))
            {
                return;
            }
            if (!clsValidation.ValidateDateStartVsEnd(dtpDateOfBirth, dtpCommencementDate))
            {
                return;
            }
            if (!clsValidation.ValidateComboBox(cmbTeacherDepartment))
            {
                return;
            }
            //if (!clsValidation.ValidateTextBox(txtTeacherSkills))
            //{
            //    txtTeacherSkills.Focus();
            //    return;
            //}
            //if (!clsValidation.ValidateForAlphabet(txtTeacherSkills))
            //{
            //    txtTeacherSkills.Focus();
            //    return;
            //}
            if (!clsValidation.ValidateRadioButton(rdbASYes, rdbASNo))
            {
                return;
            }
            #endregion

            string genderText = String.Empty;
            if (rdbMale.Checked)
            {
                genderText = "M";
            }
            else if (rdbFemale.Checked)
            {
                genderText = "F";
            }
            string leaveText = String.Empty;
            if (rdbASYes.Checked)
            {
                leaveText = "Yes";
            }
            else if (rdbASNo.Checked)
            {
                leaveText = "No";
            }
            clsTeacher objTeacher = new clsTeacher(txtTeacherFirstName.Text,
                                                   txtTeacherLastName.Text, genderText, dtpDateOfBirth.Value.ToString("yyyy-MM-dd"), txtTeacherStreetAddress.Text,
                                                   Convert.ToInt32(cmbSuburbID.Text), cmbPostCode.Text, txtTeacherPhoneNum.Text, txtTeacherEmail.Text,
                                                   dtpCommencementDate.Value.ToString("yyyy-MM-dd"), cmbTeacherDepartment.Text, leaveText);
            objTeacher.Add();
            MessageBox.Show("Teacher record successfully added!");
            objTeacher.ViewAll(dgvTeacher);
        }