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

http://blpm.googlecode.com/ · C# · 554 lines · 364 code · 43 blank · 147 comment · 16 complexity · a531d89bbba20c1fea906c3cd6f421be 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. #endregion
  69. #region --[Eventos]--
  70. /// <summary>
  71. /// Método que se ejecuta al dibujar los controles de la página.
  72. /// Se utiliza para gestionar las excepciones del método Page_Load().
  73. /// </summary>
  74. /// <param name="e"></param>
  75. protected override void OnPreRender(EventArgs e)
  76. {
  77. base.OnPreRender(e);
  78. if (AvisoMostrar)
  79. {
  80. AvisoMostrar = false;
  81. try
  82. {
  83. Master.ManageExceptions(AvisoExcepcion);
  84. }
  85. catch (Exception ex) { Master.ManageExceptions(ex); }
  86. }
  87. }
  88. /// <summary>
  89. /// Handles the Load event of the Page control.
  90. /// </summary>
  91. /// <param name="sender">The source of the event.</param>
  92. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  93. protected void Page_Load(object sender, EventArgs e)
  94. {
  95. try
  96. {
  97. propAgenda.usuario = ObjSessionDataUI.ObjDTUsuario.Nombre;
  98. Master.BotonAvisoAceptar += (VentanaAceptar);
  99. novControl.GuardarClick += (Guardar);
  100. if (!Page.IsPostBack)
  101. {
  102. base.idNovedadConsulta = 0;
  103. CargarPresentacion();
  104. if (propAgenda.idAgendaActividad > 0)
  105. {
  106. CargarLista(propAgenda);
  107. CargaAgenda();
  108. }
  109. else
  110. BuscarAgenda(propAgenda);
  111. CargarAgendaCurso();
  112. }
  113. }
  114. catch (Exception ex)
  115. {
  116. AvisoMostrar = true;
  117. AvisoExcepcion = ex;
  118. }
  119. }
  120. private void CargarAgendaCurso()
  121. {
  122. //propAgenda.idAgendaActividad = Convert.ToInt32(e.CommandArgument.ToString());
  123. propAgenda.cursoCicloLectivo.idCursoCicloLectivo = base.idCursoCicloLectivo;
  124. CargaAgenda();
  125. lblTitulo.Text = "Agenda de Actividades - " + propAgenda.cursoCicloLectivo.curso.nombre; //+ " - " + propAgenda.cursoCicloLectivo.cicloLectivo.nombre;
  126. }
  127. /// <summary>
  128. /// Ventanas the aceptar.
  129. /// </summary>
  130. /// <param name="sender">The sender.</param>
  131. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  132. void VentanaAceptar(object sender, EventArgs e)
  133. {
  134. try
  135. {
  136. switch (AccionPagina)
  137. {
  138. case enumAcciones.Limpiar:
  139. CargarPresentacion();
  140. BuscarAgenda(null);
  141. break;
  142. case enumAcciones.Guardar:
  143. AccionPagina = enumAcciones.Limpiar;
  144. GuardarAgenda(ObtenerValoresDePantalla());
  145. Master.MostrarMensaje(enumTipoVentanaInformacion.Satisfactorio.ToString(), UIConstantesGenerales.MensajeGuardadoOk, enumTipoVentanaInformacion.Satisfactorio);
  146. break;
  147. default:
  148. break;
  149. }
  150. }
  151. catch (Exception ex)
  152. {
  153. Master.ManageExceptions(ex);
  154. }
  155. }
  156. /// <summary>
  157. /// Guardars the specified sender.
  158. /// </summary>
  159. /// <param name="sender">The sender.</param>
  160. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  161. protected void Guardar(object sender, EventArgs e)
  162. {
  163. try
  164. {
  165. novControl.GuardarNovedad();
  166. }
  167. catch (Exception ex)
  168. { Master.ManageExceptions(ex); }
  169. }
  170. /// <summary>
  171. /// Handles the Click event of the btnEvaluacion control.
  172. /// </summary>
  173. /// <param name="sender">The source of the event.</param>
  174. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  175. protected void btnEvaluacion_Click(object sender, EventArgs e)
  176. {
  177. try
  178. {
  179. Response.Redirect("ManageEvaluaciones.aspx", false);
  180. }
  181. catch (Exception ex)
  182. {
  183. Master.ManageExceptions(ex);
  184. }
  185. }
  186. /// <summary>
  187. /// Handles the Click event of the btnExcursion control.
  188. /// </summary>
  189. /// <param name="sender">The source of the event.</param>
  190. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  191. protected void btnExcursion_Click(object sender, EventArgs e)
  192. {
  193. try
  194. {
  195. Response.Redirect("ManageExcursiones.aspx", false);
  196. }
  197. catch (Exception ex)
  198. {
  199. Master.ManageExceptions(ex);
  200. }
  201. }
  202. /// <summary>
  203. /// Handles the Click event of the btnReunion control.
  204. /// </summary>
  205. /// <param name="sender">The source of the event.</param>
  206. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  207. protected void btnReunion_Click(object sender, EventArgs e)
  208. {
  209. try
  210. {
  211. Response.Redirect("ManageReuniones.aspx", false);
  212. }
  213. catch (Exception ex)
  214. {
  215. Master.ManageExceptions(ex);
  216. }
  217. }
  218. /// <summary>
  219. /// Handles the Click event of the btnBuscar control.
  220. /// </summary>
  221. /// <param name="sender">The source of the event.</param>
  222. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  223. protected void btnBuscar_Click(object sender, EventArgs e)
  224. {
  225. try
  226. {
  227. BuscarFiltrando();
  228. }
  229. catch (Exception ex)
  230. {
  231. Master.ManageExceptions(ex);
  232. }
  233. }
  234. /// <summary>
  235. /// Handles the Click event of the btnAsignarRol control.
  236. /// </summary>
  237. /// <param name="sender">The source of the event.</param>
  238. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  239. protected void btnGuardar_Click(object sender, EventArgs e)
  240. {
  241. try
  242. {
  243. string mensaje = ValidarPagina();
  244. if (mensaje == string.Empty)
  245. {
  246. if (Page.IsValid)
  247. {
  248. //TODO: Aquí hay que llamar a la validación de disponibilidad de agenda
  249. AccionPagina = enumAcciones.Guardar;
  250. Master.MostrarMensaje(enumTipoVentanaInformacion.Confirmación.ToString(), UIConstantesGenerales.MensajeConfirmarCambios, enumTipoVentanaInformacion.Confirmación);
  251. }
  252. }
  253. else
  254. {
  255. Master.MostrarMensaje(enumTipoVentanaInformacion.Advertencia.ToString(), UIConstantesGenerales.MensajeDatosFaltantes + mensaje, enumTipoVentanaInformacion.Advertencia);
  256. }
  257. }
  258. catch (Exception ex)
  259. {
  260. Master.ManageExceptions(ex);
  261. }
  262. }
  263. /// <summary>
  264. /// Handles the Click event of the btnVolver control.
  265. /// </summary>
  266. /// <param name="sender">The source of the event.</param>
  267. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  268. protected void btnVolver_Click(object sender, EventArgs e)
  269. {
  270. try
  271. {
  272. base.idCursoCicloLectivo = 0;
  273. base.cursoActual = new CursoCicloLectivo();
  274. Response.Redirect("~/Private/AccesoCursos.aspx", false);
  275. }
  276. catch (Exception ex)
  277. {
  278. Master.ManageExceptions(ex);
  279. }
  280. }
  281. /// <summary>
  282. /// Método que se llama al hacer click sobre las acciones de la grilla
  283. /// </summary>
  284. /// <param name="sender">The source of the event.</param>
  285. /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param>
  286. protected void gvwReporte_RowCommand(object sender, GridViewCommandEventArgs e)
  287. {
  288. try
  289. {
  290. switch (e.CommandName)
  291. {
  292. case "Editar":
  293. break;
  294. }
  295. }
  296. catch (Exception ex)
  297. {
  298. Master.ManageExceptions(ex);
  299. }
  300. }
  301. /// <summary>
  302. /// Handles the PageIndexChanging event of the gvwReporte control.
  303. /// </summary>
  304. /// <param name="sender">The source of the event.</param>
  305. /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewPageEventArgs"/> instance containing the event data.</param>
  306. protected void gvwReporte_PageIndexChanging(object sender, GridViewPageEventArgs e)
  307. {
  308. try
  309. {
  310. gvwReporte.PageIndex = e.NewPageIndex;
  311. CargarGrilla();
  312. }
  313. catch (Exception ex) { Master.ManageExceptions(ex); }
  314. }
  315. /// <summary>
  316. /// Handles the PageIndexChanging event of the gvwAgenda control.
  317. /// </summary>
  318. /// <param name="sender">The source of the event.</param>
  319. /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewPageEventArgs"/> instance containing the event data.</param>
  320. protected void gvwAgenda_PageIndexChanging(object sender, GridViewPageEventArgs e)
  321. {
  322. try
  323. {
  324. gvwAgenda.PageIndex = e.NewPageIndex;
  325. CargarGrillaAgenda();
  326. btnBuscar.Visible = false;
  327. btnVolver.Visible = true;
  328. gvwReporte.Visible = false;
  329. udpEdit.Visible = true;
  330. udpEdit.Update();
  331. }
  332. catch (Exception ex) { Master.ManageExceptions(ex); }
  333. }
  334. /// <summary>
  335. /// Handles the Click event of the btnRegistroClases control.
  336. /// </summary>
  337. /// <param name="sender">The source of the event.</param>
  338. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  339. protected void btnRegistroClases_Click(object sender, EventArgs e)
  340. {
  341. try
  342. {
  343. Response.Redirect("ManageRegistroClases.aspx", false);
  344. }
  345. catch (Exception ex)
  346. {
  347. Master.ManageExceptions(ex);
  348. }
  349. }
  350. #endregion
  351. #region --[Métodos Privados]--
  352. /// <summary>
  353. /// Cargars the grilla.
  354. /// </summary>
  355. /// <typeparam name="T"></typeparam>
  356. /// <param name="lista">The lista.</param>
  357. private void CargarGrilla()
  358. {
  359. gvwReporte.DataSource = UIUtilidades.BuildDataTable<AgendaActividades>(listaAgenda).DefaultView;
  360. gvwReporte.DataBind();
  361. udpEdit.Visible = false;
  362. udpGrilla.Update();
  363. }
  364. /// <summary>
  365. /// Cargars the grilla agenda.
  366. /// </summary>
  367. private void CargarGrillaAgenda()
  368. {
  369. gvwAgenda.DataSource = UIUtilidades.BuildDataTable<EventoAgenda>(propAgenda.listaEventos).DefaultView;
  370. gvwAgenda.DataBind();
  371. udpEdit.Visible = false;
  372. udpGrilla.Update();
  373. }
  374. /// <summary>
  375. /// Cargars the presentacion.
  376. /// </summary>
  377. private void CargarPresentacion()
  378. {
  379. LimpiarCampos();
  380. lblTitulo.Text = "Actividades";
  381. udpEdit.Visible = false;
  382. btnVolver.Visible = false;
  383. btnGuardar.Visible = false;
  384. btnBuscar.Visible = true;
  385. gvwReporte.Visible = true;
  386. udpFiltros.Update();
  387. udpGrilla.Update();
  388. }
  389. /// <summary>
  390. /// Habilitars the botones detalle.
  391. /// </summary>
  392. /// <param name="habilitar">if set to <c>true</c> [habilitar].</param>
  393. private void HabilitarBotonesDetalle(bool habilitar)
  394. {
  395. btnExcursion.Visible = habilitar;
  396. btnEvaluacion.Visible = habilitar;
  397. btnReunion.Visible = habilitar;
  398. btnRegistroClases.Visible = habilitar;
  399. }
  400. /// <summary>
  401. /// Cargars the combos.
  402. /// </summary>
  403. //private void CargarCombos(DropDownList ddlCurso)
  404. //{
  405. // lblTitulo.Text = "Actividades - " + cicloLectivoActual.nombre;
  406. // UIUtilidades.BindCombo<Curso>(ddlCurso, listaCursos, "idCurso", "Nombre", true);
  407. //}
  408. /// <summary>
  409. /// Limpiars the campos.
  410. /// </summary>
  411. private void LimpiarCampos()
  412. {
  413. HabilitarBotonesDetalle(false);
  414. }
  415. /// <summary>
  416. /// Buscars the filtrando.
  417. /// </summary>
  418. private void BuscarFiltrando()
  419. {
  420. lblTitulo.Text = "Actividades";
  421. AgendaActividades entidad = new AgendaActividades();
  422. entidad.cursoCicloLectivo.idCicloLectivo = cicloLectivoActual.idCicloLectivo;
  423. propFiltroAgenda = entidad;
  424. BuscarAgenda(entidad);
  425. }
  426. /// <summary>
  427. /// Buscars the entidads.
  428. /// </summary>
  429. /// <param name="entidad">The entidad.</param>
  430. private void BuscarAgenda(AgendaActividades entidad)
  431. {
  432. CargarLista(entidad);
  433. CargarGrilla();
  434. }
  435. /// <summary>
  436. /// Cargars the lista.
  437. /// </summary>
  438. /// <param name="entidad">The entidad.</
  439. /// param>
  440. private void CargarLista(AgendaActividades entidad)
  441. {
  442. entidad.activo = true;
  443. if (User.IsInRole(enumRoles.Docente.ToString()))
  444. entidad.usuario = ObjSessionDataUI.ObjDTUsuario.Nombre;
  445. objBLAgenda = new BLAgendaActividades(entidad);
  446. listaAgenda = objBLAgenda.GetAgendaActividades(entidad);
  447. }
  448. /// <summary>
  449. /// Obteners the valores pantalla.
  450. /// </summary>
  451. /// <returns></returns>
  452. private AgendaActividades ObtenerValoresDePantalla()
  453. {
  454. AgendaActividades entidad = new AgendaActividades();
  455. entidad = propAgenda;
  456. if (!esNuevo)
  457. {
  458. entidad.idAgendaActividad = propAgenda.idAgendaActividad;
  459. entidad.cursoCicloLectivo.idCursoCicloLectivo = propAgenda.cursoCicloLectivo.idCursoCicloLectivo;
  460. }
  461. return entidad;
  462. }
  463. /// <summary>
  464. /// Guardars the agenda.
  465. /// </summary>
  466. /// <param name="entidad">The entidad.</param>
  467. private void GuardarAgenda(AgendaActividades entidad)
  468. {
  469. objBLAgenda = new BLAgendaActividades(entidad);
  470. objBLAgenda.Save();
  471. }
  472. /// <summary>
  473. /// Cargars the entidad.
  474. /// </summary>
  475. private void CargarValoresEnPantalla(int idCursoCicloLectivo)
  476. {
  477. BLAgendaActividades objBLAgenda = new BLAgendaActividades(new AgendaActividades() { cursoCicloLectivo = new CursoCicloLectivo() { idCursoCicloLectivo = idCursoCicloLectivo } });
  478. objBLAgenda.GetById();
  479. propAgenda = objBLAgenda.Data;
  480. novControl.visible = false;
  481. idCursoCicloLectivo = propAgenda.cursoCicloLectivo.idCursoCicloLectivo;
  482. }
  483. /// <summary>
  484. /// Validars the pagina.
  485. /// </summary>
  486. /// <returns></returns>
  487. private string ValidarPagina()
  488. {
  489. string mensaje = string.Empty;
  490. return mensaje;
  491. }
  492. /// <summary>
  493. /// Cargas the agenda.
  494. /// </summary>
  495. private void CargaAgenda()
  496. {
  497. AccionPagina = enumAcciones.Modificar;
  498. esNuevo = false;
  499. CargarValoresEnPantalla(propAgenda.cursoCicloLectivo.idCursoCicloLectivo);
  500. propAgenda.listaEventos.Sort((p, q) => DateTime.Compare(p.fechaEvento, q.fechaEvento));
  501. CargarGrillaAgenda();
  502. HabilitarBotonesDetalle(propAgenda.activo);
  503. btnBuscar.Visible = false;
  504. btnVolver.Visible = true;
  505. gvwReporte.Visible = false;
  506. udpEdit.Visible = true;
  507. udpEdit.Update();
  508. }
  509. #endregion
  510. }
  511. }