/// <summary> /// Guardamos la venta en la base de datos /// </summary> private void GuardarVenta() { int id_pago = 0; //variable que almacena la forma de pago 1 = efectivo, 2 = tarjeta y 3 = ambos if (efectivo > 0) { id_pago = 1; } else if (tarjeta > 0) { id_pago = 2; } else if (tarjeta > 0 && efectivo > 0) { id_pago = 3; } try { using (GestorVenta venta = new GestorVenta()) { venta.InsertarVenta(id_cliente, id_usuario, fecha, id_pago, saldo, "A"); } } catch (Exception e) { MessageBox.Show("Error " + e); } }
private void btn_Agregar_Click(object sender, EventArgs e) { f1 = Date.Value.ToString("MM-dd-yyyy"); if (txtPrice.Text != "" || txtDetails.Text != "") { if (radioButton1.Checked) { precio = double.Parse(txtPrice.Text); } else { precio = double.Parse(txtPrice.Text); } using (GestorVenta insertbills = new GestorVenta()) { double amount = precio; if (txtGuys.Text != "0" && txtHours.Text != "0") { insertbills.InsertarVenta(id_lastbill, f1, txtDetails.Text + " Guys: " + txtGuys.Text + " Hours: " + txtHours.Text, Double.Parse(textUnitPrice.Text), amount); } else if (txtGuys.Text == "0" && txtHours.Text == "0" && textUnitPrice.Text != "0" && textUnits.Text != "0") { insertbills.InsertarVenta(id_lastbill, f1, txtDetails.Text + " Units: " + textUnits.Text, Double.Parse(textUnitPrice.Text), amount); } else { insertbills.InsertarVenta(id_lastbill, f1, txtDetails.Text, precio, amount); } MessageBox.Show("Sirve", caption: "Alerta", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information); CargarFactura(); CalcularTotales(); LimpiarCampos(); } } else { MessageBox.Show("LLenar todos los campos"); } }