Exemple #1
0
        /// <summary>
        /// Used when adding or updating a record.
        /// </summary>
        internal static void AddOrEdit(CourseEnrollment model, CrudOperation operation, bool isForListInline = false)
        {
            CourseEnrollment objCourseEnrollment;
            CourseEnrollment objCourseEnrollmentOld = new CourseEnrollment();
            decimal          id = 0;

            if (operation == CrudOperation.Add)
            {
                objCourseEnrollment = new CourseEnrollment();
            }
            else
            {
                objCourseEnrollment    = CourseEnrollment.SelectByPrimaryKey(model.EnrollmentId);
                objCourseEnrollmentOld = objCourseEnrollment.ShallowCopy();
            }

            objCourseEnrollment.EnrollmentId = model.EnrollmentId;
            objCourseEnrollment.CourseName   = model.CourseName;
            objCourseEnrollment.StudentName  = model.StudentName;
            objCourseEnrollment.Comments     = model.Comments;

            if (operation == CrudOperation.Add)
            {
                id = objCourseEnrollment.Insert();
            }
            else
            {
                objCourseEnrollment.Update();
            }
        }
Exemple #2
0
        /// <summary>
        /// Handler, deletes a record.
        /// </summary>
        public IActionResult OnGetRemove(int id)
        {
            CourseEnrollment CourseEnrollment = CourseEnrollment.SelectByPrimaryKey(id);

            CourseEnrollment.Delete(id);
            return(new JsonResult(true));
        }
        public void LoadPage(int id, string returnUrl)
        {
            // select a record by primary key(s)
            CourseEnquiry1API.BusinessObject.CourseEnrollment objCourseEnrollment = CourseEnrollment.SelectByPrimaryKey(id);

            // assign values to this page's bound property
            CourseEnrollment = objCourseEnrollment;

            // assign the return url
            ReturnUrl = returnUrl;
        }
        public PageResult LoadPage(int id, string returnUrl)
        {
            // select a record by primary key(s)
            CourseEnquiry1API.BusinessObject.CourseEnrollment objCourseEnrollment = CourseEnrollment.SelectByPrimaryKey(id);

            // create the model used by the partial page
            AddEditCourseEnrollmentPartialModel model = new AddEditCourseEnrollmentPartialModel();

            model.CourseDropDownListData  = Course.SelectCourseDropDownListData();
            model.StudentDropDownListData = Student.SelectStudentDropDownListData();
            model.Operation        = CrudOperation.Update;
            model.ReturnUrl        = returnUrl;
            model.CourseEnrollment = objCourseEnrollment;

            // assign values to the model used by this page
            PartialModel = model;

            // assign the return url
            ReturnUrl = returnUrl;

            return(Page());
        }
Exemple #5
0
    /// <summary>
    /// Shows how to Select a record by Primary Key.  It also shows how to retrieve Lazily-loaded related Objects.  Related Objects are assigned for each Foreign Key.
    /// </summary>
    private void SelectByPrimaryKey()
    {
        int enrollmentIdSample = 12;

        // select a record by primary key(s)

        CourseEnrollment objCourseEnrollment = CourseEnrollment.SelectByPrimaryKey(enrollmentIdSample);

        if (objCourseEnrollment != null)
        {
            // if record is found, a record is returned
            int    enrollmentId = objCourseEnrollment.EnrollmentId;
            int    courseName   = objCourseEnrollment.CourseName;
            int    studentName  = objCourseEnrollment.StudentName;
            string comments     = objCourseEnrollment.Comments;

            // get the Course related to CourseName.
            Course objCourseRelatedToCourseName = objCourseEnrollment.CourseNameNavigation;

            // get the Student related to StudentName.
            Student objStudentRelatedToStudentName = objCourseEnrollment.StudentNameNavigation;
        }
    }