protected void btnEliminar_Click(object sender, EventArgs e) { PerfilDTO obj = new PerfilDTO(); PerfilDAO objDAO = new PerfilDAO(); if (this.txtIdPerfil.Text != "") { objDAO.Eliminar(Convert.ToInt32(this.txtIdPerfil.Text)); } Listar(); }
protected void btnActualizar_Click(object sender, EventArgs e) { PerfilDTO obj = new PerfilDTO(); PerfilDAO objDAO = new PerfilDAO(); obj = objDAO.ListarPorClave(Convert.ToInt32(this.txtIdPerfil.Text)); obj.NombrePerfil = this.txtNombrePerfil.Text; if (this.chkEstado.Checked) obj.Estado = "1"; else obj.Estado = "0"; objDAO.Actualizar(obj); this.lblMensaje.Text = "Se actualizo el registro"; }
protected void ListarPerfiles(int idUsuario) { List<PerfilDTO> objPerfil; UsuarioPerfilDTO objUsuarioPerfilDTO; PerfilDAO objPerfilDAO = new PerfilDAO(); UsuarioPerfilDAO objUsuarioPerfilDAO = new UsuarioPerfilDAO(); try { //CARGAR PERFILES tvwPerfiles.Nodes.Clear(); objPerfil = objPerfilDAO.Listar(); foreach (PerfilDTO perfil in objPerfil) { if (perfil.Estado.Equals("1")) { TreeNode nodo1 = new TreeNode((string)perfil.NombrePerfil); nodo1.Value = perfil.IdPerfil.ToString(); tvwPerfiles.Nodes.Add(nodo1); //VERIFICAR SI USUARIO TIENE PERFIL ASIGNADO int idPerfil = perfil.IdPerfil; objUsuarioPerfilDTO = objUsuarioPerfilDAO.ListarPorClave(idUsuario, idPerfil); if (objUsuarioPerfilDTO.IdPerfil > 0) nodo1.Checked = true; } } } catch (Exception err) { throw (err); } }
protected void Listar() { List<PerfilDTO> obj; PerfilDAO objDAO = new PerfilDAO(); try { obj = objDAO.Listar(); this.gvLista.DataSource = obj; this.gvLista.DataBind(); } catch (Exception err) { throw (err); } }
protected void gvLista_SelectedIndexChanged(object sender, EventArgs e) { PerfilDAO objDAO = new PerfilDAO(); PerfilDTO obj; try { this.txtIdPerfil.Text = gvLista.SelectedRow.Cells[0].Text; obj = objDAO.ListarPorClave(Convert.ToInt32(this.txtIdPerfil.Text)); this.txtNombrePerfil.Text = obj.NombrePerfil; if (obj.Estado == "1") this.chkEstado.Checked = true; else this.chkEstado.Checked = false; this.panRegistro.Visible = true; this.panLista.Visible = false; this.panFunciones.Visible = true; this.btnGrabar.Visible = false; this.btnActualizar.Visible = true; this.btnEliminar.Visible = true; this.btnCancelar.Visible = true; List<PerfilFuncionDTO> ListaPerfilFuncionDTO = objPerfilFuncionDAO.ListarPorPerfil(Convert.ToInt32(this.txtIdPerfil.Text)); this.gvListaFuncion.DataSource = ListaPerfilFuncionDTO; this.gvListaFuncion.DataBind(); //LISTAR FUNCIONES ListarFunciones(obj.IdPerfil); } catch (Exception err) { this.lblMensaje.Text = err.Message.ToString(); } }
protected void gvListaFuncion_SelectedIndexChanged(object sender, EventArgs e) { PerfilDAO objDAO = new PerfilDAO(); PerfilDTO obj; try { this.txtIdPerfil.Text = gvLista.SelectedRow.Cells[0].Text; obj = objDAO.ListarPorClave(Convert.ToInt32(this.txtIdPerfil.Text)); this.txtNombrePerfil.Text = obj.NombrePerfil; if (obj.Estado == "1") this.chkEstado.Checked = true; else this.chkEstado.Checked = false; } catch (Exception err) { this.lblMensaje.Text = err.Message.ToString(); } }
protected void btnGrabar_Click(object sender, EventArgs e) { PerfilDTO obj = new PerfilDTO(); PerfilDAO objDAO = new PerfilDAO(); if (this.txtIdPerfil.Text == "") { obj.NombrePerfil = this.txtNombrePerfil.Text; if (this.chkEstado.Checked) obj.Estado = "1"; else obj.Estado = "0"; int id = objDAO.Agregar(obj); this.txtIdPerfil.Text = id.ToString(); this.lblMensaje.Text = "Se registro el Perfil"; ///////////////77 obj = objDAO.ListarPorClave(Convert.ToInt32(this.txtIdPerfil.Text)); this.txtNombrePerfil.Text = obj.NombrePerfil; if (obj.Estado == "1") this.chkEstado.Checked = true; else this.chkEstado.Checked = false; this.panRegistro.Visible = true; this.panLista.Visible = false; this.panFunciones.Visible = true; this.btnGrabar.Visible = false; this.btnActualizar.Visible = true; this.btnEliminar.Visible = true; this.btnCancelar.Visible = true; //LISTAR FUNCIONES ListarFunciones(obj.IdPerfil); } else { obj = objDAO.ListarPorClave(Convert.ToInt32(this.txtIdPerfil.Text)); obj.NombrePerfil = this.txtNombrePerfil.Text; if (this.chkEstado.Checked) obj.Estado = "1"; else obj.Estado = "0"; objDAO.Actualizar(obj); this.lblMensaje.Text = "Se actualizo el registro"; } Listar(); }