private void btnGuardar_Click(object sender, EventArgs e) { using (var form = new frmOrdenFinalizadaTarjeta()) { var result = form.ShowDialog(); if (result == DialogResult.OK) { this.DialogResult = DialogResult.OK; } } Decimal total = Convert.ToDecimal(mskTotal.Text); Decimal iva = decimal.Round(total * 0.12m, 2); Decimal subototal = total - iva; try { objFactura.insertarFactura(Global.IdUsuario, Global.IdCliente, DateTime.Now, tipoDePago, subototal, iva, total); int idSiguiente = objFactura.consultarUltimoIDFactura(); foreach (clsDetalle detalle in ListaDeDetalles) { objDetalle.insertarDetalle(idSiguiente, detalle.IdPlato, detalle.Cantidad, detalle.Precio); } } catch (Exception ex) { MessageBox.Show("Error al guardar en la base de datos"); } this.Dispose(); }
private void btnGuardar_Click(object sender, EventArgs e) { if (mskEfectivo.Text != string.Empty) { decimal efectivo = Convert.ToDecimal(mskEfectivo.Text); if (efectivo > totalFactura) { decimal cambio = (efectivo - totalFactura); using (var form = new frmOrdenFinalizada(cambio)) { var result = form.ShowDialog(); if (result == DialogResult.OK) { this.DialogResult = DialogResult.OK; } } Decimal total = Convert.ToDecimal(mskTotal.Text); Decimal iva = decimal.Round(total * 0.12m, 2); Decimal subototal = total - iva; try { objFactura.insertarFactura(Global.IdUsuario, Global.IdCliente, DateTime.Now, tipoDePago, subototal, iva, total); int idSiguiente = objFactura.consultarUltimoIDFactura(); foreach (clsDetalle detalle in ListaDeDetalles) { objDetalle.insertarDetalle(idSiguiente, detalle.IdPlato, detalle.Cantidad, detalle.Precio); } } catch (Exception ex) { MessageBox.Show("Error al guardar en la base de datos"); } this.Dispose(); } else { MessageBox.Show("El efectivo ingresado es menor al total de la orden"); } } else { MessageBox.Show("ESCRIBA EL EFECTIVO QUE LE DIO EL CLIENTE"); } }