Ejemplo n.º 1
0
        public Departmentsrb GetDepartment(int id)
        {
            Departmentsrb aDepartment = new Departmentsrb();

            Query   = "SELECT * FROM Department WHERE DepartmentId='" + id + "'";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                aDepartment.Id   = Convert.ToInt32(Reader["DepartmentId"]);
                aDepartment.NAME = Reader["DepartmentName"].ToString();
            }
            return(aDepartment);
        }
Ejemplo n.º 2
0
        public JsonResult GetDepartment(int studentId)
        {
            int departmentid = 0;
            StudentsManagersrb aManagersrb = new StudentsManagersrb();
            var students        = aManagersrb.GetallStudent();
            var requiredstudent = students.Where(m => m.StudentId == studentId).ToList();

            foreach (var i in requiredstudent)
            {
                departmentid = i.DeptId;
            }
            DepartmentManagersrb aManager       = new DepartmentManagersrb();
            List <Departmentsrb> departments    = new List <Departmentsrb>();
            Departmentsrb        aDepartmentsrb = aManager.GetDepartment(departmentid);

            departments.Add(aDepartmentsrb);
            return(Json(departments));
        }