public frmInsertarLibroVentas(int idUser, int pkLibro) { InitializeComponent(); this.Text = "Actualizar Libro de Ventas"; user = idUser; idLibro = pkLibro; libro = LibroVentasBLL.GetLibroVentasById(idLibro); txtMonth.Text = libro.txtMes; txtYear.Text = libro.txtAño; cargarDatosTabla(); gdDetalleLibroVentas.Refresh(); }
private void frmReporteLibroVenta_Load(object sender, EventArgs e) { ; // TODO: This line of code loads data into the 'detalleLibroVentasDS.DetalleLibroVentas' table. You can move, or remove it, as needed. libro = LibroVentasBLL.GetLibroVentasById(idLibro); List <DetalleLibroVentas> detalles = DetalleLibroVentasBLL.GetDetalleLibroVentasByIdLibro(libro.pkLibro); ReportDataSource dt = new ReportDataSource("LV", detalles); ReportParameter pYear = new ReportParameter("Year", libro.txtAño); ReportParameter pMonth = new ReportParameter("Month", libro.txtMes); this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { pYear }); this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { pMonth }); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(dt); this.reportViewer1.RefreshReport(); }
public frmVentas() { this.Text = "Realizar Venta"; InitializeComponent(); txtNombreCliente.GotFocus += txtNombreCliente_Click; objLiteral = new NumeralToLiteral(); fecha = DateTime.Now.Year + ""; fecha += DateTime.Now.Month + ""; fecha += DateTime.Now.Day + ""; llave = LlaveFacturaBLL.GetLastLlaveFactura(); lastFactura = FacturaBLL.GetLastFactura(); lastLibroVenta = LibroVentasBLL.GetLastLibroVentas(); listaProductos = new List <Producto>(); cargarBoxDescuentos(); sumaReal = 0; sumaDescuentos = 0; }
private void btnGuardar_Click(object sender, EventArgs e) { if (idLibro != 0) { foreach (DataGridViewRow fila in gdDetalleLibroVentas.Rows) { double total = Convert.ToDouble(fila.Cells["txtImporteTotal"].Value); double impuestos = Convert.ToDouble(fila.Cells["txtImpuestos"].Value); double excentos = Convert.ToDouble(fila.Cells["txtExcentos"].Value); double tasaCero = Convert.ToDouble(fila.Cells["txtImporteVentasTasaCero;"].Value); double subtotal = Convert.ToDouble(fila.Cells["txtSubTotal"].Value); double descuentos = Convert.ToDouble(fila.Cells["txtDescuentos"].Value); double baseDF = Convert.ToDouble(fila.Cells["txtImporteBaseDF"].Value); double debitoFiscal = Convert.ToDouble(fila.Cells["txtDebitoFiscal"].Value); if (fila.Cells["txtIdRegistro"].Value.ToString() != "-1") { DetalleLibroVentasBLL.UpdateDetalle(Convert.ToInt32(fila.Cells["txtIdRegistro"].Value), Convert.ToInt32(fila.Cells["txtNro"].Value), Convert.ToDateTime(fila.Cells["dateFechaFactura"].Value), fila.Cells["txtNroFactura"].Value.ToString(), fila.Cells["txtNroAutorizacion"].Value.ToString(), fila.Cells["txtEstado"].Value.ToString(), fila.Cells["txtNitCliente"].Value.ToString(), fila.Cells["txtNombreRazon"].Value.ToString(), Convert.ToDecimal(total), Convert.ToDecimal(impuestos), Convert.ToDecimal(excentos), Convert.ToDecimal(tasaCero), Convert.ToDecimal(subtotal), Convert.ToDecimal(descuentos), Convert.ToDecimal(baseDF), Convert.ToDecimal(debitoFiscal), fila.Cells["txtCodigoControl"].Value.ToString(), idLibro, user); } else { DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(Convert.ToInt32(fila.Cells["txtNro"].Value), Convert.ToDateTime(fila.Cells["dateFechaFactura"].Value), fila.Cells["txtNroFactura"].Value.ToString(), fila.Cells["txtNroAutorizacion"].Value.ToString(), fila.Cells["txtNitCliente"].Value.ToString(), fila.Cells["txtNombreRazon"].Value.ToString(), Convert.ToDecimal(total), Convert.ToDecimal(impuestos), Convert.ToDecimal(excentos), Convert.ToDecimal(tasaCero), Convert.ToDecimal(subtotal), Convert.ToDecimal(descuentos), Convert.ToDecimal(baseDF), Convert.ToDecimal(debitoFiscal), fila.Cells["txtCodigoControl"].Value.ToString(), idLibro, user); } } } else { idLibro = LibroVentasBLL.InsertDatosLibroVentas(txtMonth.Text, txtYear.Text); foreach (DataGridViewRow fila in gdDetalleLibroVentas.Rows) { double total = Convert.ToDouble(fila.Cells["txtImporteTotal"].Value); double impuestos = Convert.ToDouble(fila.Cells["txtImpuestos"].Value); double excentos = Convert.ToDouble(fila.Cells["txtExcentos"].Value); double tasaCero = Convert.ToDouble(fila.Cells["txtImporteVentasTasaCero;"].Value); double subtotal = Convert.ToDouble(fila.Cells["txtSubTotal"].Value); double descuentos = Convert.ToDouble(fila.Cells["txtDescuentos"].Value); double baseDF = Convert.ToDouble(fila.Cells["txtImporteBaseDF"].Value); double debitoFiscal = Convert.ToDouble(fila.Cells["txtDebitoFiscal"].Value); DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(Convert.ToInt32(fila.Cells["txtNro"].Value), Convert.ToDateTime(fila.Cells["dateFechaFactura"].Value), fila.Cells["txtNroFactura"].Value.ToString(), fila.Cells["txtNroAutorizacion"].Value.ToString(), fila.Cells["txtNitCliente"].Value.ToString(), fila.Cells["txtNombreRazon"].Value.ToString(), Convert.ToDecimal(total), Convert.ToDecimal(impuestos), Convert.ToDecimal(excentos), Convert.ToDecimal(tasaCero), Convert.ToDecimal(subtotal), Convert.ToDecimal(descuentos), Convert.ToDecimal(baseDF), Convert.ToDecimal(debitoFiscal), fila.Cells["txtCodigoControl"].Value.ToString(), idLibro, user); } } }
private void btnGuardar_Click(object sender, EventArgs e) { if (validarStock() == true) { if (txtNitCliente.Text != "" && txtNombreCliente.Text != "" && tblDetalleVenta.RowCount > 0) { string nroFact = getNroFactura().ToString(); int idCliente; if (objCliente == null) { int idPersona = PersonaBLL.InsertDatosPersona(txtNitCliente.Text, txtNombreCliente.Text, "", "", "", "", 1); idCliente = ClienteBLL.InsertDatosCliente(idPersona, 1); } else { idCliente = objCliente.pkCliente; } int idFactura = 0; if (llave != null && llave.txtLlave != "") { idFactura = FacturaBLL.InsertarFactura(0, idCliente, 2, Convert.ToInt32(boxDescuentos.SelectedValue), 1, nroFact, llave.txtNroAutorizacion, llave.txtLlave, Convert.ToDecimal(sumarTotalVenta()), 1); } else { MessageBox.Show("USTED NO HA INGRESADO LA LLAVE NI EL CODIGO DE AUTORIZACIÓN DE LA FACTURA"); return; } foreach (DataGridViewRow fila in tblDetalleVenta.Rows) { if (Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString()) > 0) { if (fila.Cells["idProducto"] != null) { GananciasDTO ganancias = new GananciasDTO(); ganancias.fkProducto = Convert.ToInt32(fila.Cells["idProducto"].Value.ToString()); ganancias.intCantidad = Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString()); Producto pro = ProductoBLL.GetProductById(ganancias.fkProducto); ganancias.decValorVenta = pro.decValorVenta; ganancias.decValorCompra = pro.decValorCompra; ganancias.decTotal = Convert.ToDecimal(fila.Cells["txtSubTotal"].Value.ToString()); DetalleVentaBLL.InsertarDetalleVenta(0, Convert.ToInt32(fila.Cells["idProducto"].Value.ToString()), idFactura, Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString()), Convert.ToDecimal(fila.Cells["txtSubTotal"].Value.ToString())); GananciasBLL.InsertObjetoGanancias(ganancias); Producto auxProducto = getProductoOfList(fila.Cells["idProducto"].Value.ToString()); auxProducto.intCantidad -= Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString()); ProductoBLL.UpdateProducto(auxProducto); sumaReal += (double)auxProducto.decValorVenta * Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString()); sumaDescuentos += Convert.ToDouble(fila.Cells["txtSubTotal"].Value.ToString()); } } else { MessageBox.Show("Usted a ingresado una cantidad de 0"); return; } } if (lastLibroVenta != null) { if (lastLibroVenta.txtMes == DateTime.Now.Month.ToString() && lastLibroVenta.txtAño == DateTime.Now.Year.ToString()) { List <DetalleLibroVentas> lista = DetalleLibroVentasBLL.GetDetalleLibroVentasByIdLibro(lastLibroVenta.pkLibro); int lastNro = 0; if (lista.Count != 0) { lastNro = lista[(lista.Count - 1)].intNro; } if (sumaReal == sumaDescuentos) { sumaDescuentos = 0; } double dif = sumaReal - sumaDescuentos; double db = 0; if (dif == sumaReal) { db = sumaReal * 13 / 100; } else { db = (sumaReal - dif) * 13 / 100; } DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(lastNro + 1, DateTime.Now, nroFact, llave.txtNroAutorizacion, txtNitCliente.Text, txtNombreCliente.Text, Convert.ToDecimal(sumaReal), 0, 0, 0, Convert.ToDecimal(sumaReal), (dif == sumaReal) ? 0 : Convert.ToDecimal(dif), (dif == sumaReal) ? Convert.ToDecimal(sumaReal) : Convert.ToDecimal(sumaReal - dif), Convert.ToDecimal(db), getCodigoControl(), lastLibroVenta.pkLibro, 1); } else { int pkLibro = LibroVentasBLL.InsertDatosLibroVentas(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString()); int lastNro = 0; if (sumaReal == sumaDescuentos) { sumaDescuentos = 0; } double dif = sumaReal - sumaDescuentos; double db = 0; if (dif == sumaReal) { db = sumaReal * 13 / 100; } else { db = (sumaReal - dif) * 13 / 100; } DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(lastNro + 1, DateTime.Now, nroFact, llave.txtNroAutorizacion, txtNitCliente.Text, txtNombreCliente.Text, Convert.ToDecimal(sumaReal), 0, 0, 0, Convert.ToDecimal(sumaReal), (dif == sumaReal) ? 0 : Convert.ToDecimal(dif), (dif == sumaReal) ? Convert.ToDecimal(sumaReal) : Convert.ToDecimal(sumaReal - dif), Convert.ToDecimal(db), getCodigoControl(), pkLibro, 1); } } else { int pkLibro = LibroVentasBLL.InsertDatosLibroVentas(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString()); int lastNro = 0; if (sumaReal == sumaDescuentos) { sumaDescuentos = 0; } double dif = sumaReal - sumaDescuentos; double db = 0; if (dif == sumaReal) { db = sumaReal * 13 / 100; } else { db = (sumaReal - dif) * 13 / 100; } DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(lastNro + 1, DateTime.Now, nroFact, llave.txtNroAutorizacion, txtNitCliente.Text, txtNombreCliente.Text, Convert.ToDecimal(sumaReal), 0, 0, 0, Convert.ToDecimal(sumaReal), (dif == sumaReal) ? 0 : Convert.ToDecimal(dif), (dif == sumaReal) ? Convert.ToDecimal(sumaReal) : Convert.ToDecimal(sumaReal - dif), Convert.ToDecimal(db), getCodigoControl(), pkLibro, 1); } if (original == " COPIA") { original = "ORIGINAL"; } imprimirFactura(); original = " COPIA"; imprimirFactura(); tblDetalleVenta.RowCount = 0; txtNitCliente.Text = ""; txtNombreCliente.Text = ""; sumaReal = 0; sumaDescuentos = 0; lastFactura = FacturaBLL.GetLastFactura(); llave = LlaveFacturaBLL.GetLastLlaveFactura(); lastFactura = FacturaBLL.GetLastFactura(); lastLibroVenta = LibroVentasBLL.GetLastLibroVentas(); listaProductos = new List <Producto>(); } else { MessageBox.Show("Debe ingresar el nit, el nombre del cliente y al menos un producto"); } } }
public void cargarDatosToGrid() { gdLibrosVentas.DataSource = LibroVentasBLL.SelectAll(); }