/Docs/07-Implementacion/Source/trunk/EDUAR_Regular/EDUAR/EDUAR_UI/Private/Agenda/ManageAgendaActividades.aspx.cs

http://blpm.googlecode.com/ · C# · 600 lines · 362 code · 42 blank · 196 comment · 22 complexity · 96c4d11854ca660b35c86c85e34556d0 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web.UI;
  4. using System.Web.UI.WebControls;
  5. using EDUAR_BusinessLogic.Common;
  6. using EDUAR_Entities;
  7. using EDUAR_UI.Shared;
  8. using EDUAR_UI.Utilidades;
  9. using EDUAR_Utility.Constantes;
  10. using EDUAR_Utility.Enumeraciones;
  11. namespace EDUAR_UI
  12. {
  13. public partial class ManageAgendaActividades : EDUARBasePage
  14. {
  15. #region --[Atributos]--
  16. private BLAgendaActividades objBLAgenda;
  17. #endregion
  18. #region --[Propiedades]--
  19. /// <summary>
  20. /// Mantiene la agenda seleccionada en la grilla.
  21. /// Se utiliza para el manejo de eventos de agenda (evaluación, excursión, reunión).
  22. /// </summary>
  23. /// <value>
  24. /// The prop agenda.
  25. /// </value>
  26. public AgendaActividades propAgenda
  27. {
  28. get
  29. {
  30. if (Session["propAgenda"] == null)
  31. propAgenda = new AgendaActividades();
  32. return (AgendaActividades)Session["propAgenda"];
  33. }
  34. set { Session["propAgenda"] = value; }
  35. }
  36. /// <summary>
  37. /// Gets or sets the prop filtro agenda.
  38. /// </summary>
  39. /// <value>
  40. /// The prop filtro agenda.
  41. /// </value>
  42. public AgendaActividades propFiltroAgenda
  43. {
  44. get
  45. {
  46. if (ViewState["propFiltroAgenda"] == null)
  47. propFiltroAgenda = new AgendaActividades();
  48. return (AgendaActividades)ViewState["propFiltroAgenda"];
  49. }
  50. set { ViewState["propFiltroAgenda"] = value; }
  51. }
  52. /// <summary>
  53. /// Gets or sets the lista agenda.
  54. /// </summary>
  55. /// <value>
  56. /// The lista agenda.
  57. /// </value>
  58. public List<AgendaActividades> listaAgenda
  59. {
  60. get
  61. {
  62. if (ViewState["listaAgenda"] == null)
  63. listaAgenda = new List<AgendaActividades>();
  64. return (List<AgendaActividades>)ViewState["listaAgenda"];
  65. }
  66. set { ViewState["listaAgenda"] = value; }
  67. }
  68. /// <summary>
  69. /// Gets or sets the lista cursos.
  70. /// </summary>
  71. /// <value>
  72. /// The lista cursos.
  73. /// </value>
  74. //public List<Curso> listaCursos
  75. //{
  76. // get
  77. // {
  78. // if (ViewState["listaCursos"] == null && cicloLectivoActual != null)
  79. // {
  80. // BLCurso objCurso = new BLCurso();
  81. // listaCursos = objCurso.GetCursosCicloLectivo(new Curso() { cicloLectivo = cicloLectivoActual });
  82. // }
  83. // return (List<Curso>)ViewState["listaCursos"];
  84. // }
  85. // set { ViewState["listaCursos"] = value; }
  86. //}
  87. public List<Curso> listaCursos
  88. {
  89. get
  90. {
  91. if (ViewState["listaCursos"] == null && cicloLectivoActual != null)
  92. {
  93. BLCicloLectivo objBLCicloLectivo = new BLCicloLectivo();
  94. Asignatura objFiltro = new Asignatura();
  95. objFiltro.curso.cicloLectivo = cicloLectivoActual;
  96. if (User.IsInRole(enumRoles.Docente.ToString()))
  97. //nombre del usuario logueado
  98. objFiltro.docente.username = User.Identity.Name;
  99. listaCursos = objBLCicloLectivo.GetCursosByAsignatura(objFiltro);
  100. }
  101. return (List<Curso>)ViewState["listaCursos"];
  102. }
  103. set { ViewState["listaCursos"] = value; }
  104. }
  105. #endregion
  106. #region --[Eventos]--
  107. /// <summary>
  108. /// Método que se ejecuta al dibujar los controles de la página.
  109. /// Se utiliza para gestionar las excepciones del método Page_Load().
  110. /// </summary>
  111. /// <param name="e"></param>
  112. protected override void OnPreRender(EventArgs e)
  113. {
  114. base.OnPreRender(e);
  115. if (AvisoMostrar)
  116. {
  117. AvisoMostrar = false;
  118. try
  119. {
  120. Master.ManageExceptions(AvisoExcepcion);
  121. }
  122. catch (Exception ex) { Master.ManageExceptions(ex); }
  123. }
  124. }
  125. /// <summary>
  126. /// Handles the Load event of the Page control.
  127. /// </summary>
  128. /// <param name="sender">The source of the event.</param>
  129. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  130. protected void Page_Load(object sender, EventArgs e)
  131. {
  132. try
  133. {
  134. Master.BotonAvisoAceptar += (VentanaAceptar);
  135. if (!Page.IsPostBack)
  136. {
  137. CargarPresentacion();
  138. if (propAgenda.idAgendaActividad > 0)
  139. {
  140. CargarLista(propAgenda);
  141. CargaAgenda();
  142. }
  143. else
  144. BuscarAgenda(propAgenda);
  145. }
  146. //this.txtDescripcionEdit.Attributes.Add("onkeyup", " ValidarCaracteres(this, 4000);");
  147. }
  148. catch (Exception ex)
  149. {
  150. AvisoMostrar = true;
  151. AvisoExcepcion = ex;
  152. }
  153. }
  154. /// <summary>
  155. /// Ventanas the aceptar.
  156. /// </summary>
  157. /// <param name="sender">The sender.</param>
  158. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  159. void VentanaAceptar(object sender, EventArgs e)
  160. {
  161. try
  162. {
  163. switch (AccionPagina)
  164. {
  165. case enumAcciones.Limpiar:
  166. CargarPresentacion();
  167. BuscarAgenda(null);
  168. break;
  169. case enumAcciones.Guardar:
  170. AccionPagina = enumAcciones.Limpiar;
  171. GuardarAgenda(ObtenerValoresDePantalla());
  172. Master.MostrarMensaje(enumTipoVentanaInformacion.Satisfactorio.ToString(), UIConstantesGenerales.MensajeGuardadoOk, enumTipoVentanaInformacion.Satisfactorio);
  173. break;
  174. default:
  175. break;
  176. }
  177. }
  178. catch (Exception ex)
  179. {
  180. Master.ManageExceptions(ex);
  181. }
  182. }
  183. /// <summary>
  184. /// Handles the Click event of the btnEvaluacion control.
  185. /// </summary>
  186. /// <param name="sender">The source of the event.</param>
  187. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  188. protected void btnEvaluacion_Click(object sender, EventArgs e)
  189. {
  190. try
  191. {
  192. Response.Redirect("ManageEvaluaciones.aspx", false);
  193. }
  194. catch (Exception ex)
  195. {
  196. Master.ManageExceptions(ex);
  197. }
  198. }
  199. /// <summary>
  200. /// Handles the Click event of the btnExcursion control.
  201. /// </summary>
  202. /// <param name="sender">The source of the event.</param>
  203. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  204. protected void btnExcursion_Click(object sender, EventArgs e)
  205. {
  206. try
  207. {
  208. Response.Redirect("ManageExcursiones.aspx", false);
  209. }
  210. catch (Exception ex)
  211. {
  212. Master.ManageExceptions(ex);
  213. }
  214. }
  215. /// <summary>
  216. /// Handles the Click event of the btnReunion control.
  217. /// </summary>
  218. /// <param name="sender">The source of the event.</param>
  219. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  220. protected void btnReunion_Click(object sender, EventArgs e)
  221. {
  222. try
  223. {
  224. Response.Redirect("ManageReuniones.aspx", false);
  225. }
  226. catch (Exception ex)
  227. {
  228. Master.ManageExceptions(ex);
  229. }
  230. }
  231. /// <summary>
  232. /// Handles the Click event of the btnBuscar control.
  233. /// </summary>
  234. /// <param name="sender">The source of the event.</param>
  235. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  236. protected void btnBuscar_Click(object sender, EventArgs e)
  237. {
  238. try
  239. {
  240. BuscarFiltrando();
  241. }
  242. catch (Exception ex)
  243. {
  244. Master.ManageExceptions(ex);
  245. }
  246. }
  247. /// <summary>
  248. /// Handles the Click event of the btnAsignarRol control.
  249. /// </summary>
  250. /// <param name="sender">The source of the event.</param>
  251. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  252. protected void btnGuardar_Click(object sender, EventArgs e)
  253. {
  254. try
  255. {
  256. string mensaje = ValidarPagina();
  257. if (mensaje == string.Empty)
  258. {
  259. if (Page.IsValid)
  260. {
  261. //TODO: Aquí hay que llamar a la validación de disponibilidad de agenda
  262. AccionPagina = enumAcciones.Guardar;
  263. Master.MostrarMensaje(enumTipoVentanaInformacion.Confirmación.ToString(), UIConstantesGenerales.MensajeConfirmarCambios, enumTipoVentanaInformacion.Confirmación);
  264. }
  265. }
  266. else
  267. {
  268. Master.MostrarMensaje(enumTipoVentanaInformacion.Advertencia.ToString(), UIConstantesGenerales.MensajeDatosFaltantes + mensaje, enumTipoVentanaInformacion.Advertencia);
  269. }
  270. }
  271. catch (Exception ex)
  272. {
  273. Master.ManageExceptions(ex);
  274. }
  275. }
  276. /// <summary>
  277. /// Handles the Click event of the btnVolver control.
  278. /// </summary>
  279. /// <param name="sender">The source of the event.</param>
  280. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  281. protected void btnVolver_Click(object sender, EventArgs e)
  282. {
  283. try
  284. {
  285. CargarPresentacion();
  286. BuscarAgenda(propFiltroAgenda);
  287. propAgenda = new AgendaActividades();
  288. }
  289. catch (Exception ex)
  290. {
  291. Master.ManageExceptions(ex);
  292. }
  293. }
  294. /// <summary>
  295. /// Método que se llama al hacer click sobre las acciones de la grilla
  296. /// </summary>
  297. /// <param name="sender">The source of the event.</param>
  298. /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param>
  299. protected void gvwReporte_RowCommand(object sender, GridViewCommandEventArgs e)
  300. {
  301. try
  302. {
  303. switch (e.CommandName)
  304. {
  305. case "Editar":
  306. propAgenda.idAgendaActividad = Convert.ToInt32(e.CommandArgument.ToString());
  307. CargaAgenda();
  308. lblTitulo.Text = "Agenda del Curso: " + propAgenda.cursoCicloLectivo.curso.nombre + " - " + propAgenda.cursoCicloLectivo.cicloLectivo.nombre;
  309. break;
  310. }
  311. }
  312. catch (Exception ex)
  313. {
  314. Master.ManageExceptions(ex);
  315. }
  316. }
  317. /// <summary>
  318. /// Handles the SelectedIndexChanged event of the ddlCicloLectivo control.
  319. /// </summary>
  320. /// <param name="sender">The source of the event.</param>
  321. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  322. //protected void ddlCicloLectivo_SelectedIndexChanged(object sender, EventArgs e)
  323. //{
  324. // try
  325. // {
  326. // int idCicloLectivo = Convert.ToInt32(ddlCicloLectivo.SelectedValue);
  327. // CargarComboCursos(idCicloLectivo, ddlCurso);
  328. // }
  329. // catch (Exception ex)
  330. // {
  331. // Master.ManageExceptions(ex);
  332. // }
  333. //}
  334. /// <summary>
  335. /// Handles the PageIndexChanging event of the gvwReporte control.
  336. /// </summary>
  337. /// <param name="sender">The source of the event.</param>
  338. /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewPageEventArgs"/> instance containing the event data.</param>
  339. protected void gvwReporte_PageIndexChanging(object sender, GridViewPageEventArgs e)
  340. {
  341. try
  342. {
  343. gvwReporte.PageIndex = e.NewPageIndex;
  344. CargarGrilla();
  345. }
  346. catch (Exception ex) { Master.ManageExceptions(ex); }
  347. }
  348. /// <summary>
  349. /// Handles the PageIndexChanging event of the gvwAgenda control.
  350. /// </summary>
  351. /// <param name="sender">The source of the event.</param>
  352. /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewPageEventArgs"/> instance containing the event data.</param>
  353. protected void gvwAgenda_PageIndexChanging(object sender, GridViewPageEventArgs e)
  354. {
  355. try
  356. {
  357. gvwAgenda.PageIndex = e.NewPageIndex;
  358. CargarGrillaAgenda();
  359. btnBuscar.Visible = false;
  360. btnVolver.Visible = true;
  361. gvwReporte.Visible = false;
  362. udpFiltrosBusqueda.Visible = false;
  363. udpEdit.Visible = true;
  364. udpEdit.Update();
  365. }
  366. catch (Exception ex) { Master.ManageExceptions(ex); }
  367. }
  368. #endregion
  369. #region --[Métodos Privados]--
  370. /// <summary>
  371. /// Cargars the grilla.
  372. /// </summary>
  373. /// <typeparam name="T"></typeparam>
  374. /// <param name="lista">The lista.</param>
  375. private void CargarGrilla()
  376. {
  377. gvwReporte.DataSource = UIUtilidades.BuildDataTable<AgendaActividades>(listaAgenda).DefaultView;
  378. gvwReporte.DataBind();
  379. udpEdit.Visible = false;
  380. udpGrilla.Update();
  381. }
  382. /// <summary>
  383. /// Cargars the grilla agenda.
  384. /// </summary>
  385. private void CargarGrillaAgenda()
  386. {
  387. gvwAgenda.DataSource = UIUtilidades.BuildDataTable<EventoAgenda>(propAgenda.listaEventos).DefaultView;
  388. gvwAgenda.DataBind();
  389. udpEdit.Visible = false;
  390. udpGrilla.Update();
  391. }
  392. /// <summary>
  393. /// Cargars the presentacion.
  394. /// </summary>
  395. private void CargarPresentacion()
  396. {
  397. LimpiarCampos();
  398. lblTitulo.Text = "Actividades";
  399. CargarCombos(ddlCurso);
  400. udpEdit.Visible = false;
  401. btnVolver.Visible = false;
  402. btnGuardar.Visible = false;
  403. udpFiltrosBusqueda.Visible = true;
  404. btnBuscar.Visible = true;
  405. gvwReporte.Visible = true;
  406. udpFiltros.Update();
  407. udpGrilla.Update();
  408. }
  409. /// <summary>
  410. /// Habilitars the botones detalle.
  411. /// </summary>
  412. /// <param name="habilitar">if set to <c>true</c> [habilitar].</param>
  413. private void HabilitarBotonesDetalle(bool habilitar)
  414. {
  415. btnExcursion.Visible = habilitar;
  416. btnEvaluacion.Visible = habilitar;
  417. btnReunion.Visible = habilitar;
  418. }
  419. /// <summary>
  420. /// Cargars the combos.
  421. /// </summary>
  422. private void CargarCombos(DropDownList ddlCurso)
  423. {
  424. lblCicloLectivoValor.Text = cicloLectivoActual.nombre;
  425. UIUtilidades.BindCombo<Curso>(ddlCurso, listaCursos, "idCurso", "Nombre", true);
  426. //ddlCurso.Enabled = false;
  427. }
  428. /// <summary>
  429. /// Cargars the combo cursos.
  430. /// </summary>
  431. /// <param name="idCicloLectivo">The id ciclo lectivo.</param>
  432. /// <param name="ddlCurso">The DDL curso.</param>
  433. //private void CargarComboCursos(int idCicloLectivo, DropDownList ddlCurso)
  434. //{
  435. // if (idCicloLectivo > 0)
  436. // {
  437. // List<Curso> listaCurso = new List<Curso>();
  438. // BLCicloLectivo objBLCicloLectivo = new BLCicloLectivo();
  439. // Curso objCurso = new Curso();
  440. // listaCurso = objBLCicloLectivo.GetCursosByCicloLectivo(idCicloLectivo);
  441. // UIUtilidades.BindCombo<Curso>(ddlCurso, listaCurso, "idCurso", "nombre", true);
  442. // ddlCurso.Enabled = true;
  443. // }
  444. // else
  445. // {
  446. // ddlCurso.Enabled = false;
  447. // }
  448. //}
  449. /// <summary>
  450. /// Limpiars the campos.
  451. /// </summary>
  452. private void LimpiarCampos()
  453. {
  454. //ddlCicloLectivo.SelectedIndex = 0;
  455. if (ddlCurso.Items.Count > 0) ddlCurso.SelectedIndex = 0;
  456. HabilitarBotonesDetalle(false);
  457. //chkActivo.Checked = true;
  458. }
  459. /// <summary>
  460. /// Buscars the filtrando.
  461. /// </summary>
  462. private void BuscarFiltrando()
  463. {
  464. lblTitulo.Text = "Actividades";
  465. //calfecha.ValidarRangoDesde();
  466. AgendaActividades entidad = new AgendaActividades();
  467. //entidad.cursoCicloLectivo.idCurso = Convert.ToInt32(ddlCurso.SelectedValue);
  468. entidad.cursoCicloLectivo.idCursoCicloLectivo = Convert.ToInt32(ddlCurso.SelectedValue);
  469. entidad.cursoCicloLectivo.idCicloLectivo = cicloLectivoActual.idCicloLectivo;
  470. //entidad.fechaCreacion = Convert.ToDateTime(calfecha.ValorFecha);
  471. //entidad.activo = chkActivo.Checked;
  472. propFiltroAgenda = entidad;
  473. BuscarAgenda(entidad);
  474. }
  475. /// <summary>
  476. /// Buscars the entidads.
  477. /// </summary>
  478. /// <param name="entidad">The entidad.</param>
  479. private void BuscarAgenda(AgendaActividades entidad)
  480. {
  481. CargarLista(entidad);
  482. CargarGrilla();
  483. }
  484. /// <summary>
  485. /// Cargars the lista.
  486. /// </summary>
  487. /// <param name="entidad">The entidad.</param>
  488. private void CargarLista(AgendaActividades entidad)
  489. {
  490. entidad.activo = true;
  491. if (User.IsInRole(enumRoles.Docente.ToString()))
  492. entidad.usuario = ObjSessionDataUI.ObjDTUsuario.Nombre;
  493. objBLAgenda = new BLAgendaActividades(entidad);
  494. listaAgenda = objBLAgenda.GetAgendaActividades(entidad);
  495. }
  496. /// <summary>
  497. /// Obteners the valores pantalla.
  498. /// </summary>
  499. /// <returns></returns>
  500. private AgendaActividades ObtenerValoresDePantalla()
  501. {
  502. AgendaActividades entidad = new AgendaActividades();
  503. entidad = propAgenda;
  504. if (!esNuevo)
  505. {
  506. entidad.idAgendaActividad = propAgenda.idAgendaActividad;
  507. entidad.cursoCicloLectivo.idCursoCicloLectivo = propAgenda.cursoCicloLectivo.idCursoCicloLectivo;
  508. }
  509. return entidad;
  510. }
  511. /// <summary>
  512. /// Guardars the agenda.
  513. /// </summary>
  514. /// <param name="entidad">The entidad.</param>
  515. private void GuardarAgenda(AgendaActividades entidad)
  516. {
  517. objBLAgenda = new BLAgendaActividades(entidad);
  518. objBLAgenda.Save();
  519. }
  520. /// <summary>
  521. /// Cargars the entidad.
  522. /// </summary>
  523. private void CargarValoresEnPantalla(int idAgendaActividad)
  524. {
  525. BLAgendaActividades objBLAgenda = new BLAgendaActividades(new AgendaActividades() { idAgendaActividad = idAgendaActividad });
  526. objBLAgenda.GetById();
  527. propAgenda = objBLAgenda.Data;
  528. }
  529. /// <summary>
  530. /// Validars the pagina.
  531. /// </summary>
  532. /// <returns></returns>
  533. private string ValidarPagina()
  534. {
  535. string mensaje = string.Empty;
  536. return mensaje;
  537. }
  538. /// <summary>
  539. /// Cargas the agenda.
  540. /// </summary>
  541. private void CargaAgenda()
  542. {
  543. AccionPagina = enumAcciones.Modificar;
  544. esNuevo = false;
  545. CargarValoresEnPantalla(propAgenda.idAgendaActividad);
  546. propAgenda.listaEventos.Sort((p, q) => DateTime.Compare(p.fechaEvento, q.fechaEvento));
  547. CargarGrillaAgenda();
  548. HabilitarBotonesDetalle(propAgenda.activo);
  549. btnBuscar.Visible = false;
  550. btnVolver.Visible = true;
  551. gvwReporte.Visible = false;
  552. udpFiltrosBusqueda.Visible = false;
  553. udpEdit.Visible = true;
  554. udpEdit.Update();
  555. }
  556. #endregion
  557. }
  558. }