private void btnBuscar_Click(object sender, EventArgs e) { //ClienteNEG bl = new ClienteNEG(); Venta c = new Venta(); //c.Correlativo = txtCorrelativo_buscar.Text; c.NroDocumento = txtNro_busqueda.Text; //dgvClientes.DataSource = bl.Buscar(c); //dgvVentas.DataSource = VentaNEG.Instancia().Buscar(c) dgvVentas.DataSource = VentaNEG.Instancia().listarVentas(); }
private void btnRegistrar_Click(object sender, EventArgs e) { if (txtCodigo.Text == "") { StockTienda c = new StockTienda(); c.FechaIngresoTienda = dtpFechaIngreso.Value; //c.idCliente = codigoClienteSeleccionado; c.idUsuario = idUsuario; if (radActivo.Enabled == true) { c.Estado = true; } else if (radInactivo.Enabled == true) { c.Estado = false; } foreach (DataGridViewRow row in dgvDetalleStock.Rows) { DetalleStockTienda de = new DetalleStockTienda(); DetalleStockTienda dStockFinal = StockTiendaNEG.Instancia().ObtenerStockActual(Convert.ToInt32(row.Cells["idArticulo"].Value)); de.idArticulo = Convert.ToInt32(row.Cells["idArticulo"].Value); DetalleIngresoAlmacen dPrecioActual = DetalleIngresoNEG.Instancia().obtenerPrecioVenta(de.idArticulo); int cantidad = Convert.ToInt32(row.Cells["cantidad"].Value); de.idDetalleIngresoAlmacen = dPrecioActual.idDetalleIngresoAlmacen; de.StockInicial = Convert.ToInt32(row.Cells["cantidad"].Value); de.StockFinal = Convert.ToInt32(row.Cells["cantidad"].Value) + dStockFinal.StockFinal; VentaNEG.Instancia().reducirStock(de.idArticulo, cantidad); c.Lineas.Add(de); } StockTiendaNEG.RegistrarIngresoTienda(c); MessageBox.Show("El ingreso de Stock a Tienda fue exitoso."); this.Dispose(); } else { if (radInactivo.Checked == true) { } this.Dispose(); } }
private void rptFactura_Load(object sender, EventArgs e) { // TODO: esta línea de código carga datos en la tabla 'SigVentasDataSet.SP_Venta_Listar_' Puede moverla o quitarla según sea necesario. // TODO: esta línea de código carga datos en la tabla 'SigVentasDataSet.SP_Venta_Listar_' Puede moverla o quitarla según sea necesario. DataTable dt = VentaNEG.ObtenerVenta("001", "0000001", 1); //Limpiemos el DataSource del informe reportViewer1.Visible = true; reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.ReportPath = "Report1.rdlc"; reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("SigVentasDataSet", dt)); reportViewer1.LocalReport.Refresh(); /*RptCrm.Visible = true; * RptCrm.LocalReport.DataSources.Clear(); * ReportDataSource rds = new ReportDataSource("dsCrmrpt", dtval);*/ /*RptCrm.LocalReport.ReportPath = "Report1.rdlc"; * RptCrm.LocalReport.DataSources.Add(rds); * RptCrm.DataBind(); * RptCrm.LocalReport.Refresh();*/ /*ReportParameter[] parameters = new ReportParameter[2]; * parameters[0] = new ReportParameter("parameterTitulo", Titulo); * parameters[1] = new ReportParameter("parameterEmpresa", Empresa); * * reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Encabezado", Invoice)); * reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Detalle", Detail)); * * * reportViewer1.LocalReport.SetParameters(parameters); * * * * reportViewer1.RefreshReport();*/ }
private void InvoiceGenerate() { // //Hacemos una instancia de la clase EFactura para //llenarla con los valores contenidos en los controles del Formulario String NroActual; Venta nroVentaActual = VentaNEG.Instancia().obtenerUltimaVenta(cboTipComp.SelectedIndex + 1); if (nroVentaActual.NroDocumento == "") { int i = 1; NroActual = i.ToString("D7"); //obj.NroDocumento = "000001"; } else { string UltimoNro = nroVentaActual.NroDocumento; int UltimoNroDoc; int.TryParse(UltimoNro, out UltimoNroDoc); int NuevoNum = UltimoNroDoc + 1; NroActual = NuevoNum.ToString("D7"); } Venta c = new Venta(); c.FechaVenta = dtpFechaVenta.Value; c.idCliente = codigoClienteSeleccionado; c.TotalVenta = totalPagar; c.IgvVenta = igv; c.idUsuario = idUsuario; c.Correlativo = "001"; if (radActivo.Enabled == true) { c.Estado = true; } else if (radInactivo.Enabled == true) { c.Estado = false; } //c.numero = Convert.ToInt32(txtNumero.Text); c.SubTotalVenta = sub; c.idTipoComprobante = cboTipComp.SelectedIndex + 1; c.NroDocumento = NroActual; //Recorremos los Rows existentes actualmente en el control DataGridView //para asignar los datos a las propiedades foreach (DataGridViewRow row in dgvDetalle.Rows) { DetalleVenta d = new DetalleVenta(); d.idArticulo = Convert.ToInt32(row.Cells["idArticulo"].Value); d.PrecioVenta = Convert.ToDecimal(row.Cells["PU"].Value); d.Cantidad = Convert.ToInt32(row.Cells["cantidad"].Value); d.idDetalleIngresoAlmacen = 1; int cantidad = Convert.ToInt32(row.Cells["cantidad"].Value); VentaNEG.Instancia().reducirStock(d.idArticulo, cantidad); //StockTiendaNEG.Instancia().reducirStock(d.idArticulo, cantidad); c.Lineas.Add(d); } // //Creamos una instancia del Formulario que contiene nuestro //ReportViewer // rptFactura frm = new rptFactura(); //Usamos las propiedades publicas del formulario, aqui es donde enviamos el valor //que se mostrara en los parametros creados en el LocalReport, para este ejemplo //estamos Seteando los valores directamente pero usted puede usar algun control // frm.Titulo = "Este es un ejemplo de Factura"; frm.Empresa = "Este es un ejemplo del Nombre de la Empresa"; // //Recuerde que invoice es una Lista Generica declarada en FacturaRtp, es una lista //porque el origen de datos del LocalReport unicamente permite ser enlazado a objetos que //implementen IEnumerable. // //Usamos el metod Add porque Invoice es una lista e invoice es una entidad simple frm.Invoice.Add(c); // //Enviamos el detalle de la Factura, como Detail es una lista e invoide.Details tambien //es un lista del tipo EArticulo bastara con igualarla // frm.Detail = c.Lineas; frm.Show(); int idComp = cboTipComp.SelectedIndex + 1; //rpt.SetDataSource(VentaNEG.ObtenerVenta(txtSerie.Text, NroActual, idComp)); //rpt.SetParameterValue("texto", txtTotalNum.Text); //rpt.PrintToPrinter(1, false, 1, 1); }
private void btnRegistrarVenta_Click(object sender, EventArgs e) { if (this.codigoClienteSeleccionado == -1) { this.mError("No ha seleccionado aún ningun Cliente"); } if (txtCodigo.Text == "") { String NroActual; Venta nroVentaActual = VentaNEG.Instancia().obtenerUltimaVenta(cboTipComp.SelectedIndex + 1); if (nroVentaActual.NroDocumento == "") { int i = 1; NroActual = i.ToString("D7"); //obj.NroDocumento = "000001"; } else { string UltimoNro = nroVentaActual.NroDocumento; int UltimoNroDoc; int.TryParse(UltimoNro, out UltimoNroDoc); int NuevoNum = UltimoNroDoc + 1; NroActual = NuevoNum.ToString("D7"); } Venta c = new Venta(); c.FechaVenta = dtpFechaVenta.Value; c.idCliente = codigoClienteSeleccionado; c.TotalVenta = totalPagar; c.IgvVenta = igv; c.idUsuario = idUsuario; c.Correlativo = "001"; if (radActivo.Enabled == true) { c.Estado = true; } else if (radInactivo.Enabled == true) { c.Estado = false; } //c.numero = Convert.ToInt32(txtNumero.Text); c.SubTotalVenta = sub; c.idTipoComprobante = cboTipComp.SelectedIndex + 1; c.NroDocumento = NroActual; foreach (DataGridViewRow row in dgvDetalle.Rows) { DetalleVenta d = new DetalleVenta(); d.idArticulo = Convert.ToInt32(row.Cells["idArticulo"].Value); d.PrecioVenta = Convert.ToDecimal(row.Cells["PU"].Value); d.Cantidad = Convert.ToInt32(row.Cells["cantidad"].Value); d.idDetalleIngresoAlmacen = 1; int cantidad = Convert.ToInt32(row.Cells["cantidad"].Value); VentaNEG.Instancia().reducirStock(d.idArticulo, cantidad); //StockTiendaNEG.Instancia().reducirStock(d.idArticulo, cantidad); c.Lineas.Add(d); } VentaNEG.RegistrarFacturacion(c); txtSerie.Text = "001"; txtCorrelativo.Text = NroActual; MessageBox.Show("La Venta se realizó correctamente."); DialogResult result = MessageBox.Show("Desea Imprimir?", "Imprimir", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { int idComp = cboTipComp.SelectedIndex + 1; //rpt.SetDataSource(VentaNEG.ObtenerVenta(txtSerie.Text, NroActual, idComp)); //rpt.SetParameterValue("", d.); //rpt.SetParameterValue("texto", txtTotalNum.Text); //Establecemos los datos al reporte //this.crReporte.ReportSource = rpt; //rpt.PrintToPrinter(1, false, 1, 1); //this.Dispose(); } else if (result == DialogResult.No) { DialogResult result2 = MessageBox.Show("Desea realizar otra venta?", "Cerrar", MessageBoxButtons.YesNo); if (result2 == DialogResult.Yes) { this.Dispose(); } else if (result2 == DialogResult.No) { txtBarCodeArticulo.Clear(); txtCodigo.Clear(); txtCorrelativo.Clear(); txtDireccionCliente.Clear(); txtNombreArticulo.Clear(); txtNombreCliente.Clear(); txtPrecio.Clear(); txtRucCliente.Clear(); txtSerie.Clear(); txtStockActual.Text = "0"; nudCantidad.Value = 1; txtTotalNum.Clear(); foreach (DataGridViewRow row in dgvDetalle.Rows) { decimal igvTotal = Convert.ToDecimal(18); //Indice dila actualmente seleccionado y que vamos a eliminar int indiceFila = this.dgvDetalle.CurrentCell.RowIndex; //Fila que vamos a eliminar DataRow row2 = this.dtDetalle.Rows[indiceFila]; //Disminuimos el total a pagar this.totalPagar = this.totalPagar - Convert.ToDecimal(row2["subTotal"].ToString()); this.lblTotalPagar.Text = "Total Pagar: S/." + totalPagar.ToString("#0.00#"); this.sub = totalPagar / ((igvTotal / 100) + 1); this.lblSubTotal.Text = "Sub Total: S/." + sub.ToString("#0.00#"); this.igv = totalPagar - sub; this.lblIGV.Text = "IGV(18%): S/." + igv.ToString("#0.00#"); //Removemos la fila this.dtDetalle.Rows.Remove(row2); } txtTotalNum.Clear(); } } } /*else * { * * //VALIDACIÓN PARA ANULAR FACTURA - VERIFICACIÓN POR CONTRASEÑA * if (radInactivo.Checked ==true) * { * * frmAnularVentaVerificar frame3 = new frmAnularVentaVerificar(); * frame3.estableceFormulario3(this); * frame3.ShowDialog(); * } * * this.Dispose(); * * }*/ }
private void btnBuscar_Click(object sender, EventArgs e) { dgvReporteVentas.DataSource = VentaNEG.Instancia().reporteVentasxDias("24/07/2016", "25/08/2016"); }