/Docs/07-Implementacion/Source/trunk/EDUAR_actual/EDUAR/EDUAR_DataAccess/Common/DATutor.cs

http://blpm.googlecode.com/ · C# · 211 lines · 172 code · 24 blank · 15 comment · 23 complexity · 6775d8bce4b431b696e31e1b9a4d3bc2 MD5 · raw file

  1. using System;
  2. using EDUAR_DataAccess.Shared;
  3. using EDUAR_Entities;
  4. using System.Collections.Generic;
  5. using EDUAR_Utility.Excepciones;
  6. using EDUAR_Utility.Enumeraciones;
  7. using System.Data.SqlClient;
  8. using System.Data;
  9. namespace EDUAR_DataAccess.Common
  10. {
  11. public class DATutor : DataAccesBase<Tutor>
  12. {
  13. #region --[Atributos]--
  14. private const string ClassName = "DATutor";
  15. #endregion
  16. #region --[Constructor]--
  17. public DATutor()
  18. {
  19. }
  20. public DATutor(DATransaction objDATransaction)
  21. : base(objDATransaction)
  22. {
  23. }
  24. #endregion
  25. #region --[Implementación métodos heredados]--
  26. public override string FieldID
  27. {
  28. get { throw new NotImplementedException(); }
  29. }
  30. public override string FieldDescription
  31. {
  32. get { throw new NotImplementedException(); }
  33. }
  34. public override Tutor GetById(Tutor entidad)
  35. {
  36. throw new NotImplementedException();
  37. }
  38. public override void Create(Tutor entidad)
  39. {
  40. throw new NotImplementedException();
  41. }
  42. public override void Create(Tutor entidad, out int identificador)
  43. {
  44. throw new NotImplementedException();
  45. }
  46. public override void Update(Tutor entidad)
  47. {
  48. throw new NotImplementedException();
  49. }
  50. public override void Delete(Tutor entidad)
  51. {
  52. throw new NotImplementedException();
  53. }
  54. #endregion
  55. #region --[Métodos Públicos]--
  56. /// <summary>
  57. /// Gets the tutores.
  58. /// </summary>
  59. /// <param name="entidad">The entidad.</param>
  60. /// <returns></returns>
  61. public List<Tutor> GetTutores(Tutor entidad)
  62. {
  63. try
  64. {
  65. Transaction.DBcomand = Transaction.DataBase.GetStoredProcCommand("Tutor_Select");
  66. if (entidad != null)
  67. {
  68. if (entidad.activo != null)
  69. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@activo", DbType.Boolean, entidad.activo);
  70. }
  71. IDataReader reader = Transaction.DataBase.ExecuteReader(Transaction.DBcomand);
  72. List<Tutor> listaTutores = new List<Tutor>();
  73. Tutor objTutor;
  74. while (reader.Read())
  75. {
  76. objTutor = new Tutor();
  77. objTutor.idTutor = Convert.ToInt32(reader["idTutor"]);
  78. objTutor.nombre = reader["nombre"].ToString();
  79. objTutor.apellido = reader["apellido"].ToString();
  80. objTutor.activo = Convert.ToBoolean(reader["activo"]);
  81. listaTutores.Add(objTutor);
  82. }
  83. return listaTutores;
  84. }
  85. catch (SqlException ex)
  86. {
  87. throw new CustomizedException(string.Format("Fallo en {0} - GetTutores()", ClassName),
  88. ex, enuExceptionType.SqlException);
  89. }
  90. catch (Exception ex)
  91. {
  92. throw new CustomizedException(string.Format("Fallo en {0} - GetTutores()", ClassName),
  93. ex, enuExceptionType.DataAccesException);
  94. }
  95. }
  96. /// <summary>
  97. /// Gets the tutores por curso.
  98. /// </summary>
  99. /// <param name="entidad">The entidad.</param>
  100. /// <returns></returns>
  101. public List<Tutor> GetTutoresPorCurso(AlumnoCurso entidad)
  102. {
  103. try
  104. {
  105. Transaction.DBcomand = Transaction.DataBase.GetStoredProcCommand("TutoresPorCurso_Select");
  106. if (entidad != null)
  107. {
  108. if (entidad.cursoCicloLectivo.idCursoCicloLectivo > 0)
  109. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCursoCicloLectivo", DbType.Int32, entidad.cursoCicloLectivo.idCursoCicloLectivo);
  110. if (entidad.curso.cicloLectivo.idCicloLectivo > 0)
  111. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCicloLectivo", DbType.Int32, entidad.curso.cicloLectivo.idCicloLectivo);
  112. }
  113. IDataReader reader = Transaction.DataBase.ExecuteReader(Transaction.DBcomand);
  114. List<Tutor> listaTutores = new List<Tutor>();
  115. Tutor objTutor;
  116. while (reader.Read())
  117. {
  118. objTutor = new Tutor();
  119. objTutor.idTutor = Convert.ToInt32(reader["idTutor"]);
  120. objTutor.nombre = reader["nombre"].ToString();
  121. objTutor.apellido = reader["apellido"].ToString();
  122. objTutor.idPersona = Convert.ToInt32(reader["idPersona"]);
  123. listaTutores.Add(objTutor);
  124. }
  125. return listaTutores;
  126. }
  127. catch (SqlException ex)
  128. {
  129. throw new CustomizedException(string.Format("Fallo en {0} - GetTutoresPorCurso()", ClassName),
  130. ex, enuExceptionType.SqlException);
  131. }
  132. catch (Exception ex)
  133. {
  134. throw new CustomizedException(string.Format("Fallo en {0} - GetTutoresPorCurso()", ClassName),
  135. ex, enuExceptionType.DataAccesException);
  136. }
  137. }
  138. /// <summary>
  139. /// Gets the alumnos tutor.
  140. /// </summary>
  141. /// <param name="entidad">The entidad.</param>
  142. /// <returns></returns>
  143. public List<Alumno> GetAlumnosTutor(Tutor entidad, int idCicloLectivo =0, int idCurso = 0)
  144. {
  145. try
  146. {
  147. Transaction.DBcomand = Transaction.DataBase.GetStoredProcCommand("TutorAlumno_Select");
  148. if (entidad != null)
  149. {
  150. if (!string.IsNullOrEmpty(entidad.username))
  151. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@username", DbType.String, entidad.username);
  152. if (entidad.activo != null)
  153. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@activo", DbType.Boolean, entidad.activo);
  154. if (entidad.idTutor != 0)
  155. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idTutor", DbType.Int32, entidad.idTutor);
  156. if (idCicloLectivo != 0)
  157. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCicloLectivo", DbType.Int32, idCicloLectivo);
  158. if (idCurso != 0 && idCurso !=-1)
  159. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCurso", DbType.Int32, idCurso);
  160. }
  161. IDataReader reader = Transaction.DataBase.ExecuteReader(Transaction.DBcomand);
  162. List<Alumno> listaAlumnos = new List<Alumno>();
  163. Alumno objAlumno;
  164. while (reader.Read())
  165. {
  166. objAlumno = new Alumno();
  167. objAlumno.idAlumno = Convert.ToInt32(reader["idAlumno"]);
  168. objAlumno.nombre = reader["nombre"].ToString();
  169. objAlumno.apellido = reader["apellido"].ToString();
  170. listaAlumnos.Add(objAlumno);
  171. }
  172. return listaAlumnos;
  173. }
  174. catch (SqlException ex)
  175. {
  176. throw new CustomizedException(string.Format("Fallo en {0} - GetAlumnosTutor()", ClassName),
  177. ex, enuExceptionType.SqlException);
  178. }
  179. catch (Exception ex)
  180. {
  181. throw new CustomizedException(string.Format("Fallo en {0} - GetAlumnosTutor()", ClassName),
  182. ex, enuExceptionType.DataAccesException);
  183. }
  184. }
  185. #endregion
  186. }
  187. }