//Vendido Tab private void button8_Click(object sender, EventArgs e) { //Updating Producto Vendido ProductNonQuery.ProductQueryStock0(dataGridView3); //Updating ganancias ProductNonQuery.ProductQueryGain(dataGridView1); }
//Actualizar ventas del dia btn private void button12_Click(object sender, EventArgs e) { //Updating Ventas del dia table ProductNonQuery.ProductQuerySecondT(dataGridView2); //Ganancias //Updating ganancias ProductNonQuery.ProductQueryGainT2(dataGridView6); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios"); } else { ProductNonQuery.DeleteProduct(textBox1.Text); } }
private void cmbProduct() { // Actualizar ComboBox 1 comboBox1.DataSource = null; comboBox1.ValueMember = "idProducto"; comboBox1.DisplayMember = "nombre"; comboBox1.DataSource = ProductNonQuery.getLista(); // Actualizar ComboBox 2 comboBox2.DataSource = null; comboBox2.ValueMember = "idProducto"; comboBox2.DisplayMember = "nombre"; comboBox2.DataSource = ProductNonQuery.getLista(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("") || textBox2.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios"); } else { int idBusiness = BusinessNonQuery.BusinessQuery(textBox2.Text); ProductNonQuery.AddProduct(idBusiness, textBox1.Text); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("") || textBox2.Text.Equals("") || textBox3.Text.Equals("") || textBox4.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios"); } else { //Agregando producto: ProductNonQuery.AddProduct(textBox1.Text, textBox2.Text, "0", textBox3.Text, textBox4.Text, "0", "0", "0", "0"); //int idProduct = ProductNonQuery.idProduct(textBox1.Text); ProductNonQuery.UpdateProduct(textBox1.Text); } }
//Pedir private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("") || textBox2.Text.Equals("")) { MessageBox.Show("No se pueden dejar campos vacios"); } else { string createdate = textBox1.Text; var Product = comboBox2.SelectedItem.ToString(); int idProduct = ProductNonQuery.ProductQueryid(Product); int idUser = UserNonQuery.UserQueryId(textBox2.Text); int idAddress = AddressNonQuery.AddressQueryId(idUser); OrderNonQuery.AddOrder(createdate, idProduct, idAddress); } }
//Sell Button (Sell Tab) private void button1_Click(object sender, EventArgs e) { Product p = new Product(); ProductNonQuery.getLista().ForEach(product => { if (comboBox1.SelectedValue.Equals(product.idProducto)) { p = product; } }); if (p.stock_actual == 0) { MessageBox.Show("Ya no hay " + p.nombre + " disponible", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (Convert.ToDecimal(textBox1.Text) > p.stock_actual) { MessageBox.Show("Solamente hay: " + p.stock_actual + " de " + p.nombre + ", no se pueden vender " + textBox1.Text, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (p.stock_actual != 0) { try { ConnectionDB.ExecuteNonQuery($"UPDATE GANANCIA SET cantidad_vendida = (cantidad_vendida)+'{textBox1.Text}' WHERE idProducto = '{comboBox1.SelectedValue}';"); MessageBox.Show("Se vendio " + textBox1.Text + " de " + p.nombre); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error actualizando"); } //Agregando a t3 try { decimal ganancia; ganancia = (Convert.ToDecimal(textBox1.Text) * p.precio_unidad_venta) - (Convert.ToDecimal(textBox1.Text) * p.precio_unidad_compra); ConnectionDB.ExecuteNonQuery($"INSERT INTO GANANCIADIAARTICULO (nombre, cantidad_vendida, ganancia) VALUES('{p.nombre}', '{textBox1.Text}', '{ganancia}');"); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error actualizando T2 "); } try { ConnectionDB.ExecuteNonQuery($"UPDATE GANANCIA SET stock_actual = stock_actual-{textBox1.Text} WHERE idProducto = {comboBox1.SelectedValue};"); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error actualizando"); } try { ConnectionDB.ExecuteNonQuery($"UPDATE GANANCIA SET precio_venta_acumulado = (precio_unidad_venta * cantidad_vendida) WHERE idProducto = {comboBox1.SelectedValue};"); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error actualizando"); } try { ConnectionDB.ExecuteNonQuery($"UPDATE GANANCIA SET ganancia = (precio_unidad_venta*cantidad_vendida)-(precio_unidad_compra*cantidad_vendida) WHERE idProducto = {comboBox1.SelectedValue};"); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error actualizando"); } } }
//Actualizar Historial de ventas private void button4_Click(object sender, EventArgs e) { //Updating Ventas historial ProductNonQuery.ProductQueryT3(dataGridView4); }
//Update Product btn private void button10_Click(object sender, EventArgs e) { ProductNonQuery.UpdateProductStock(Convert.ToInt32(comboBox1.SelectedValue), Convert.ToInt32(textBox2.Text)); }
private void button11_Click(object sender, EventArgs e) { //Updating Product Table ProductNonQuery.ProductQueryAll(dataGridView5); }
private void button9_Click(object sender, EventArgs e) { //Updating Producto Vendido ProductNonQuery.ProductQueryStock0(dataGridView5); }
private void button2_Click(object sender, EventArgs e) { ProductNonQuery.ProductQuery(dataGridView2); }