private void CreateReportTemplate(ReportInfo info, DataTable printTable) { GridppReport Report = new GridppReport(); Report.InsertReportHeader(); Report.InsertDetailGrid(); foreach (DataColumn col in printTable.Columns) { GRFieldType grFieldType = ConvertToGRFieldType(col.DataType); Report.DetailGrid.Recordset.AddField(col.ColumnName, grFieldType); IGRColumn c = Report.DetailGrid.Columns.Add(); c.Name = col.ColumnName; c.TitleCell.Text = col.ColumnName; c.ContentCell.DataField = col.ColumnName; } if (info.ReportParameters != null) { for (int i = 0; i < info.ReportParameters.Length; i++) { if (Report.Parameters.IndexByName(info.ReportParameters[i].Text) < 0) { IGRParameter p = Report.Parameters.Add(); p.Name = info.ReportParameters[i].Text; p.DataType = GRParameterDataType.grptString; } } } Report.SaveToFile(info.TemplateFile); }
private void UpdateReportTemplate(ReportInfo info, DataTable printTable) { if (!this.checkBox1.Checked) { return; } GridppReport Report = new GridppReport(); bool bChanged = false; Report.LoadFromFile(ri.TemplateFile); if (ri.ReportParameters != null) { for (int i = 0; i < ri.ReportParameters.Length; i++) { if (Report.Parameters.IndexByName(ri.ReportParameters[i].Text) < 0) { IGRParameter p = Report.Parameters.Add(); p.Name = ri.ReportParameters[i].Text; p.DataType = GRParameterDataType.grptString; bChanged = true; } } } if (printTable != null) { if (Report.DetailGrid == null) { Report.InsertDetailGrid(); } foreach (DataColumn dtcol in printTable.Columns) { GRFieldType grFieldType = ConvertToGRFieldType(dtcol.DataType); if (Report.DetailGrid.Recordset.Fields.IndexByName(dtcol.ColumnName) < 0) { Report.DetailGrid.Recordset.AddField(dtcol.ColumnName, grFieldType); IGRColumn c = Report.DetailGrid.Columns.Add(); c.Name = dtcol.ColumnName; c.TitleCell.Text = dtcol.ColumnName; c.ContentCell.DataField = dtcol.ColumnName; bChanged = true; } } } if (bChanged) { Report.SaveToFile(ri.TemplateFile); } }