protected void gdvRoles_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Editar") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gdvRoles.Rows[index]; String idRol = gdvRoles.Rows[index].Cells[2].Text; lblHeader.InnerText = "Editar Rol"; updpnlModalHeader.Update(); txtIdRol.Value = idRol; txtRol.Value = Server.HtmlDecode(gdvRoles.Rows[index].Cells[3].Text); txtDescripcion.Value = Server.HtmlDecode(gdvRoles.Rows[index].Cells[4].Text); CargarCombos(); CargarPrivilegios(Convert.ToInt16(idRol)); updpnlGrid.Update(); lblIdRol.Visible = true; txtIdRol.Visible = true; lblPrivilegios.Visible = true; gdvPrivilegios.Visible = true; cmbPrivilegios.Visible = true; btnAgregarPrivilegio.Visible = true; updpnlModal.Update(); } else if (e.CommandName == "Borrar") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gdvRoles.Rows[index]; String idRol = gdvRoles.Rows[index].Cells[2].Text; lblMensaje.Visible = false; Cls_Roles_BLL objBLL = new Cls_Roles_BLL(); Cls_Roles_DAL objDAL = new Cls_Roles_DAL(); objDAL.iId_Rol = Convert.ToInt32(idRol.Trim()); objBLL.Eliminar(ref objDAL); if (!string.IsNullOrEmpty(objDAL.sError)) { lblMensaje.Text = objDAL.sError; lblMensaje.Visible = true; lblMensaje.ForeColor = System.Drawing.Color.Red; } else { CargarRoles(); lblMensaje.Visible = true; lblMensaje.Text = "Registro eliminado correctamente"; lblMensaje.ForeColor = System.Drawing.Color.White; updpnlGrid.Update(); } } }
protected void btnGuardar_Click(object sender, EventArgs e) { try { lblMensaje.Visible = false; Cls_Roles_BLL objBLL = new Cls_Roles_BLL(); Cls_Roles_DAL objDAL = new Cls_Roles_DAL(); objDAL.sRol = txtRol.Value.ToString().Trim(); objDAL.sDescripcion = txtDescripcion.Value.ToString().Trim(); if (txtIdRol.Visible == false) { objDAL.cAccion = 'I'; objBLL.Insertar(ref objDAL); } else { objDAL.iId_Rol = Convert.ToInt32(txtIdRol.Value.ToString().Trim()); objDAL.cAccion = 'U'; objBLL.Editar(ref objDAL); } if (!string.IsNullOrEmpty(objDAL.sError)) { lblMensaje.Text = objDAL.sError; lblMensaje.Visible = true; lblMensaje.ForeColor = System.Drawing.Color.Red; } else { if (objDAL.cAccion == 'U') { ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowPopup", "alert('Registro editado correctamente');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowPopup", "alert('Registro agregado correctamente');", true); } CargarRoles(); } updpnlGrid.Update(); LimpiarCampos(); } catch (Exception ex) { lblMensaje.Visible = true; lblMensaje.Text = ex.Message.ToString(); } }
private void CargarRoles() { Cls_Roles_BLL objBLL = new Cls_Roles_BLL(); Cls_Roles_DAL objDAL = new Cls_Roles_DAL(); gdvRoles.DataSource = null; gdvRoles.DataBind(); objBLL.Listar(ref objDAL); if (objDAL.sError == string.Empty) { gdvRoles.SelectedIndex = -1; if (txtBuscar.Value == string.Empty) { gdvRoles.DataSource = objDAL.dtTabla; } else { DataTable dt = objDAL.dtTabla; EnumerableRowCollection <DataRow> query = from dtRoles in dt.AsEnumerable() where dtRoles.Field <string>("Rol").ToLower().Replace(" ", "").Contains(txtBuscar.Value.ToLower().Replace(" ", "")) select dtRoles; DataView view = query.AsDataView(); gdvRoles.DataSource = view; } gdvRoles.DataBind(); if (gdvRoles.Rows.Count > 0) { gdvRoles.Visible = true; lblMensaje.Visible = false; lblMensaje.Text = ""; } else { gdvRoles.Visible = false; lblMensaje.Visible = true; lblMensaje.Text = "No hay datos que mostrar"; } } else { lblMensaje.Text = objDAL.sError; } }
public void CargarCombos() { Cls_Roles_BLL objBLL = new Cls_Roles_BLL(); Cls_Roles_DAL objDAL = new Cls_Roles_DAL(); objBLL.Listar(ref objDAL); if (objDAL.sError == string.Empty) { cmbRoles.DataSource = null; cmbRoles.DataSource = objDAL.dtTabla; cmbRoles.DataTextField = "Rol"; cmbRoles.DataValueField = "Id_Rol"; cmbRoles.DataBind(); cmbRoles.SelectedIndex = 0; } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowPopup", "alert('Se presento un problema a la hora de cargar el combo de roles');", true); } }
public bool eliminarRol(byte bIdRol, ref string sMsj_error) { Cls_Roles_BLL Obj_Rol_BLL = new Cls_Roles_BLL(); return(Obj_Rol_BLL.Eliminar(bIdRol, ref sMsj_error)); }
public bool actualizarRol(byte bIdRol, string sDescripcion, ref string sMsj_error) { Cls_Roles_BLL Obj_Rol_BLL = new Cls_Roles_BLL(); return(Obj_Rol_BLL.Actualizar(bIdRol, sDescripcion, ref sMsj_error)); }
public string insertarRol(string sDescripcion, ref string sMsj_error) { Cls_Roles_BLL Obj_Rol_BLL = new Cls_Roles_BLL(); return(Obj_Rol_BLL.Insertar(sDescripcion, ref sMsj_error)); }
public DataTable filtrarRol(byte bIdRol, string sDescripcion, ref string sMsj_error) { Cls_Roles_BLL Obj_Rol_BLL = new Cls_Roles_BLL(); return(Obj_Rol_BLL.Filtrar(bIdRol, sDescripcion, ref sMsj_error)); }
public DataTable listarRol(ref string sMsj_error) { Cls_Roles_BLL Obj_Rol_BLL = new Cls_Roles_BLL(); return(Obj_Rol_BLL.Listar(ref sMsj_error)); }