private void btnReporte_Click(object sender, EventArgs e) { DataTable dt = ArmoSql(); ManejaArticulos objManejaArticulos = new ManejaArticulos(); frmReportes objfrmReporte; objfrmReporte = new frmReportes("ReporteArticulos.rdlc", objManejaArticulos.ReporteDeArticulosGral(dt), "ArticulosReporteGral"); objfrmReporte.Show(); }
private void btnReporte_Click(object sender, EventArgs e) { string strSql; strSql = "select c.fechaalta,c.nrofactura,p.id, p.razonsocial,c.total "; strSql += " from compras c, dbo.Proveedores p "; strSql += " where c.proveedorid=p.id and c.fechabaja is null "; if (txtCodigoCompra.Text != "") { if (cboCodigoCompra.Text == "=") { strSql += " and c.nrofactura = '" + txtCodigoCompra.Text + "')"; } if (cboCodigoCompra.Text == "like") { strSql += " and c.nrofactura like '" + txtCodigoCompra.Text + "%' )"; } if (cboCodigoCompra.Text == "path") { strSql += " and c.nrofactura like '%" + txtCodigoCompra.Text + "%' )"; } } if (cboProveedor.Text != "") { strSql += " and p.id =" + cboProveedor.SelectedValue; } strSql += " and c.fechaalta between DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaCompraDesde.Text + "'))" + " and DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechadeCompraHasta.Text + "'))"; // strSql += " group by f.facturaid, f.fechaalta ,f.ubicacion, f.estado, e.emp_nombre + ' ' + e.emp_apellido , c.cli_nombre + ' '+ c.cli_apellido , f.total "; LlenaCombos objLlenaCombos = new LlenaCombos(); DataTable dt = objLlenaCombos.GetSqlDataAdapterbySql(strSql); ManejaCompras objManejaCompras = new ManejaCompras(); frmReportes objfrmReporte; objfrmReporte = new frmReportes("ReporteCompras.rdlc", objManejaCompras.ReporteDeCompras(dt), "ComprasReporte"); objfrmReporte.Show(); }
private void CargoDatos() { string strSql = ""; strSql = "select * from ("; if (ckPagos.Checked) { strSql += ArmoPagos(); if (ckDevoluciones.Checked) { strSql += " UNION "; strSql += ArmoDevoluciones(); } } else { strSql += ArmoDevoluciones(); } strSql += " ) tabla order by fecha"; LlenaCombos objLlenaCombos = new LlenaCombos(); DataTable dt = objLlenaCombos.GetSqlDataAdapterbySql(strSql); ManejaVentas objManejaVentas = new ManejaVentas(); frmReportes objfrmReporte; objfrmReporte = new frmReportes("ReportePagosDevoluciones.rdlc", objManejaVentas.ReporteDePagosDevoluciones(dt), "VentasReportePago"); objfrmReporte.Show(); }
private void CargoDatos() { string strSql; //Tengo 3 formas de busqueda //1-Detallado por Cantidad total de articulos //2-Detallado de articulos //3-Totales if (rbInformeDetallado.Checked && rbArticulosCantidadTotal.Checked) { strSql = " select f.facturaid, f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido as empleado, c.cli_nombre + ' '+ c.cli_apellido as cliente, isnull( sum(d.cantidad),0) as cantidad, "; strSql += " isnull(f.efectivoabona,0) as efectivo, isnull((select sum(d.tarjetaabona) from dbo.Tarjetas_Detalle d where d.facturaid =f.facturaid),0) as tarjeta , isnull( (select sum(d.chequeabona) from dbo.Cheques_Detalle d where d.facturaid =f.facturaid),0) as cheque , isnull(f.ctacte,0) as Ctacte, isnull(f.total,0) as total, f.descuento, f.neto "; strSql += " from dbo.Factura f, dbo.Empleados e, dbo.Clientes c, dbo.Factura_Detalle d "; strSql += " where f.empleadoid= e.emp_id and f.clienteid = c.cli_id and f.facturaid = d.facturaid "; } else if (rbInformeDetallado.Checked && rbArticulosDetallado.Checked) { strSql = " select f.facturaid, f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido as empleado, c.cli_nombre + ' '+ c.cli_apellido as cliente, d.cantidad,a.descripcion, d.descuento, d.puni, d.total "; strSql += " from dbo.Factura f, dbo.Empleados e, dbo.Clientes c, dbo.Factura_Detalle d, dbo.Articulos a "; strSql += " where f.empleadoid= e.emp_id and f.clienteid = c.cli_id and f.facturaid = d.facturaid and a.id = d.articuloid "; } else if (rbInformeDetallado.Checked && rbDetalladoMedioDePago.Checked) { strSql = " select f.facturaid, f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido as empleado, c.cli_nombre + ' '+ c.cli_apellido as cliente, a.numero_caja, m.descripcion, sum (p.importe) as total, p.mediopago, p.fecha "; strSql += " from dbo.Factura f, dbo.Empleados e, dbo.Clientes c, dbo.Ventas_Pagos p, dbo.Medio_Pago m, Cierre_Caja a"; strSql += " where f.empleadoid= e.emp_id and f.clienteid = c.cli_id and f.facturaid = ventas_id and p.mediopago = m.mediopago and p.cierrecajaid = a.cierrecajaid "; } else { /* strSql = " select f.facturaid, f.empleadoid, f.clienteid, f.subtotal as efectivo,f.ctacte as Ctacte, f.total, "; * strSql += " (select sum(cantidad) from dbo.Factura_Detalle d where f.facturaid = d.facturaid) as cantidad "; * strSql += " from dbo.Factura f "; * strSql += " LEFT OUTER JOIN dbo.Tarjetas_Detalle t ON f.facturaid = t.facturaid "; * strSql += " LEFT OUTER JOIN dbo.Cheques_Detalle che ON f.facturaid = che.facturaid,"; * strSql += " dbo.Empleados e, dbo.Clientes c,dbo.Factura_Detalle d "; * strSql += " where f.empleadoid= e.emp_id "; * strSql += " and f.clienteid = c.cli_id "; * strSql += " and f.facturaid = d.facturaid ";*/ strSql = " select f.facturaid, f.empleadoid, f.clienteid, "; strSql += " isnull((select sum(importe) from dbo.Ventas_Pagos p where f.facturaid = p.ventas_id and p.fecha between DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaPagoDesde.Text + "'))" + " and DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaPagoHasta.Text + "')+1)"; strSql += " ),0) as pagado,f.ctacte as Ctacte, f.total, "; strSql += " (select sum(cantidad) from dbo.Factura_Detalle d where f.facturaid = d.facturaid) as cantidad "; strSql += " from dbo.Factura f, dbo.Empleados e, dbo.Clientes c,dbo.Factura_Detalle d "; strSql += " where f.empleadoid= e.emp_id "; strSql += " and f.clienteid = c.cli_id "; strSql += " and f.facturaid = d.facturaid "; } if (txtCodigoVenta.Text != "") { strSql += " and f.facturaid " + cboCodigoVenta.Text + txtCodigoVenta.Text; } if (cboVendedor.Text != "") { strSql += " and e.emp_id =" + cboVendedor.SelectedValue; } if (cboCliente.Text != "") { strSql += " and c.cli_id =" + cboCliente.SelectedValue; } if (cboEstado.Text != "") { strSql += " and f.estado = '" + cboEstado.Text + "'"; } if (cboFaltaDePago.Text != "") { if (cboFaltaDePago.Text == "CON DEUDA") { strSql += " and f.ctacte > 0"; } else { strSql += " and f.ctacte = 0"; } } if (rbInformeDetallado.Checked && rbDetalladoMedioDePago.Checked) { strSql += " and p.fecha between DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaPagoDesde.Text + "'))" + " and DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaPagoHasta.Text + "')+1)"; } strSql += " and f.fechaalta between DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaVentaDesde.Text + "'))" + " and DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechadeVentaHasta.Text + "')+1)"; if (txtCodigoArticulo.Text != "") { if (txtCodigoArticulo.Text.Length > 1) { if (txtCodigoArticulo.Text.Substring(0, 2).Trim() == "20" && txtCodigoArticulo.Text.Trim().Length == 13) //Los dos primeros digitos tienen que se 20 y el ancho del codigo de barra tiene que ser de 12 digitos { //Si es un codigo de balanza electronica strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and SUBSTRING(a.idextra,1,6)= '" + txtCodigoArticulo.Text.Substring(0, 6) + "')"; if (cboCodigoArticulo.Text == "like") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and SUBSTRING(a.idextra,1,6) like '" + txtCodigoArticulo.Text.Substring(0, 6) + "%' )"; } if (cboCodigoArticulo.Text == "path") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and SUBSTRING(a.idextra,1,6) like '%" + txtCodigoArticulo.Text.Substring(0, 6) + "%' )"; } } } else { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and a.idextra= '" + txtCodigoArticulo.Text + "')"; if (cboCodigoArticulo.Text == "like") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and a.idextra like '" + txtCodigoArticulo.Text + "%' )"; } if (cboCodigoArticulo.Text == "path") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d,dbo.Articulos a where d.articuloid=a.id and a.idextra like '%" + txtCodigoArticulo.Text + "%' )"; } } } if (txtDescripcionArticulo.Text != "") { if (cboDescripcionArticulo.Text == "=") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d, dbo.Articulos a where a.id = d.articuloid and a.descripcion = '" + txtDescripcionArticulo.Text + "')"; } if (cboDescripcionArticulo.Text == "like") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d, dbo.Articulos a where a.id = d.articuloid and a.descripcion like '" + txtDescripcionArticulo.Text + "%' )"; } if (cboDescripcionArticulo.Text == "path") { strSql += " and f.facturaid in (select d.facturaid from dbo.Factura_Detalle d, dbo.Articulos a where a.id = d.articuloid and a.descripcion like '%" + txtDescripcionArticulo.Text + "%' )"; } } if (cboMedioPago.Text != "") { strSql += " and p.mediopago =" + cboMedioPago.SelectedValue; } if (rbInformeDetallado.Checked && rbArticulosCantidadTotal.Checked) { strSql += " group by f.facturaid,f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido, c.cli_nombre + ' '+ c.cli_apellido, f.descuento, f.neto, f.efectivoabona,f.total,ctacte "; } else { if (rbInformeDetallado.Checked && rbArticulosDetallado.Checked) { strSql += " group by f.facturaid, f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido, c.cli_nombre + ' '+ c.cli_apellido , d.cantidad,a.descripcion, d.descuento, d.puni, d.total "; } else if (rbInformeDetallado.Checked && rbDetalladoMedioDePago.Checked) { strSql += " group by f.facturaid,f.fechaalta , f.estado, e.emp_nombre + ' ' + e.emp_apellido, c.cli_nombre + ' '+ c.cli_apellido, a.numero_caja, m.descripcion, p.mediopago, p.fecha "; } else { strSql += " group by f.facturaid, f.empleadoid, f.clienteid, f.subtotal,f.ctacte, f.total "; } } //Seteo los checks de ordenamiento if (rbInformeDetallado.Checked) { if (rbOrden2CantidadDeArticulos.Checked) { strSql += " order by cantidad"; } else if (rbOrden2Fecha.Checked) { strSql += " order by f.fechaalta"; } else if (rbOrden2MayorGanancia.Checked) { strSql += " order by total desc"; } else if (rbOrden2MenorGanancia.Checked) { strSql += " order by total asc"; } else if (rbOrden2NumeroFactura.Checked) { strSql += " order by f.facturaid asc"; } } LlenaCombos objLlenaCombos = new LlenaCombos(); DataTable dt = objLlenaCombos.GetSqlDataAdapterbySql(strSql); ManejaVentas objManejaVentas = new ManejaVentas(); frmReportes objfrmReporte; if (rbInformeDetallado.Checked && rbArticulosCantidadTotal.Checked) { objfrmReporte = new frmReportes("ReportePorCantidadDeArticulos.rdlc", objManejaVentas.ReporteDeCantidadTotalesDeArticulos(dt), "VentasReporte"); } else if (rbInformeDetallado.Checked && rbArticulosDetallado.Checked) { objfrmReporte = new frmReportes("ReporteDetalladoPorArticulos.rdlc", objManejaVentas.ReporteDetalladoPorArticulos(dt), "VentasReporte"); } else if (rbInformeDetallado.Checked && rbDetalladoMedioDePago.Checked) { objfrmReporte = new frmReportes("ReporteDetalladoPorMedioDePago.rdlc", objManejaVentas.ReporteDetalladoPorMedioDePago(dt), "VentasReporte"); } else { objfrmReporte = new frmReportes("ReporteTotales.rdlc", objManejaVentas.ReporteTotales(dt, Convert.ToDateTime(dtpFechaVentaDesde.Text), Convert.ToDateTime(dtpFechadeVentaHasta.Text)), "VentasReporte"); } objfrmReporte.Show(); }
private void CargoDatos() { string strSql; if (rbFechaVenta.Checked) { strSql = "select f.fechaalta, f.facturaid,idextra,descripcion, rubro, marca,f.ubicacion, stock, precioefectivo, cantidad, d.descuento, d.total "; strSql += " from dbo.Articulos a LEFT OUTER JOIN dbo.Proveedores P ON a.proveedor = P.id , dbo.Factura_Detalle D, dbo.Factura f "; strSql += " where a.id = D.articuloid and d.facturaid = f.facturaid "; if (ckCumplida.Checked) { strSql += " and ( f.estado='CUMPLIDA' "; } if (ckCancelada.Checked && ckCancelada.Checked) { strSql += " or f.estado='CANCELADA' "; } if (ckCancelada.Checked && !ckCancelada.Checked) { strSql += " and (f.estado='CANCELADA' "; } if (ckCumplida.Checked || ckCancelada.Checked) { strSql += " ) "; } strSql += " and f.fechaalta between DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechaVentaDesde.Text + "'))" + " and DATEADD(D, 0, DATEDIFF(D, 0," + "'" + dtpFechadeVentaHasta.Text + "')+1)"; } else { strSql = " select a.id,idextra,descripcion, rubro, marca, stock, a.ubicacion, precioefectivo, isnull (sum(cantidad),0) as cantidad, isnull (sum(d.total),0) as total "; strSql += " from dbo.Articulos a LEFT OUTER JOIN dbo.Proveedores P ON a.proveedor = P.id LEFT OUTER JOIN dbo.Factura_Detalle D ON a.id = D.articuloid LEFT OUTER JOIN dbo.Factura F On F.facturaid = D.facturaid "; if (ckCumplida.Checked) { strSql += " and ( f.estado='CUMPLIDA' "; } if (ckCancelada.Checked && ckCancelada.Checked) { strSql += " or f.estado='CANCELADA' "; } if (ckCancelada.Checked && !ckCancelada.Checked) { strSql += " and (f.estado='CANCELADA' "; } if (ckCumplida.Checked || ckCancelada.Checked) { strSql += " ) "; } strSql += " where 1=1 "; } if (txtCodigo.Text != "") { if (txtCodigo.Text.Substring(0, 2).Trim() == "20" && txtCodigo.Text.Trim().Length == 13) //Los dos primeros digitos tienen que se 20 y el ancho del codigo de barra tiene que ser de 12 digitos { //Reemplazo la busqueda, //El codigo de barra se conforma de la siguiente manera //20PPPPIIIIIIX //20- Codigo Identificatorio. 2Digitos //P- Codigo PLU . 4Digitos //I-Importe. 6Digitos //X-Digito Control. 1Digito //Ejemplo: //2000010003006 //Es un producto de almacen if (cboCodigo.Text == "=") { strSql += " and SUBSTRING(a.idextra,1,6) = '" + txtCodigo.Text.Substring(0, 6) + "'"; } if (cboCodigo.Text == "like") { strSql += " and SUBSTRING(a.idextra,1,6) like '" + txtCodigo.Text.Substring(0, 6) + "%' "; } if (cboCodigo.Text == "path") { strSql += " and SUBSTRING(a.idextra,1,6) '%" + txtCodigo.Text.Substring(0, 6) + "%' "; } } else { if (cboCodigo.Text == "=") { strSql += " and a.idextra = '" + txtCodigo.Text + "'"; } if (cboCodigo.Text == "like") { strSql += " and a.idextra like '" + txtCodigo.Text + "%' "; } if (cboCodigo.Text == "path") { strSql += " and a.idextra like '%" + txtCodigo.Text + "%' "; } } } if (txtDescripcion.Text != "") { if (cboDescripcion.Text == "=") { strSql += " and a.descripcion = '" + txtDescripcion.Text + "'"; } if (cboDescripcion.Text == "like") { strSql += " and a.descripcion like '" + txtDescripcion.Text + "%' "; } if (cboDescripcion.Text == "path") { strSql += " and a.descripcion like '%" + txtDescripcion.Text + "%' "; } } if (cboRubro.Text != "") { strSql += " and a.rubro = '" + cboRubro.Text + "'"; } if (cboMarca.Text != "") { strSql += " and a.marca = '" + cboMarca.Text + "'"; } if (txtUbicacion.Text != "") { if (cboUbicacion.Text == "=") { strSql += " and a.ubicacion = '" + txtUbicacion.Text + "'"; } if (cboUbicacion.Text == "like") { strSql += " and a.ubicacion like '" + txtUbicacion.Text + "%' "; } if (cboUbicacion.Text == "path") { strSql += " and a.ubicacion like '%" + txtUbicacion.Text + "%' "; } } if (cboProveedor.Text != "") { strSql += " and a.proveedor =" + cboProveedor.SelectedValue; } if (txtStock.Text != "") { strSql += " and a.stock " + cboStock.Text + txtStock.Text; } if (CkStockMinimo.Checked) { strSql += " and a.stock<=a.stockminimo"; } if (cboEstadoArt.Text != "") { if (cboEstadoArt.Text == "ALTA") { strSql += " and a.fechabaja is null "; } else { strSql += " and a.fechabaja is not null "; } } if (rbFechaVenta.Checked) { strSql += " order by f.fechaalta"; } else { strSql += " group by a.id,idextra,descripcion, a.fechaalta, rubro, marca,a.ubicacion, stock, precioefectivo "; } if (rbCodigo.Checked) { strSql += " order by idextra"; } else if (rbMarca.Checked) { strSql += " order by marca"; } else if (rbMasVendido.Checked) { strSql += " order by cantidad desc "; } else if (rbMayorGanancia.Checked) { strSql += " order by total desc "; } else if (rbMenosVendido.Checked) { strSql += " order by cantidad asc "; } else if (rbOrdenAlfabetico.Checked) { strSql += " order by descripcion "; } else if (rbRubro.Checked) { strSql += " order by rubro "; } LlenaCombos objLlenaCombos = new LlenaCombos(); DataTable dt = objLlenaCombos.GetSqlDataAdapterbySql(strSql); ManejaArticulos objManejaArticulos = new ManejaArticulos(); frmReportes objfrmReporte; if (rbFechaVenta.Checked) { objfrmReporte = new frmReportes("ReporteArticulosVenta.rdlc", objManejaArticulos.ReporteDeArticulosVenta(dt), "ArticulosReporte"); } else { objfrmReporte = new frmReportes("ReporteArticulosGeneral.rdlc", objManejaArticulos.ReporteDeArticulos(dt), "ArticulosReporte"); } objfrmReporte.Show(); }