Exemple #1
0
        public ActionResult Register(FormCollection frmController)
        {
            Course_DAL  course_DAL   = new Course_DAL();
            Student_DAL student_DAL  = new Student_DAL();
            int         id_course    = int.Parse(frmController["CourseName"]);
            string      student_name = frmController["txtStudentName"];

            Student_Ent student_Ent = new Student_Ent();

            student_Ent.StudentName = student_name;

            //Add Student to SQL
            if (!(student_DAL.Add(student_Ent)))
            {
                ViewBag.Courses = course_DAL.GetCourses();
                ViewBag.Message = "Có Lỗi Xảy Ra !";

                return(View());
            }

            int id_student = student_DAL.GetID_byName(student_name);

            if (!course_DAL.Add_Register(id_course, id_student))
            {
                ViewBag.Courses = course_DAL.GetCourses();
                ViewBag.Message = "Có Lỗi Xảy Ra !";

                return(View());
            }

            ViewBag.Courses = course_DAL.GetCourses();
            ViewBag.Message = "Successfully !";
            return(View());
        }
Exemple #2
0
        public ActionResult Create(Student_Ent stu_ent)
        {
            Student_DAL student_DAL = new Student_DAL();

            if (!(student_DAL.Check_Exist(stu_ent.StudentID)))
            {
                ViewBag.Message = "ID Tồn Tại !";
                return(View());
            }

            if (!(student_DAL.Add(stu_ent)))
            {
                ViewBag.Message = "Có Lỗi Xảy Ra !";
                return(View());
            }

            return(RedirectToAction("Student", "Student"));
        }