protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals(ComandosGrid.Editar.Value)) { int RowIndex = Convert.ToInt32((e.CommandArgument).ToString()); GridViewRow gvrow = GridView1.Rows[RowIndex]; hdfEditID.Value = Utilidades_GridView.DevolverIdRow(e, GridView1); var _Categoria = Mgr_Categoria.Get_Categoria(Convert.ToInt32(hdfEditID.Value)); txtNombreEdit.Text = _Categoria.nombre; txtDescripcionEdit.Text = _Categoria.descripcion; ddlEmpresaEdit.SelectedValue = Convert.ToString(_Categoria.id_empresa); Modal.registrarModal("editModal", "EditModalScript", this); } if (e.CommandName.Equals(ComandosGrid.Eliminar.Value)) { int RowIndex = Convert.ToInt32((e.CommandArgument).ToString()); GridViewRow gvrow = GridView1.Rows[RowIndex]; hdfIDDel.Value = Utilidades_GridView.DevolverIdRow(e, GridView1); Modal.registrarModal("deleteModal", "DeleteModalScript", this); } }
protected void Guardar(object sender, EventArgs e) { int idCategoria = 0; if (ddlCategoriaAdd.SelectedValue == "Otro") { categoria nuevo = new categoria() { nombre = txtCatAddOtro.Text, descripcion = txtCatAddOtro.Text, id_empresa = ObjUsuario.Id_empresa }; Capa_Datos.CRUD.Add_Fila(nuevo); List <categoria> ListaCategoria = new List <categoria>(); ListaCategoria = Mgr_Categoria.Get_Categoria(txtCatAddOtro.Text); foreach (var item in ListaCategoria) { idCategoria = item.id_categorias; } } else { idCategoria = Convert.ToInt32(ddlCategoriaAdd.SelectedValue); } int IdUsuario = 0; if (ObjUsuario.isResponsable()) { IdUsuario = ObjUsuario.Id_usuario; } else { IdUsuario = Convert.ToInt32(ddlUsuAdd.SelectedValue); } alarma nuevoAlarma = new alarma() { descripcion = txtDescripcion.Text, fecha = Convert.ToDateTime(txtFecha.Text), prioridad = ddlPrioridadAdd.SelectedValue, id_categorias = idCategoria, id_usuario = IdUsuario }; ObjUsuario.Error = Capa_Datos.CRUD.Add_Fila(nuevoAlarma); Modal.MostrarAlertaAdd(phAlerta, divAlerta, lbAlerta, ObjUsuario.Error, txtBuscar); CargarListas(); LlenarGridView(); }