using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.Drawing; using System.Data; using FastReport; using FastReport.Data; using FastReport.Dialog; using FastReport.Barcode; using FastReport.Table; using FastReport.Utils; using System.Text.RegularExpressions; using System.Text; namespace FastReport { public class ReportScript { private void TanuloOsszesito_StartPage(object sender, EventArgs e) { bool isMulasztasokUjLapon; Boolean.TryParse(Report.Parameters.FindByName("isMulasztasokUjLapon").Value.ToString(), out isMulasztasokUjLapon); DataHeader2.StartNewPage = isMulasztasokUjLapon; bool isPHMegjelenites = true; Boolean.TryParse(Report.Parameters.FindByName("PHMegjelenitese").Value.ToString(), out isPHMegjelenites); Rich9.Visible = isPHMegjelenites; string idoszakName = ""; switch(Report.Parameters.FindByName("Idoszak").Value.ToString()) { case "1519": idoszakName = "első félévében"; break; case "1520": idoszakName=""; EvVegiHatarozat.Visible = true; break; case "1522": idoszakName="I. negyedévében"; break; case "1524": idoszakName="II. negyedévében"; break; case "1523": idoszakName="III. negyedévében"; break; case "1525": idoszakName="IV. negyedévében"; break; } Text2.Text = string.Format(Text2.Text, idoszakName); // Tanulók DataSourceBase tanuloAlapadatok = Report.GetDataSource("TanuloAlapAdatok"); DataTanuloAlapadatok.DataSource = tanuloAlapadatok; tanuloAlapadatok.Init(); //Gondviselo DataSourceBase tanuloGondviselo = Report.GetDataSource("TanuloGondviselo"); DataGondviselo.DataSource = tanuloGondviselo; Relation rel7 = new Relation(); rel7.Name = "TanuloEler"; rel7.ParentDataSource = tanuloAlapadatok; rel7.ChildDataSource = tanuloGondviselo; rel7.ParentColumns = new string[] { "TANULOID" }; rel7.ChildColumns = new string[] { "tanuloID" }; Report.Dictionary.Relations.Add(rel7); tanuloGondviselo.Init(tanuloAlapadatok); // Tanulók elérhetőségei DataSourceBase tanuloElerhetosegei = Report.GetDataSource("TanuloElerhetosegei"); DataTanuloElerhetosegei.DataSource = tanuloElerhetosegei; Relation rel2 = new Relation(); rel2.Name = "TanuloEler"; rel2.ParentDataSource = tanuloAlapadatok; rel2.ChildDataSource = tanuloElerhetosegei; rel2.ParentColumns = new string[] { "TANULOID" }; rel2.ChildColumns = new string[] { "tanuloID" }; Report.Dictionary.Relations.Add(rel2); tanuloElerhetosegei.Init(tanuloAlapadatok); //Targyak DataSourceBase tanuloTargyak = Report.GetDataSource("TanuloTantargyak"); DataTanuloTargyak.DataSource = tanuloTargyak; Relation rel3 = new Relation(); rel3.Name = "TanuloTargyEler"; rel3.ParentDataSource = tanuloAlapadatok; rel3.ChildDataSource = tanuloTargyak; rel3.ParentColumns = new string[] { "TANULOID", "TanuloCsoportId" }; rel3.ChildColumns = new string[] { "TanuloId", "TanuloCsoportId" }; Report.Dictionary.Relations.Add(rel3); tanuloTargyak.Init(tanuloAlapadatok); //IgazoltMulasztas DataSourceBase tanuloMulasztas = Report.GetDataSource("TanuloMulasztasai"); DataTanuloMulasztottOrak.DataSource = tanuloMulasztas; Relation rel4 = new Relation(); rel4.Name = "TanuloMulasztasEler"; rel4.ParentDataSource = tanuloAlapadatok; rel4.ChildDataSource = tanuloMulasztas; rel4.ParentColumns = new string[] { "TANULOID", "TanuloCsoportId" }; rel4.ChildColumns = new string[] { "TanuloId", "TanuloCsoportId" }; Report.Dictionary.Relations.Add(rel4); tanuloMulasztas.Init(tanuloAlapadatok); //Felmentesek DataSourceBase tanuloFelmentes = Report.GetDataSource("TanuloTantargyiFelmentesei"); Data.DataSource = tanuloFelmentes; Relation rel5 = new Relation(); rel5.Name = "TanuloFelmentesEler"; rel5.ParentDataSource = tanuloAlapadatok; rel5.ChildDataSource = tanuloFelmentes; rel5.ParentColumns = new string[] { "TANULOID", "TanuloCsoportId" }; rel5.ChildColumns = new string[] { "TanuloId", "TanuloCsoportId" }; Report.Dictionary.Relations.Add(rel5); tanuloFelmentes.Init(tanuloAlapadatok); //Feljegyzesek DataSourceBase tanuloFeljegyzes = Report.GetDataSource("TantestuletFeljegyzes"); Data2.DataSource = tanuloFeljegyzes; Relation rel6 = new Relation(); rel6.Name = "TanuloFeljegyzesEler"; rel6.ParentDataSource = tanuloAlapadatok; rel6.ChildDataSource = tanuloFeljegyzes; rel6.ParentColumns = new string[] { "TANULOID", "TanuloCsoportId" }; rel6.ChildColumns = new string[] { "TanuloId", "TanuloCsoportId" }; Report.Dictionary.Relations.Add(rel6); tanuloFeljegyzes.Init(tanuloAlapadatok); int fontSizeDifference = (int)Report.GetParameterValue("FontSizeDifference"); SetChildObjects(TanuloOsszesito.PageHeader.Objects, fontSizeDifference); SetChildObjects(DataTanuloAlapadatok.Objects, fontSizeDifference); SetChildObjects(DataGondviselo.Objects, fontSizeDifference); SetChildObjects(DataTanuloElerhetosegei.Objects, fontSizeDifference); SetChildObjects(DataHeader1.Objects, fontSizeDifference); SetChildObjects(DataTanuloTargyak.Objects, fontSizeDifference); SetChildObjects(DataTanuloMulasztottOrak.Objects, fontSizeDifference); SetChildObjects(DataHeader3.Objects, fontSizeDifference); SetChildObjects(Data.Objects, fontSizeDifference); SetChildObjects(DataHeader4.Objects, fontSizeDifference); SetChildObjects(Data2.Objects, fontSizeDifference); SetChildObjects(Data3.Objects, fontSizeDifference); } private void SetChildObjects(ReportComponentCollection collection, int fontSizeDifference) { foreach(ReportComponentBase text in collection) { if (text is RichObject) { SetTextFont((RichObject)text, fontSizeDifference); } if (text is TextObject) { SetTextFont((TextObject)text, fontSizeDifference); } } } private void SetTextFont(TextObject text, int fontSizeDifference) { int fontSizeCorrection = ((fontSizeDifference != 0) && (text.Font.Size > 14)) ? 1 : 0; Font font = new Font(text.Font.FontFamily, text.Font.Size - (fontSizeDifference + fontSizeCorrection), text.Font.Style); text.Font = font; } private void SetTextFont(RichObject text, int fontSizeDifference) { Regex regex = new Regex("\\\\fs\\d{2}"); foreach(Match m in regex.Matches(text.Text)) { int size = int.Parse(m.Value.Substring(3)); int fontSizeCorrection = ((fontSizeDifference != 0) && (size > 28)) ? 2 : 0; text.Text = text.Text.Replace(m.Value, "\\fs" + (size - (fontSizeDifference + fontSizeCorrection))); } } private void SetTextHtml2Rich(RichObject text) { StringBuilder sb = new StringBuilder(text.Text); sb.Replace("<b>", @"\b ") .Replace("</b>", @"\b0 ") .Replace("<u>", @"\ul ") .Replace("</u>", @"\ulnone ") .Replace("<i>", @"\i ") .Replace("</i>", @"\i0 ") .Replace("<sub>", @"\dn ") .Replace("</sub>", @"\dn0 ") .Replace("<sup>", @"\up ") .Replace("</sup>", @"\up0 "); text.Text = sb.ToString(); } private void Rich3_AfterData(object sender, EventArgs e) { SetTextHtml2Rich((RichObject)sender); } } }