Thumb

Part-13: Create Update course info in ASP.NET MVC AngularJs JQUERY Javascript

Part-04: Bootstrap Admin Dashboard Template setup in School Management Software Part 5: How to use AngularJS in ASP.NET MVC Part-6: CRUD Operation Insert Data using AngularJS in ASP.NET MVC Part-7: CRUD Operation & Load Data using AngularJS in ASP.NET MVC Part-08: CRUD Operation Edit, Delete Data using Angularjs in ASP.NET MVC Part-3: Create Database and Table in sql server for school management system Part-09: Insert Section data using ASP.NET MVC AngularJs Part-10: Edit Update and Delete Section data using Angular js | ASP.NET MVC | Jquery Part-11: Cascading Dropdownlist Section Batch selection in asp.net MVC JQUERY AngularJS Part-12: Insert & Delete course information for school management software using ASP.NET MVC Javascript Angularjs Part-13: Create Update course info in ASP.NET MVC AngularJs JQUERY Javascript Part-14: Insert data and Page design bootstrap using ASP.NET MVC JQUERY AngularJS Part-15: Insert & Get data using store procedure in SQL Server ASP.NET MVC AngularJS JQUERY Part-16: Load student list,bootstrap and Inactive using ASP.NET MVC AngularJS Jquery Part-17: User authentication using Store procedure Javascript AngularJS JQUERY ASP.NET MVC Part-18: User authentication, authorization and login using ASP.NET MVC AngularJS Javascript JQUERY Part-19: User Registration & Insert semester Info using AngularJS in ASP.NET MVC Part-20: Load semester info & Student course offer page design using ASP.NET MVC JQUERY Angularjs Part-21: Course Offer Entry Using Jquery Multiple Data Save (Part-1) using ASP.NET MVC AngularJS SMS-22: Student Course Offer Entry happens Using Jquery Multiple Data Save List view dropdownlist Load using Angular js in ASP.NET MVC SMS-23: Student course offer list semester search using ASP.NET MVC AngularJS JQUERY SMS-24: Student Marks Entry page in table column input marks entry using Jquery & Angular js in ASP.NET MVC SMS-25: Student Course Mark multiple data save using jquery with Stored Procedure & Angular js in ASP.NET MVC SMS-26: Student Marks list show by search student name and trimester Jquery & Angular js in ASP.NET MVC SMS-27: Student profile create and browse profile using Store procedure AngularJS Jquery ASP.NET SMS-28: Student Result show by search trimester and myasp server registration and login using Jquery & Angular js in ASP.NET MVC

11/7/2021 8:45:49 AM

This course will teach you to create and update course information using store procedure in ASP.NET MVC JQUERY and AngularJS. Will show how you can load data using storeprocedure and load data in your dropdown list using jquery angularjs and javascript along with ASP.NET MVC framework.

Steps:

Step-1:

  • Add GetMAsterDataByID() JsonResult CourseController.cs Controller.
  • Go to Solution Explorer > Controllers Folder>   CourseController.css>    in this controller with writing the below code.
        public JsonResult GetMAsterDataByID(int MasterId)
        {
            DataSet ds = aDal.LoadDataByMasterIDDAL(MasterId);
            List<CourseDAO> lists = new List<CourseDAO>();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                lists.Add(new CourseDAO
                {
                    CourseId = Convert.ToInt32(dr["CourseId"]),
                    SectionId = Convert.ToInt32(dr["SectionId"]),

                    CourseName = Convert.ToString(dr["CourseName"]),
                    BatchId = Convert.ToInt32(dr["BatchId"])
                });
                //ddlLoadSectonbyBatchID(Convert.ToInt32(dr["BatchId"]));
            }
            return Json(lists, JsonRequestBehavior.AllowGet);
        } 

Step-2:

  • Add LoadDataByMasterIDDAL() in CourseDAL.css  class.
  • Go to Solution Explorer > DAL Folder > CourseDAL.css  Class with writing the below code.
        public DataSet LoadDataByMasterIDDAL(int CourseId)
        {
            SqlCommand com = new SqlCommand("Get_CourseMaterDataById", conn);
            com.CommandType = CommandType.StoredProcedure;
            com.Parameters.AddWithValue("@CourseId", CourseId);
            SqlDataAdapter da = new SqlDataAdapter(com);
            DataSet dss = new DataSet();
            da.Fill(dss);
            return dss;
        }

Step-3:

  • Create store Procedure for Course Get One Record.
  • Go to SQL Server 2014 > dbStudentMangeSystem database> Programmability> stored procedures> Select New> stored procedure>Create Get_CourseMaterDataById with writing the below code.
