PageRenderTime 72ms CodeModel.GetById 19ms app.highlight 44ms RepoModel.GetById 2ms app.codeStats 0ms

/Docs/07-Implementacion/Source/trunk/EDUAR_Regular/EDUAR_SI/EDUAR_SI_DataAccess/DAImportarDatos.cs

http://blpm.googlecode.com/
C# | 1294 lines | 1050 code | 100 blank | 144 comment | 31 complexity | 89ad42033ae8132d1e1eff1c93ee8d01 MD5 | raw file
   1using System;
   2using System.Data.SqlClient;
   3using EDUAR_Entities;
   4using EDUAR_Utility.Enumeraciones;
   5using EDUAR_Utility.Excepciones;
   6using System.Data;
   7using System.Collections.Generic;
   8
   9namespace EDUAR_SI_DataAccess
  10{
  11	public class DAImportarDatos : DABase
  12	{
  13		#region --[Atributos]--
  14		private const string ClassName = "DAImportarDatos";
  15		#endregion
  16
  17		#region --[Propiedades]--
  18		#endregion
  19
  20		#region --[Constructores]--
  21		/// <summary>
  22		/// Constructor. LLama al constructor de la clase base DABase.
  23		/// </summary>
  24		/// <param name="connectionString">Cadena de conexión a la base de datos</param>
  25		public DAImportarDatos(String connectionString)
  26			: base(connectionString)
  27		{
  28
  29		}
  30		#endregion
  31
  32		#region --[Métodos Públicos]--
  33		/// <summary>
  34		/// Guarda una colección de personas en base de datos
  35		/// </summary>
  36		/// <param name="objeto">Colección de Persona</param>
  37		public int GrabarPersona(Persona persona, SqlTransaction transaccion, int? idCargoPersonal, int idPersonaTransaccional)
  38		{
  39			try
  40			{
  41				using (SqlCommand command = new SqlCommand())
  42				{
  43					command.CommandType = System.Data.CommandType.StoredProcedure;
  44					command.CommandText = "Personas_Insert";
  45					command.CommandTimeout = 10;
  46
  47					command.Connection = transaccion.Connection;
  48					command.Transaction = transaccion;
  49
  50					command.Parameters.AddWithValue("idPersona", 0).Direction = ParameterDirection.Output;
  51					command.Parameters.AddWithValue("nombre", persona.nombre);
  52					command.Parameters.AddWithValue("apellido", persona.apellido);
  53					command.Parameters.AddWithValue("numeroDocumento", persona.numeroDocumento);
  54					command.Parameters.AddWithValue("idTipoDocumento", persona.idTipoDocumento);
  55					command.Parameters.AddWithValue("domicilio", persona.domicilio);
  56					command.Parameters.AddWithValue("barrio", persona.barrio);
  57					command.Parameters.AddWithValue("localidad", persona.localidad.nombre);
  58					command.Parameters.AddWithValue("sexo", persona.sexo);
  59					if (ValidarFechaSQL(persona.fechaNacimiento))
  60						command.Parameters.AddWithValue("fechaNacimiento", persona.fechaNacimiento);
  61					command.Parameters.AddWithValue("telefonoFijo", persona.telefonoFijo);
  62					command.Parameters.AddWithValue("telefonoCelular", persona.telefonoCelular);
  63					command.Parameters.AddWithValue("telefonoCelularAlternativo", persona.telefonoCelularAlternativo);
  64					command.Parameters.AddWithValue("email", persona.email);
  65					command.Parameters.AddWithValue("activo", persona.activo);
  66					command.Parameters.AddWithValue("idTipoPersona", persona.idTipoPersona);
  67					command.Parameters.AddWithValue("idCargoPersonal", idCargoPersonal);
  68					command.Parameters.AddWithValue("idPersonaTransaccional", idPersonaTransaccional);
  69
  70					command.ExecuteNonQuery();
  71					return Convert.ToInt32(command.Parameters["idPersona"].Value);
  72				}
  73			}
  74			catch (SqlException ex)
  75			{
  76				//if (transaccion != null) transaccion.Rollback();
  77				throw new CustomizedException(String.Format("Fallo en {0} - GrabarPersona()", ClassName),
  78									ex, enuExceptionType.SqlException);
  79			}
  80			catch (Exception ex)
  81			{
  82				//if (transaccion != null) transaccion.Rollback();
  83				throw new CustomizedException(String.Format("Fallo en {0} - GrabarPersona()", ClassName),
  84									ex, enuExceptionType.DataAccesException);
  85			}
  86		}
  87
  88		/// <summary>
  89		/// Grabars the alumno.
  90		/// </summary>
  91		/// <param name="alumno">The alumno.</param>
  92		/// <param name="transaccion">The transaccion.</param>
  93		public void GrabarAlumno(Alumno alumno, SqlTransaction transaccion)
  94		{
  95			try
  96			{
  97				using (SqlCommand command = new SqlCommand())
  98				{
  99					command.Connection = transaccion.Connection;
 100					command.Transaction = transaccion;
 101
 102					command.CommandType = System.Data.CommandType.StoredProcedure;
 103					command.CommandText = "Alumnos_Insert";
 104					command.CommandTimeout = 10;
 105
 106					command.Parameters.AddWithValue("idAlumno", alumno.idAlumno).Direction = ParameterDirection.Output;
 107					command.Parameters.AddWithValue("idAlumnoTransaccional", alumno.idAlumnoTransaccional);
 108					command.Parameters.AddWithValue("idPersona", alumno.idPersona);
 109					command.Parameters.AddWithValue("legajo", alumno.legajo);
 110					command.Parameters.AddWithValue("fechaAlta", DBNull.Value);
 111					command.Parameters.AddWithValue("fechaBaja", DBNull.Value);
 112					command.ExecuteNonQuery();
 113					command.Parameters.Clear();
 114				}
 115			}
 116			catch (SqlException ex)
 117			{
 118				//if (transaccion != null) transaccion.Rollback();
 119				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAlumno()", ClassName),
 120									ex, enuExceptionType.SqlException);
 121			}
 122			catch (Exception ex)
 123			{
 124				//if (transaccion != null) transaccion.Rollback();
 125				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAlumno()", ClassName),
 126									ex, enuExceptionType.DataAccesException);
 127			}
 128		}
 129
 130		/// <summary>
 131		/// Grabars the pais.
 132		/// </summary>
 133		/// <param name="colPaises">The col paises.</param>
 134		public void GrabarPais(List<Paises> listaPaises, SqlTransaction transaccion)
 135		{
 136			try
 137			{
 138				using (SqlCommand command = new SqlCommand())
 139				{
 140					command.CommandType = System.Data.CommandType.StoredProcedure;
 141					command.CommandText = "Paises_Insert";
 142					command.CommandTimeout = 10;
 143
 144					command.Connection = transaccion.Connection;
 145					command.Transaction = transaccion;
 146
 147					foreach (Paises pais in listaPaises)
 148					{
 149						command.Parameters.AddWithValue("idPais", 0).Direction = ParameterDirection.Output;
 150						command.Parameters.AddWithValue("idPaisTransaccional", pais.idPaisTransaccional);
 151						command.Parameters.AddWithValue("nombre", pais.nombre);
 152						command.Parameters.AddWithValue("descripcion", pais.descripcion);
 153						command.Parameters.AddWithValue("activo", pais.activo);
 154						command.ExecuteNonQuery();
 155						command.Parameters.Clear();
 156					}
 157				}
 158			}
 159			catch (SqlException ex)
 160			{
 161				throw new CustomizedException(String.Format("Fallo en {0} - GrabarPais()", ClassName),
 162									ex, enuExceptionType.SqlException);
 163			}
 164			catch (Exception ex)
 165			{
 166				throw new CustomizedException(String.Format("Fallo en {0} - GrabarPais()", ClassName),
 167									ex, enuExceptionType.DataAccesException);
 168			}
 169		}
 170
 171		/// <summary>
 172		/// Grabars the provincia.
 173		/// </summary>
 174		/// <param name="colProvincias">The col provincias.</param>
 175		public void GrabarProvincia(List<Provincias> listaProvincias, SqlTransaction transaccion)
 176		{
 177			try
 178			{
 179				using (SqlCommand command = new SqlCommand())
 180				{
 181					command.CommandType = System.Data.CommandType.StoredProcedure;
 182					command.CommandText = "Provincias_Insert";
 183					command.CommandTimeout = 10;
 184
 185					command.Connection = transaccion.Connection;
 186					command.Transaction = transaccion;
 187
 188					foreach (Provincias provincia in listaProvincias)
 189					{
 190						command.Parameters.AddWithValue("idProvincia", 0).Direction = ParameterDirection.Output;
 191						command.Parameters.AddWithValue("idProvinciaTransaccional", provincia.idProvinciaTransaccional);
 192						command.Parameters.AddWithValue("nombre", provincia.nombre);
 193						command.Parameters.AddWithValue("descripcion", provincia.descripcion);
 194						command.Parameters.AddWithValue("idPais", provincia.idPais);
 195						command.Parameters.AddWithValue("activo", provincia.activo);
 196						command.ExecuteNonQuery();
 197						command.Parameters.Clear();
 198					}
 199				}
 200			}
 201			catch (SqlException ex)
 202			{
 203				throw new CustomizedException(String.Format("Fallo en {0} - GrabarProvincia()", ClassName),
 204									ex, enuExceptionType.SqlException);
 205			}
 206			catch (Exception ex)
 207			{
 208				throw new CustomizedException(String.Format("Fallo en {0} - GrabarProvincia()", ClassName),
 209									ex, enuExceptionType.DataAccesException);
 210			}
 211		}
 212
 213		/// <summary>
 214		/// Grabars the localidad.
 215		/// </summary>
 216		/// <param name="colLocalidades">The col localidades.</param>
 217		public void GrabarLocalidad(List<Localidades> ListaLocalidades, SqlTransaction transaccion)
 218		{
 219			try
 220			{
 221				using (SqlCommand command = new SqlCommand())
 222				{
 223					command.CommandType = System.Data.CommandType.StoredProcedure;
 224					command.CommandText = "Localidades_Insert";
 225					command.CommandTimeout = 10;
 226
 227					command.Connection = transaccion.Connection;
 228					command.Transaction = transaccion;
 229
 230					foreach (Localidades localidad in ListaLocalidades)
 231					{
 232						command.Parameters.AddWithValue("idLocalidad", 0);
 233						command.Parameters.AddWithValue("idLocalidadTransaccional", 0);
 234						command.Parameters.AddWithValue("nombre", localidad.nombre);
 235						command.Parameters.AddWithValue("descripcion", "");
 236						command.Parameters.AddWithValue("idProvincia", localidad.idProvincia);
 237						command.Parameters.AddWithValue("activo", localidad.activo);
 238						command.ExecuteNonQuery();
 239						command.Parameters.Clear();
 240					}
 241				}
 242			}
 243			catch (SqlException ex)
 244			{
 245				throw new CustomizedException(String.Format("Fallo en {0} - GrabarLocalidad()", ClassName),
 246									ex, enuExceptionType.SqlException);
 247			}
 248			catch (Exception ex)
 249			{
 250				throw new CustomizedException(String.Format("Fallo en {0} - GrabarLocalidad()", ClassName),
 251									ex, enuExceptionType.DataAccesException);
 252			}
 253		}
 254
 255		/// <summary>
 256		/// Grabars the tipos documentos.
 257		/// </summary>
 258		/// <param name="colTipoDocumento">The col tipos documentos.</param>
 259		public void GrabarTipoDocumento(List<TipoDocumento> listaTipoDocumento, SqlTransaction transaccion)
 260		{
 261			try
 262			{
 263				using (SqlCommand command = new SqlCommand())
 264				{
 265					command.CommandType = System.Data.CommandType.StoredProcedure;
 266					command.CommandText = "TipoDocumento_Insert";
 267					command.CommandTimeout = 10;
 268
 269					command.Connection = transaccion.Connection;
 270					command.Transaction = transaccion;
 271
 272					foreach (TipoDocumento tipoDocumento in listaTipoDocumento)
 273					{
 274						command.Parameters.AddWithValue("idTipoDocumento", 0);
 275						command.Parameters.AddWithValue("idTipoDocumentoTransaccional", tipoDocumento.idTipoDocumentoTransaccional);
 276						command.Parameters.AddWithValue("nombre", tipoDocumento.nombre);
 277						command.Parameters.AddWithValue("descripcion", tipoDocumento.descripcion);
 278						command.Parameters.AddWithValue("activo", tipoDocumento.activo);
 279						command.ExecuteNonQuery();
 280						command.Parameters.Clear();
 281					}
 282				}
 283			}
 284			catch (SqlException ex)
 285			{
 286				if (transaccion != null) transaccion.Rollback();
 287				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTipoDocumento()", ClassName),
 288									ex, enuExceptionType.SqlException);
 289			}
 290			catch (Exception ex)
 291			{
 292				if (transaccion != null) transaccion.Rollback();
 293				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTipoDocumento()", ClassName),
 294									ex, enuExceptionType.DataAccesException);
 295			}
 296		}
 297
 298		/// <summary>
 299		/// Grabars the valores escalas calificaciones.
 300		/// </summary>
 301		/// <param name="listaValoresCalificacion">The lista valores calificacion.</param>
 302		/// <param name="transaccion">The transaccion.</param>
 303		public void GrabarValoresEscalasCalificaciones(List<ValoresEscalaCalificacion> listaValoresCalificacion, SqlTransaction transaccion)
 304		{
 305			try
 306			{
 307				using (SqlCommand command = new SqlCommand())
 308				{
 309					command.CommandType = System.Data.CommandType.StoredProcedure;
 310					command.CommandText = "ValoresEscalaCalificacion_Insert";
 311					command.CommandTimeout = 10;
 312
 313					command.Connection = transaccion.Connection;
 314					command.Transaction = transaccion;
 315
 316					foreach (ValoresEscalaCalificacion valorEscala in listaValoresCalificacion)
 317					{
 318						command.Parameters.AddWithValue("idValorEscalaCalificacion", 0);
 319						command.Parameters.AddWithValue("idValorEscalaCalificacionTransaccional", valorEscala.idValorEscalaCalificacionTransaccional);
 320						command.Parameters.AddWithValue("nombre", valorEscala.nombre);
 321						command.Parameters.AddWithValue("descripcion", valorEscala.descripcion);
 322						command.Parameters.AddWithValue("activo", valorEscala.activo);
 323						command.Parameters.AddWithValue("valor", valorEscala.valor);
 324						command.Parameters.AddWithValue("aprobado", valorEscala.aprobado);
 325						//command.Parameters.AddWithValue("idEscalaCalificacion", valorEscala.idEscalaCalificacion);
 326						command.ExecuteNonQuery();
 327						command.Parameters.Clear();
 328					}
 329				}
 330			}
 331			catch (SqlException ex)
 332			{
 333				if (transaccion != null) transaccion.Rollback();
 334				throw new CustomizedException(String.Format("Fallo en {0} - GrabarValoresEscalasCalificaciones()", ClassName),
 335									ex, enuExceptionType.SqlException);
 336			}
 337			catch (Exception ex)
 338			{
 339				if (transaccion != null) transaccion.Rollback();
 340				throw new CustomizedException(String.Format("Fallo en {0} - GrabarValoresEscalasCalificaciones()", ClassName),
 341									ex, enuExceptionType.DataAccesException);
 342			}
 343		}
 344
 345		/// <summary>
 346		/// Grabars the personal.
 347		/// </summary>
 348		/// <param name="personal">The personal.</param>
 349		/// <param name="transaccion">The transaccion.</param>
 350		public void GrabarPersonal(Personal personal, SqlTransaction transaccion)
 351		{
 352			try
 353			{
 354				using (SqlCommand command = new SqlCommand())
 355				{
 356					command.CommandType = System.Data.CommandType.StoredProcedure;
 357					command.CommandText = "Personal_Insert";
 358					command.CommandTimeout = 10;
 359
 360					command.Connection = transaccion.Connection;
 361					command.Transaction = transaccion;
 362
 363					command.Parameters.AddWithValue("idPersonal", personal.IdPersonal).Direction = ParameterDirection.Output;
 364					command.Parameters.AddWithValue("idPersonalTransaccional", personal.IdPersonalTransaccional);
 365					command.Parameters.AddWithValue("idPersona", personal.idPersona);
 366					command.Parameters.AddWithValue("legajo", personal.legajo);
 367					command.Parameters.AddWithValue("fechaAlta", DBNull.Value);
 368					command.Parameters.AddWithValue("fechaBaja", DBNull.Value);
 369					command.Parameters.AddWithValue("activo", personal.activo);
 370					command.Parameters.AddWithValue("idCargoPersonal", personal.cargo.idCargoTransaccional);
 371					command.ExecuteNonQuery();
 372					command.Parameters.Clear();
 373				}
 374			}
 375			catch (SqlException ex)
 376			{
 377				throw new CustomizedException(String.Format("Fallo en {0} - GrabarPersonal()", ClassName),
 378									ex, enuExceptionType.SqlException);
 379			}
 380			catch (Exception ex)
 381			{
 382				throw new CustomizedException(String.Format("Fallo en {0} - GrabarPersonal()", ClassName),
 383									ex, enuExceptionType.DataAccesException);
 384			}
 385		}
 386
 387		/// <summary>
 388		/// Grabars the cargo personal.
 389		/// </summary>
 390		/// <param name="listaCargosPersonal">The lista cargos personal.</param>
 391		/// <param name="transaccion">The transaccion.</param>
 392		public void GrabarCargoPersonal(List<CargoPersonal> listaCargosPersonal, SqlTransaction transaccion)
 393		{
 394			try
 395			{
 396				using (SqlCommand command = new SqlCommand())
 397				{
 398					command.CommandType = System.Data.CommandType.StoredProcedure;
 399					command.CommandText = "CargosPersonal_Insert";
 400					command.CommandTimeout = 10;
 401
 402					command.Connection = transaccion.Connection;
 403					command.Transaction = transaccion;
 404
 405					foreach (CargoPersonal cargoPersonal in listaCargosPersonal)
 406					{
 407						command.Parameters.AddWithValue("idCargoPersonal", 0);
 408						command.Parameters.AddWithValue("idCargoPersonalTransaccional", cargoPersonal.idCargoTransaccional);
 409						command.Parameters.AddWithValue("nombre", cargoPersonal.nombre);
 410						command.Parameters.AddWithValue("descripcion", cargoPersonal.descripcion);
 411						command.Parameters.AddWithValue("activo", cargoPersonal.activo);
 412						command.ExecuteNonQuery();
 413						command.Parameters.Clear();
 414					}
 415				}
 416			}
 417			catch (SqlException ex)
 418			{
 419				throw new CustomizedException(String.Format("Fallo en {0} - GrabarCargoPersonal()", ClassName),
 420									ex, enuExceptionType.SqlException);
 421			}
 422			catch (Exception ex)
 423			{
 424				throw new CustomizedException(String.Format("Fallo en {0} - GrabarCargoPersonal()", ClassName),
 425									ex, enuExceptionType.DataAccesException);
 426			}
 427			finally
 428			{
 429				//if (sqlConnectionConfig.State == ConnectionState.Open)
 430				//    sqlConnectionConfig.Close();
 431			}
 432		}
 433
 434		/// <summary>
 435		/// Grabars the asignatura.
 436		/// </summary>
 437		/// <param name="listaAsignatura">The lista asignatura.</param>
 438		public void GrabarAsignatura(List<Asignatura> listaAsignatura, SqlTransaction transaccion)
 439		{
 440			try
 441			{
 442				using (SqlCommand command = new SqlCommand())
 443				{
 444					command.CommandType = System.Data.CommandType.StoredProcedure;
 445					command.CommandText = "Asignatura_Insert";
 446					command.CommandTimeout = 10;
 447
 448					command.Connection = transaccion.Connection;
 449					command.Transaction = transaccion;
 450
 451					foreach (Asignatura asignatura in listaAsignatura)
 452					{
 453						command.Parameters.AddWithValue("idAsignatura", 0);
 454						command.Parameters.AddWithValue("idAsignaturaTransaccional", asignatura.idAsignaturaTransaccional);
 455						command.Parameters.AddWithValue("nombre", asignatura.nombre);
 456						command.ExecuteNonQuery();
 457						command.Parameters.Clear();
 458					}
 459				}
 460			}
 461			catch (SqlException ex)
 462			{
 463				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAsignatura()", ClassName),
 464									ex, enuExceptionType.SqlException);
 465			}
 466			catch (Exception ex)
 467			{
 468				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAsignatura()", ClassName),
 469									ex, enuExceptionType.DataAccesException);
 470			}
 471		}
 472
 473		/// <summary>
 474		/// Grabars the ciclo lectivo.
 475		/// </summary>
 476		/// <param name="listaCicloLectivo">The lista ciclo lectivo.</param>
 477		public void GrabarCicloLectivo(List<CicloLectivo> listaCicloLectivo, SqlTransaction transaccion)
 478		{
 479			try
 480			{
 481				using (SqlCommand command = new SqlCommand())
 482				{
 483					command.CommandType = System.Data.CommandType.StoredProcedure;
 484					command.CommandText = "CicloLectivo_Insert";
 485					command.CommandTimeout = 10;
 486
 487					command.Connection = transaccion.Connection;
 488					command.Transaction = transaccion;
 489
 490					foreach (CicloLectivo cicloLectivo in listaCicloLectivo)
 491					{
 492						command.Parameters.AddWithValue("idCicloLectivo", 0);
 493						command.Parameters.AddWithValue("idCicloLectivoTransaccional", cicloLectivo.idCicloLectivoTransaccional);
 494						command.Parameters.AddWithValue("nombre", cicloLectivo.nombre);
 495						command.Parameters.AddWithValue("fechaInicio", cicloLectivo.fechaInicio);
 496						command.Parameters.AddWithValue("fechaFin", cicloLectivo.fechaFin);
 497						command.Parameters.AddWithValue("activo", cicloLectivo.activo);
 498						command.ExecuteNonQuery();
 499						command.Parameters.Clear();
 500					}
 501				}
 502			}
 503			catch (SqlException ex)
 504			{
 505				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAsignatura()", ClassName),
 506									ex, enuExceptionType.SqlException);
 507			}
 508			catch (Exception ex)
 509			{
 510				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAsignatura()", ClassName),
 511									ex, enuExceptionType.DataAccesException);
 512			}
 513		}
 514
 515		/// <summary>
 516		/// Grabars the nivel.
 517		/// </summary>
 518		/// <param name="listaNiveles">The lista niveles.</param>
 519		public void GrabarNivel(List<Nivel> listaNiveles, SqlTransaction transaccion)
 520		{
 521			try
 522			{
 523				using (SqlCommand command = new SqlCommand())
 524				{
 525					command.CommandType = System.Data.CommandType.StoredProcedure;
 526					command.CommandText = "Nivel_Insert";
 527					command.CommandTimeout = 10;
 528
 529					command.Connection = transaccion.Connection;
 530					command.Transaction = transaccion;
 531
 532					foreach (Nivel nivel in listaNiveles)
 533					{
 534						command.Parameters.AddWithValue("idNivel", 0);
 535						command.Parameters.AddWithValue("idNivelTransaccional", nivel.idNivelTransaccional);
 536						command.Parameters.AddWithValue("nombre", nivel.nombre);
 537						command.ExecuteNonQuery();
 538						command.Parameters.Clear();
 539					}
 540				}
 541			}
 542			catch (SqlException ex)
 543			{
 544				throw new CustomizedException(String.Format("Fallo en {0} - GrabarNivel()", ClassName),
 545									ex, enuExceptionType.SqlException);
 546			}
 547			catch (Exception ex)
 548			{
 549				throw new CustomizedException(String.Format("Fallo en {0} - GrabarNivel()", ClassName),
 550									ex, enuExceptionType.DataAccesException);
 551			}
 552		}
 553
 554		/// <summary>
 555		/// Grabars the cursos.
 556		/// </summary>
 557		/// <param name="listaCursos">The lista cursos.</param>
 558		public void GrabarCursos(List<Curso> listaCursos, SqlTransaction transaccion)
 559		{
 560			try
 561			{
 562				using (SqlCommand command = new SqlCommand())
 563				{
 564					command.CommandType = System.Data.CommandType.StoredProcedure;
 565					command.CommandText = "Curso_Insert";
 566					command.CommandTimeout = 10;
 567
 568					command.Connection = transaccion.Connection;
 569					command.Transaction = transaccion;
 570
 571					foreach (Curso curso in listaCursos)
 572					{
 573						command.Parameters.AddWithValue("idCurso", 0);
 574						command.Parameters.AddWithValue("idCursoTransaccional", curso.idCursoTransaccional);
 575						command.Parameters.AddWithValue("nombre", curso.nombre);
 576						command.Parameters.AddWithValue("idNivel", curso.nivel.idNivelTransaccional);
 577						command.ExecuteNonQuery();
 578						command.Parameters.Clear();
 579					}
 580				}
 581			}
 582			catch (SqlException ex)
 583			{
 584				throw new CustomizedException(String.Format("Fallo en {0} - GrabarNivel()", ClassName),
 585									ex, enuExceptionType.SqlException);
 586			}
 587			catch (Exception ex)
 588			{
 589				throw new CustomizedException(String.Format("Fallo en {0} - GrabarNivel()", ClassName),
 590									ex, enuExceptionType.DataAccesException);
 591			}
 592		}
 593
 594		/// <summary>
 595		/// Grabars the orientacion.
 596		/// </summary>
 597		/// <param name="listaOrientacion">The lista orientacion.</param>
 598		public void GrabarOrientacion(List<Orientacion> listaOrientacion, SqlTransaction transaccion)
 599		{
 600			try
 601			{
 602				using (SqlCommand command = new SqlCommand())
 603				{
 604					command.CommandType = System.Data.CommandType.StoredProcedure;
 605					command.CommandText = "Orientacion_Insert";
 606					command.CommandTimeout = 10;
 607
 608					command.Connection = transaccion.Connection;
 609					command.Transaction = transaccion;
 610
 611					foreach (Orientacion orientacion in listaOrientacion)
 612					{
 613						command.Parameters.AddWithValue("idOrientacion", 0);
 614						command.Parameters.AddWithValue("idOrientacionTransaccional", orientacion.idOrientacionTransaccional);
 615						command.Parameters.AddWithValue("nombre", orientacion.nombre);
 616						command.Parameters.AddWithValue("descripcion", orientacion.descripcion);
 617						command.ExecuteNonQuery();
 618						command.Parameters.Clear();
 619					}
 620				}
 621			}
 622			catch (SqlException ex)
 623			{
 624				throw new CustomizedException(String.Format("Fallo en {0} - GrabarOrientacion()", ClassName),
 625									ex, enuExceptionType.SqlException);
 626			}
 627			catch (Exception ex)
 628			{
 629				throw new CustomizedException(String.Format("Fallo en {0} - GrabarOrientacion()", ClassName),
 630									ex, enuExceptionType.DataAccesException);
 631			}
 632		}
 633
 634		/// <summary>
 635		/// Grabars the asignatura curso.
 636		/// </summary>
 637		/// <param name="listaAsignatura">The lista asignatura.</param>
 638		public void GrabarAsignaturaCurso(List<AsignaturaCicloLectivo> listaAsignatura, SqlTransaction transaccion)
 639		{
 640			try
 641			{
 642				using (SqlCommand command = new SqlCommand())
 643				{
 644					command.CommandType = System.Data.CommandType.StoredProcedure;
 645					command.CommandText = "AsignaturaCicloLectivo_Insert";
 646					command.CommandTimeout = 10;
 647
 648					command.Connection = transaccion.Connection;
 649					command.Transaction = transaccion;
 650
 651					foreach (AsignaturaCicloLectivo item in listaAsignatura)
 652					{
 653						//command.Parameters.AddWithValue("idAsignaturaCicloLectivo", 0);
 654						command.Parameters.AddWithValue("idAsignaturaCicloLectivoTransaccional", item.idAsignaturaCicloLectivoTransaccional);
 655						command.Parameters.AddWithValue("idAsignatura", item.asignatura.idAsignaturaTransaccional);
 656						command.Parameters.AddWithValue("idDocente", item.docente.IdPersonalTransaccional);
 657						command.Parameters.AddWithValue("idCursoCicloLectivo", item.cursoCicloLectivo.idCursoCicloLectivoTransaccional);
 658						command.ExecuteNonQuery();
 659						command.Parameters.Clear();
 660					}
 661				}
 662			}
 663			catch (SqlException ex)
 664			{
 665				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAsignaturaCurso()", ClassName),
 666									ex, enuExceptionType.SqlException);
 667			}
 668			catch (Exception ex)
 669			{
 670				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAsignaturaCurso()", ClassName),
 671									ex, enuExceptionType.DataAccesException);
 672			}
 673		}
 674
 675		/// <summary>
 676		/// Grabars the periodo.
 677		/// </summary>
 678		/// <param name="listaPeriodo">The lista periodo.</param>
 679		public void GrabarPeriodo(List<Periodo> listaPeriodo, SqlTransaction transaccion)
 680		{
 681			try
 682			{
 683				using (SqlCommand command = new SqlCommand())
 684				{
 685					command.CommandType = System.Data.CommandType.StoredProcedure;
 686					command.CommandText = "Periodo_Insert";
 687					command.CommandTimeout = 10;
 688
 689					command.Connection = transaccion.Connection;
 690					command.Transaction = transaccion;
 691
 692					foreach (Periodo periodo in listaPeriodo)
 693					{
 694						command.Parameters.AddWithValue("idPeriodo", 0);
 695						command.Parameters.AddWithValue("idPeriodoTransaccional", periodo.idPeriodoTransaccional);
 696						command.Parameters.AddWithValue("nombre", periodo.nombre);
 697						command.Parameters.AddWithValue("idCicloLectivo", periodo.cicloLectivo.idCicloLectivoTransaccional);
 698						command.Parameters.AddWithValue("fechaInicio", periodo.fechaInicio);
 699						command.Parameters.AddWithValue("fechaFin", periodo.fechaFin);
 700						command.ExecuteNonQuery();
 701						command.Parameters.Clear();
 702					}
 703				}
 704			}
 705			catch (SqlException ex)
 706			{
 707				throw new CustomizedException(String.Format("Fallo en {0} - GrabarPeriodo()", ClassName),
 708									ex, enuExceptionType.SqlException);
 709			}
 710			catch (Exception ex)
 711			{
 712				throw new CustomizedException(String.Format("Fallo en {0} - GrabarPeriodo()", ClassName),
 713									ex, enuExceptionType.DataAccesException);
 714			}
 715		}
 716
 717		/// <summary>
 718		/// Grabars the calificacion.
 719		/// </summary>
 720		/// <param name="listaCalificacion">The lista calificacion.</param>
 721		public void GrabarCalificacion(List<Calificacion> listaCalificacion, SqlTransaction transaccion)
 722		{
 723			try
 724			{
 725				using (SqlCommand command = new SqlCommand())
 726				{
 727					command.CommandType = System.Data.CommandType.StoredProcedure;
 728					command.CommandText = "Calificacion_Insert";
 729					command.CommandTimeout = 10;
 730
 731					command.Connection = transaccion.Connection;
 732					command.Transaction = transaccion;
 733
 734					foreach (Calificacion calificacion in listaCalificacion)
 735					{
 736						command.Parameters.AddWithValue("idCalificacion", 0);
 737						command.Parameters.AddWithValue("idCalificacionTransaccional", calificacion.idCalificacionTransaccional);
 738						command.Parameters.AddWithValue("observaciones", calificacion.observacion);
 739						command.Parameters.AddWithValue("fecha", calificacion.fecha);
 740						command.Parameters.AddWithValue("idValorCalificacion", calificacion.escala.idValorEscalaCalificacionTransaccional);
 741						command.Parameters.AddWithValue("idAlumnoCursoCicloLectivo", calificacion.alumnoCurso.idAlumnoCursoCicloLectivoTransaccional);
 742						command.Parameters.AddWithValue("idAsignatura", calificacion.asignatura.idAsignaturaTransaccional);
 743						command.Parameters.AddWithValue("idPeriodo", calificacion.periodo.idPeriodoTransaccional);
 744						command.Parameters.AddWithValue("idInstanciaCalificacion", calificacion.instanciaCalificacion.idInstanciaCalificacion);
 745						command.ExecuteNonQuery();
 746						command.Parameters.Clear();
 747					}
 748				}
 749			}
 750			catch (SqlException ex)
 751			{
 752				throw new CustomizedException(String.Format("Fallo en {0} - GrabarCalificacion()", ClassName),
 753									ex, enuExceptionType.SqlException);
 754			}
 755			catch (Exception ex)
 756			{
 757				throw new CustomizedException(String.Format("Fallo en {0} - GrabarCalificacion()", ClassName),
 758									ex, enuExceptionType.DataAccesException);
 759			}
 760		}
 761
 762		/// <summary>
 763		/// Grabars the Tutor.
 764		/// </summary>
 765		/// <param name="tutor">The tutor.</param>
 766		/// <param name="transaccion">The transaccion.</param>
 767		public void GrabarTutor(Tutor tutor, SqlTransaction transaccion)
 768		{
 769			try
 770			{
 771				using (SqlCommand command = new SqlCommand())
 772				{
 773					command.CommandType = System.Data.CommandType.StoredProcedure;
 774					command.CommandText = "Tutor_Insert";
 775					command.CommandTimeout = 10;
 776
 777					command.Connection = transaccion.Connection;
 778					command.Transaction = transaccion;
 779
 780					command.Parameters.AddWithValue("idTutor", tutor.idTutor).Direction = ParameterDirection.Output;
 781					command.Parameters.AddWithValue("idTutorTransaccional", tutor.idTutorTransaccional);
 782					command.Parameters.AddWithValue("idTipoTutor", tutor.tipoTutor.idTipoTutorTransaccional);
 783					command.Parameters.AddWithValue("telefonoTrabajo", tutor.telefonoCelularAlternativo);
 784					command.Parameters.AddWithValue("idPersona", tutor.idPersona);
 785					command.ExecuteNonQuery();
 786					command.Parameters.Clear();
 787				}
 788			}
 789			catch (SqlException ex)
 790			{
 791				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTutor()", ClassName),
 792									ex, enuExceptionType.SqlException);
 793			}
 794			catch (Exception ex)
 795			{
 796				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTutor()", ClassName),
 797									ex, enuExceptionType.DataAccesException);
 798			}
 799		}
 800
 801		//TODO: Primero hacer GrabarTipoAsistencia()
 802		/// <summary>
 803		/// Grabars the tipo asistencia.
 804		/// </summary>
 805		/// <param name="listadoTipoAsistencia">The listado tipo asistencia.</param>
 806		public void GrabarTipoAsistencia(List<TipoAsistencia> listadoTipoAsistencia, SqlTransaction transaccion)
 807		{
 808			try
 809			{
 810				using (SqlCommand command = new SqlCommand())
 811				{
 812					command.CommandType = System.Data.CommandType.StoredProcedure;
 813					command.CommandText = "TipoAsistencia_Insert";
 814					command.CommandTimeout = 10;
 815
 816					command.Connection = transaccion.Connection;
 817					command.Transaction = transaccion;
 818
 819					foreach (TipoAsistencia unTipoAsistencia in listadoTipoAsistencia)
 820					{
 821						command.Parameters.AddWithValue("idTipoAsistencia", 0);
 822						command.Parameters.AddWithValue("idTipoAsistenciaTransaccional", unTipoAsistencia.idTipoAsistenciaTransaccional);
 823						command.Parameters.AddWithValue("valor", unTipoAsistencia.valor);
 824						command.Parameters.AddWithValue("descripcion", unTipoAsistencia.descripcion);
 825						command.ExecuteNonQuery();
 826						command.Parameters.Clear();
 827					}
 828				}
 829			}
 830			catch (SqlException ex)
 831			{
 832				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTipoAsistenica()", ClassName),
 833									ex, enuExceptionType.SqlException);
 834			}
 835			catch (Exception ex)
 836			{
 837				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTipoAsistencia()", ClassName),
 838									ex, enuExceptionType.DataAccesException);
 839			}
 840		}
 841
 842		/// <summary>
 843		/// Grabars the asistencia.
 844		/// </summary>
 845		/// <param name="listadoAsistencia">The listado asistencia.</param>
 846		public void GrabarAsistencia(List<Asistencia> listadoAsistencia, SqlTransaction transaccion)
 847		{
 848			try
 849			{
 850				using (SqlCommand command = new SqlCommand())
 851				{
 852					command.CommandType = System.Data.CommandType.StoredProcedure;
 853					command.CommandText = "Asistencia_Insert";
 854					command.CommandTimeout = 10;
 855
 856					command.Connection = transaccion.Connection;
 857					command.Transaction = transaccion;
 858
 859					foreach (Asistencia unaAsistencia in listadoAsistencia)
 860					{
 861						command.Parameters.AddWithValue("idAsistencia", 0);
 862						command.Parameters.AddWithValue("idAsistenciaTransaccional", unaAsistencia.idAsistenciaTransaccional);
 863						command.Parameters.AddWithValue("fecha", unaAsistencia.fecha);
 864						command.Parameters.AddWithValue("idTipoAsistencia", unaAsistencia.tipoAsistencia.idTipoAsistenciaTransaccional);
 865						command.Parameters.AddWithValue("idAlumno", unaAsistencia.alumno.idAlumnoCursoCicloLectivoTransaccional);
 866						command.ExecuteNonQuery();
 867						command.Parameters.Clear();
 868					}
 869				}
 870			}
 871			catch (SqlException ex)
 872			{
 873				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAsistenica()", ClassName),
 874									ex, enuExceptionType.SqlException);
 875			}
 876			catch (Exception ex)
 877			{
 878				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAsistencia()", ClassName),
 879									ex, enuExceptionType.DataAccesException);
 880			}
 881		}
 882
 883		/// <summary>
 884		/// Grabars the tipo sancion.
 885		/// </summary>
 886		/// <param name="listadoTipoSancion">The listado tipo sancion.</param>
 887		public void GrabarTipoSancion(List<TipoSancion> listadoTipoSancion, SqlTransaction transaccion)
 888		{
 889			try
 890			{
 891				using (SqlCommand command = new SqlCommand())
 892				{
 893					command.CommandType = System.Data.CommandType.StoredProcedure;
 894					command.CommandText = "TipoSancion_Insert";
 895					command.CommandTimeout = 10;
 896
 897					command.Connection = transaccion.Connection;
 898					command.Transaction = transaccion;
 899
 900					foreach (TipoSancion unTipoSancion in listadoTipoSancion)
 901					{
 902						command.Parameters.AddWithValue("idTipoSancion", 0);
 903						command.Parameters.AddWithValue("idTipoSancionTransaccional", unTipoSancion.idTipoSancionTransaccional);
 904						command.Parameters.AddWithValue("nombre", unTipoSancion.nombre);
 905						command.Parameters.AddWithValue("descripcion", unTipoSancion.descripcion);
 906						command.ExecuteNonQuery();
 907						command.Parameters.Clear();
 908					}
 909				}
 910			}
 911			catch (SqlException ex)
 912			{
 913				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTipoSancion()", ClassName),
 914									ex, enuExceptionType.SqlException);
 915			}
 916			catch (Exception ex)
 917			{
 918				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTipoSancion()", ClassName),
 919									ex, enuExceptionType.DataAccesException);
 920			}
 921		}
 922
 923		/// <summary>
 924		/// Grabars the motivo sancion.
 925		/// </summary>
 926		/// <param name="listadoMotivoSancion">The listado motivo sancion.</param>
 927		public void GrabarMotivoSancion(List<MotivoSancion> listadoMotivoSancion, SqlTransaction transaccion)
 928		{
 929			try
 930			{
 931				using (SqlCommand command = new SqlCommand())
 932				{
 933					command.CommandType = System.Data.CommandType.StoredProcedure;
 934					command.CommandText = "MotivoSancion_Insert";
 935					command.CommandTimeout = 10;
 936
 937					command.Connection = transaccion.Connection;
 938					command.Transaction = transaccion;
 939
 940					foreach (MotivoSancion unMotivoSancion in listadoMotivoSancion)
 941					{
 942						command.Parameters.AddWithValue("idMotivoSancion", 0);
 943						command.Parameters.AddWithValue("idMotivoSancionTransaccional", unMotivoSancion.idMotivoSancionTransaccional);
 944						command.Parameters.AddWithValue("descripcion", unMotivoSancion.descripcion);
 945						command.ExecuteNonQuery();
 946						command.Parameters.Clear();
 947					}
 948				}
 949			}
 950			catch (SqlException ex)
 951			{
 952				throw new CustomizedException(String.Format("Fallo en {0} - GrabarMotivoSancion()", ClassName),
 953									ex, enuExceptionType.SqlException);
 954			}
 955			catch (Exception ex)
 956			{
 957				throw new CustomizedException(String.Format("Fallo en {0} - GrabarMotivoSancion()", ClassName),
 958									ex, enuExceptionType.DataAccesException);
 959			}
 960		}
 961
 962		/// <summary>
 963		/// Grabars the sancion.
 964		/// </summary>
 965		/// <param name="listadoSancion">The listado sancion.</param>
 966		public void GrabarSancion(List<Sancion> listadoSancion, SqlTransaction transaccion)
 967		{
 968			try
 969			{
 970				using (SqlCommand command = new SqlCommand())
 971				{
 972					command.CommandType = System.Data.CommandType.StoredProcedure;
 973					command.CommandText = "Sancion_Insert";
 974					command.CommandTimeout = 10;
 975
 976					command.Connection = transaccion.Connection;
 977					command.Transaction = transaccion;
 978
 979					foreach (Sancion unaSancion in listadoSancion)
 980					{
 981						command.Parameters.AddWithValue("idSancion", 0);
 982						command.Parameters.AddWithValue("idSancionTransaccional", unaSancion.idSancionTransaccional);
 983						command.Parameters.AddWithValue("cantidad", unaSancion.cantidad);
 984						command.Parameters.AddWithValue("fecha", unaSancion.fecha.Date);
 985						command.Parameters.AddWithValue("idMotivoSancion", unaSancion.motivoSancion.idMotivoSancionTransaccional);
 986						command.Parameters.AddWithValue("idTipoSancion", unaSancion.tipoSancion.idTipoSancionTransaccional);
 987						command.Parameters.AddWithValue("idAlumno", unaSancion.alumno.idAlumnoCursoCicloLectivoTransaccional);
 988						command.ExecuteNonQuery();
 989						command.Parameters.Clear();
 990					}
 991				}
 992			}
 993			catch (SqlException ex)
 994			{
 995				throw new CustomizedException(String.Format("Fallo en {0} - GrabarSancion()", ClassName),
 996									ex, enuExceptionType.SqlException);
 997			}
 998			catch (Exception ex)
 999			{
1000				throw new CustomizedException(String.Format("Fallo en {0} - GrabarSancion()", ClassName),
1001									ex, enuExceptionType.DataAccesException);
1002			}
1003		}
1004
1005		/// <summary>
1006		/// Grabars the tipo tutor.
1007		/// </summary>
1008		/// <param name="listadoTipoTutor">The listado tipo tutor.</param>
1009		public void GrabarTipoTutor(List<TipoTutor> listadoTipoTutor, SqlTransaction transaccion)
1010		{
1011			try
1012			{
1013				using (SqlCommand command = new SqlCommand())
1014				{
1015					command.CommandType = System.Data.CommandType.StoredProcedure;
1016					command.CommandText = "TipoTutor_Insert";
1017					command.CommandTimeout = 10;
1018
1019					command.Connection = transaccion.Connection;
1020					command.Transaction = transaccion;
1021
1022					foreach (TipoTutor unTipoTutor in listadoTipoTutor)
1023					{
1024						command.Parameters.AddWithValue("idTipoTutor", 0);
1025						command.Parameters.AddWithValue("descripcion", unTipoTutor.descripcion);
1026						command.Parameters.AddWithValue("idTipoTutorTransaccional", unTipoTutor.idTipoTutorTransaccional);
1027						command.ExecuteNonQuery();
1028						command.Parameters.Clear();
1029					}
1030				}
1031			}
1032			catch (SqlException ex)
1033			{
1034				if (transaccion != null) transaccion.Rollback();
1035				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTipoTutor()", ClassName),
1036									ex, enuExceptionType.SqlException);
1037			}
1038			catch (Exception ex)
1039			{
1040				if (transaccion != null) transaccion.Rollback();
1041				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTipoTutor()", ClassName),
1042									ex, enuExceptionType.DataAccesException);
1043			}
1044		}
1045
1046		/// <summary>
1047		/// Grabars the tutores alumno.
1048		/// </summary>
1049		/// <param name="listaAlumnos">The lista alumnos.</param>
1050		public void GrabarTutoresAlumno(List<Alumno> listaAlumnos, SqlTransaction transaccion)
1051		{
1052			try
1053			{
1054				using (SqlCommand command = new SqlCommand())
1055				{
1056					command.CommandType = System.Data.CommandType.StoredProcedure;
1057					command.CommandText = "TutorAlumno_Insert";
1058					command.CommandTimeout = 10;
1059
1060					command.Connection = transaccion.Connection;
1061					command.Transaction = transaccion;
1062
1063					foreach (Alumno alumno in listaAlumnos)
1064					{
1065						foreach (Tutor tutor in alumno.listaTutores)
1066						{
1067							command.Parameters.AddWithValue("idTutor", tutor.idTutorTransaccional);
1068							command.Parameters.AddWithValue("idAlumno", alumno.idAlumnoTransaccional);
1069
1070							command.ExecuteNonQuery();
1071							command.Parameters.Clear();
1072						}
1073					}
1074				}
1075			}
1076			catch (SqlException ex)
1077			{
1078				if (transaccion != null) transaccion.Rollback();
1079				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTutoresAlumno()", ClassName),
1080									ex, enuExceptionType.SqlException);
1081			}
1082			catch (Exception ex)
1083			{
1084				if (transaccion != null) transaccion.Rollback();
1085				throw new CustomizedException(String.Format("Fallo en {0} - GrabarTutoresAlumno()", ClassName),
1086									ex, enuExceptionType.DataAccesException);
1087			}
1088		}
1089
1090		/// <summary>
1091		/// Grabars the tipo asistencia.
1092		/// </summary>
1093		/// <param name="listadoTipoAsistencia">The listado tipo asistencia.</param>
1094        public void GrabarDiasHorarios(List<DiasHorarios> listadoDiasHorario, SqlTransaction transaccion)
1095		{
1096			try
1097			{
1098				//foreach (DiasHorarios unDiasHorarios in listadoDiasHorarios)
1099				//    {
1100				//        GrabarModulos(unDiasHorarios.modulos);
1101				//    }
1102				using (SqlCommand command = new SqlCommand())
1103				{
1104					if (sqlConnectionConfig.State == ConnectionState.Closed) sqlConnectionConfig.Open();
1105
1106					command.Connection = sqlConnectionConfig;
1107					command.CommandType = System.Data.CommandType.StoredProcedure;
1108					command.CommandText = "DiaHorario_Insert";
1109					command.CommandTimeout = 10;
1110
1111					transaccion = sqlConnectionConfig.BeginTransaction();
1112					command.Transaction = transaccion;
1113
1114                    foreach (DiasHorarios unDiasHorarios in listadoDiasHorario)
1115					{
1116						command.Parameters.AddWithValue("idDiaHorario", 0).Direction = ParameterDirection.Output;
1117						command.Parameters.AddWithValue("idDiaHorarioTransaccional", unDiasHorarios.idDiaHorarioTransaccional);
1118						command.Parameters.AddWithValue("idCurso", unDiasHorarios.idCursoTransaccional);
1119						command.Parameters.AddWithValue("idAsignatura", unDiasHorarios.idAsignaturaTransaccional);
1120						command.Parameters.AddWithValue("idDiaSemana", (int)unDiasHorarios.unDia);
1121						command.Parameters.AddWithValue("idNivel", (int)unDiasHorarios.idNivelTransaccional);
1122						//command.Parameters.AddWithValue("idModulo", 1);
1123						//GrabarModulos(unDiasHorarios.modulos);
1124						command.ExecuteNonQuery();
1125						unDiasHorarios.idDiaHorario = Convert.ToInt32(command.Parameters["idDiaHorario"].Value);
1126						command.Parameters.Clear();
1127					}
1128					transaccion.Commit();
1129				}
1130			}
1131			catch (SqlException ex)
1132			{
1133				if (transaccion != null) transaccion.Rollback();
1134				throw new CustomizedException(String.Format("Fallo en {0} - GrabarDiasHorarios()", ClassName),
1135									ex, enuExceptionType.SqlException);
1136			}
1137			catch (Exception ex)
1138			{
1139				if (transaccion != null) transaccion.Rollback();
1140				throw new CustomizedException(String.Format("Fallo en {0} - GrabarDiasHorarios()", ClassName),
1141									ex, enuExceptionType.DataAccesException);
1142			}
1143			finally
1144			{
1145				if (sqlConnectionConfig.State == ConnectionState.Open)
1146					sqlConnectionConfig.Close();
1147
1148				GrabarModulos(listadoDiasHorario);
1149
1150			}
1151
1152		}
1153
1154
1155		/// <summary>
1156		/// Grabars the tipo asistencia.
1157		/// </summary>
1158		/// <param name="listadoTipoAsistencia">The listado tipo asistencia.</param>
1159		public void GrabarModulos(List<DiasHorarios> listadoDiasHorarios)
1160		{
1161			SqlTransaction transaccion = null;
1162			try
1163			{
1164				using (SqlCommand command = new SqlCommand())
1165				{
1166					if (sqlConnectionConfig.State == ConnectionState.Closed) sqlConnectionConfig.Open();
1167
1168					command.Connection = sqlConnectionConfig;
1169					command.CommandType = System.Data.CommandType.StoredProcedure;
1170					command.CommandText = "Modulo_Insert";
1171					command.CommandTimeout = 10;
1172
1173					transaccion = sqlConnectionConfig.BeginTransaction();
1174					command.Transaction = transaccion;
1175
1176					foreach (DiasHorarios unDiasHorarios in listadoDiasHorarios)
1177					{
1178						foreach (Modulo unModulo in unDiasHorarios.modulos)
1179						{
1180							command.Parameters.AddWithValue("idModulo", 0);
1181							command.Parameters.AddWithValue("horaInicio", unModulo.horaInicio);
1182							command.Parameters.AddWithValue("horaFinalizacion", unModulo.horaFinalizacion);
1183							command.Parameters.AddWithValue("idDiaHorario", unDiasHorarios.idDiaHorario);
1184							command.ExecuteNonQuery();
1185							command.Parameters.Clear();
1186						}
1187					}
1188					transaccion.Commit();
1189				}
1190			}
1191			catch (SqlException ex)
1192			{
1193				if (transaccion != null) transaccion.Rollback();
1194				throw new CustomizedException(String.Format("Fallo en {0} - GrabarModulo()", ClassName),
1195									ex, enuExceptionType.SqlException);
1196			}
1197			catch (Exception ex)
1198			{
1199				if (transaccion != null) transaccion.Rollback();
1200				throw new CustomizedException(String.Format("Fallo en {0} - GrabarModulo()", ClassName),
1201									ex, enuExceptionType.DataAccesException);
1202			}
1203			finally
1204			{
1205				//if (sqlConnectionConfig.State == ConnectionState.Open)
1206				//    sqlConnectionConfig.Close();
1207			}
1208
1209		}
1210
1211		/// <summary>
1212		/// Grabars the alumno curso.
1213		/// </summary>
1214		/// <param name="listaAlumnoCurso">The lista alumno curso.</param>
1215		public void GrabarAlumnoCurso(List<AlumnoCursoCicloLectivo> listaAlumnoCurso, SqlTransaction transaccion)
1216		{
1217			try
1218			{
1219				using (SqlCommand command = new SqlCommand())
1220				{
1221					command.CommandType = System.Data.CommandType.StoredProcedure;
1222					command.CommandText = "AlumnoCursoCicloLectivo_Insert";
1223					command.CommandTimeout = 10;
1224
1225					command.Connection = transaccion.Connection;
1226					command.Transaction = transaccion;
1227
1228					foreach (AlumnoCursoCicloLectivo alumnoCurso in listaAlumnoCurso)
1229					{
1230						command.Parameters.AddWithValue("idAlumnoCursoCicloLectivo", 0);
1231						command.Parameters.AddWithValue("idAlumnoCursoCicloLectivoTransaccional", alumnoCurso.idAlumnoCursoCicloLectivoTransaccional);
1232						command.Parameters.AddWithValue("idAlumno", alumnoCurso.alumno.idAlumnoTransaccional);
1233						command.Parameters.AddWithValue("idCursoCicloLectivo", alumnoCurso.cursoCicloLectivo.idCursoCicloLectivoTransaccional);
1234						command.ExecuteNonQuery();
1235						command.Parameters.Clear();
1236					}
1237				}
1238			}
1239			catch (SqlException ex)
1240			{
1241				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAlumnoCurso()", ClassName),
1242									ex, enuExceptionType.SqlException);
1243			}
1244			catch (Exception ex)
1245			{
1246				throw new CustomizedException(String.Format("Fallo en {0} - GrabarAlumnoCurso()", ClassName),
1247									ex, enuExceptionType.DataAccesException);
1248			}
1249		}
1250
1251		/// <summary>
1252		/// Grabars the curso ciclo lectivo.
1253		/// </summary>
1254		/// <param name="listaCursoCicloLectivo">The lista curso ciclo lectivo.</param>
1255		/// <param name="transaccion">The transaccion.</param>
1256		public void GrabarCursoCicloLectivo(List<CursoCicloLectivo> listaCursoCicloLectivo, SqlTransaction transaccion)
1257		{
1258			try
1259			{
1260				using (SqlCommand command = new SqlCommand())
1261				{
1262					command.CommandType = System.Data.CommandType.StoredProcedure;
1263					command.CommandText = "CursoCicloLectivo_Insert";
1264					command.CommandTimeout = 10;
1265
1266					command.Connection = transaccion.Connection;
1267					command.Transaction = transaccion;
1268
1269					foreach (CursoCicloLectivo cursosCicloLectivo in listaCursoCicloLectivo)
1270					{
1271						command.Parameters.AddWithValue("idCursoCicloLectivo", 0);
1272						command.Parameters.AddWithValue("idCursoCicloLectivoTransaccional", cursosCicloLectivo.idCursoCicloLectivoTransaccional);
1273						command.Parameters.AddWithValue("idCurso", cursosCicloLectivo.idCurso);
1274						command.Parameters.AddWithValue("idCicloLectivo", cursosCicloLectivo.idCicloLectivo);
1275						//command.Parameters.AddWithValue("idPreceptor", cursosCicloLectivo.curso.idCursoTransaccional);
1276						command.ExecuteNonQuery();
1277						command.Parameters.Clear();
1278					}
1279				}
1280			}
1281			catch (SqlException ex)
1282			{
1283				throw new CustomizedException(String.Format("Fallo en {0} - GrabarCursoCicloLectivo()", ClassName),
1284									ex, enuExceptionType.SqlException);
1285			}
1286			catch (Exception ex)
1287			{
1288				throw new CustomizedException(String.Format("Fallo en {0} - GrabarCursoCicloLectivo()", ClassName),
1289									ex, enuExceptionType.DataAccesException);
1290			}
1291		}
1292		#endregion
1293	}
1294}