C sharp - botón de búsqueda y datagrid en C #

 
Vista:
Imágen de perfil de Antonio
Val: 2
Ha disminuido su posición en 71 puestos en C sharp (en relación al último mes)
Gráfica de C sharp

botón de búsqueda y datagrid en C #

Publicado por Antonio (4 intervenciones) el 11/10/2016 23:24:52
Hola a todos
 
Tengo un botón de búsqueda y cuadrícula de datos en C #, requiero realizar una consulta en la base de datos y cargar los datos en mí datagrid

como puedo cargar los datos de nuevo mi búsqueda datagrid

es mi código

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
conexion.ConnectionString = @"Data Source = SHINIL-PC040\SQLEXPRESS; Initial Catalog = produccion; Integrated Security = True";
            if(TXTORDEN_PRODUCCION.Text == "" || TXTTURNO.Text == "" || TXTMAQUINAS.Text == "" || TXTHORAINICIO.Text == "" || TXTHORAFIN.Text == "")
            {
                MessageBox.Show("Te falta campo");
            }
            else
            {
 
                if (checkBox1.Checked == true)
                {
                    try
                    {
 
                        comando.Connection = conexion;
                        conexion.Open();
                        string SqlAction = "select orden, turno, operador, horainicio, horafin, articulo, totalpiezasok, totalcajas, piezascondefecto, maquina from conteo2 where CONVERT(varchar(10), horafin, 108) >= @horainicio and CONVERT(varchar(10), horafin, 108)<= @horafin and orden = @orden  and turno = @turno and maquina = @maquina ";
                        // "SELECT MOLDE, PROYECTO, ITEMPARTE, COLOR, SNP FROM PARTE WHERE ITEMPARTE = @ITEMPARTE";  
                        SqlCommand cmd = new SqlCommand(SqlAction, conexion);
                        cmd.Parameters.AddWithValue("@orden", TXTORDEN_PRODUCCION.Text);
                        cmd.Parameters.AddWithValue("@turno", TXTTURNO.Text);
                        cmd.Parameters.AddWithValue("@maquina", TXTMAQUINAS.Text);
                        cmd.Parameters.AddWithValue("@horainicio", TXTHORAINICIO.Text);
                        cmd.Parameters.AddWithValue("@horafin", TXTHORAFIN.Text);
 
 
                        }
 
                        conexion.Close();
                    }
 
                    catch (Exception Ex)
                    {
                        MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
                MessageBox.Show("selecciono ok produccion");
                }
                if (checkBox2.Checked == true)
                {
                    MessageBox.Show("selecciono paros");
                }
                if (checkBox1.Checked == false & checkBox2.Checked == false)
                {
                    MessageBox.Show("tiene que seleccionar un reporte");
                }
            }
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 158
Bronce
Ha disminuido 1 puesto en C sharp (en relación al último mes)
Gráfica de C sharp

botón de búsqueda y datagrid en C #

Publicado por Yamil (1164 intervenciones) el 11/10/2016 23:52:32
Agrega despues de crear el ultimo parametro estas lineas
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
gridview.datasource=dt;
gridview.databind();
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar