// Eventos de la página protected void Page_Load(object sender, EventArgs e) { ENTRol oENTRol = new ENTRol(); String sDefaultErrorMessage = ""; try { // Mensaje de error por default sDefaultErrorMessage = gcEncryption.EncryptString("[V03] Acceso ilegal a la página", true); // Validaciones if (this.Request.QueryString["key"] == null) { this.Response.Redirect("~/Application/WebApp/Private/SysApp/saNotificacion.aspx?key=" + sDefaultErrorMessage, false); } if (!HasValidParams(this.Request.QueryString["key"].ToString(), ref oENTRol)){ this.Response.Redirect("~/Application/WebApp/Private/SysApp/saNotificacion.aspx?key=" + sDefaultErrorMessage, false); } // Consultar Órdenes de Compra SelectRol(oENTRol); }catch (Exception){ // Do Nothing } }
///<remarks> /// <name>DARol.InsertRol</name> /// <create>21-Octubre-2013</create> /// <author>GCSoft - Web Project Creator BETA 1.0</author> ///</remarks> ///<summary>Crea una nueva opción en el Rol</summary> ///<param name="oENTRol">Entidad de Rol con los parámetros necesarios para crear el registro</param> ///<param name="sConnection">Cadena de conexión a la base de datos</param> ///<param name="iAlternateDBTimeout">Valor en milisegundos del Timeout en la consulta a la base de datos. 0 si se desea el Timeout por default</param> ///<returns>Una entidad de respuesta</returns> public ENTResponse InsertRol(ENTRol oENTRol, String sConnection, Int32 iAlternateDBTimeout) { SqlConnection sqlCnn = new SqlConnection(sConnection); SqlCommand sqlCom; SqlParameter sqlPar; SqlDataAdapter sqlDA; ENTResponse oENTResponse = new ENTResponse(); // Configuración de objetos sqlCom = new SqlCommand("uspcatRol_Ins", sqlCnn); sqlCom.CommandType = CommandType.StoredProcedure; // Timeout alternativo en caso de ser solicitado if (iAlternateDBTimeout > 0) { sqlCom.CommandTimeout = iAlternateDBTimeout; } // Parametros sqlPar = new SqlParameter("sDescripcion", SqlDbType.VarChar); sqlPar.Value = oENTRol.sDescripcion; sqlCom.Parameters.Add(sqlPar); sqlPar = new SqlParameter("sNombre", SqlDbType.VarChar); sqlPar.Value = oENTRol.sNombre; sqlCom.Parameters.Add(sqlPar); sqlPar = new SqlParameter("tiActivo", SqlDbType.TinyInt); sqlPar.Value = oENTRol.tiActivo; sqlCom.Parameters.Add(sqlPar); sqlPar = new SqlParameter("tblSubMenu", SqlDbType.Structured); sqlPar.Value = oENTRol.tblSubMenu; sqlCom.Parameters.Add(sqlPar); // Inicializaciones oENTResponse.dsResponse = new DataSet(); sqlDA = new SqlDataAdapter(sqlCom); // Transacción try{ sqlCnn.Open(); sqlDA.Fill(oENTResponse.dsResponse); sqlCnn.Close(); }catch (SqlException sqlEx){ oENTResponse.ExceptionRaised(sqlEx.Message); }catch (Exception ex){ oENTResponse.ExceptionRaised(ex.Message); }finally{ if (sqlCnn.State == ConnectionState.Open) { sqlCnn.Close(); } sqlCnn.Dispose(); } // Resultado return oENTResponse; }
///<remarks> /// <name>BPRol.SelectRol</name> /// <create>21-Octubre-2013</create> /// <author>GCSoft - Web Project Creator BETA 1.0</author> ///</remarks> ///<summary>Consulta el catálogo de Rols</summary> ///<param name="oENTRol">Entidad de Rol con los filtros necesarios para la consulta</param> ///<returns>Una entidad de respuesta</returns> public ENTResponse SelectRol(ENTRol oENTRol) { DARol oDARol = new DARol(); ENTResponse oENTResponse = new ENTResponse(); try{ // Transacción en base de datos oENTResponse = oDARol.SelectRol(oENTRol, this.sConnectionApplication, 0); // Validación de error en consulta if (oENTResponse.GeneratesException) { return oENTResponse; } // Validación de mensajes de la BD oENTResponse.sMessage = oENTResponse.dsResponse.Tables[0].Rows[0]["sResponse"].ToString(); if (oENTResponse.sMessage != "") { return oENTResponse; } }catch (Exception ex){ oENTResponse.ExceptionRaised(ex.Message); } // Resultado return oENTResponse; }
private void SelectRol_Action() { ENTResponse oENTResponse = new ENTResponse(); ENTRol oENTRol = new ENTRol(); ENTSession oENTSession; BPRol oBPRol = new BPRol(); DataTable tblRol; try { // Estado inicial this.lblActionMessage.Text = ""; // Formulario oENTRol.idRol = 0; oENTRol.sNombre = ""; oENTRol.tiActivo = Int16.Parse(this.ddlActionStatus.SelectedItem.Value); // Transacción oENTResponse = oBPRol.SelectRol(oENTRol); // Validaciones if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); } if (oENTResponse.sMessage != "") { this.lblActionMessage.Text = oENTResponse.sMessage; } // Seguridad oENTSession = (ENTSession)this.Session["oENTSession"]; tblRol = (oENTSession.idRol != 1 ? deleteDataTableRow(oENTResponse.dsResponse.Tables[1], "idRol", "1") : oENTResponse.dsResponse.Tables[1]); // Llenado de combo this.ddlActionRol.DataTextField = "sNombre"; this.ddlActionRol.DataValueField = "idRol"; this.ddlActionRol.DataSource = tblRol; this.ddlActionRol.DataBind(); // Agregar Item de selección this.ddlActionRol.Items.Insert(0, new ListItem("[Seleccione]", "0")); } catch (Exception ex) { throw (ex); } }
void SelectRol(ENTRol oENTRol) { ENTResponse oENTResponse = new ENTResponse(); BPRol oBPRol = new BPRol(); try{ // Transacción oENTResponse = oBPRol.SelectRol(oENTRol); // Validaciones if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); } // Transacción exitosa ExportExcel(oENTResponse.dsResponse.Tables[2], "Rol"); }catch (Exception ex){ throw (ex); } }
// Funciones del programador Boolean HasValidParams(String sKey, ref ENTRol oENTRol) { Boolean ValidParams = true; try{ // Query String sKey = gcEncryption.DecryptString(sKey, true); // Parámetros de consulta (sNombre|tiActivo) oENTRol.sNombre = sKey.Split(new Char[] { '|' })[0].ToString(); oENTRol.tiActivo = Int16.Parse(sKey.Split(new Char[] { '|' })[1].ToString()); // Parámetros validos ValidParams = true; }catch(Exception){ ValidParams = false; } return ValidParams; }
private void UpdateRol_Estatus(Int32 idRol, RolActionTypes RolActionType) { ENTRol oENTRol = new ENTRol(); ENTResponse oENTResponse = new ENTResponse(); BPRol oBPRol = new BPRol(); try { // Formulario oENTRol.idRol = idRol; switch (RolActionType) { case RolActionTypes.DeleteRol: oENTRol.tiActivo = 0; break; case RolActionTypes.ReactivateRol: oENTRol.tiActivo = 1; break; default: throw new Exception("Opción inválida"); } // Transacción oENTResponse = oBPRol.UpdateRol_Estatus(oENTRol); // Validaciones if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); } if (oENTResponse.sMessage != "") { throw (new Exception(oENTResponse.sMessage)); } // Actualizar datos SelectRol(); } catch (Exception ex) { throw (ex); } }
private void UpdateRol(Int32 idRol) { ENTRol oENTRol = new ENTRol(); ENTResponse oENTResponse = new ENTResponse(); BPRol oBPRol = new BPRol(); DataTable tblSelected; DataRow rowSelected; try { // Formulario oENTRol.idRol = idRol; oENTRol.sDescripcion = this.txtActionDescripcion.Text.Trim(); oENTRol.sNombre = this.txtActionNombre.Text.Trim(); oENTRol.tiActivo = Int16.Parse(this.ddlActionStatus.SelectedValue); // Listado de SubMenús asociados tblSelected = (DataTable)this.ViewState["tblSubMenu"]; oENTRol.tblSubMenu = new DataTable("tblSubMenu"); oENTRol.tblSubMenu.Columns.Add("idSubMenu", typeof(Int32)); foreach (DataRow rowCurrentSelected in tblSelected.Select("tiSelected = 1")) { rowSelected = oENTRol.tblSubMenu.NewRow(); rowSelected["idSubMenu"] = rowCurrentSelected["idSubMenu"]; oENTRol.tblSubMenu.Rows.Add(rowSelected); } // Transacción oENTResponse = oBPRol.UpdateRol(oENTRol); // Validaciones if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); } if (oENTResponse.sMessage != "") { throw (new Exception(oENTResponse.sMessage)); } // Transacción exitosa ClearActionPanel(); // Actualizar grid SelectRol(); // Mensaje de usuario ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Convert.ToString(Guid.NewGuid()), "alert('Rol actualizado con éxito!'); focusControl('" + this.txtNombre.ClientID + "');", true); } catch (Exception ex) { throw (ex); } }
private void SelectRol_ForEdit(Int32 idRol) { ENTRol oENTRol = new ENTRol(); ENTResponse oENTResponse = new ENTResponse(); BPRol oBPRol = new BPRol(); DataTable tblSubMenu = null; try { // Formulario oENTRol.idRol = idRol; oENTRol.sNombre = ""; oENTRol.tiActivo = 2; // Transacción oENTResponse = oBPRol.SelectRol(oENTRol); // Validaciones if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); } // Mensaje de la BD this.lblActionMessage.Text = oENTResponse.sMessage; // Llenado de formulario this.txtActionNombre.Text = oENTResponse.dsResponse.Tables[1].Rows[0]["sNombre"].ToString(); this.txtActionDescripcion.Text = oENTResponse.dsResponse.Tables[1].Rows[0]["sDescripcion"].ToString(); this.ddlActionStatus.SelectedValue = oENTResponse.dsResponse.Tables[1].Rows[0]["tiActivo"].ToString(); this.ddlActionMenu.SelectedIndex = 0; // SubMenus asociados al Rol tblSubMenu = (DataTable)this.ViewState["tblSubMenu"]; foreach (DataRow rowAssociated in oENTResponse.dsResponse.Tables[3].Rows) { if (tblSubMenu.Select("idSubMenu = " + rowAssociated["idSubMenu"]).Length == 1) { tblSubMenu.Select("idSubMenu = " + rowAssociated["idSubMenu"])[0]["tiSelected"] = "1"; } } // Actualizar ViewState this.ViewState["tblSubMenu"] = tblSubMenu; this.ViewState["tblSubMenu_Filtered"] = this.ViewState["tblSubMenu"]; // Llenado de controles this.gvActionSubMenu.DataSource = tblSubMenu; this.gvActionSubMenu.DataBind(); } catch (Exception ex) { throw (ex); } }
private void SelectRol() { ENTRol oENTRol = new ENTRol(); ENTResponse oENTResponse = new ENTResponse(); BPRol oBPRol = new BPRol(); String sMessage = ""; try { // Formulario oENTRol.sNombre = this.txtNombre.Text; oENTRol.tiActivo = Int16.Parse(this.ddlStatus.SelectedItem.Value); // Transacción oENTResponse = oBPRol.SelectRol(oENTRol); // Validaciones if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); } // Mensaje de la BD if (oENTResponse.sMessage != "") { sMessage = "alert('" + gcJavascript.ClearText(oENTResponse.sMessage) + "');"; } // Llenado de controles this.gvRol.DataSource = oENTResponse.dsResponse.Tables[1]; this.gvRol.DataBind(); // Mensaje al usuario ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Convert.ToString(Guid.NewGuid()), sMessage, true); } catch (Exception ex) { throw (ex); } }