PageRenderTime 65ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

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