Example #1
0
        }//------------------------

        #endregion

        #region Programer-Defined Functions
        //this procedure will validate controls
        public Boolean ValidateControls()
        {
            Boolean isValid = true;

            _errProvider.SetError(this.cboYear, "");
            _errProvider.SetError(this.cboSemester, "");
            _errProvider.SetError(this.cboExamDescription, "");
            _errProvider.SetError(this.txtExamDate, "");

            if (String.IsNullOrEmpty(_majorExamScheduleInfo.YearId))
            {
                _errProvider.SetError(this.cboYear, "You must select a school year.");
                _errProvider.SetIconAlignment(this.cboYear, ErrorIconAlignment.MiddleRight);

                isValid = false;
            }

            if (!String.IsNullOrEmpty(_majorExamScheduleInfo.CourseGroupId))
            {
                if (_majorExamScheduleManager.IsSemestral(this.cboCourseGroup.SelectedIndex) && String.IsNullOrEmpty(_majorExamScheduleInfo.SemesterSysId))
                {
                    _errProvider.SetError(this.cboSemester, "You must select a semester.");
                    _errProvider.SetIconAlignment(this.cboSemester, ErrorIconAlignment.MiddleRight);

                    isValid = false;
                }
            }

            if (String.IsNullOrEmpty(_majorExamScheduleInfo.ExamInformationId))
            {
                _errProvider.SetError(this.cboExamDescription, "You must select a examination information.");
                _errProvider.SetIconAlignment(this.cboExamDescription, ErrorIconAlignment.MiddleRight);

                isValid = false;
            }

            if (String.IsNullOrEmpty(_majorExamScheduleInfo.ExamDate))
            {
                _errProvider.SetError(this.txtExamDate, "You must create a examination schedule date.");
                _errProvider.SetIconAlignment(this.txtExamDate, ErrorIconAlignment.MiddleRight);

                isValid = false;
            }

            if (isValid)
            {
                DateTime inputDate = DateTime.Parse(_majorExamScheduleManager.ServerDateTime);

                if (!String.IsNullOrEmpty(_majorExamScheduleInfo.ExamDate) && DateTime.TryParse(_majorExamScheduleInfo.ExamDate, out inputDate))
                {
                    if (!_majorExamScheduleManager.IsValidDate(_dateStart, _dateEnd, inputDate))
                    {
                        _errProvider.SetError(this.txtExamDate, "Invalid examination date.");
                        _errProvider.SetIconAlignment(this.txtExamDate, ErrorIconAlignment.MiddleRight);

                        isValid = false;
                    }
                }

                if (_majorExamScheduleManager.IsExistsYearSemesterIDExamDateInformationIDExamSchedule(_userInfo, _majorExamScheduleInfo))
                {
                    _errProvider.SetError(this.cboExamDescription, "The examination description/date already exist.");
                    _errProvider.SetIconAlignment(this.cboExamDescription, ErrorIconAlignment.MiddleRight);

                    isValid = false;
                }
            }

            return(isValid);
        }//-------------------