public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { ReportComprasVentas rpt = new ReportComprasVentas(); rpt.Site = this.Site; return(rpt); }
private void buttonGenerarReporte_Click(object sender, EventArgs e) { string datosEmpleado = ""; ClaseCapaDatosFerreteria cpd = new ClaseCapaDatosFerreteria(); ClaseBitacoraFerreteria cbf = new ClaseBitacoraFerreteria(); try { datosEmpleado = cpd.ExtraerCodigo3("CONCAT(Apellidos,',',Nombre) AS ", "NombreC", "" + " bd_ferreteria.tbl_Persona, bd_ferreteria.tbl_usuario, bd_ferreteria.tbl_Empleado", "tbl_Empleado.status ", " 1 AND tbl_Persona.status = 1 " + "AND tbl_Persona.id = tbl_Empleado.tbl_Persona_id " + "AND tbl_usuario.tbl_empleado_DPI = tbl_empleado.DPI " + "AND tbl_usuario.id = " + cbf.GetUserCodeForLog() ); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } /// ReporteadorFerreteria.REPORTS.ReportComprasVentas objRpt = new ReporteadorFerreteria.REPORTS.ReportComprasVentas(); ReporteadorFerreteria.DATASETS.DataSetP ds1 = new ReporteadorFerreteria.DATASETS.DataSetP(); foreach (DataGridViewRow row in DataGridViewDetalles.Rows) { ReporteadorFerreteria.DATASETS.DataSetP.tbl_ReporteVentaCompraRow rowVentaCompra = ds1.tbl_ReporteVentaCompra.Newtbl_ReporteVentaCompraRow(); rowVentaCompra.id = Convert.ToString(row.Cells["ID"].Value); rowVentaCompra.FechaEmision = Convert.ToString(row.Cells["FECHA EMISION"].Value); rowVentaCompra.FechaCancelacion = Convert.ToString(row.Cells["FECHA CANCELACION"].Value); rowVentaCompra.Total = Convert.ToString(row.Cells["TOTAL"].Value); rowVentaCompra.Objetivo = Convert.ToString(row.Cells[titleObjetivo].Value); rowVentaCompra.Cancelado = Convert.ToString(row.Cells["CANCELADO"].Value); rowVentaCompra.Saldo = Convert.ToString(row.Cells["SALDO"].Value); ds1.tbl_ReporteVentaCompra.Addtbl_ReporteVentaCompraRow(rowVentaCompra); } objRpt.SetDataSource(ds1); TextObject txtObject = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextBy"]; TextObject txtObjectDate = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextDate"]; TextObject txtTotal = (TextObject)objRpt.ReportDefinition.Sections["Section4"].ReportObjects["TextTotal"]; TextObject txtSaldo = (TextObject)objRpt.ReportDefinition.Sections["Section4"].ReportObjects["TextSaldo"]; string type = ""; if (tablaObj == "tbl_comprasencabezado") { type = "COMPRAS"; } else { type = "VENTAS"; } TextObject txtObjectType = (TextObject)objRpt.ReportDefinition.Sections["Section1"].ReportObjects["TextType"]; txtTotal.Text = sumarFilas(3).ToString(); txtSaldo.Text = sumarFilas(6).ToString(); txtObjectDate.Text = DateTime.Now.ToLongTimeString(); txtObject.Text = datosEmpleado; txtObjectType.Text = type; UI_Visualizador form = new UI_Visualizador(); form.crystalReportViewerGlobal.ReportSource = objRpt; form.ShowDialog(); }