Beispiel #1
0
        private void btnVenderProducto_Click(object sender, EventArgs e)
        {
            Detalle pDetalle = new Detalle();

            bool[] numerico = new bool[] { true }; // Para verificar si es numerico
            numerico[0] = Numerico.EsNumericoFloat(textoCant.Text.Trim());

            if (textoCant.Text.Trim() != "" && comboBoxProducto.Text.Trim() != "" && comboBoxCliente.Text.Trim() != "")
            {
                if (numerico[0] == true)
                {
                    DataTable dt  = TablaDetalle.obtenerFact(comboBoxCliente.Text.Trim());
                    DataRow   row = dt.Rows[0];
                    pDetalle.Factura_idFactura    = Convert.ToString(row["idFactura"]);
                    pDetalle.Productos_idProducto = comboBoxProducto.Text.Trim();
                    pDetalle.Cantidad             = textoCant.Text.Trim();
                    int resultado2 = TablaDetalle.AgregarDetalle(pDetalle);
                    comboBoxProducto.Text = "";
                    textProducto.Text     = "";
                    textoCant.Text        = "";
                    MessageBox.Show("Producto Vendido");
                }
                else
                {
                    MessageBox.Show("El campo de texto con asterisco, Deben de ser numeros enteros");
                }
            }
            else
            {
                MessageBox.Show("Debe de rellenar los campos con asterisco");
            }
        }
Beispiel #2
0
        public static int AgregarDetalle(Detalle pDetalle)
        {
            int retorno = 0;

            // INSERT INTO `detalle`(`idDetalle`, `Factura_idFactura`, `Productos_idProducto`, `Cantidad`, `Precio`) VALUES ([value-1],[value-2],[value-3],[value-4],[value-5])

            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO `detalle`(`idDetalle`, `Factura_idFactura`, `Productos_idProducto`, `Cantidad`) VALUES ('{0}','{1}','{2}','{3}')",
                                                                  pDetalle.idDetalle, pDetalle.Factura_idFactura, pDetalle.Productos_idProducto, pDetalle.Cantidad), BDConexion.ObtenerConexion());

            retorno = comando.ExecuteNonQuery();

            return(retorno);
        }