コード例 #1
0
ファイル: course.aspx.cs プロジェクト: DylanJK/School
        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);
            }
        }
コード例 #2
0
ファイル: course.aspx.cs プロジェクト: DylanJK/School
        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();
            }
        }
コード例 #3
0
ファイル: course.aspx.cs プロジェクト: DylanJK/School
        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);
        }