I am working on a desktop application in Windows Forms and MySQL as a database manager.
How do you rest in inventories when you make a Sale?
That's the code I use for the save sales button. The data is added to a sale table, and the fields of the tables. The code works and saves me, but I want to subtract from the inventory.
Save button code:
private void button8_Click(object sender, EventArgs e)
{
Login.Venta_Tienda.VentaR pCliente = new Login.Venta_Tienda.VentaR();
pCliente.Idproducto_V = textBox1.Text.Trim();
pCliente.Producto_V = comboBox1.Text.Trim();
pCliente.Cantidad_V = textBox2.Text.Trim();
pCliente.Preciocxu_V = textBox3.Text.Trim();
pCliente.Total_V = textBox5.Text.Trim();
pCliente.Fechafac_V = dateTimePicker1.Value.Year
+ "/" + dateTimePicker1.Value.Month + "/" + dateTimePicker1.Value.Day;
int resultado = Login.Venta_Tienda.MetodosVenta.Agregarp(pCliente);
if (resultado > 0)
{
MessageBox.Show(
"Venta Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK,
MessageBoxIcon.Information
);
}
else
{
MessageBox.Show(
"No se pudo guardar el cliente", "Fallo!!", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation
);
}
}
Table fields ventatienda
:
Idventa Int,
Idproducto VARCHAR,
Producto VARCHAR,
Cantidad VARCHAR,
Preciocxu VARCHAR,
Total VARCHAR,
Fechafac VARCHAR
Table fields inventariomarket
:
campos INT,
IdProducto VARCHAR,
Producto VARCHAR,
Existencias VARCHAR,
Precioxunidad VARCHAR,
Proveedor VARCHAR,
Fecha_Recibido Date