protected void btnGuardar_Click1(object sender, EventArgs e) { //Validar Campos en Blanco if (txtdescripcion.Value.Trim().Equals(string.Empty)) { //se agrega el label que indique lo que no hay datos lblGuardar.InnerText = "Debe ingresar datos"; lblGuardar.Visible = true; } else { lblGuardar.Visible = false; Cls_Rol_DAL Obj_Rol_DAL = new Cls_Rol_DAL(); Cls_Rol_BLL Obj_Rol_BLL = new Cls_Rol_BLL(); Obj_Rol_DAL.sDescripcion = this.txtdescripcion.Value.ToString(); if ((BD)Session["tipo"] == BD.Actualizar) { Obj_Rol_DAL.bIdRol = Convert.ToByte(this.txtRoles.Value); // Si se edita se debe de obtener el ID Obj_Rol_BLL.crudRol(ref Obj_Rol_DAL, BD.Actualizar); } else if ((BD)Session["tipo"] == BD.Insertar) { Obj_Rol_BLL.crudRol(ref Obj_Rol_DAL, BD.Insertar); } Response.Redirect(pantallaMantenimiento, true); } //Validar campos en Blanco }
//boton modificar protected void btnEditar_Click(object sender, EventArgs e) { //Recorre Grid buscando chk foreach (GridViewRow row in PersonaGridView.Rows) { //busca el la fila if (row.RowType == DataControlRowType.DataRow) { //si esta checkeado instancia las propiedades del objeto if ((row.Cells[0].FindControl("chkRow") as CheckBox).Checked) { //Se instancia objeto Obj_Persona_DAL = new Cls_Persona_DAL(); //Secion tipo Editar Session["tipo"] = BD.Actualizar; Obj_Persona_DAL.sIdPersona = row.Cells[0].Text; Obj_Persona_DAL.sNombre = WebUtility.HtmlDecode(row.Cells[1].Text); Obj_Persona_DAL.sDireccion = WebUtility.HtmlDecode(row.Cells[2].Text); // INICIO: Obtener Rol Cls_Rol_BLL Obj_Rol_BLL = new Cls_Rol_BLL(); Cls_Rol_DAL Obj_Rol_DAL = new Cls_Rol_DAL(); Obj_Rol_DAL.sDescripcion = row.Cells[3].Text; Obj_Rol_BLL.crudRol(ref Obj_Rol_DAL, BD.Filtrar); Obj_Persona_DAL.bIdRol = Convert.ToByte(Obj_Rol_DAL.DS.Tables[0].Rows[0][0].ToString()); // FIN: Obtener Rol //Sesion persona lleva el objeto Session["Persona"] = Obj_Persona_DAL; Response.Redirect(pantallaMantenimiento, false); } } } }
protected void btnEliminar_Click(object sender, EventArgs e) { if (vFiltra) { Obj_Rol_DAL = new Cls_Rol_DAL(); //Recorre Grid buscando chk foreach (GridViewRow row in RolesGridView.Rows) { //busca el la fila if (row.RowType == DataControlRowType.DataRow) { //si esta checkeado instancia las propiedades del objeto CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox); if (chkRow.Checked) { Obj_Rol_DAL.bIdRol = Convert.ToByte(row.Cells[0].Text); //llamado metodo eliminar estados Obj_Rol_BLL.crudRol(ref Obj_Rol_DAL, BD.Eliminar);// eliminar estados } } } if (Obj_Rol_DAL.SMsjError == string.Empty) { this.errorMensaje.InnerHtml = "Rol Eliminado con exito."; this.BindGrid(); } else { this.errorMensaje.InnerHtml = "Se presento un error a la hora de Eliminar Rol."; this.BindGrid(); } } }
protected void btnEditar_Click(object sender, EventArgs e) { //Recorre Grid buscando chk foreach (GridViewRow row in RolesGridView.Rows) { //busca el la fila if (row.RowType == DataControlRowType.DataRow) { //si esta checkeado instancia las propiedades del objeto CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox); if (chkRow.Checked) { //Se instancia objeto Obj_Rol_DAL = new Cls_Rol_DAL(); Obj_Rol_DAL.bIdRol = Convert.ToByte(row.Cells[0].Text.Trim()); Obj_Rol_DAL.sDescripcion = row.Cells[1].Text.Trim(); //Secion tipo Editar Session["tipo"] = BD.Actualizar; //Sesion estado lleva el objeto Session["Rol"] = Obj_Rol_DAL; Response.Redirect(pantallaMantenimiento, false); } } } }
private void BindGrid() { //Se instancia objeto Obj_Rol_DAL = new Cls_Rol_DAL(); if (this.txtFiltrar.Value == string.Empty)//listar { //llamado metodo listar roles Obj_Rol_BLL.crudRol(ref Obj_Rol_DAL, BD.Listar); } else { Obj_Rol_DAL.sDescripcion = this.txtFiltrar.Value; //llamado metodo listar roles Obj_Rol_BLL.crudRol(ref Obj_Rol_DAL, BD.Filtrar); } if (Obj_Rol_DAL.SMsjError == string.Empty) { //Carga de Grid con DataSet instanciado en DAL this.RolesGridView.DataSource = Obj_Rol_DAL.DS.Tables[0]; this.RolesGridView.DataBind(); } else { this.errorMensaje.InnerHtml = "Se presento un error a la hora de listar Estados."; this.BindGrid(); } }
private void CargarRoles() { Cls_Rol_DAL Obj_Rol_DAL = new Cls_Rol_DAL(); Obj_Rol_BLL.crudRol(ref Obj_Rol_DAL, BD.Listar); DropDownRol.DataSource = Obj_Rol_DAL.DS.Tables[0]; DropDownRol.DataTextField = "Descripcion"; DropDownRol.DataValueField = "IdRol"; DropDownRol.DataBind(); }
public void crudRol(ref Cls_Rol_DAL Obj_Rol_DAL, BD Accion) { // Se instancia el Objeto de CatalogosMantenimientosClient (WCF) CatalogosMantenimientosClient Obj_Rol_Client = new CatalogosMantenimientosClient(); try { // Se abre la conexion al servicio Obj_Rol_Client.Open(); // Se cargan trae el DataTable y se carga al Obj_Rol_DAL string sMsjError = string.Empty; switch (Accion) { case BD.Actualizar: Obj_Rol_Client.actualizarRol(Obj_Rol_DAL.bIdRol, Obj_Rol_DAL.sDescripcion, ref sMsjError); break; case BD.Eliminar: Obj_Rol_Client.eliminarRol(Obj_Rol_DAL.bIdRol, ref sMsjError); break; case BD.Filtrar: Obj_Rol_DAL.DS.Tables.Add(Obj_Rol_Client.filtrarRol(Obj_Rol_DAL.bIdRol, Obj_Rol_DAL.sDescripcion, ref sMsjError)); break; case BD.Insertar: Obj_Rol_Client.insertarRol(Obj_Rol_DAL.sDescripcion, ref sMsjError); break; case BD.Listar: Obj_Rol_DAL.DS.Tables.Add(Obj_Rol_Client.listarRol(ref sMsjError)); break; default: break; } Obj_Rol_DAL.SMsjError = sMsjError; } catch (Exception ex) { Obj_Rol_DAL.SMsjError = ex.Message.ToString(); } finally { if (Obj_Rol_Client.State == System.ServiceModel.CommunicationState.Opened) { Obj_Rol_Client.Close(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.txtRoles.Disabled = true; if ((BD)Session["tipo"] == BD.Actualizar) { Cls_Rol_DAL rol = (Cls_Rol_DAL)Session["Rol"]; this.mantenimiento.InnerHtml = "Modificacion de Roles"; this.txtRoles.Value = rol.bIdRol.ToString(); this.txtdescripcion.Value = WebUtility.HtmlDecode(rol.sDescripcion); } else if ((BD)Session["tipo"] == BD.Insertar) { lbltxtroles.Visible = false; this.mantenimiento.InnerHtml = "Nuevos Roles"; this.txtRoles.Visible = false; // Este campo es Identity se debe de ocultar al ser nuevo this.txtRoles.Value = string.Empty; this.txtdescripcion.Value = string.Empty; } } }