Example #1
0
        public void ExecuteFile(string FileName, string OutputFileName)
        {
            string LogFile = FileName + ".log";

            if (System.IO.File.Exists(LogFile))
            {
                System.IO.File.Delete(LogFile);
            }

            SqlWebReport.SwrReport sr = new SqlWebReport.SwrReport();
            sr.Output = OutputFileName;
            sr.AddConnection(new SqlWebReport.ItemConnection("Database", db));
            sr.Cmp.SetLogFile(LogFile);
            SwrForms.Report.ShowReport(sr, FileName, new List <SqlWebReport.ParamQuery>());
        }
Example #2
0
        public void Execute(string ReportTitle, bool StyleDetail, int ReportStyleIndex, string[] Fields, string[] Counters)
        {
            bool   PossuiTot    = false;
            String sCols        = "";
            String sColsRep     = "";
            String sColsRepForm = "";
            String sColsTot     = "";

            //String sLines = "";

            for (int i = 0; i < Fields.Length; i++)
            {
                String xCssS = "class='sum'";
                String xCssT = "class='tit'";
                String xCss  = "";

                SqlWebReport.FieldType ft = SqlWebReport.SwrUtility.GetFieldType(Table.Columns[Fields[i]].DataType);

                #region [formata xCssT, xCss e xCssS]
                #region if (ft == enmFieldType.Int || ft == enmFieldType.Decimal)
                if (ft == SqlWebReport.FieldType.Int || ft == SqlWebReport.FieldType.Decimal)
                {
                    if (StyleDetail)
                    {
                        xCssS = "class='sum vlr'";
                        xCssT = "class='tit vlr'";
                        xCss  = "class='vlr'";
                    }
                    else
                    {
                        xCssS = "class='sum'";
                        xCssT = "class='tit'";
                        xCss  = "class='vlr'";
                    }
                }
                #endregion
                #region else if (ft == enmFieldType.Date || ft == enmFieldType.Time || ft == enmFieldType.DateTime || ft == enmFieldType.Bool)
                else if (ft == SqlWebReport.FieldType.Date || ft == SqlWebReport.FieldType.Time || ft == SqlWebReport.FieldType.DateTime || ft == SqlWebReport.FieldType.Bool)
                {
                    if (StyleDetail)
                    {
                        xCssS = "class='sum cen'";
                        xCssT = "class='tit cen'";
                        xCss  = "class='cen'";
                    }
                    else
                    {
                        xCssS = "class='sum'";
                        xCssT = "class='tit'";
                        xCss  = "class='vlr'";
                    }
                }
                #endregion
                #endregion

                #region Cria linhas dos totais
                if (Utility.ItemInList(Fields[i], Counters))
                {
                    PossuiTot     = true;
                    sCols        += "      <?$T_" + Fields[i] + ".mov(0)?>\n";
                    sColsRep     += "      <?$T_" + Fields[i] + ".add(D." + Fields[i] + ")?>\n";
                    sColsRepForm += "      <?$T_" + Fields[i] + ".add(D." + Fields[i] + ")?>\n";
                    sColsTot     += "      <td " + xCssS + "><?$T_" + Fields[i] + ".format(\"#,##0.00\")?></td>\n";
                }
                else
                {
                    sColsTot += "      <td " + xCssS + ">&nbsp;</td>\n";
                }
                #endregion

                #region Cria colunas e linhas para os modelos detail e form
                sCols        += string.Format("      <td {0}>{1}</td>\n", xCssT, Fields[i]);
                sColsRep     += string.Format("      <td {0}><?{1}?></td>\n", xCss, GetFieldValue(Fields[i], ft));
                sColsRepForm += string.Format("    <tr><td {0}>{1}</td><td {2}><?{3}?></td></tr>\n", xCssT, Fields[i], xCss, GetFieldValue(Fields[i], ft));
                #endregion
            }

            string sql = LastSqlQuery;
            sql = sql.Replace("\n", "\n      ");
            String lnTot = "";

            if (PossuiTot)
            {
                if (StyleDetail)
                {
                    lnTot =
                        "  <!-- Rodapé do Relatório -->\n" +
                        "    <tr><td>&nbsp;</td></tr>\n" +
                        "    <tr>\n" + sColsTot +
                        "    </tr>\n";
                }
                else
                {
                    lnTot =
                        "  <!-- Rodapé do Relatório -->\n" +
                        "    <tr><td>&nbsp;</td></tr>\n" +
                        "    <tr><td class='sum'>Total</td>\n" + sColsTot +
                        "    </tr>\n";
                }
            }

            String lnCols    = "";
            String lnColsRep = "";

            if (StyleDetail)
            {
                lnCols = "    <tr>\n" + sCols + "    </tr>\n";
            }

            if (StyleDetail)
            {
                lnColsRep = "    <tr>\n" + sColsRep + "    </tr>\n";
            }
            else
            {
                lnColsRep = "    <tr><td><br /></td></tr>\n" + sColsRepForm;
            }

            String strCode =
                "<?\n" +
                "  $sc = \"" + db.ConnectionString + "\";\n" +
                "  connection.add(\"Database\",\"" + db.ConnectionType.ToString() + "\",$sc);\n" +
                "  D.new(\"Database\");\n" +
                "  D.sql(\n      \"" + sql + "\"\n  );\n" +
                "?>\n" +
                "<?band1?>\n" +
                "  <style type=\"text/css\" media=\"screen\">\n" +
                "    body\n" +
                "    {\n" +
                "      background-color:#aaa;\n" +
                "      padding:20px 20px 0 20px;\n" +
                "    }\n" +
                "    .page\n" +
                "    {\n" +
                "      background-color:White;\n" +
                "      border:1px solid #777;\n" +
                "      padding:60px 40px 40px 60px;\n" +
                "    }\n" +
                "  </style>\n" +
                "  <style type=\"text/css\" media=\"all\">\n" +
                ReportStyleList[ReportStyleIndex].Style +
                "  </style>\n\n" +
                "<div class='page'>\n" +
                "  <!-- Cabeçalho do Relatório -->\n" +
                "  <h1>" + ReportTitle + "</h1>\n" +
                "  <p>Emissao : <?sys.now()?></p>\n" +
                "  <table>\n" +
                lnCols +
                "  <!-- Conteúdo do Relatório -->\n" +
                "<?band2:band1?>\n" +
                "  <?band.dst(D)?>\n" +
                lnColsRep +
                "<?endband1?>\n" +
                lnTot +
                "  </table>\n" +
                "</div>";

            if (System.IO.File.Exists(ReportFile))
            {
                System.IO.File.Delete(ReportFile);
            }

            TextFile tf = new TextFile();
            tf.Open(enmOpenMode.Writing, ReportFile);
            tf.Write(strCode);
            tf.Close();

            SqlWebReport.SwrReport sr = new SqlWebReport.SwrReport();
            sr.AddConnection(new SqlWebReport.ItemConnection("Database", db));
            SwrForms.Report.ShowReport(sr, ReportFile, new List <SqlWebReport.ParamQuery>());
        }