Esempio n. 1
0
        private void BusquedaProductos()
        {
            DataTable dt = new DataTable();

            try
            {
                P.Marca = txtBuscarProducto.Text;
                dt      = P.BusquedaProductos(P.Marca);
                dataGridView1.Rows.Clear();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dataGridView1.Rows.Add(dt.Rows[i][0]);
                    dataGridView1.Rows[i].Cells[0].Value = dt.Rows[i][0].ToString();
                    dataGridView1.Rows[i].Cells[1].Value = dt.Rows[i][1].ToString();
                    dataGridView1.Rows[i].Cells[2].Value = dt.Rows[i][2].ToString();
                    dataGridView1.Rows[i].Cells[3].Value = dt.Rows[i][3].ToString();
                    dataGridView1.Rows[i].Cells[4].Value = dt.Rows[i][4].ToString();
                    dataGridView1.Rows[i].Cells[5].Value = dt.Rows[i][5].ToString();
                    dataGridView1.Rows[i].Cells[6].Value = dt.Rows[i][6].ToString();
                    dataGridView1.Rows[i].Cells[7].Value = Convert.ToDateTime(dt.Rows[i][7].ToString()).ToShortDateString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dataGridView1.ClearSelection();
        }
Esempio n. 2
0
 private void txtBuscarProducto_TextChanged(object sender, EventArgs e)
 {
     if (txtBuscarProducto.TextLength > 0)
     {
         DataTable dt = new DataTable();
         P.Producto = txtBuscarProducto.Text;
         dt         = P.BusquedaProductos(P.Producto);
         try
         {
             dataGridView1.Rows.Clear();
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 dataGridView1.Rows.Add(dt.Rows[i][0]);
                 dataGridView1.Rows[i].Cells[0].Value = dt.Rows[i][0].ToString();
                 dataGridView1.Rows[i].Cells[1].Value = dt.Rows[i][1].ToString();
                 dataGridView1.Rows[i].Cells[2].Value = dt.Rows[i][2].ToString();
                 dataGridView1.Rows[i].Cells[3].Value = dt.Rows[i][3].ToString();
                 dataGridView1.Rows[i].Cells[4].Value = dt.Rows[i][4].ToString();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         dataGridView1.ClearSelection();
     }
     else
     {
         CargarListado();
     }
 }