PageRenderTime 16ms CodeModel.GetById 7ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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