Posted by : sinhalamp3 Monday, June 13, 2016

using StudentController;
using StudentMoodle.common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using StudentData;

namespace StudentMoodle
{
    public partial class InsertStudent : System.Web.UI.Page
    {
        static Student_Controller _studentController;
        static JavaScriptSerializer _Serializer;
        static StringBuilder _StringBuilder;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                _studentController = new Student_Controller(MyDataLayer.Instance.Context);
            }
        }

        [WebMethod]
        public static bool saveStudent(object student)
        {

            try
            {
                _Serializer = new JavaScriptSerializer();
                _StringBuilder = new StringBuilder();
                _Serializer.Serialize(student, _StringBuilder);
                StudentData.Student Student_ = _Serializer.Deserialize(_StringBuilder.ToString());
                return _studentController.saveStudent(Student_);
               
            }
            catch (Exception)
            {
                return false;
            }
        }

        [WebMethod]
        public static Array LoadStudentsToUpdate()
        {
            return _studentController.LoadStudentsToUpdate();
        }

        [WebMethod]
        public static Array SearchStudents(string student_id)
        {
           return _studentController.SearchStudents(student_id);
     
        }

        [WebMethod]
        public static Array GetStudentByID(string student_id)
        {
            return _studentController.GetStudentByID(student_id);
        }
       

        [WebMethod]
        public static Array LoadSchoolsToDropSown()
        {
            return _studentController.LoadSchoolsToDropDown();
        }

        [WebMethod]
        public static bool UpdateStudent(object student)
        {
            try
            {
                _Serializer = new JavaScriptSerializer();
                _StringBuilder = new StringBuilder();

                _Serializer.Serialize(student, _StringBuilder);
                StudentData.Student Student = _Serializer.Deserialize(_StringBuilder.ToString());
                return _studentController.UpdateStudent(Student);
               

            }
            catch (Exception)
            {
                return false;

            }
        }

        [WebMethod]
        public static Array LoadStudentsToGrid()
        {
            return _studentController.GetFirst25StudentsToPageLoadGrid();
        }

        [WebMethod]
        public static Array FetchStudentsToGrid(string studentIdOrName)
        {
            return _studentController.GetFetchStudents(studentIdOrName);
        }

        [WebMethod]
        public static bool DeleteStudent(string Student_ID)
        {
            return _studentController.DeleteStudent(Student_ID);
        }

    }
}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

Blogger templates

lakshika345@gmail.com. Powered by Blogger.

- Copyright © mp3s for you -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -