static string GenerateTableHeaderRow(ReportBuilder reportBuilder, ReportTable table) { ReportColumns[] columns = table.ReportDataColumns; ReportTextBoxControl ColumnCell = new ReportTextBoxControl(); ReportDimensions padding = new ReportDimensions(); if (columns == null) { return(""); } string strTableRow = ""; strTableRow = @"<TablixRow> <Height>0.6cm</Height> <TablixCells>"; for (int i = 0; i < columns.Length; i++) { ColumnCell = columns[i].ColumnCell; padding = columns[i].HeaderColumnPadding; strTableRow += @"<TablixCell> <CellContents> " + GenerateTextBox("txtHeader_" + table.ReportName + "_", ColumnCell.Name, columns[i].HeaderText == null || columns[i].HeaderText.Trim() == "" ? ColumnCell.Name : columns[i].HeaderText, false, padding) + @" </CellContents> </TablixCell>"; } strTableRow += @"</TablixCells></TablixRow>"; return(strTableRow); }
static string GetTableColumns(ReportBuilder reportBuilder, ReportTable table) { ReportColumns[] columns = table.ReportDataColumns; ReportTextBoxControl ColumnCell = new ReportTextBoxControl(); if (columns == null) { return(""); } string strColumnHeirarchy = ""; strColumnHeirarchy = @" <TablixColumns>"; for (int i = 0; i < columns.Length; i++) { ColumnCell = columns[i].ColumnCell; strColumnHeirarchy += @" <TablixColumn> <Width>" + ColumnCell.Size.Width.ToString() + @"cm</Width> </TablixColumn>"; } strColumnHeirarchy += @"</TablixColumns>"; return(strColumnHeirarchy); }
static string GetSortingDetails(ReportBuilder reportBuilder) { //return ""; ReportTable[] tables = reportBuilder.Body.ReportControlItems.ReportTable; ReportColumns[] columns = reportBuilder.Body.ReportControlItems.ReportTable[0].ReportDataColumns; ReportTextBoxControl sortColumn = new ReportTextBoxControl(); if (columns == null) { return(""); } string strSorting = ""; strSorting = @" <SortExpressions>"; for (int i = 0; i < columns.Length; i++) { sortColumn = columns[i].ColumnCell; strSorting += "<SortExpression><Value>=Fields!" + sortColumn.Name + @".Value</Value>"; if (columns[i].SortDirection == ReportSort.Descending) { strSorting += "<Direction>Descending</Direction>"; } strSorting += @"</SortExpression>"; } strSorting += "</SortExpressions>"; return(strSorting); }
static string GenerateTableRow(ReportBuilder reportBuilder, ReportTable table) { ReportColumns[] columns = table.ReportDataColumns; ReportTextBoxControl ColumnCell = new ReportTextBoxControl(); ReportScale colHeight = ColumnCell.Size; ReportDimensions padding = new ReportDimensions(); if (columns == null) { return(""); } string strTableRow = ""; strTableRow = @"<TablixRow> <Height>0.6cm</Height> <TablixCells>"; for (int i = 0; i < columns.Length; i++) { ColumnCell = columns[i].ColumnCell; padding = ColumnCell.Padding; strTableRow += @"<TablixCell> <CellContents> " + GenerateTextBox("txtCell_" + table.ReportName + "_", ColumnCell.Name, "", true, padding) + @" </CellContents> </TablixCell>"; } strTableRow += @"</TablixCells></TablixRow>"; return(strTableRow); }
private void PostaviIzvjestaj(DataSet ds) { DataTable dt = ds.Tables[0]; this.reportViewer1.Reset(); this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(dt.TableName, dt)); ReportBuilder reportBuilder = new ReportBuilder(); reportBuilder.DataSource = ds; reportBuilder.Page = new ReportPage(); ReportSections reportFooter = new ReportSections(); ReportItems reportFooterItems = new ReportItems(); ReportTextBoxControl[] footerTxt = new ReportTextBoxControl[3]; footerTxt[0] = new ReportTextBoxControl() { Name = "txtCopyright", ValueOrExpression = new string[] { string.Format("Copyright {0}", DateTime.Now.Year) } }; footerTxt[1] = new ReportTextBoxControl() { Name = "ExecutionTime", ValueOrExpression = new string[] { "Izvjestaj generiran " + DateTime.Now.ToString() } }; footerTxt[2] = new ReportTextBoxControl() { Name = "PageNumber", ValueOrExpression = new string[] { "Stranica ", ReportGlobalParameters.CurrentPageNumber, " of ", ReportGlobalParameters.TotalPages } }; reportFooterItems.TextBoxControls = footerTxt; reportFooter.ReportControlItems = reportFooterItems; reportBuilder.Page.ReportFooter = reportFooter; ReportSections reportHeader = new ReportSections(); reportHeader.Size = new ReportScale(); reportHeader.Size.Height = 0.05; ReportItems reportHeaderItems = new ReportItems(); ReportTextBoxControl[] headerTxt = new ReportTextBoxControl[1]; headerTxt[0] = new ReportTextBoxControl() { Name = "txtReportTitle", ValueOrExpression = new string[] { "Stanje na dan : " + DateTime.Now.ToString() } }; reportHeaderItems.TextBoxControls = headerTxt; reportHeader.ReportControlItems = reportHeaderItems; reportBuilder.Page.ReportHeader = reportHeader; this.reportViewer1.LocalReport.LoadReportDefinition(ReportEngine.GenerateReport(reportBuilder)); this.reportViewer1.RefreshReport(); }
static string GenerateFirstWhiteSpacesRow(ReportBuilder reportBuilder, ReportTable table, string filter) { ReportColumns[] columns = table.ReportDataColumns; ReportTextBoxControl ColumnCell = new ReportTextBoxControl(); ReportScale colHeight = ColumnCell.Size; ReportDimensions padding = new ReportDimensions(); if (columns == null) { return(""); } string strTableRow = ""; strTableRow += @"<TablixRow> <Height>0.6cm</Height> <TablixCells>"; for (int i = 0; i < columns.Length; i++) { if (i == 0) { ColumnCell = columns[i].ColumnCell; padding = ColumnCell.Padding; strTableRow += @"<TablixCell> <CellContents> " + GenerateFirstRowWhiteTextBox(filter, filter, ColumnCell.Name, "", true, padding) + @" </CellContents> </TablixCell>"; } else { count += 3; ColumnCell = columns[i].ColumnCell; padding = ColumnCell.Padding; strTableRow += @"<TablixCell />"; } } strTableRow += @"</TablixCells> </TablixRow>"; return(strTableRow); }
/// <summary> /// Bind Report With DataSet /// </summary> /// <param name="ds">DataSet</param> public void DataBind(DataSet ds) { int count = 0; foreach (DataTable dt in ds.Tables) { count++; var report_name = "Report" + count; DataTable dt1 = new DataTable(report_name.ToString()); dt1 = ds.Tables[count - 1]; dt1.TableName = report_name.ToString(); } //Report Viewer, Builder and Engine ReportViewer1.Reset(); for (int i = 0; i < ds.Tables.Count; i++) { ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource(ds.Tables[i].TableName, ds.Tables[i])); } ReportBuilder reportBuilder = new ReportBuilder(); reportBuilder.DataSource = ds; reportBuilder.Page = new ReportPage(); ReportSections reportFooter = new ReportSections(); ReportItems reportFooterItems = new ReportItems(); ReportTextBoxControl[] footerTxt = new ReportTextBoxControl[3]; //string footer = string.Format("Copyright {0} Report Generated On {1} Page {2}", DateTime.Now.Year, DateTime.Now, ReportGlobalParameters.CurrentPageNumber); string footer = string.Format("Copyright {0} Report Generated On {1} Page {2} of {3} ", DateTime.Now.Year, DateTime.Now, ReportGlobalParameters.CurrentPageNumber, ReportGlobalParameters.TotalPages); footerTxt[0] = new ReportTextBoxControl() { Name = "txtCopyright", ValueOrExpression = new string[] { footer } }; reportFooterItems.TextBoxControls = footerTxt; reportFooter.ReportControlItems = reportFooterItems; reportBuilder.Page.ReportFooter = reportFooter; ReportSections reportHeader = new ReportSections(); reportHeader.Size = new ReportScale(); reportHeader.Size.Height = 0.56849; ReportItems reportHeaderItems = new ReportItems(); ReportTextBoxControl[] headerTxt = new ReportTextBoxControl[1]; headerTxt[0] = new ReportTextBoxControl() { Name = "txtReportTitle", ValueOrExpression = new string[] { "Report Name: " + ReportTitle } }; reportHeaderItems.TextBoxControls = headerTxt; reportHeader.ReportControlItems = reportHeaderItems; reportBuilder.Page.ReportHeader = reportHeader; ReportViewer1.LocalReport.LoadReportDefinition(ReportEngine.GenerateReport(reportBuilder)); ReportViewer1.LocalReport.DisplayName = ReportName; }
/// <summary> /// Bind Report With DataSet /// </summary> /// <param name="ds">DataSet</param> public void RDataBind(DataSet ds, string filter, bool showThisGrouped, int[] lista) { int count = 0; foreach (DataTable dt in ds.Tables) { count++; var report_name = "Report" + count; DataTable dt1 = new DataTable(report_name.ToString()); dt1 = ds.Tables[count - 1]; dt1.TableName = report_name.ToString(); } //Report Viewer, Builder and Engine ReportViewer ReportViewer1 = new ReportViewer(); ReportViewer1.Reset(); for (int i = 0; i < ds.Tables.Count; i++) { ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource(ds.Tables[i].TableName, ds.Tables[i])); } ReportBuilder reportBuilder = new ReportBuilder(); reportBuilder.DataSource = ds; reportBuilder.Page = new ReportPage(); ReportSections reportFooter = new ReportSections(); ReportItems reportFooterItems = new ReportItems(); ReportTextBoxControl[] footerTxt = new ReportTextBoxControl[3]; //string footer = string.Format("Copyright {0} Report Generated On {1} Page {2}", DateTime.Now.Year, DateTime.Now, ReportGlobalParameters.CurrentPageNumber); string footer = string.Format("Copyright {0} Report Generated On {1} Page {2} of {3} ", DateTime.Now.Year, DateTime.Now, ReportGlobalParameters.CurrentPageNumber, ReportGlobalParameters.TotalPages); footerTxt[0] = new ReportTextBoxControl() { Name = "txtCopyright", ValueOrExpression = new string[] { footer } }; reportFooterItems.TextBoxControls = footerTxt; reportFooter.ReportControlItems = reportFooterItems; reportBuilder.Page.ReportFooter = reportFooter; ReportSections reportHeader = new ReportSections(); reportHeader.Size = new ReportScale(); reportHeader.Size.Height = 0.56849; ReportItems reportHeaderItems = new ReportItems(); ReportTextBoxControl[] headerTxt = new ReportTextBoxControl[3]; headerTxt[0] = new ReportTextBoxControl() { Name = "txtReportTitle", ValueOrExpression = new string[] { "NOMBRE DEL REPORTE: 2" + ReportTitle } }; headerTxt[1] = new ReportTextBoxControl() { Name = "txtReportTitle2", ValueOrExpression = new string[] { "Razon Social: 0 " + Empresa } }; headerTxt[2] = new ReportTextBoxControl() { Name = "txtReportTitle1", ValueOrExpression = new string[] { "Ruc: 1 " + Ruc } }; reportHeaderItems.TextBoxControls = headerTxt; reportHeader.ReportControlItems = reportHeaderItems; reportBuilder.Page.ReportHeader = reportHeader; ReportViewer1.LocalReport.LoadReportDefinition(ReportEngine.GenerateReport(reportBuilder, filter, showThisGrouped, lista)); ReportViewer1.LocalReport.DisplayName = ReportName; ReportViewer1.Dock = DockStyle.Fill; Form Frm = new Form(); Frm.Size = new Size(750, 550); Frm.Controls.Add(ReportViewer1); Frm.Show(); ReportViewer1.RefreshReport(); }
private void btnRechargeCardView_Click(object sender, EventArgs e) { if (!ValidateDataCardInput()) { return; } dgvRechargeCardHistory.DataSource = null; DateTime date_begin = new DateTime(dtpSaleGasBegin.Value.Year, dtpSaleGasBegin.Value.Month, dtpSaleGasBegin.Value.Day, 0, 0, 0); DateTime date_end = new DateTime(dtpSaleGasEnd.Value.Date.Year, dtpSaleGasEnd.Value.Month, dtpSaleGasEnd.Value.Day, 23, 59, 59); String customerId = (cboRechargeCardCustomer.SelectedItem as ComboboxItem).Value.ToString(); Task <String> task = SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterTask( () => { return(m_service.SGMSaleGas_GetCardReport(customerId, date_begin, date_end, txtRechargeCardID.Text.Trim())); }); SGM_WaitingIdicator.WaitingForm.waitingFrm.progressReporter.RegisterContinuation(task, () => { String stResponse = task.Result as String; DataTransfer dataResponse = JSonHelper.ConvertJSonToObject(stResponse); if (dataResponse.ResponseCode == DataTransfer.RESPONSE_CODE_SUCCESS) { if (dataResponse.ResponseDataSet != null) { dgvRechargeCardHistory.DataSource = dataResponse.ResponseDataSet.Tables[0]; cardReportViewer.Reset(); String tableName = dataResponse.ResponseDataSet.Tables[0].TableName; DataTable data = dataResponse.ResponseDataSet.Tables[0]; cardReportViewer.LocalReport.DataSources.Add(new ReportDataSource(tableName, data)); ReportBuilder reportBuilder = new ReportBuilder(); reportBuilder.DataSource = dataResponse.ResponseDataSet; reportBuilder.Page = new ReportPage(); ReportSections reportHeader = new ReportSections(); reportHeader.Size = new ReportScale(); reportHeader.Size.Height = 0.1; ReportItems reportHeaderItems = new ReportItems(); ReportTextBoxControl[] headerTxt = new ReportTextBoxControl[1]; headerTxt[0] = new ReportTextBoxControl() { Name = "txtReportTitle", ValueOrExpression = new string[] { string.Format("Sales Report: {0}", DateTime.Now) } }; reportHeaderItems.TextBoxControls = headerTxt; reportHeader.ReportControlItems = reportHeaderItems; reportBuilder.Page.ReportHeader = reportHeader; cardReportViewer.LocalReport.LoadReportDefinition(ReportEngine.GenerateReport(reportBuilder)); cardReportViewer.RefreshReport(); } else { frmMsg.ShowMsg(SGMText.SGM_INFO, SGMText.REPORT_NO_DATA, SGMMessageType.SGM_MESSAGE_TYPE_INFO); } } else { frmMsg.ShowMsg(SGMText.SGM_ERROR, dataResponse.ResponseErrorMsg, SGMMessageType.SGM_MESSAGE_TYPE_ERROR); } }, SynchronizationContext.Current); }