I currently have a grid that is automatically filled when I open the form, but when writing in the txt (code of the extinguisher) I need to filter in the grid depending on the id_extintor with the data already loaded in the grid (without connection to the database).
loading the grid first generated the dataset, then the datatable what I want to achieve is to filter the datagridview with the data already in it to avoid an overload of back and forth to the server, every time I write a number.
I currently load the grid in a class and I call it when I open the form.
private void cargar()
{
grillas grilla = new grillas();
grilla.llenargrillaextintorsincliente(grilla_cliente);
}
//
public void llenargrillaextintorsincliente(DataGridView grillaparticular)
{
try
{
//ejecuta sentencia sql y abre conexion
int asignado = 2;
int estado = 1;
MySqlCommand cmd = new MySqlCommand("select a.id_extintor,a.rut_cliente,a.fecha_recarga,a.fecha_vencimiento as vencimiento,b.descripcion_kilo as kilo,c.descripcion_tipo as tipo,d.descripcion_estado as estado,e.descripcion_asignado as asignado from tb_extintores a INNER JOIN tb_kilos_extintor b ON a.id_kilo = b.id_kilo INNER JOIN tb_tipo_extintor c ON a.id_tipo = c.id_tipo INNER JOIN tb_estado d ON a.id_estado = d.id_estado INNER JOIN tb_extintor_asignado e ON a.id_asignado = e.id_asignado where a.id_asignado = '" + asignado + "' AND a.id_estado ='"+estado+"'", conexion.obtenerConexion());
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
// devuelve la los datos a la grilla
grillaparticular.DataSource = dt;
}
catch (Exception f)
{
MessageBox.Show("error");
}
finally
{
// con.Close();
conexion.obtenerConexion().Close();
}
}