private FastReport.Report CreateReport(String body, int id_group) { Report report = new Report(); report.LoadFromString(body); var postgresConn = FindConnection(report, "Current data") as PostgresDataConnection; report.Parameters.FindByName("idGroup").Value = id_group.ToString(); if (postgresConn == null) { postgresConn = new PostgresDataConnection() { Name = "Current data", Enabled = true }; report.Dictionary.Connections.Add(postgresConn); } postgresConn.ConnectionString = MainPluginClass.App.ConnectionString; foreach (TableDataSource item in postgresConn.Tables) { item.SelectCommand = item.SelectCommand.Replace("@idGroup", id_group.ToString()); } return(report); }
private static TableDataSource FindTablePhotoDataSource(PostgresDataConnection pgConnFR, TableModel_M tm) { foreach (TableDataSource item in pgConnFR.Tables) { if (item.Name == tm.Table.nameDB + "_photo") { return(item); } } return(null); }
private FastReport.Report CreateReport() { var report = new Report(); if (!_reportItemM.IsNew) { report.LoadFromString(_reportItemM.Body); } var postgresConn = FindConnection(report, "Current data") as PostgresDataConnection; if (postgresConn == null) { postgresConn = new PostgresDataConnection() { Name = "Current data", Enabled = true }; report.Dictionary.Connections.Add(postgresConn); } postgresConn.ConnectionString = Program.connString.ToString(); Interfaces.tablesInfo tableInfo = null; if (_reportItemM.Type == enTypeReport.Table || _reportItemM.Type == enTypeReport.Object) { tableInfo = Program.app.getTableInfo(_filter.IdTable); } if (_isDesign) { cti.ThreadProgress.ShowWait("CreateReport"); foreach (var item in _reports) { try { var table = FindTableDataSource(postgresConn, item); if (table == null) { table = CreateTableDataSource(item); table.Enabled = (_reportItemM.Type == enTypeReport.Object || _reportItemM.Type == enTypeReport.Table); postgresConn.Tables.Add(table); } if (item.Table.photo) { var tmPhoto = new TableModel_M(item.Table, item.Type, true); var tablePhoto = FindTablePhotoDataSource(postgresConn, tmPhoto); if (tablePhoto == null) { tablePhoto = CreateTablePhotoDataSource(tmPhoto); tablePhoto.Enabled = false; postgresConn.Tables.Add(tablePhoto); } //var pkColumn = table.Columns.FindByName(item.Table.pkField); //var pkColumnPhoto = tablePhoto.Columns.FindByName("id_obj"); //var relName = table.TableName + "_" + item.Table.nameMap + "_photo"; //RelationCollection //var ds = new DataSet(); //ds.Tables.Add(table); //ds.Tables.Add(tablePhoto); //var d = new DataRelation(relName, pkColumn, pkColumnPhoto); //report.RegisterData(d, relName); // Declare all the tables that will have relations var nameRelation = table.TableName + "_" + item.Table.nameMap + "_photo"; Relation rel = report.Dictionary.Relations.FindByName(nameRelation); if (rel == null) { var ParentTable = postgresConn.FindObject(item.Table.nameDB) as TableDataSource; var PhotoTable = postgresConn.FindObject(item.Table.nameDB + "_photo") as TableDataSource; // Declare the relations rel = new Relation(); rel.Enabled = false; rel.Name = nameRelation; rel.ParentDataSource = ParentTable; rel.ChildDataSource = PhotoTable; rel.ParentColumns = new string[] { item.Table.pkField }; rel.ChildColumns = new string[] { Resources.Report_VM_photoIdObj }; report.Dictionary.Relations.Add(rel); } } } catch (Exception ex) { Debug.WriteLine(ex.Message, "NpgsqlException"); continue; } } cti.ThreadProgress.Close("CreateReport"); } //if (tableInfo != null) //report.SetParameterValue("idCurrentObject", "\"" + tableInfo.pkField + "\" = " + _filter.IdObj); return(report); }
public PeopleController(PostgresDataConnection connection) { _connection = connection; }