using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Table;
using FastReport.Utils;
using FastReport.Format;
using Sm.FastReports;
using Sm.FastReports.Link;
using Sm.Interfaces;
using Sm.Objects;
using Sm.Core;
namespace FastReport
{
public class ReportScript
{
RepHost host;
// название отчета
private string sRepName = "Какой то отчет";
// подзаголовок отчета: места хранения
private string sLocName;
// подзаголовок отчета: группы товаров
private string sGroupName;
// подзаголовок отчета: период отчета
private string sDateName;
// контрагент "От имени"
private string sUserName;
private void _StartReport(object sender, EventArgs e)
{
// Хост отчёта даёт доступ к полезным сервисам
host = new RepHost(Report);
// Стартуем транзакцию
RepTransaction transaction = new RepTransaction(host.Connection);
// контрагент "От имени"
sUserName = RepClientInfo.GetClientName(host.Connection, Report.GetParameterValue("P_USER_ID"));
// заголовок отчета
sRepName = "Остатки по состоянию на " + ToString(Report.GetParameterValue("P_DATE"));
// фильтр по местам хранения
RepOracleRunner.ExecuteProcedure(host.Connection,"Supermag.RepTools.LoadLoc",
Report.GetParameterValue("P_STORED_ALL"),
Report.GetParameterValue("P_STORED_NAME"),
Report.GetParameterValue("P_PARTNER"),
null);
// подзаголовок отчета: места хранения
sLocName = RepOracleRunner.ExecuteScalar<string>(host.Connection, "select supermag.RepTools.LocString(10) from dual");
// фильтр по группам товаров
RepOracleRunner.ExecuteProcedure(host.Connection,"Supermag.RepTools.LoadClass",
Report.GetParameterValue("P_GROUP_ALL"),
Report.GetParameterValue("P_BGROUP"),
Report.GetParameterValue("P_GROUP_TREE"));
// подзаголовок отчета: группы товаров
sGroupName = RepOracleRunner.ExecuteScalar<string>(host.Connection, "select supermag.RepTools.ClassString(10) from dual");
// подзаголовок отчета: период отчета
string sFirstDate = ToString(Report.GetParameterValue("P_FIRSTDATE"));
string sLastDate = ToString(Report.GetParameterValue("P_LASTDATE"));
int iCountDay = (RepConvert.ToSmDate(sLastDate)-RepConvert.ToSmDate(sFirstDate)).Days;
string sCountDay = Safe.ToSqlNumber( iCountDay );
sDateName = "с "+sFirstDate+" по "+sLastDate+" ( "+sCountDay+" дн. )";
// данные отчета
string sSQL =
SqlFormat("select"+
" CMS.ARTICLE, CMS.name from "+
" supermag.smcard cms left join (SELECT ost.ARTICLE, sum (OST.QUANTITY) quanto from supermag.SMGOODS ost GROUP BY ost.ARTICLE ) ost on (ost.ARTICLE=CMS.ARTICLE and OST.QUANTO=0) "+
" LEFT JOIN (SELECT logi.article FROM supermag.SMCARDSECURITYLOG "+
" logi where logi.ACTIONCODE = 3 "+
" and logi.EVENTTIME between ("+RepSqlText.ToSqlDate(sLastDate)+")-90 and "+RepSqlText.ToSqlDate(sLastDate)+
" ) n on (n.article=cms.article) "+
" LEFT JOIN (SELECT reps.article from supermag.FFMAPREP reps "+
" where reps.saletype NOT IN (WI, WO, IW, CS, CR, PO, PN) and REPS.SALEDATE between "+RepSqlText.ToSqlDate(sFirstDate)+" and "+RepSqlText.ToSqlDate(sLastDate)+
" )reps on (reps.ARTICLE=CMS.ARTICLE) "+
" where CMS.ARTICLE=OST.ARTICLE "+
" and OST.QUANTO is not null "+
" and cms.ACCEPTED=1 "+
" and n.article is null"+
" and reps.article is null"+
" GROUP BY CMS.ARTICLE, cms.Name"
);
host.TableDataSourcePreInit("RepData", sSQL);
}
}
}
<Dictionary>
<SupermagFastReportConnection Name="Connection" LoginPrompt="true">
<TableDataSource Name="Table2" Alias="RepData" DataType="System.Int32" Enabled="true" SelectCommand="SELECT
'' ARTICLE
'' NAME
'' SALETYPE
''>
<Column Name="ARTICLE" DataType="System.String"/>
<Column Name="NAME" DataType="System.String"/>
<Column Name="SALETYPE" DataType="System.String"/>
</TableDataSource>
</SupermagFastReportConnection>
<Relation Name="DocSpec_DocSpecScale" ParentDataSource="Table2" ChildDataSource="null" ParentColumns="SPECITEM" ChildColumns="SPECITEM" Enabled="true"/>
<Parameter Name="P_STORED_ALL" DataType="System.Int32"/>
<Parameter Name="P_STORED_NAME" DataType="System.String"/>
<Parameter Name="P_PARTNER" DataType="System.Int32"/>
<Parameter Name="P_BGROUP" DataType="System.Int32"/>
<Parameter Name="P_GROUP_ALL" DataType="System.Int32"/>
<Parameter Name="P_GROUP_TREE" DataType="System.String"/>
<Parameter Name="P_FIRSTDATE" DataType="System.String"/>
<Parameter Name="P_LASTDATE" DataType="System.String"/>
<Parameter Name="P_SURNAME" DataType="System.String"/>
<Parameter Name="P_USER_ID" DataType="System.Int32"/>
<Parameter Name="P_DATE" DataType="System.String"/>
</Dictionary>
<ReportPage Name="Page1" RawPaperSize="9" FirstPageSource="15" OtherPagesSource="15" Fill.Color="White" TitleBeforeHeader="false" PaperWidth="280">
<PageHeaderBand Name="PageHeader" Width="800.06" Height="40.12" CanGrow="true">
</PageHeaderBand>
<DataBand Name="DataSpec" Top="167.1" Width="718.2" CanGrow="true" DataSource="Table2" PrintIfDetailEmpty="true" PrintIfDatasourceEmpty="true" >
<TextObject Name="txtArticle" VertAlign="Center" Width="100" Height="29.00" CanGrow="true" CanBreak="false" Text="[RepData.ARTICLE]" HorzAlign="Left" Font="Arial, 8pt"Border.Lines="Right, Bottom, left,top" Border.Width="0.3" HorzAlign="Center"/>
<TextObject Name="txtNAME" VertAlign="Center" Left="100" Width="450" Height="29.00" CanGrow="true" CanBreak="false" Text="[RepData.NAME]" Font="Arial, 8pt" Border.Lines=" Bottom, left, right,top" Border.Width="0.3"/>
<TextObject Name="txtSALETYPE" VertAlign="Center" Left="100" Width="250" Height="29.00" CanGrow="true" CanBreak="false" Text="[RepData.SALETYPE]" Font="Arial, 8pt" Border.Lines=" Bottom, left, right,top" Border.Width="0.3"/>
</DataBand>
</ReportPage>
NOT IN (WI, WO, IW, CS, CR, PO, PN)