/Docs/07-Implementacion/Source/trunk/EDUAR_Regular/EDUAR/EDUAR_DataAccess/Common/DACurso.cs

http://blpm.googlecode.com/ · C# · 176 lines · 124 code · 21 blank · 31 comment · 11 complexity · ad936c2500e728d4f69c4279b71c24e3 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using EDUAR_DataAccess.Shared;
  6. using EDUAR_Entities;
  7. using EDUAR_Utility.Enumeraciones;
  8. using EDUAR_Utility.Excepciones;
  9. namespace EDUAR_DataAccess.Common
  10. {
  11. public class DACurso : DataAccesBase<Curso>
  12. {
  13. #region --[Atributos]--
  14. private const string ClassName = "DACurso";
  15. #endregion
  16. #region --[Constructor]--
  17. public DACurso()
  18. {
  19. }
  20. public DACurso(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 Curso GetById(Curso entidad)
  35. {
  36. throw new NotImplementedException();
  37. }
  38. public override void Create(Curso entidad)
  39. {
  40. throw new NotImplementedException();
  41. }
  42. public override void Create(Curso entidad, out int identificador)
  43. {
  44. throw new NotImplementedException();
  45. }
  46. public override void Update(Curso entidad)
  47. {
  48. throw new NotImplementedException();
  49. }
  50. public override void Delete(Curso entidad)
  51. {
  52. throw new NotImplementedException();
  53. }
  54. #endregion
  55. #region --[Métodos Públicos]--
  56. /// <summary>
  57. /// Gets the cursos.
  58. /// </summary>
  59. /// <param name="entidad">The entidad.</param>
  60. /// <returns></returns>
  61. public List<Curso> GetCursos(Curso entidad)
  62. {
  63. try
  64. {
  65. Transaction.DBcomand = Transaction.DataBase.GetStoredProcCommand("Curso_Select");
  66. if (entidad != null)
  67. {
  68. //if (entidad.cicloLectivo.idCicloLectivo > 0)
  69. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCicloLectivo", DbType.Int32, entidad.cicloLectivo.idCicloLectivo);
  70. //if (entidad.idCicloLectivo > 0)
  71. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCicloLectivo", DbType.Int32, entidad.idCicloLectivo);
  72. //if (entidad.pagina.idPagina > 0)
  73. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idPagina", DbType.Int32, entidad.pagina.idPagina);
  74. //if (!string.IsNullOrEmpty(entidad.pagina.titulo))
  75. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@titulo", DbType.String, entidad.pagina.titulo);
  76. //if (ValidarFechaSQL(entidad.fecha))
  77. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@fecha", DbType.Date, entidad.fecha);
  78. //if (ValidarFechaSQL(entidad.hora))
  79. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@hora", DbType.Date, entidad.hora);
  80. }
  81. IDataReader reader = Transaction.DataBase.ExecuteReader(Transaction.DBcomand);
  82. List<Curso> listaCursos = new List<Curso>();
  83. Curso objCurso;
  84. while (reader.Read())
  85. {
  86. objCurso = new Curso();
  87. objCurso.idCurso = Convert.ToInt32(reader["idCurso"]);
  88. //objCurso.division = reader["division"].ToString();
  89. objCurso.nombre = reader["nombre"].ToString();
  90. listaCursos.Add(objCurso);
  91. }
  92. return listaCursos;
  93. }
  94. catch (SqlException ex)
  95. {
  96. throw new CustomizedException(string.Format("Fallo en {0} - GetCursos()", ClassName),
  97. ex, enuExceptionType.SqlException);
  98. }
  99. catch (Exception ex)
  100. {
  101. throw new CustomizedException(string.Format("Fallo en {0} - GetCursos()", ClassName),
  102. ex, enuExceptionType.DataAccesException);
  103. }
  104. }
  105. // Chequear y preguntar stored procedure
  106. // preguntar el tema division
  107. public List<Curso> GetCursosCicloLectivo(Curso entidad)
  108. {
  109. try
  110. {
  111. Transaction.DBcomand = Transaction.DataBase.GetStoredProcCommand("CursosCicloLectivo_Select");
  112. if (entidad != null)
  113. {
  114. if (entidad.idCurso > 0)
  115. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCurso", DbType.Int32, entidad.idCurso);
  116. if (entidad.cicloLectivo != null && entidad.cicloLectivo.idCicloLectivo != 0)
  117. Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCicloLectivo", DbType.Int32, entidad.cicloLectivo.idCicloLectivo);
  118. //if (!string.IsNullOrEmpty(entidad.nombre))
  119. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@nombre", DbType.String, entidad.nombre);
  120. //if (entidad.preceptor != null && entidad.preceptor.idPreceptor != 0)
  121. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idPreceptor", DbType.Int32, entidad.preceptor.idPreceptor);
  122. //if (entidad.nivel != null && entidad.nivel.idNivel != 0)
  123. // Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idNivel", DbType.Int32, entidad.nivel.idNivel);
  124. }
  125. IDataReader reader = Transaction.DataBase.ExecuteReader(Transaction.DBcomand);
  126. List<Curso> listaCursos = new List<Curso>();
  127. Curso objCurso;
  128. while (reader.Read())
  129. {
  130. objCurso = new Curso();
  131. objCurso.idCurso = Convert.ToInt32(reader["idCursoCicloLectivo"]);
  132. objCurso.nombre = reader["nombre"].ToString();
  133. //objCurso.nivel.idNivel = (int)reader["idCurso"];
  134. // Preguntar como hacer con esto
  135. // objCurso.orientacion = (int)reader["idOrientacion"];
  136. //if (reader["idPreceptor"] != DBNull.Value)
  137. // objCurso.preceptor.idPreceptor = Convert.ToInt32(reader["idPreceptor"]);
  138. listaCursos.Add(objCurso);
  139. }
  140. return listaCursos;
  141. }
  142. catch (SqlException ex)
  143. {
  144. throw new CustomizedException(string.Format("Fallo en {0} - GetCursos()", ClassName),
  145. ex, enuExceptionType.SqlException);
  146. }
  147. catch (Exception ex)
  148. {
  149. throw new CustomizedException(string.Format("Fallo en {0} - GetCursos()", ClassName),
  150. ex, enuExceptionType.DataAccesException);
  151. }
  152. }
  153. #endregion
  154. }
  155. }