Exemplo n.º 1
0
        private void RemoveCourse(int CourseId)
        {
            var mCourse = new clsSchool.CourseDB().GetById(CourseId);

            if (mCourse != null)
            {
                mCourse.Active = false;
                bool ok = new clsSchool.CourseDB().Update(mCourse);
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }

            CourseId = 0;
            if (!string.IsNullOrEmpty(hdfCourseId.Value))
            {
                CourseId = hdfCourseId.Value.ToInt();
            }

            UnloadForm(CourseId);

            if (CourseId > 0)
            {
                bool ok = new clsSchool.CourseDB().Update(mCourseBase);
                if (!ok)
                {
                    CourseId = -1;
                }
            }
            else
            {
                CourseId          = new clsSchool.CourseDB().Add(mCourseBase);
                hdfCourseId.Value = CourseId.ToString();
            }

            if (CourseId < 0)
            {
                //  InputFailed("The database update failed, please try again.");
            }
            else
            {
                LoadGrid();
                ResetForm();
            }
        }
Exemplo n.º 3
0
        private bool ValidateInput()
        {
            bool r = true;

            if (string.IsNullOrEmpty(txtCode.Text))
            {
                lblError.Text    = "Please enter the Course Code";
                lblError.Visible = true;
                timError.Enabled = true;
                r = false;
                return(r);
            }

            if (string.IsNullOrEmpty(txtName.Text))
            {
                lblError.Text    = "Please enter the Course Name";
                lblError.Visible = true;
                timError.Enabled = true;
                r = false;
                return(r);
            }

            if (hdfCourseId.Value.ToInt() == 0)
            {
                var mCourse = new clsSchool.CourseDB().GetByCode(txtCode.Text);

                if (mCourse != null)
                {
                    lblError.Text    = "This Course Code already exists in the system";
                    lblError.Visible = true;
                    timError.Enabled = true;
                    r = false;
                    return(r);
                }
            }

            return(r);
        }