public ViewStudentWithDEpartment GetStudent() { ViewStudentWithDEpartment viewStudentWithDEpartment = new ViewStudentWithDEpartment(); Query = "SELECT TOP 1 * FROM ViewStudentWithDEpartment ORDER BY Id DESC"; Command.CommandText = Query; Command.Connection = Connection; Connection.Open(); Reader = Command.ExecuteReader(); if (Reader.HasRows) { while (Reader.Read()) { string[] date = Reader["Date"].ToString().Split(' '); viewStudentWithDEpartment.Name = Reader["Name"].ToString(); viewStudentWithDEpartment.Email = Reader["Email"].ToString(); viewStudentWithDEpartment.ContactNo = Reader["ContactNo"].ToString(); viewStudentWithDEpartment.Address = Reader["Address"].ToString(); viewStudentWithDEpartment.Date = date[0]; viewStudentWithDEpartment.RegNo = Reader["RegNo"].ToString(); viewStudentWithDEpartment.Department = Reader["Department"].ToString(); } Reader.Close(); } Connection.Close(); return(viewStudentWithDEpartment); }
public List <ViewStudentWithDEpartment> GetStudentRegNoId() { List <ViewStudentWithDEpartment> viewStudentWithDEpartments = new List <ViewStudentWithDEpartment>(); Query = "SELECT*FROM ViewStudentWithDEpartment"; Command.CommandText = Query; Command.Connection = Connection; Connection.Open(); Reader = Command.ExecuteReader(); if (Reader.HasRows) { while (Reader.Read()) { ViewStudentWithDEpartment viewStudentWithDEpartment = new ViewStudentWithDEpartment(); viewStudentWithDEpartment.Id = Int32.Parse(Reader["Id"].ToString()); viewStudentWithDEpartment.RegNo = Reader["RegNo"].ToString(); viewStudentWithDEpartments.Add(viewStudentWithDEpartment); } Reader.Close(); } Connection.Close(); return(viewStudentWithDEpartments); }
public ActionResult GetStudentByRegNo(int id) { ViewStudentWithDEpartment viewStudentWithDEpartment = studentManager.GetStudentByRegNo(id); return(Json(viewStudentWithDEpartment)); }
public JsonResult GetStudent() { ViewStudentWithDEpartment student = studentManager.GetStudent(); return(Json(student)); }