コード例 #1
0
        public bool Valid()
        {
            ClearErrors();

            if (IsNew && Courses.Any(c => Code == c.Code) || IsNew && Code == 0)
            {
                AddError("Code", Properties.Resources.Error_Exist);
            }
            if (string.IsNullOrEmpty(Title))
            {
                AddError("Title", Properties.Resources.Error_RequiredTitle);
            }
            if (Teacher == null)
            {
                AddError("Teacher", Properties.Resources.Error_Required);
            }
            if (StartDate.CompareTo(FinishDate) > 0 || FinishDate.CompareTo(StartDate) < 0)
            {
                AddError("StartDate", Properties.Resources.Error_StartDate);
                AddError("FinishDate", Properties.Resources.Error_FinishDate);
            }
            if (StartTime.CompareTo(EndTime) > 0)
            {
                AddError("StartTime", Properties.Resources.Error_StartTime);
                AddError("EndTime", Properties.Resources.Error_EndTime);
            }

            RaiseErrors();

            return(true);
        }