Esempio n. 1
0
        private void AddCourse(object obj)
        {
            if (CourseName == null || CourseName.Length == 0)
            {
                Output = "Please enter course name";
                return;
            }
            if (CourseID == null || CourseID.Length == 0)
            {
                Output = "Please enter course ID";
                return;
            }
            foreach (char c in CourseID.Trim())
            {
                if (c < '0' || c > '9')
                {
                    Output = "courseID can only contain numbers, invalid character '" + c + "'";
                    return;
                }
            }
            if (MaxPart == null || MaxPart.Length == 0)
            {
                Output = "Please enter max number of participants";
                return;
            }

            try
            {
                Dal.AddCourse(CourseID, CourseName, int.Parse(MaxPart));
                Output = "Course added";
            }
            catch (Exception e)
            {
                HandleException(e);
            }
        }