private void BindGrid(int currentPage) { SisPackController.AdministrarGrillas.Configurar(grdPerfiles, "PerfilID", this.CantidadOpciones); if (Session["grdPerfilesSession"] == null) { IPerfil perfil = PerfilFactory.GetPerfil(); //perfil.Nombre = this.txtPerfil.Text; //perfil.CategoriaPerfilID = Utiles.Validaciones.obtieneEntero(this.cmbCategoria.SelectedValue); this.dsPerfiles = perfil.GetPerfilesUsuario(Utiles.Validaciones.obtieneEntero(this.txtUsuarioID.Text)); } else { this.dsPerfiles = (DsPerfil)Session["grdPerfilesSession"]; foreach (DataGridItem item in grdPerfiles.Items) { DsPerfil.DatosRow dr = (DsPerfil.DatosRow) this.dsPerfiles.Datos.Rows[item.DataSetIndex]; CheckBox chk = (CheckBox)item.FindControl("perfilAsignado"); dr.Asignado = chk.Checked; } } // actualizo la grilla Session["grdPerfilesSession"] = this.dsPerfiles; grdPerfiles.DataSource = this.dsPerfiles; grdPerfiles.CurrentPageIndex = currentPage; grdPerfiles.DataBind(); }
private void btnGrabar_Click(object sender, System.EventArgs e) { ArrayList colPerfil = new ArrayList(); DsPerfil ds = (DsPerfil)grdPerfiles.DataSource; foreach (DsPerfil.DatosRow dr in ds.Datos) { // si el perfil esta asignado, lo guardo en la coleccion if (dr.Asignado) { IPerfil perfil = PerfilFactory.GetPerfil(); perfil.CategoriaPerfilID = dr.CategoriaPerfilID; perfil.Descripcion = dr.Descripcion; perfil.Nombre = dr.Nombre; perfil.PerfilID = dr.PerfilID; perfil.TipoEstadoID = dr.EstadoUsuarioPerfilID; colPerfil.Add(perfil); } } IUsuarios usuario = UsuariosFactory.GetUsuario(); usuario.UsuarioID = Utiles.Validaciones.obtieneEntero(this.txtUsuarioID.Text); usuario.AsignarPerfiles(colPerfil); }
/* Método que obtiene todos los perfiles que tiene asignado un usuario determinado. */ public DsPerfil GetPerfilesAsignadosByUsuarioID() { DsPerfil ds = new DsPerfil(); SqlParameter pUsuarioID = new SqlParameter("@UsuarioID", Utiles.BaseDatos.IntToSql(this.UsuarioID)); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "PerfilesByUsuarioID", pUsuarioID); return(ds); }
/* Método que obtiene todos los perfiles que tienen asignada una opción determinada. */ public DsPerfil GetPerfilesByOpcionID() { DsPerfil ds = new DsPerfil(); SqlParameter pOpcionID = new SqlParameter("@OpcionID", Utiles.BaseDatos.StrToSql(this.OpcionID)); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "PerfilesByOpcionID", pOpcionID); return(ds); }
public override global::System.Data.DataSet Clone() { DsPerfil cln = ((DsPerfil)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public DsPerfil GetPerfilDataSet() { DsPerfil ds = new DsPerfil(); SqlParameter pNombre = new SqlParameter("@Nombre", this.Nombre); SqlParameter pCategoriaPerfilID = new SqlParameter("@CategoriaPerfilID", Utiles.BaseDatos.IntToSql(this.CategoriaPerfilID)); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "PerfilSEL", pNombre, pCategoriaPerfilID); return(ds); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { DsPerfil ds = new DsPerfil(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public bool Consultar() { // Creo un dataset DsPerfil ds = new DsPerfil(); // creo un parametro para pasarle al store procedure SqlParameter pPerfilID = new SqlParameter("@PerfilID", this.PerfilID); // lleno el dataset con lo que devuelve el store Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "PerfilONE", pPerfilID); // obtengo el primer registro (y el unico) DsPerfil.DatosRow dr = (DsPerfil.DatosRow)ds.Datos.Rows[0]; // si el dataset tiene datos... if (ds.Datos.Rows.Count > 0) { this.categoriaPerfilID = dr.CategoriaPerfilID; this.descripcion = dr.Descripcion; this.nombre = dr.Nombre; this.perfilID = dr.PerfilID; this.tipoEstadoID = dr.EstadoUsuarioPerfilID; } return(true); }
private void grdPerfiles_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { BindGrid(0); DsPerfil ds = (DsPerfil)grdPerfiles.DataSource; // Obtengo la fila que se va a eliminar DsPerfil.DatosRow dr = (DsPerfil.DatosRow)ds.Datos.Rows[e.Item.DataSetIndex]; // Creo el objeto y le seteo el id IPerfil perfil = PerfilFactory.GetPerfil(); perfil.PerfilID = dr.PerfilID; // Lo elimino try { perfil.Eliminar(); } catch (Exception ex) { ((ErrorWeb)phErrores.FindControl("Error")).setMensaje(TraducirTexto(ex.Message)); } // Actualizo la grilla BindGrid(0); }
private void BindGrid(int currentPage) { try { #region Consulta de permisos por perfil if (this.rbPermisosPorPerfil.Checked && !this.ddlPerfilPorCategoria.SelectedValue.Trim().Equals("")) { /* Consultar si existe el perfil, dependiendo de los filtros ingresados. */ IPerfil perfil = PerfilFactory.GetPerfil(); perfil.PerfilID = this.ddlPerfilPorCategoria.SelectedValue.Trim().Equals("")?0: Convert.ToInt32(this.ddlPerfilPorCategoria.SelectedValue.Trim()); if (perfil.Consultar()) { IOpcion opcion = OpcionFactory.GetOpcion(); opcion.OpcionPadreID = ""; DsOpcion ds = opcion.GetOpcionesByPerfilID(perfil.PerfilID); tvwMain.Controls.Clear(); foreach (DsOpcion.DatosRow dr in ds.Datos) { // obtengo el nodo padre squishyTREE.TreeNode n1 = tvwMain.AddNode(dr.OpcionID, "n1"); n1.AddTaggedValue("val1", dr.Descripcion); // busco los hijos de este padre this.BuscarHijos(perfil.PerfilID, dr.OpcionID, n1); } } this.tvwMain.Visible = true; this.butImprimir.Visible = true; tvwMain.ExpandAll(); } else { this.tvwMain.Visible = false; this.butImprimir.Visible = false; } #endregion #region Consulta de usuarios por perfil if (this.rbUsuariosPorPerfil.Checked && !this.ddlPerfilPorCategoria.SelectedValue.Trim().Equals("")) { AdministrarGrillas.Configurar(dtgDatosUsuarios, "UsuarioID", this.CantidadOpciones); IPerfil usuarios = PerfilFactory.GetPerfil(); usuarios.PerfilID = ddlPerfilPorCategoria.SelectedValue.Trim().Equals("")?0:Convert.ToInt32(ddlPerfilPorCategoria.SelectedValue.Trim()); DsUsuarios dsUsuarios = usuarios.GetUsuariosByPerfilID(); this.dtgDatosUsuarios.DataSource = dsUsuarios; this.dtgDatosUsuarios.CurrentPageIndex = currentPage; this.dtgDatosUsuarios.DataBind(); usuarios = null; dsUsuarios = null; this.dtgDatosUsuarios.Visible = true; } else { this.dtgDatosUsuarios.Visible = false; } #endregion #region Consulta de perfiles por permiso if (this.rbPerfilesPorPermiso.Checked && !this.ddlPermiso.SelectedValue.Trim().Equals("")) { AdministrarGrillas.Configurar(dtgDatosPerfiles, "PerfilID", this.CantidadOpciones); IOpcion permiso = OpcionFactory.GetOpcion(); permiso.OpcionID = this.ddlPermiso.SelectedValue.Trim().Equals("")?"":this.ddlPermiso.SelectedValue.Trim(); DsPerfil dsPerfilesO = permiso.GetPerfilesByOpcionID(); this.dtgDatosPerfiles.DataSource = dsPerfilesO; this.dtgDatosUsuarios.CurrentPageIndex = currentPage; this.dtgDatosPerfiles.DataBind(); permiso = null; dsPerfilesO = null; this.dtgDatosPerfiles.Visible = true; } else { this.dtgDatosPerfiles.Visible = false; } #endregion #region Consulta de perfiles por usuario if (this.rbPerfilesPorUsuario.Checked) { AdministrarGrillas.Configurar(dtgDatosPerfiles, "PerfilID", this.CantidadOpciones); IUsuarios perfiles = UsuariosFactory.GetUsuario(); perfiles.UsuarioID = cUsuario.UsuarioID.Trim().Equals("")?0:Convert.ToInt32(cUsuario.UsuarioID.Trim()); DsPerfil dsPerfiles = perfiles.GetPerfilesAsignadosByUsuarioID(); this.dtgDatosPerfiles.DataSource = dsPerfiles; this.dtgDatosUsuarios.CurrentPageIndex = currentPage; this.dtgDatosPerfiles.DataBind(); perfiles = null; dsPerfiles = null; this.dtgDatosPerfiles.Visible = true; } else if (!this.rbPerfilesPorPermiso.Checked) { this.dtgDatosPerfiles.Visible = false; } #endregion Page.RegisterStartupScript("mostrar", "<script language='javascript'>VisualizarGrilla();\n</script>"); } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); DsPerfil ds = new DsPerfil(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "DatosDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }