Exemplo n.º 1
0
        private bool InputValidated()
        {
            ep.Clear();
            if (rbFemale.Checked)
            {
                _student.Gender = "Female";
            }
            else
            {
                _student.Gender = "Male";
            }

            if (txtFirstName.Text == string.Empty)
            {
                ep.SetError(txtFirstName, "Type First Name");
            }
            if (txtLastName.Text == string.Empty)
            {
                ep.SetError(txtLastName, "Type Last Name");
            }

            if (!dtpDateOfBirth.Checked)
            {
                ep.SetError(dtpDateOfBirth, "Select Date of Birth");
            }

            if (!dtpDateOfAdmissionToActivityCentre.Checked)
            {
                ep.SetError(dtpDateOfAdmissionToActivityCentre, "Select Date of admission to Activity centre");
            }

            if (cmbEthnicity.SelectedIndex == -1)
            {
                ep.SetError(cmbEthnicity, "Select Ethnicity");
            }

            if (txtAddr1.Text == string.Empty)
            {
                ep.SetError(txtAddr1, "Type Addr 1");
            }
            if (txtAddr2.Text == string.Empty)
            {
                ep.SetError(txtAddr2, "Type Addr 2");
            }
            if (txtAddr3.Text == string.Empty)
            {
                ep.SetError(txtAddr3, "Type Addr 3");
            }
            if (txtPostcode.Text == string.Empty)
            {
                ep.SetError(txtPostcode, "Type Postcode");
            }

            return(!fi.EPHasErrors());
            //if (fi.EPHasErrors())
            //    return;
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (_changedOccured)
            {
                ep.Clear();
                if (rbFemale.Checked)
                {
                    _student.Gender = "Female";
                }
                else
                {
                    _student.Gender = "Male";
                }

                if (txtFirstName.Text == string.Empty)
                {
                    ep.SetError(txtFirstName, "Type First Name");
                }
                if (txtLastName.Text == string.Empty)
                {
                    ep.SetError(txtLastName, "Type Last Name");
                }

                if (!dtpDateOfBirth.Checked)
                {
                    ep.SetError(dtpDateOfBirth, "Select Date of Birth");
                }

                if (!dtpDateOfAdmissionToActivityCentre.Checked)
                {
                    ep.SetError(dtpDateOfAdmissionToActivityCentre, "Select Date of admission to Activity centre");
                }

                if (cmbEthnicity.SelectedIndex == -1)
                {
                    ep.SetError(cmbEthnicity, "Select Ethnicity");
                }

                if (txtAddr1.Text == string.Empty)
                {
                    ep.SetError(txtAddr1, "Type Addr 1");
                }
                if (txtAddr2.Text == string.Empty)
                {
                    ep.SetError(txtAddr2, "Type Addr 2");
                }
                if (txtAddr3.Text == string.Empty)
                {
                    ep.SetError(txtAddr3, "Type Addr 3");
                }
                if (txtPostcode.Text == string.Empty)
                {
                    ep.SetError(txtPostcode, "Type Postcode");
                }

                if (fi.EPHasErrors())
                {
                    return;
                }



                try
                {
                    if (txtPreferredName.Text == string.Empty)
                    {
                        _student.PreferredName = _student.FirstName;
                    }
                    if (cmbEthnicity.SelectedIndex != -1)
                    {
                        _student.Ethnicity = cmbEthnicity.Text;
                    }
                    if (!dtpDateOfAdmissionToResidence.Checked)
                    {
                        _student.IsResident = false;
                        _student.DateOfAdmissionToResidence = null;
                    }



                    SaveChanges();
                    MessageBox.Show("Student record saved", "Save record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Errorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }