コード例 #1
0
ファイル: EditarFactura.cs プロジェクト: frijey/JMB-SALON
        public void RealizarBusqueda()
        {
            Buscar_Producto.busqueda = tbproducto.Text;
            Form f = new Buscar_Producto();

            f.ShowDialog();

            if (probuscar)
            {
                try
                {
                    dt = oper.ExtraeData("SELECT id, nombre, precio FROM producto WHERE id = '" + idproducto + "';");
                    dataGridView2.DataSource = dt;
                    dataGridView2.Refresh();

                    //Agregar el Producto al Grid Visual
                    dataGridView1detalle.Rows.Add();

                    dataGridView1detalle.Rows[numproducto].Cells[0].Value = dataGridView2.Rows[0].Cells[0].Value;                  //id producto buscado
                    dataGridView1detalle.Rows[numproducto].Cells[1].Value = dataGridView2.Rows[0].Cells[1].Value;                  //nombre producto buscado
                    dataGridView1detalle.Rows[numproducto].Cells[2].Value = 1;                                                     //cantidad producto buscado default 1
                    dataGridView1detalle.Rows[numproducto].Cells[3].Value = Convert.ToInt32(dataGridView2.Rows[0].Cells[2].Value); //precio
                    dataGridView1detalle.Rows[numproducto].Cells[4].Value = dataGridView2.Rows[0].Cells[2].Value;                  //total

                    tbproducto.Text = "";                                                                                          //Para limpiar el cuadro de texto de buscar.

                    numproducto++;                                                                                                 // Para hacer que el número de produto incremente y se agregue en la siguiente fila.
                    rastreonum.Text = numproducto.ToString();

                    probuscar = false; // Para cerrar la búsqueda

                    modificado          = true;
                    btnimprimir.Enabled = false;
                    btnguardar.Enabled  = true;
                }
                catch (Exception)
                {
                    MessageBox.Show("Error al agregar producto, inténtelo de nuevo", "Agregar");
                    return;
                }

                ActualizarTotales();
            }
            else
            {
                ActualizarTotales();
            }
            ActualizarTotales();
        }
コード例 #2
0
ファイル: facturar.cs プロジェクト: frijey/JMB-SALON
        public void RealizarBusqueda()
        {
            Buscar_Producto.busqueda = tbproducto.Text;
            Form f = new Buscar_Producto();

            f.ShowDialog();

            if (probuscar)
            {
                try
                {
                    dt = oper.ExtraeData("SELECT id, nombre, precio FROM producto WHERE id = '" + idproducto + "';");
                    dataGridView1.DataSource = dt;
                    dataGridView1.Refresh();

                    agregandoproducto = true;
                    dataGridView1detalle.Rows.Add();

                    dataGridView1detalle.Rows[numproducto].Cells[0].Value = dataGridView1.Rows[0].Cells[0].Value;                  //id producto buscado
                    dataGridView1detalle.Rows[numproducto].Cells[1].Value = dataGridView1.Rows[0].Cells[1].Value;                  //nombre producto buscado
                    dataGridView1detalle.Rows[numproducto].Cells[2].Value = 1;                                                     //cantidad producto buscado default 1
                    dataGridView1detalle.Rows[numproducto].Cells[3].Value = Convert.ToInt32(dataGridView1.Rows[0].Cells[2].Value); //precio
                    dataGridView1detalle.Rows[numproducto].Cells[4].Value = dataGridView1.Rows[0].Cells[2].Value;                  //total
                    numproducto++;                                                                                                 // Para hacer que el número de produto incremente y se agregue en la siguiente fila.
                    tbproducto.Text = "";
                    //totalfactura += Convert.ToInt32(dataGridView1.Rows[0].Cells[2].Value); //Para ir sumando el total

                    probuscar = false; // Para cerrar la búsqueda

                    agregandoproducto = false;
                    ActualizarTotales();
                }
                catch (Exception)
                {
                    MessageBox.Show("Error al agregar producto, inténtelo de nuevo", "Agregar");
                    return;
                }
                ActualizarTotales();
            }
            else
            {
                ActualizarTotales();
            }
            ActualizarTotales();
        }