create proc [dbo].[Get_CourseMaterDataById]
@CourseId int
as
begin
select * from tblCourse where CourseId=@CourseId

end

Step-4:

  • Add GetOneRecord() Function in  CourseControllerJS.js.
  • Go to Solution Explorer > Scripts Folder.> AngularController Folder> ‘CourseControllerJS.js’> to get one record.
   $scope.GetOneRecord = function (CourseId) {
        $http.get("/Course/GetMAsterDataByID?MasterId=" + CourseId).then(function (d) {
              $scope.CourseDAO = d.data[0];
              $scope.btnSaveTextCo = "Update";
              $http.get("/Course/ddlLoadSectonbyBatchID?BatchId=" + d.data[0].BatchId).then(function(d) {
                  $scope.Section = d.data;
              }, function (error) {
                  alert("Faild");
              });
        }, function (error) {
            alert("Faild");
        });
    };

For Update Course Information follow below step

Step-5:

  • Add Update_Info() JsonResult CourseController.cs Controller.
        public JsonResult Update_Info(CourseDAO aDao)
        {
            string Mes = "";
            try
            {
                aDal.UpdateInfoDAL(aDao);
                Mes = "Operation Successful!!";
            }
            catch (Exception e)
            {
                Mes = "Operation Faild!!";
            }
            return Json(Mes, JsonRequestBehavior.AllowGet);
        }

Step-6:

  • Add UpdateInfoDAL() in CourseDAL.css  class.
  • Go to Solution Explorer > DAL Folder > CourseDAL.css  Class with writing the below code.
        public void UpdateInfoDAL(CourseDAO aDao)
        {
            SqlCommand com = new SqlCommand("Update_CourseByMasterId", conn);
            com.CommandType = CommandType.StoredProcedure;
            com.Parameters.AddWithValue("@CourseId", aDao.CourseId);
            com.Parameters.AddWithValue("@CourseName", aDao.CourseName);
            com.Parameters.AddWithValue("@BatchId", aDao.BatchId);
            com.Parameters.AddWithValue("@SectionId", aDao.SectionId);
            conn.Open();
            com.ExecuteNonQuery();
            conn.Close();
        }

Step-7:

  • Create store Procedure for Course Get One Record.
  • Go to SQL Server 2014 > dbStudentMangeSystem database> Programmability> stored procedures> Select New> stored procedure>Create Update_CourseByMasterId with writing the below code.
create proc [dbo].[Update_CourseByMasterId]

@CourseId int,
@CourseName nvarchar(500),
@BatchId  int,
@SectionId int
as 

begin

update tblCourse set  CourseName=@CourseName, BatchId=@BatchId,SectionId= @SectionId  where CourseId=@CourseId
end

Step-8:

  • Add Update Info in  CourseControllerJS.js file.
  • Go to Solution Explorer > Scripts Folder.> AngularController Folder> Create   ‘CourseControllerJS.js’> for   update information    with writing the below highlight code.
  $scope.SaveData = function () {
        if ($scope.btnSaveTextCo == "Save") {
            $scope.btnSaveTextCo = "Saving.....";
            $http({
                method: 'POST',
                url: '/Course/Save_Info',
                data: $scope.CourseDAO
            }).success(function (a) {
                $scope.btnSaveTextCo = "Save";
                $scope.CourseDAO = null;
                alert(a);
            }).error(function () {
                alert("Faild");
            });
        } else {
            $scope.btnSaveTextCo = "Updating.....";
            $http({
                method: 'POST',
                url: '/Course/Update_Info',
                data: $scope.CourseDAO
            }).success(function (a) {
                $scope.btnSaveTextCo = "Save";
                $scope.CourseDAO = null;
                alert(a);
            }).error(function () {
                alert("Faild");
            });
        }
    };

Step-9: Run Application.

Step-10:

  • Add Controller  StudentController.cs.
  • Go to Solution Explorer > Controllers Folder> Add > Controller> Select MVC 5 Controller-Empty> Click ‘Add’ button> Give Controller Name ’ StudentController’ >  in this controller with writing the below code.
       public ActionResult StudentList()
        {
            return View();
        }
  • In the StudentList() Action Result Mouse right button Select Add View > Click Add Button> StudentList.cshtml  page has been created.
  • Add Another Action result SectionEntry()with writing the below code.
        public ActionResult StudentEntry()
        {
            return View();
        }

In the StudentEntry() Action Result Mouse right button Select Add View > Click Add Button> StudentEntry.cshtml  page has been created.

Step-11: Run Application.

About Teacher

Reza Karim

Software Engineer

More about him