From b182d47b7c844c5a65f5f7699c1b7bff898f42f3 Mon Sep 17 00:00:00 2001 From: Administrador Date: Thu, 13 Jun 2019 05:00:15 +0000 Subject: [PATCH] Agrega mantenimiento de programa git-tfs-id: [http://192.168.1.10:8080/tfs/AyA]$/SINORT;C495 --- AYA.FROPI/AyABL/ADM/ProgramaBL.cs | 4 - AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx | 116 ++++ .../FOPI/webforms/ADM/wfrPrograma.aspx.cs | 598 ++++++++++++++++++ 3 files changed, 714 insertions(+), 4 deletions(-) create mode 100644 AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx create mode 100644 AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx.cs diff --git a/AYA.FROPI/AyABL/ADM/ProgramaBL.cs b/AYA.FROPI/AyABL/ADM/ProgramaBL.cs index 9fc972065..2a6cc134b 100644 --- a/AYA.FROPI/AyABL/ADM/ProgramaBL.cs +++ b/AYA.FROPI/AyABL/ADM/ProgramaBL.cs @@ -46,10 +46,6 @@ namespace AyABL.ADM cargarCondicionBusqueda(arlCondiciones, p_arlCondicionesBuscador); - if (objProgramaEL.Padre != 0) - { - arlCondiciones.Add(buscarPorPadre(objProgramaEL.Padre, Tablas.programa, operadorLogico.AND, operadorGeneral.EQUAL)); - } if (objProgramaEL.PK != 0) { diff --git a/AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx b/AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx new file mode 100644 index 000000000..ca9fdeaa6 --- /dev/null +++ b/AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx @@ -0,0 +1,116 @@ +<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="wfrPrograma.aspx.cs" Inherits="webforms_ADM_wfrPrograma" %> + + + + + + + + + + + + + +
+
+ <%-- ************************************************************************** Buscador ************************************************************************************* --%> +
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ Gestión de Regiones + <%-- ********************************************************************** Grid ********************************************************************************* --%> +
+
+ + + + + + + + + + + + + + + + + + +
+
  +
+
+
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+ <%--Botones Superiores--%> +
+
+ + +
+
+
+ <%-- ********************************************************************** Datos del Registro *********************************************************************************** --%> +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
diff --git a/AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx.cs b/AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx.cs new file mode 100644 index 000000000..224aba146 --- /dev/null +++ b/AYA.FROPI/FOPI/webforms/ADM/wfrPrograma.aspx.cs @@ -0,0 +1,598 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.HtmlControls; + +using AyABL; +using AyABL.ADM; +using AyABL.RCS; +using AyADAL; + +public partial class webforms_ADM_wfrPrograma : General +{ + #region Inicializar Formulario (R0) + + override protected void OnInit(EventArgs e) //M0 + { + try + { + base.OnInit(e); + + InicializarFormulario(); + } + catch (Exception ex) + { + MensajeError("Error en R0M0", ex); + } + } + + private void InicializarFormulario() //M1 + { + try + { + Response.Cache.SetCacheability(HttpCacheability.NoCache); + construirGridView(); + Javascript.CheckAllGridViewItems(Page); + + } + catch (Exception ex) + { + MensajeError("Error en R0M1", ex); + } + } + + #endregion + + #region Variables (R1) + + GridView grvListaDatosTemp; + ArrayList arlCondicionesFiltroBusqueda = new ArrayList(); + + ProgramaBL objProgramaBL; + + + #endregion + + #region Eventos Formulario (R2) + + protected void Page_Load(object sender, EventArgs e) //M0 + { + try + { + + if (!IsPostBack) + { + llenarGridView(true); + ComandosxMenu(); + mostrarFilaTabla(1); + } + } + catch (Exception ex) + { + MensajeError("Error en R2M0", ex); + } + + + } + + #endregion + + #region Eventos Controles Web (R3) + + /// + /// Metodo que se utiliza para extraer información del registro de la base de datos y ser mostrado en el div de Controles + /// + /// + /// + + protected void grvListaDatos_RowCommand(object sender, GridViewCommandEventArgs e) //M0 + { + try + { + if (e.CommandName == "editar") + { + int i = Convert.ToInt32(e.CommandArgument); + GridViewRow selectedRow = grvListaDatos.Rows[i]; + int intPkRegion = Convert.ToInt32(selectedRow.Cells[2].Text); + ViewState["PkPrograma"] = intPkRegion; + ViewState["MODO"] = "Modifica"; + + mostrarFilaTabla(2); + + mostrarDatos(intPkRegion); + } + } + catch (Exception ex) + { + MensajeError("Error en R3M0", ex); + } + } + + /// + /// Metodo que se utiliza para la paginación del Grid en caso de que el Rol desee ver mas registros + /// + /// + /// + + protected void grvListaDatos_PageIndexChanging(object sender, GridViewPageEventArgs e) //M1 + { + try + { + grvListaDatos.PageIndex = e.NewPageIndex; + llenarGridView(true); + } + catch (Exception ex) + { + MensajeError("Error R3M1", ex); + } + } + + /// + ///Activar el botón de Refrescar + /// + /// + /// + + protected void btnRefrescar_Click(object sender, System.Web.UI.ImageClickEventArgs e) //M2 + { + try + { + llenarGridView(true); + } + catch (Exception ex) + { + MensajeError("Error en R3M2", ex); + } + } + + /// + /// Activa el evento del botón Buscar (binoculares) + /// + /// + /// + protected void btnBuscar_Click(object sender, System.Web.UI.ImageClickEventArgs e) //M3 + { + try + { + llenarGridView(true); + } + catch (Exception ex) + { + MensajeError("Error en R3M3", ex); + } + + } + + /// + /// Activa el evento del boton Nuevo + /// + /// + /// + + protected void btnNuevo_Click(object sender, EventArgs e) //M4 + { + try + { + ViewState["MODO"] = "Nuevo"; + mostrarFilaTabla(2); + //MensajeError("Error en R3M4", null); + } + catch (Exception ex) + { + MensajeError("Error en R3M4", ex); + } + } + + /// + /// Metodo que activa el botón de Eliminar + /// + /// + /// + protected void btnEliminar_Click(object sender, EventArgs e) //M5 + { + try + { + //********** Instanciar objeto ****** + + // recorro el grid + foreach (GridViewRow row in grvListaDatos.Rows) + { + + HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[0].Controls[1]; + if (chkTemp != null) + { + // si el registro esta marcado + if (chkTemp.Checked) + { + //Iguala la variable al valor en la celda seleccionada + int intPkEliminar = Convert.ToInt32(row.Cells[2].Text); + string registro = row.Cells[3].Text; + //Obtiene el valor del objeto y lo iguala a la variable + //**********aqui******** = intPkEliminar; + + //Ejecuta el eliminar con el valor de la variable + eliminarDatos(intPkEliminar, registro); + } + } + } + llenarGridView(true); + } + catch (Exception ex) + { + MensajeError("Error en R3M5", ex); + } + } + + /// + ///Activa el metodo del boton Anterior, regresa a mostrar el listado + /// + /// + /// + + protected void btnAnterior_Click(object sender, EventArgs e) //M6 + { + try + { + llenarGridView(true); + divDatosSuperiores.Visible = true; + divDatosInferiores.Visible = false; + } + catch (Exception ex) + { + MensajeError("Error en R3M6", ex); + } + } + + /// + /// Activa el evento del boton guardar. + /// + /// + /// + + protected void btnGuardar_Click(object sender, EventArgs e) //M7 + { + try + { + string strMensaje = string.Empty; + + //******Reparar, aqui no van los llenarGridView(true); + if (GuardarDatos()) + llenarGridView(true); + else + llenarGridView(true); + + mostrarFilaTabla(1); + } + catch (Exception ex) + { + MensajeError("Error en R3M7", ex); + } + } + + protected void ddlTipoRegion_SelectedIndexChanged(object sender, EventArgs e) //M8 + { + llenarGridView(true); + } + + + #endregion + + #region Metodos Personalizados (R4) + + /// + /// Oculta los divs según la necesidad + /// + /// + private void mostrarFilaTabla(int p_intFila) //M0 + { + try + { + divDatosSuperiores.Visible = false; + divDatosInferiores.Visible = false; + + switch (p_intFila) + { + case 1: + llenarGridView(true); + divDatosSuperiores.Visible = true; + break; + case 2: + llenarGridView(true); + divDatosInferiores.Visible = true; + break; + } + } + catch (Exception ex) + { + MensajeError("Error en R4M0", ex); + } + } + + /// + /// Metodo que se utiliza para contruir el Grid al inicio de la pantalla + /// + private void construirGridView() //M1 + { + try + { + //Se Instancia la variable con el control + grvListaDatosTemp = (GridView)divDatosSuperiores.FindControl("grvListaDatos"); + + //Se crean las columnas del grid + GridViewBoundField bdfPkRegion = new GridViewBoundField("PKPROGRAMA", "PK", false, false, false); + GridViewBoundField bdfNombreRegion = new GridViewBoundField("NOMBREPROGRAMA", "NOMBRE PROGRAMA", true, false, true); + + ////Asigna las columnas a los campos a la hora de hacer la consulta + grvListaDatosTemp.Columns.Add(bdfPkRegion); + grvListaDatosTemp.Columns.Add(bdfNombreRegion); + + ////Le damos estilo a las filas (opcional) + grvListaDatosTemp.Columns[0].ItemStyle.Width = 25; + grvListaDatosTemp.Columns[1].ItemStyle.Width = 25; + grvListaDatosTemp.Columns[2].ItemStyle.Width = 25; + + } + catch (Exception ex) + { + MensajeError("Error en R4M1", ex); + } + } + + /// + /// Metodo que se utiliza para limpiar los campos en la pantalla + /// + private void limpiarCampos() //M2 + { + try + { + + } + catch (Exception ex) + { + MensajeError("Error en R4M2", ex); + } + } + + /// + /// Metodo que se utiliza con el buscador de la parte superior de la pantalla, y hace que se despliegue la información de acuerdo + /// a lo solicitado + /// + private void Buscar() //M3 + { + try + { + llenarGridView(true); + } + catch (Exception ex) + { + MensajeError("Error en R4M3", ex); + } + } + + /// + /// Metodo que se utiliza para el despliegue de los botones segun el rol del usuario + /// + private void ComandosxMenu() //M4 + { + try + { + //General general = null; + + DataSet dsComandos = getComandos(); + + if (dsComandos != null) + { + foreach (DataRow drTemp in dsComandos.Tables[0].Rows) + { + switch (drTemp["NOMBRECOMANDO"].ToString().ToUpper()) + { + case "NUEVO": + btnNuevo.Visible = true; + break; + case "ELIMINAR": + btnEliminar.Visible = true; + break; + case "MODIFICA": + //Inicio de variable tipo VIEWSTATE + ViewState["PUEDEMODIFICAR"] = true; + btnGuardar.Visible = true; + break; + } + } + } + } + catch (Exception ex) + { + MensajeError("Error en R4M4", ex); + } + } + + #endregion + + #region Metodos Controles a Datos (R5) + + /// + /// guarda y modifica registros en la tabla. + /// + /// + + private bool GuardarDatos() //M0 + { + bool blnValorRetornado = false; //Se utiliza para verificar si se ejecuto el proceso tanto de guardar como el de eliminar + + try + { + string strModo = ViewState["MODO"].ToString(); + ViewState["PUEDEMODIFICAR"] = true; + + //Igualar los valores de los controles a las propiedades del objeto a utilizar + //Ejemplo + objProgramaBL = new ProgramaBL(); + objProgramaBL.objProgramaEL.Nombre = txtNombre.Text; + + + if (strModo == "Nuevo") + { + //Si es un nuevo registro se llama al metodo respectivo del objeto para hacer la inserción + //***** Para este caso se obtiene el pk al utilizar el metodo del objeto para insertar información ******* + //Ejemplo + if (objProgramaBL.insertarPrograma()) + { + + blnValorRetornado = true; + + GuardarEventoBitacora( + Session["LOGIN"].ToString(), //Usuario + AccionBitacora.INSERT.ToString(), //Accion que se va a ejecutar + MensajesBitacora.IngresarRegistro + ": " + txtNombre.Text, //Mensaje de la bitacora + "wfrPrograma.aspx" + ); + } + } + else if (strModo == "Modifica") + { + //Si se va a modificar el registro y si tiene el permiso de modificar + if (Convert.ToBoolean(ViewState["PUEDEMODIFICAR"]) != false) + { + // Para hacer la modificación del registro se debe proporsionar la PK del registro a modificar + //Ejemplo + objProgramaBL.objProgramaEL.PK = Convert.ToInt32(ViewState["PkPrograma"]); + if (objProgramaBL.actualizarPrograma()) + { + + blnValorRetornado = true; + + //Se ingresa a bitacora la transacción + GuardarEventoBitacora( + Session["LOGIN"].ToString(), + AccionBitacora.UPDATE.ToString(), + MensajesBitacora.ModificarRegistro + ": " + ViewState["PkPrograma"].ToString() + ", " + txtNombre.Text, + "wfrPrograma.aspx" + ); + } + } + } + } + catch (Exception ex) + { + MensajeError("Error en R5M0", ex); + General.ReportarError(ex, Session["LOGIN"].ToString()); + } + return blnValorRetornado; + } + + /// + /// Metodo que se utiliza para eliminar registros de la base de datos + /// + /// + + private void eliminarDatos(int p_intPkPrograma, string registro) //M1 + { + try + { + //Para eliminar datos inicialmente se instancia el objeto + //Ejemplo + objProgramaBL = new ProgramaBL(); + + //Se asignan los valores a las propiedades el objeto + //Ejemplo + objProgramaBL.objProgramaEL.PK = p_intPkPrograma; + + if (objProgramaBL.borradoLogicoPrograma()) + { + + //Se ingresa a bitacora la transacción + GuardarEventoBitacora( + Session["LOGIN"].ToString(), + AccionBitacora.DELETE.ToString(), + MensajesBitacora.EliminarRegistro + ": " + registro, + "wfrPrograma.aspx" + ); + } + + } + catch (Exception ex) + { + MensajeError("Error en R5M1", ex); + General.ReportarError(ex, Session["LOGIN"].ToString()); + } + } + + #endregion + + #region Metodos Datos a Controles (R6) + + /// + /// Carga el grid principal + /// + /// + private void llenarGridView(bool p_Llenar) //M0 + { + try + { + if (!IsPostBack || p_Llenar) + { + //Se llena el dataset con la información + //Ejemplo + arlCondicionesFiltroBusqueda = new ArrayList(); + objProgramaBL = new ProgramaBL(); + objProgramaBL.objProgramaEL.PK = 0; + DataSet dsListaDatos = objProgramaBL.getPrograma(arlCondicionesFiltroBusqueda); + + //Hago el llamado del metodo que carga el grid o listado + //Ejemplo + General.detalleGridView(dsListaDatos, grvListaDatosTemp, lblTotalDatos); + } + } + catch (Exception ex) + { + MensajeError("Error en R6M0", ex); + } + } + /// + /// Muestra los datos del registro + + /// + /// + private void mostrarDatos(int p_intPkConsultar) //M1 + { + try + { + //Se instancia el objeto + //Ejemplo + objProgramaBL = new ProgramaBL(); + + //Se obtiene la PK del registro por medio el parametro + //Ejemplo + objProgramaBL.objProgramaEL.PK = p_intPkConsultar; + + + //Se llena un dataset con la inforación suministrada. + //Ejemplo + DataSet dsPrograma = objProgramaBL.getPrograma(null); + + //Se llenan los campos + //Ejemplo + if (dsPrograma.Tables[0].Rows.Count > 0) + { + + txtNombre.Text = dsPrograma.Tables[0].Rows[0]["NOMBREPROGRAMA"].ToString(); + } + } + catch (Exception ex) + { + MensajeError("Error en R6M1", ex); + General.ReportarError(ex, Session["LOGIN"].ToString()); + } + } + + + + #endregion +} \ No newline at end of file