using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Stimulsoft.Report; using System.Data; using System.Data.Sql; using System.Data.SqlClient; using Stimulsoft.Report.Dictionary; using Stimulsoft.Report.Export; using Stimulsoft.Base.Services; using Stimulsoft.Base; using ns_MoneyFlow.DAL; using System.Web.Configuration; using System.Web.Security; using System.IO; using Stimulsoft.Report.Components; using Stimulsoft.Base.Drawing; using Stimulsoft.Report.Web; using System.Drawing; using Stimulsoft.Controls; public partial class Default2 : System.Web.UI.Page { private StiReport report = new StiReport(); protected void Page_Load(object sender, EventArgs e) { try { StiReport report = CreateReport2(); report.Render(false); StiWebViewer1.Report = report; StiWebViewer1.ViewMode = StiWebViewMode.WholeReport; //StiReportResponse.ResponseAsPdf(this.Page, report, false); //StiOptions.Web.AllowUseResponseFlush = false; } catch (SqlException ex) { ErrorExtension ErrorExtension = new ErrorExtension(); ErrorExtension.ToLogString(ex, ""); Response.Redirect("ErrorPage.aspx?Error=2&Page=" + Page.Title); } catch (Exception ex) { ErrorExtension ErrorExtension = new ErrorExtension(); ErrorExtension.ToLogString(ex, ""); Response.Redirect("ErrorPage.aspx?Error=1&Page=" + Page.Title); } } public StiReport CreateReport2() { StiReport report = new StiReport(); cs_GeneralLedger.cs_GLReports objBalanceSheetRep = new cs_GeneralLedger.cs_GLReports(); objBalanceSheetRep.Login = (string)Session["UserID"]; objBalanceSheetRep.LoginPassword = (string)Session["Password"]; DataSet dsBSReport = objBalanceSheetRep.m_BalanceSheetReport(11, "26/5/2013", "GL", true, "abc"); dsBSReport.Tables[0].TableName = "dtBSRepTitleDetails"; DataTable dtRepDet = dsBSReport.Tables[0]; dsBSReport.Tables[1].TableName = "dtBSUsersPCList"; DataTable dtUserPC = dsBSReport.Tables[1]; dsBSReport.Tables[2].TableName = "dtBSLiabs"; DataTable dtRepLiab = dsBSReport.Tables[2]; dsBSReport.Tables[3].TableName = "dtBSAssets"; DataTable dtRepAsst = dsBSReport.Tables[3]; report.RegData(dsBSReport); report.Dictionary.Synchronize(); StiPage MainRepPage = report.Pages[0]; MainRepPage.PaperSize = System.Drawing.Printing.PaperKind.Ledger; MainRepPage.Orientation = StiPageOrientation.Landscape; MainRepPage.PrintOn = StiPrintOnType.AllPages; MainRepPage.Enabled = true; //Create Report Title Band StiReportTitleBand TitleBand = new StiReportTitleBand(); TitleBand.Height =3; TitleBand.Name = "TitleBand"; TitleBand.Enabled = true; TitleBand.Printable = true; TitleBand.CanGrow = true; TitleBand.PrintIfEmpty = true; MainRepPage.Components.Add(TitleBand); // Panel in title band StiPanel pnReportTitle = new StiPanel(new RectangleD(0, 0, MainRepPage.PageWidth, 0.5)); TitleBand.Components.Add(pnReportTitle); // Company Logo in title band StiImage imgCompLogo = new StiImage(new RectangleD(3.5, 0, 3, 1.4)); imgCompLogo.Enabled = true; imgCompLogo.Printable = true; imgCompLogo.CanShrink = true; imgCompLogo.AspectRatio = true; pnReportTitle.Components.Add(imgCompLogo); // Get the logo image from the given path DataRow dr = dtRepDet.Rows[0]; if (dr["CompLogoPath"].ToString() != "") { if (File.Exists(Server.MapPath(dr["CompLogoPath"].ToString()))) { imgCompLogo.Image = Stimulsoft.Base.Drawing.StiImageFromURL.LoadBitmap(Server.MapPath(dr["CompLogoPath"].ToString())); } } // Company Name in title band StiText txtCompName = new StiText(new RectangleD(3.5, 1.5, 3, 0.4)); txtCompName.Text.Value = dr["CompanyName"].ToString(); txtCompName.Font = new Font("Arial", 10F, System.Drawing.FontStyle.Bold); txtCompName.HorAlignment = StiTextHorAlignment.Center; txtCompName.VertAlignment = StiVertAlignment.Center; txtCompName.CanGrow = true; txtCompName.Enabled = true; txtCompName.Printable = true; pnReportTitle.Components.Add(txtCompName); // Company Address in title band StiText txtCompAddress = new StiText(new RectangleD(3.5, 1.9 , 3, 0.4)); txtCompAddress.Text.Value = dr["CompAddress"].ToString(); txtCompAddress.Font = new Font("Arial", 10F, System.Drawing.FontStyle.Bold); txtCompAddress.HorAlignment = StiTextHorAlignment.Center; txtCompAddress.VertAlignment = StiVertAlignment.Center; txtCompAddress.CanGrow = true; txtCompAddress.Enabled = true; txtCompAddress.Printable = true; pnReportTitle.Components.Add(txtCompAddress); // Report title in title band StiText txtReportTitle = new StiText(new RectangleD(3.5 ,2.3, 3 , 0.5)); txtReportTitle.Text.Value = dr["Heading"].ToString(); txtReportTitle.Font = new Font("Arial", 10F, System.Drawing.FontStyle.Bold); txtReportTitle.HorAlignment = StiTextHorAlignment.Center; txtReportTitle.VertAlignment = StiVertAlignment.Center; txtReportTitle.CanGrow = true; txtReportTitle.Enabled = true; txtReportTitle.Printable = true; pnReportTitle.Components.Add(txtReportTitle); StiHeaderBand hbMain = new StiHeaderBand(new RectangleD(0, 0.5, MainRepPage.PageWidth, 0.5)); MainRepPage.Components.Add(hbMain); //StiGroupHeaderBand hbMain = new StiGroupHeaderBand(new RectangleD(0, 0.5, MainRepPage.PageWidth, 0.5)); //MainRepPage.Components.Add(hbMain); // Add the main databand StiDataBand dbMain = new StiDataBand(new RectangleD(0, 0.5, MainRepPage.PageWidth, 2)); dbMain.Name = "stidbMain"; dbMain.Printable = true; dbMain.PrintOnAllPages = true; MainRepPage.Components.Add(dbMain); // Create the liability sub report page StiPage LiabRep = new StiPage(); LiabRep.PaperSize = System.Drawing.Printing.PaperKind.Custom; LiabRep.PageWidth = (dbMain.Width - MainRepPage.Margins.Left - MainRepPage.Margins.Right) / 2; LiabRep.Orientation = StiPageOrientation.Portrait; LiabRep.Margins.Top = MainRepPage.Margins.Top; LiabRep.Margins.Bottom = MainRepPage.Margins.Bottom; LiabRep.Margins.Left = 0; LiabRep.Margins.Right = 0; LiabRep.PrintOn = StiPrintOnType.AllPages; report.Pages.Add(LiabRep); // Create the Asset sub report page StiPage AssetRep = new StiPage(); AssetRep.PaperSize = System.Drawing.Printing.PaperKind.Custom; AssetRep.PageWidth = (dbMain.Width - MainRepPage.Margins.Left - MainRepPage.Margins.Right) / 2; AssetRep.Orientation = StiPageOrientation.Portrait; AssetRep.Margins.Top = MainRepPage.Margins.Top; AssetRep.Margins.Bottom = MainRepPage.Margins.Bottom; AssetRep.Margins.Left = 0; AssetRep.Margins.Right = 0; AssetRep.PrintOn = StiPrintOnType.AllPages; report.Pages.Add(AssetRep); // Create Sub report for Liabilities StiSubReport SubRep1 = new StiSubReport(new RectangleD(0, 0, LiabRep.PageWidth , 1)); SubRep1.Name = "subLiabRep"; SubRep1.Page = LiabRep; SubRep1.SubReportPageGuid = LiabRep.Guid; dbMain.Components.Add(SubRep1); // Calculate the starting point for the Asset sub report double AssetL = (dbMain.Width - MainRepPage.Margins.Left - MainRepPage.Margins.Right) / 2; // Create Sub report for Assets StiSubReport SubRep2 = new StiSubReport(new RectangleD(AssetL, 0, AssetRep.PageWidth, 1)); SubRep2.Name = "subAssetRep"; SubRep2.Page = AssetRep; SubRep2.SubReportPageGuid = AssetRep.Guid; dbMain.Components.Add(SubRep2); // Variables for calculating the width of the text boxes in each band double columnWidth = LiabRep.PageWidth / ((dtUserPC.Rows.Count + 2) * 2); double x = columnWidth * 2; double gap = x * 2 / 6; double pos = 0; // ---------------------------------------------------- Liabilities -------------------------------------------------------- // //Create Databand for header band in Liabilities sub report StiDataBand dbinhbLiab = new StiDataBand(new RectangleD(0, 0, LiabRep.PageWidth, 0.8)); dbinhbLiab.Height = 0.8; dbinhbLiab.Name = "LiabHeaderDataBand"; dbinhbLiab.PrintOnAllPages = true; LiabRep.Components.Add(dbinhbLiab); // "Liabilities" header StiText txtLiabHdr = new StiText(new RectangleD(pos, 0, (x * 2), 0.7)); txtLiabHdr.Text.Value = "Liabilities"; txtLiabHdr.Font = new Font("Arial", 8F, System.Drawing.FontStyle.Bold); txtLiabHdr.HorAlignment = StiTextHorAlignment.Center; txtLiabHdr.VertAlignment = StiVertAlignment.Center; txtLiabHdr.Name = "HeaderTextL"; txtLiabHdr.Border.Side = StiBorderSides.All; txtLiabHdr.ShrinkFontToFit = true; dbinhbLiab.Components.Add(txtLiabHdr); //Add databand for Chart of Accounts StiDataBand dbLiabAccts = new StiDataBand();//new RectangleD(0, 3, LiabRep.PageWidth, 0.8)); ; dbLiabAccts.DataSourceName = "dtBSLiabs"; dbLiabAccts.Height = 0.3; dbLiabAccts.Sort = new System.String[] { "ASC", "CompAccName" }; LiabRep.Components.Add(dbLiabAccts); StiText txtLiabAccts = new StiText(new RectangleD(gap * 2, 0, (x * 2) - (gap * 2), 0.4)); txtLiabAccts.Text.Value = "{dtBSLiabs.CompAccName}"; txtLiabAccts.HorAlignment = StiTextHorAlignment.Left; txtLiabAccts.VertAlignment = StiVertAlignment.Center; txtLiabAccts.Border.Side = StiBorderSides.None; txtLiabAccts.Type = StiSystemTextType.DataColumn; txtLiabAccts.WordWrap = true; txtLiabAccts.ShrinkFontToFit = true; dbLiabAccts.Components.Add(txtLiabAccts); // Add footer band to display 'Difference in Opening balance' //StiFooterBand fbLiab = new StiFooterBand(); //fbLiab.Height = 0.4; //fbLiab.Enabled = false; //fbLiab.Printable = true; //fbLiab.PrintIfEmpty = true; //LiabRep.Components.Add(fbLiab); //// Panel in footer band //StiPanel pnfbLiab = new StiPanel(new RectangleD(0, 0, LiabRep.PageWidth, 0.4)); //fbLiab.Components.Add(pnfbLiab); //StiText txtDiffOpBalLiab = new StiText(new RectangleD(0.05, 0, x, 0.4)); //txtDiffOpBalLiab.Text.Value = "Difference in Opening Balance"; //txtDiffOpBalLiab.WordWrap = true; //txtDiffOpBalLiab.ShrinkFontToFit = true; //pnfbLiab.Components.Add(txtDiffOpBalLiab); //------------------------------------------------------ Assets --------------------------------------------------// //Create Databand for header band in Assets sub report StiDataBand dbinhbAsset = new StiDataBand(new RectangleD(0, 0, AssetRep.PageWidth, 0.8)); dbinhbAsset.Height = 0.8; dbinhbAsset.Name = "AssetHeaderDataBand"; dbinhbAsset.PrintOnAllPages = true; AssetRep.Components.Add(dbinhbAsset); // "Assets" header StiText txtAssetHdr = new StiText(new RectangleD(pos, 0, (x * 2), 0.7)); txtAssetHdr.Text.Value = "Assets"; txtAssetHdr.Font = new Font("Arial", 8F, System.Drawing.FontStyle.Bold); txtAssetHdr.HorAlignment = StiTextHorAlignment.Center; txtAssetHdr.VertAlignment = StiVertAlignment.Center; txtAssetHdr.Name = "HeaderTextA"; txtAssetHdr.Border.Side = StiBorderSides.All; txtAssetHdr.ShrinkFontToFit = true; dbinhbAsset.Components.Add(txtAssetHdr); //Add databand for Chart of Accounts StiDataBand dbAssetAccts = new StiDataBand(); dbAssetAccts.DataSourceName = "dtBSAssets"; dbAssetAccts.Height = 0.3; dbAssetAccts.Sort = new System.String[] { "ASC", "CompAccName" }; AssetRep.Components.Add(dbAssetAccts); StiText txtAssetAccts = new StiText(new RectangleD(gap * 2, 0, (x * 2) - (gap * 2), 0.4)); txtAssetAccts.Text.Value = "{dtBSAssets.CompAccName}"; txtAssetAccts.HorAlignment = StiTextHorAlignment.Left; txtAssetAccts.VertAlignment = StiVertAlignment.Center; txtAssetAccts.Border.Side = StiBorderSides.None; txtAssetAccts.Type = StiSystemTextType.DataColumn; txtAssetAccts.WordWrap = true; txtAssetAccts.ShrinkFontToFit = true; dbAssetAccts.Components.Add(txtAssetAccts); // Add footer band to display 'Difference in Opening balance' //StiFooterBand fbAsset = new StiFooterBand(); //fbAsset.Height = 0.4; //fbAsset.Enabled = false; //fbAsset.Printable = true; //fbAsset.PrintIfEmpty = true; //AssetRep.Components.Add(fbAsset); //// Panel in footer band //StiPanel pnfbAsset = new StiPanel(new RectangleD(0, 0, AssetRep.PageWidth, 0.4)); //fbAsset.Components.Add(pnfbAsset); //StiText txtDiffOpBalAsset = new StiText(new RectangleD(0.05, 0, x, 0.4)); //txtDiffOpBalAsset.Text.Value = "Difference in Opening Balance"; //txtDiffOpBalAsset.WordWrap = true; //txtDiffOpBalAsset.ShrinkFontToFit = true; //pnfbAsset.Components.Add(txtDiffOpBalAsset); // Set the starting point for the PC headers pos = pos + (x * 2); double k = 0; foreach (DataRow drUserPC in dtUserPC.Rows) { // ------------------------------------- Liabilities ------------------------------------------ // // Header with PC Num and name StiText txtLiabPChdr = new StiText(new RectangleD(pos, 0, x, 0.7)); txtLiabPChdr.Text.Value = drUserPC["ProfitCenter"].ToString() + System.Environment.NewLine + "Amt in Rs."; txtLiabPChdr.Font = new Font("Arial", 8F, System.Drawing.FontStyle.Bold); txtLiabPChdr.HorAlignment = StiTextHorAlignment.Center; txtLiabPChdr.VertAlignment = StiVertAlignment.Center; txtLiabPChdr.WordWrap = true; txtLiabPChdr.Border.Side = StiBorderSides.All; txtLiabPChdr.ShrinkFontToFit = true; dbinhbLiab.Components.Add(txtLiabPChdr); // Amount field for each chart of account StiText txtLiabAcctAmt = new StiText(new RectangleD(pos, 0, columnWidth, 0.4)); txtLiabAcctAmt.HorAlignment = StiTextHorAlignment.Right; txtLiabAcctAmt.VertAlignment = StiVertAlignment.Center; txtLiabAcctAmt.Border.Side = StiBorderSides.None; txtLiabAcctAmt.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular); txtLiabAcctAmt.Text.Value = "{dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + "}"; txtLiabAcctAmt.Type = StiSystemTextType.DataColumn; txtLiabAcctAmt.ShrinkFontToFit = true; txtLiabAcctAmt.WordWrap = true; dbLiabAccts.Components.Add(txtLiabAcctAmt); // If the amount is negative, then display in brackets and in red colour StiCondition cndLiabAcctAmt = new StiCondition(); cndLiabAcctAmt.Item = StiFilterItem.Value; cndLiabAcctAmt.DataType = StiFilterDataType.Numeric; cndLiabAcctAmt.TextColor = Color.Red; cndLiabAcctAmt.Column = "dtBSLiabs.n" + drUserPC["PC_Num"].ToString(); cndLiabAcctAmt.Condition = StiFilterCondition.LessThan; cndLiabAcctAmt.Value1 = "0"; cndLiabAcctAmt.Enabled = true; cndLiabAcctAmt.CanAssignExpression = true; cndLiabAcctAmt.AssignExpression = "\"(\" + " + "(dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + " * -1)" + " + \")\""; txtLiabAcctAmt.Conditions.Add(cndLiabAcctAmt); //---------------------------------------------- Assets -------------------------------------------------// // Header with PC Num and name StiText txtAssetPChdr = new StiText(new RectangleD(pos, 0, x, 0.7)); txtAssetPChdr.Text.Value = drUserPC["ProfitCenter"].ToString() + System.Environment.NewLine + "Amt in Rs."; txtAssetPChdr.Font = new Font("Arial", 8F, System.Drawing.FontStyle.Bold); txtAssetPChdr.HorAlignment = StiTextHorAlignment.Center; txtAssetPChdr.VertAlignment = StiVertAlignment.Center; txtAssetPChdr.WordWrap = true; txtAssetPChdr.Border.Side = StiBorderSides.All; txtAssetPChdr.ShrinkFontToFit = true; dbinhbAsset.Components.Add(txtAssetPChdr); // Amount field for each chart of account StiText txtAssetAcctAmt = new StiText(new RectangleD(pos, 0, columnWidth, 0.4)); txtAssetAcctAmt.HorAlignment = StiTextHorAlignment.Right; txtAssetAcctAmt.VertAlignment = StiVertAlignment.Center; txtAssetAcctAmt.Border.Side = StiBorderSides.None; txtAssetAcctAmt.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular); txtAssetAcctAmt.Text.Value = "{dtBSAssets.n" + drUserPC["PC_Num"].ToString() + "}"; txtAssetAcctAmt.Type = StiSystemTextType.DataColumn; txtAssetAcctAmt.WordWrap = true; txtAssetAcctAmt.ShrinkFontToFit = true; dbAssetAccts.Components.Add(txtAssetAcctAmt); // If the amount is negative, then display in brackets and in red colour StiCondition cndAssetAcctAmt = new StiCondition(); cndAssetAcctAmt.Item = StiFilterItem.Value; cndAssetAcctAmt.DataType = StiFilterDataType.Numeric; cndAssetAcctAmt.TextColor = Color.Red; cndAssetAcctAmt.Column = "dtBSAssets.n" + drUserPC["PC_Num"].ToString(); cndAssetAcctAmt.Condition = StiFilterCondition.LessThan; cndAssetAcctAmt.Value1 = "0"; cndAssetAcctAmt.Enabled = true; cndAssetAcctAmt.CanAssignExpression = true; cndAssetAcctAmt.AssignExpression = "\"(\" + " + "(dtBSAssets.n" + drUserPC["PC_Num"].ToString() + " * -1)" + " + \")\""; txtAssetAcctAmt.Conditions.Add(cndAssetAcctAmt); pos = pos + x; k = pos - 0.01; } //StiFooterBand fbMain = new StiFooterBand(new RectangleD(0,10,MainRepPage.Width,1)); ////fbMain.Height = 0; //fbMain.CanGrow = true; //fbMain.Enabled = true; //fbMain.KeepFooterTogether = true; //fbMain.Printable = true; //MainRepPage.Components.Add(fbMain); // Report summary band StiReportSummaryBand rsbReportSummary = new StiReportSummaryBand(); rsbReportSummary.Height = 0.4; rsbReportSummary.CanGrow = true; rsbReportSummary.Enabled = true; rsbReportSummary.KeepReportSummaryTogether = true; rsbReportSummary.PrintIfEmpty = true; rsbReportSummary.Printable = true; MainRepPage.Components.Add(rsbReportSummary); StiVerticalLinePrimitive stiLine1 = new Stimulsoft.Report.Components.StiVerticalLinePrimitive(); stiLine1.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD();//0, 0, 0.01, 4); stiLine1.Guid = null; stiLine1.EndCap = new Stimulsoft.Base.Drawing.StiCap(10, Stimulsoft.Base.Drawing.StiCapStyle.None, 10, true, System.Drawing.Color.Red); stiLine1.StartCap = new Stimulsoft.Base.Drawing.StiCap(10, Stimulsoft.Base.Drawing.StiCapStyle.None, 10, true, System.Drawing.Color.Red); stiLine1.Interaction = null; stiLine1.Color = Color.Red; //dbgrhdrLiabPrim.Components.Add(stiLine1); //hbMain.Components.Add(stiLine1); stiLine1.Page = MainRepPage; stiLine1.Parent = hbMain; hbMain.Components.Add(stiLine1); // stiLine1.PrintOn = StiPrintOnType.AllPages; StiStartPointPrimitive stiLineStart1 = new StiStartPointPrimitive(); stiLineStart1.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(2, 0, 0,0); stiLineStart1.Left = stiLine1.Left; stiLineStart1.Top = stiLine1.Top; stiLineStart1.Guid = null; stiLineStart1.Page = MainRepPage; stiLineStart1.ReferenceToGuid = stiLine1.Guid; stiLineStart1.Interaction = null; stiLineStart1.Parent = hbMain; hbMain.Components.Add(stiLineStart1); StiEndPointPrimitive stiLineEnd1 = new StiEndPointPrimitive(); stiLineEnd1.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0, 0, 0, 0); stiLineEnd1.Left = stiLine1.Right; stiLineEnd1.Top = stiLine1.Bottom; stiLineEnd1.Guid = null; stiLineEnd1.Page = MainRepPage; stiLineEnd1.ReferenceToGuid = stiLine1.Guid; stiLineEnd1.Interaction = null; stiLineEnd1.Parent = rsbReportSummary; rsbReportSummary.Components.Add(stiLineEnd1); // Panel in report summary band for Liabilities StiPanel pnrsbLiab = new StiPanel(new RectangleD(0, 0, LiabRep.PageWidth, 0.4)); rsbReportSummary.Components.Add(pnrsbLiab); // Total on Liabilities side StiText txtrsbLiabTtl = new StiText(new RectangleD(0, 0, (x * 2), 0.7)); txtrsbLiabTtl.Text.Value = "Total"; txtrsbLiabTtl.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); txtrsbLiabTtl.HorAlignment = StiTextHorAlignment.Center; txtrsbLiabTtl.VertAlignment = StiVertAlignment.Center; txtrsbLiabTtl.Border.Side = StiBorderSides.All; txtrsbLiabTtl.WordWrap = true; txtrsbLiabTtl.ShrinkFontToFit = true; txtrsbLiabTtl.CanGrow = true; txtrsbLiabTtl.Enabled = true; txtrsbLiabTtl.Printable = true; pnrsbLiab.Components.Add(txtrsbLiabTtl); // Panel in report summary band for Assets StiPanel pnrsbAsset = new StiPanel(new RectangleD(AssetL, 0, AssetRep.PageWidth, 0.4)); rsbReportSummary.Components.Add(pnrsbAsset); // Total on Assets side StiText txtrsbAssetTtl = new StiText(new RectangleD(0, 0, (x * 2), 0.7)); txtrsbAssetTtl.Text.Value = "Total"; txtrsbAssetTtl.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); txtrsbAssetTtl.HorAlignment = StiTextHorAlignment.Center; txtrsbAssetTtl.VertAlignment = StiVertAlignment.Center; txtrsbAssetTtl.Border.Side = StiBorderSides.All; txtrsbAssetTtl.WordWrap = true; txtrsbAssetTtl.ShrinkFontToFit = true; txtrsbAssetTtl.Printable = true; pnrsbAsset.Components.Add(txtrsbAssetTtl); pos = x * 2; foreach (DataRow drUserPC in dtUserPC.Rows) { // ------------------------------------- Liabilities ------------------------------------------ // // Total is the sum total of all the PC transactions for the Liabilities side accounts StiText txtLiabPCTotAmt = new StiText(new RectangleD(pos, 0, x , 0.7)); //txtLiabPCTotAmt.Text.Value = new StiExpression("{Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")}"); //txtLiabPCTotAmt.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); txtLiabPCTotAmt.HorAlignment = StiTextHorAlignment.Right; txtLiabPCTotAmt.VertAlignment = StiVertAlignment.Center; txtLiabPCTotAmt.ShrinkFontToFit = true; txtLiabPCTotAmt.Border.Side = StiBorderSides.All; txtLiabPCTotAmt.WordWrap= true; pnrsbLiab.Components.Add(txtLiabPCTotAmt); // If the sum of all the PC transactions on the Liabilities side accounts is greater than that on the Assets side accounts and if the sum of all transactions on the Liabilities side accounts is greater than zero, then display the sum of all transactions on the Liabilities side accounts StiCondition cndLiabTotPCAmt1 = new StiCondition(); cndLiabTotPCAmt1.Item = StiFilterItem.Expression; cndLiabTotPCAmt1.Expression = new StiExpression("(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")) < (Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")) && Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ") >= 0"); cndLiabTotPCAmt1.TextColor = Color.Black; cndLiabTotPCAmt1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); cndLiabTotPCAmt1.Enabled = true; cndLiabTotPCAmt1.CanAssignExpression = true; cndLiabTotPCAmt1.AssignExpression = "Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")"; txtLiabPCTotAmt.Conditions.Add(cndLiabTotPCAmt1); // If the sum of all the PC transactions on the Liabilities side accounts is greater than that on the Assets side accounts and if the sum of all transactions on the Liabilities side accounts is less than zero, then display the sum of all transactions on the Liabilities side accounts in red colour and in brackets StiCondition cndLiabTotPCAmt2 = new StiCondition(); cndLiabTotPCAmt2.Item = StiFilterItem.Expression; cndLiabTotPCAmt2.Expression = new StiExpression("(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")) < (Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")) && Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ") < 0"); cndLiabTotPCAmt2.TextColor = Color.Red; cndLiabTotPCAmt2.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); cndLiabTotPCAmt2.Enabled = true; cndLiabTotPCAmt2.CanAssignExpression = true; cndLiabTotPCAmt2.AssignExpression = "\"(\" + " + "(Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ") * -1)" + " + \")\""; txtLiabPCTotAmt.Conditions.Add(cndLiabTotPCAmt2); // If the sum of all the PC transactions on the Assets side accounts is greater than that on the Liabilities side accounts and if the sum of all transactions on the Assets side accounts is greater than zero, then display the sum of all transactions on the Assets side accounts StiCondition cndLiabTotPCAmt3 = new StiCondition(); cndLiabTotPCAmt3.Item = StiFilterItem.Expression; cndLiabTotPCAmt3.Expression = new StiExpression("(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")) > (Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")) && Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ") >= 0"); cndLiabTotPCAmt3.TextColor = Color.Black; cndLiabTotPCAmt3.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); cndLiabTotPCAmt3.Enabled = true; cndLiabTotPCAmt3.CanAssignExpression = true; cndLiabTotPCAmt3.AssignExpression = "Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")"; txtLiabPCTotAmt.Conditions.Add(cndLiabTotPCAmt3); // If the sum of all the PC transactions on the Assets side accounts is greater than that on the Liabilities side accounts and if the sum of all transactions on the Assets side accounts is less than zero, then display the sum of all transactions on the Assets side accounts in red colour and in brackets StiCondition cndLiabTotPCAmt4 = new StiCondition(); cndLiabTotPCAmt4.Item = StiFilterItem.Expression; cndLiabTotPCAmt4.Expression = new StiExpression("(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")) > (Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")) && Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ") < 0"); cndLiabTotPCAmt4.TextColor = Color.Red; cndLiabTotPCAmt4.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); cndLiabTotPCAmt4.Enabled = true; cndLiabTotPCAmt4.CanAssignExpression = true; cndLiabTotPCAmt4.AssignExpression = "\"(\" + " + "(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ") * -1)" + " + \")\""; txtLiabPCTotAmt.Conditions.Add(cndLiabTotPCAmt4); //---------------------------------------------- Assets -------------------------------------------------// // Total is the sum total of all the PC transactions for the Assets side accounts StiText txtAssetPCTotAmt = new StiText(new RectangleD(pos, 0, x , 0.7)); //txtAssetPCTotAmt.Text.Value = new StiExpression("{Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")}"); //txtAssetPCTotAmt.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); txtAssetPCTotAmt.HorAlignment = StiTextHorAlignment.Right; txtAssetPCTotAmt.VertAlignment = StiVertAlignment.Center; txtAssetPCTotAmt.ShrinkFontToFit = true; txtAssetPCTotAmt.Border.Side = StiBorderSides.All; txtAssetPCTotAmt.WordWrap = true; pnrsbAsset.Components.Add(txtAssetPCTotAmt); // If the sum of all the PC transactions on the Assets side accounts is greater than that on the Liabilities side account, and if the sum of all transactions on the Assets side accounts is greater than zero, then display the sum of all transactions on the Assets side accounts StiCondition cndAssetTotPCAmt1 = new StiCondition(); cndAssetTotPCAmt1.Item = StiFilterItem.Expression; cndAssetTotPCAmt1.Expression = new StiExpression("(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")) > (Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")) && Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ") >= 0"); cndAssetTotPCAmt1.TextColor = Color.Black; cndAssetTotPCAmt1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); cndAssetTotPCAmt1.Enabled = true; cndAssetTotPCAmt1.CanAssignExpression = true; cndAssetTotPCAmt1.AssignExpression = "Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")"; txtAssetPCTotAmt.Conditions.Add(cndAssetTotPCAmt1); // If the sum of all the PC transactions on the Assets side accounts is greater than that on the Liabilities side account, and if the sum of all transactions on the Assets side accounts is lesser than zero, then display the sum of all transactions on the Assets side accounts in brackets and in red colour StiCondition cndAssetTotPCAmt2 = new StiCondition(); cndAssetTotPCAmt2.Item = StiFilterItem.Expression; cndAssetTotPCAmt2.Expression = new StiExpression("(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")) > (Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")) && Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ") < 0"); cndAssetTotPCAmt2.TextColor = Color.Black; cndAssetTotPCAmt2.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); cndAssetTotPCAmt2.Enabled = true; cndAssetTotPCAmt2.CanAssignExpression = true; cndAssetTotPCAmt2.AssignExpression = "\"(\" + " + "(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ") * -1)" + " + \")\""; txtAssetPCTotAmt.Conditions.Add(cndAssetTotPCAmt2); // If the sum of all the PC transactions on the Liabilities side accounts is greater than that on the Assets side account, and if the sum of all transactions on the Liabilities side accounts is greater than zero, then display the sum of all transactions on the Liabilities side accounts StiCondition cndAssetTotPCAmt3 = new StiCondition(); cndAssetTotPCAmt3.Item = StiFilterItem.Expression; cndAssetTotPCAmt3.Expression = new StiExpression("(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")) < (Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")) && Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ") >= 0"); cndAssetTotPCAmt3.TextColor = Color.Black; cndAssetTotPCAmt3.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); cndAssetTotPCAmt3.Enabled = true; cndAssetTotPCAmt3.CanAssignExpression = true; cndAssetTotPCAmt3.AssignExpression = "Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")"; txtAssetPCTotAmt.Conditions.Add(cndAssetTotPCAmt3); // If the sum of all the PC transactions on the Liabilities side accounts is greater than that on the Assets side account, and if the sum of all transactions on the Liabilities side accounts is lesser than zero, then display the sum of all transactions on the Liabilities side accounts in brackets and in red colour StiCondition cndAssetTotPCAmt4 = new StiCondition(); cndAssetTotPCAmt4.Item = StiFilterItem.Expression; cndAssetTotPCAmt4.Expression = new StiExpression("(Totals.Sum(" + dbAssetAccts.Name + ", dtBSAssets.n" + drUserPC["PC_Num"].ToString() + ")) < (Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ")) && Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ") < 0"); cndAssetTotPCAmt4.TextColor = Color.Black; cndAssetTotPCAmt4.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold); cndAssetTotPCAmt4.Enabled = true; cndAssetTotPCAmt4.CanAssignExpression = true; cndAssetTotPCAmt4.AssignExpression = "\"(\" + " + "(Totals.Sum(" + dbLiabAccts.Name + ", dtBSLiabs.n" + drUserPC["PC_Num"].ToString() + ") * -1)" + " + \")\""; txtAssetPCTotAmt.Conditions.Add(cndAssetTotPCAmt4); pos = pos + x; } return report; } }