PageRenderTime 42ms CodeModel.GetById 12ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://blpm.googlecode.com/
C# | 196 lines | 153 code | 26 blank | 17 comment | 11 complexity | d227bc068cf01924d8b27a8f33ef31db MD5 | raw file
  1using System;
  2using EDUAR_DataAccess.Shared;
  3using EDUAR_Entities;
  4using System.Collections.Generic;
  5using System.Data;
  6using System.Data.SqlClient;
  7using EDUAR_Utility.Excepciones;
  8using EDUAR_Utility.Enumeraciones;
  9
 10namespace EDUAR_DataAccess.Common
 11{
 12	public class DANivel : DataAccesBase<Nivel>
 13	{
 14		#region --[Atributos]--
 15		private const string ClassName = "DANivel";
 16		#endregion
 17
 18		#region --[Constructor]--
 19		public DANivel()
 20		{
 21		}
 22
 23		public DANivel(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 Nivel GetById(Nivel entidad)
 42		{
 43			throw new NotImplementedException();
 44		}
 45
 46		public override void Create(Nivel entidad)
 47		{
 48			throw new NotImplementedException();
 49		}
 50
 51		public override void Create(Nivel entidad, out int identificador)
 52		{
 53			throw new NotImplementedException();
 54		}
 55
 56		public override void Update(Nivel entidad)
 57		{
 58			throw new NotImplementedException();
 59		}
 60
 61		public override void Delete(Nivel entidad)
 62		{
 63			throw new NotImplementedException();
 64		}
 65		#endregion
 66
 67		#region --[Métodos Públicos]--
 68		/// <summary>
 69		/// Gets the by curso ciclo lectivo.
 70		/// </summary>
 71		/// <param name="idCicloLectivo">The id ciclo lectivo.</param>
 72		/// <returns></returns>
 73		public List<Nivel> GetByCursoCicloLectivo(CicloLectivo entidad)
 74		{
 75			try
 76			{
 77				Transaction.DBcomand = Transaction.DataBase.GetStoredProcCommand("NivelesCursoCicloLectivo_Select");
 78				if (entidad.idCicloLectivo > 0)
 79					Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCicloLectivo", DbType.Int32, entidad.idCicloLectivo);
 80
 81				IDataReader reader = Transaction.DataBase.ExecuteReader(Transaction.DBcomand);
 82
 83				List<Nivel> listaNiveles = new List<Nivel>();
 84				Nivel objNivel;
 85				while (reader.Read())
 86				{
 87					objNivel = new Nivel();
 88
 89					objNivel.idNivel = Convert.ToInt32(reader["idNivel"]);
 90					objNivel.nombre = reader["nombre"].ToString();
 91
 92					listaNiveles.Add(objNivel);
 93				}
 94				return listaNiveles;
 95			}
 96			catch (SqlException ex)
 97			{
 98				throw new CustomizedException(string.Format("Fallo en {0} - GetByCursoCicloLectivo()", ClassName),
 99									ex, enuExceptionType.SqlException);
100			}
101			catch (Exception ex)
102			{
103				throw new CustomizedException(string.Format("Fallo en {0} - GetByCursoCicloLectivo()", ClassName),
104									ex, enuExceptionType.DataAccesException);
105			}
106		}
107
108        /// <summary>
109        /// Gets the niveles.
110        /// </summary>
111        /// <returns></returns>
112        /// <exception cref="CustomizedException">
113        /// </exception>
114        public List<Nivel> GetNiveles(AsignaturaCicloLectivo entidad)
115        {
116            try
117            {
118                Transaction.DBcomand = Transaction.DataBase.GetStoredProcCommand("AsignaturaNivel_Select");
119                if (entidad != null)
120                {
121                    if (entidad.cursoCicloLectivo.cicloLectivo.idCicloLectivo > 0)
122                        Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idCicloLectivo", DbType.Int32, entidad.cursoCicloLectivo.cicloLectivo.idCicloLectivo);
123                    if (entidad.cursoCicloLectivo.curso.nivel.idNivel > 0)
124                        Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@idNivel", DbType.Int32, entidad.cursoCicloLectivo.curso.nivel.idNivel);
125                    if (entidad.docente != null && !string.IsNullOrEmpty(entidad.docente.username))
126                        Transaction.DataBase.AddInParameter(Transaction.DBcomand, "@docente", DbType.String, entidad.docente.username);
127                }
128                IDataReader reader = Transaction.DataBase.ExecuteReader(Transaction.DBcomand);
129
130                List<Nivel> listaNiveles = new List<Nivel>();
131                Nivel objNivel;
132                while (reader.Read())
133                {
134                    objNivel = new Nivel();
135
136                    objNivel.idNivel = Convert.ToInt32(reader["idNivel"]);
137                    objNivel.nombre = reader["nivel"].ToString();
138
139                    listaNiveles.Add(objNivel);
140                }
141                return listaNiveles;
142            }
143            catch (SqlException ex)
144            {
145                throw new CustomizedException(string.Format("Fallo en {0} - GetNiveles(AsignaturaCicloLectivo)", ClassName),
146                                    ex, enuExceptionType.SqlException);
147            }
148            catch (Exception ex)
149            {
150                throw new CustomizedException(string.Format("Fallo en {0} - GetNiveles(AsignaturaCicloLectivo)", ClassName),
151                                    ex, enuExceptionType.DataAccesException);
152            }
153        }
154
155        /// <summary>
156        /// Gets the niveles.
157        /// </summary>
158        /// <returns></returns>
159        /// <exception cref="CustomizedException">
160        /// </exception>
161        public List<Nivel> GetNiveles()
162        {
163            try
164            {
165                Transaction.DBcomand = Transaction.DataBase.GetStoredProcCommand("NivelesCursoCicloLectivo_Select");
166               
167                IDataReader reader = Transaction.DataBase.ExecuteReader(Transaction.DBcomand);
168
169                List<Nivel> listaNiveles = new List<Nivel>();
170                Nivel objNivel;
171                while (reader.Read())
172                {
173                    objNivel = new Nivel();
174
175                    objNivel.idNivel = Convert.ToInt32(reader["idNivel"]);
176                    objNivel.nombre = reader["nombre"].ToString();
177
178                    listaNiveles.Add(objNivel);
179                }
180                return listaNiveles;
181            }
182            catch (SqlException ex)
183            {
184                throw new CustomizedException(string.Format("Fallo en {0} - GetNiveles()", ClassName),
185                                    ex, enuExceptionType.SqlException);
186            }
187            catch (Exception ex)
188            {
189                throw new CustomizedException(string.Format("Fallo en {0} - GetNiveles()", ClassName),
190                                    ex, enuExceptionType.DataAccesException);
191            }
192        }
193		#endregion
194
195	}
196}