private void btnimprimir_Click(object sender, EventArgs e) { string idcli = txtIdVenta.Text; if (idcli == "0") { MessageBox.Show("Por favor seleccione una boleta", "aviso"); } else { V_ReporteBoleta form = new V_ReporteBoleta(); form.idVenta = Convert.ToInt32(txtIdVenta.Text); form.Show(); } }
private void btnGuardar_Click(object sender, EventArgs e) { Int16 idCliente; Int16.TryParse(txtIdCliente.Text, out idCliente); if (idCliente == 0) { MessageBox.Show("Ingrese Cliente", "Aviso"); return; } if (dgvLista.Rows.Count == 0) { MessageBox.Show("Ingrese Productos /Servicios", "Aviso"); return; } Venta venta = new Venta(); venta.Cliente = new Cliente(); venta.VentaDetalles = new List <VentaDetalle>(); venta.FechaVenta = dtpFecha.Value; venta.Cliente.Idcliente = idCliente; venta.Serie = txtSerie.Text; venta.Numero = txtNumero.Text; venta.TipoComprobante = cboTipoComprobante.Text.Substring(0, 1); decimal igv = 0; decimal.TryParse(txtIGV.Text, out igv); venta.Igv = igv / 100; foreach (DataGridViewRow row in dgvLista.Rows) { VentaDetalle ventaDetalle = new VentaDetalle(); ventaDetalle.Producto = new Producto(); ventaDetalle.Producto.Idproducto = Int16.Parse(row.Cells["idpv"].Value.ToString()); ventaDetalle.Cantidad = Int32.Parse(row.Cells["cantidad"].Value.ToString()); ventaDetalle.PrecioUnitario = Decimal.Parse(row.Cells["preciopv"].Value.ToString()); venta.VentaDetalles.Add(ventaDetalle); } C_Venta C_venta = new C_Venta(); C_venta.insertar(venta); txtIdVenta.Text = venta.IdVenta.ToString(); MessageBox.Show("VENTA REALIZADA SATISFACTORIAMENTE", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult result = MessageBox.Show("¿Desea imprimir?", "Imprimir Documento", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { //---------------- imprimir-------------------------- try { string tipoComprobante = cboTipoComprobante.Text; if (tipoComprobante.CompareTo("FACTURA") == 0) { V_ReporteFactura form = new V_ReporteFactura(); form.idVenta = Convert.ToInt32(txtIdVenta.Text); form.Show(); } else { V_ReporteBoleta form = new V_ReporteBoleta(); form.idVenta = Convert.ToInt32(txtIdVenta.Text); form.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } //-------------------------------------------------------- } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { result = DialogResult.No; } { this.Close(); } }