Exemple #1
0
        } //---------------------------

        #endregion

        #region Programmer-Defined Function Procedures

        //this function determines if the controls are validated
        protected Boolean ValidateControls()
        {
            Boolean isValid = true;

            _errProvider.SetError(this.cboDepartment, "");
            _errProvider.SetError(this.txtCode, "");
            _errProvider.SetError(this.txtTitle, "");
            _errProvider.SetError(this.cboCourseGroup, "");
            _errProvider.SetError(this.lblLecture, "");
            _errProvider.SetError(this.lblHours, "");

            if (this.cboDepartment.SelectedIndex == -1)
            {
                _errProvider.SetError(this.cboDepartment, "Please select a department.");
                isValid = false;
            }

            if (String.IsNullOrEmpty(this.txtCode.Text.Trim()))
            {
                _errProvider.SetError(this.txtCode, "An auxiliary service code is required.");
                isValid = false;
            }
            else
            {
                if (String.IsNullOrEmpty(this.txtTitle.Text.Trim()))
                {
                    _errProvider.SetError(this.txtTitle, "An auxiliary service descriptive title is required.");
                    isValid = false;
                }
                else if (_auxiliaryManager.IsExistCodeDescriptionAuxiliaryServiceInformation(_userInfo, _serviceInfo))
                {
                    _errProvider.SetError(this.txtCode, "The auxiliary service code and descriptive title already exist.");
                    _errProvider.SetError(this.txtTitle, "The auxiliary code and descriptive title already exist.");
                    isValid = false;
                }
            }

            if (this.cboCourseGroup.SelectedIndex == -1)
            {
                _errProvider.SetError(this.cboCourseGroup, "Please select a course group for the subject.");
                isValid = false;
            }

            Byte lecUnits;

            if (Byte.TryParse(this.txtLecture.Text, out lecUnits))
            {
                if (this.optUnits.Checked && lecUnits == 0)
                {
                    _errProvider.SetError(this.lblLecture, "A lecture units is required.");
                    isValid = false;
                }
            }

            if (this.optHours.Checked && this.hrmHours.IsHourMinuteZero())
            {
                _errProvider.SetError(this.lblHours, "A number of hours/minutes must not be equal to zero.");
                isValid = false;
            }

            return(isValid);
        }