<ScriptText>using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using System.Reflection;
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
{
string qMainSQL=" SELECT article, cardname, ctg_code, subgrp_name, ctg_name, status_text, last_income_dt, last_income_cl, accprice, sales, remains_on_end, cashprice, extracharge, extracharge_art/100, step, minprice, sales_to, profit, CASE sales_to WHEN 0 THEN 0 ELSE profit/sales_to*100 END margin, inAuction, (SELECT rate FROM supermag.smaltunits a WHERE a.article=s.article AND a.altunit=2) volume FROM ( SELECT s.*, CASE status WHEN 1 THEN 'Активна' WHEN 2 THEN 'Неактивна' ELSE 'Не определено' END status_text, CASE accprice WHEN 0 THEN 0 ELSE cashprice/accprice-1 END extracharge, CASE status WHEN 1 THEN sales*cashprice WHEN 2 THEN remains_on_end*cashprice ELSE 0 END sales_to, (cashprice-accprice)* CASE status WHEN 1 THEN sales WHEN 2 THEN remains_on_end ELSE 0 END profit, supermag.classifier.NORMALIZECLASSIF(ctg_code) ctg, TO_CHAR(d.createdat,'dd.mm.yyyy') last_income_dt, (SELECT name FROM supermag.smclientinfo c WHERE c.id=d.clientindex) last_income_cl FROM supermag.rep$pricecut s LEFT OUTER JOIN supermag.smdocuments d ON d.doctype='WI' AND d.id=s.last_income ORDER BY ctg ASC, article ASC) s ";
string sLocName;
string sGroupName;
string sUserName;
string sDateName;
RepHost host;
private void _StartReport(object sender, EventArgs e)
{
// Хост отчёта
host = new RepHost(Report);
// контрагент "От имени"
sUserName = RepClientInfo.GetClientName(host.Connection, Report.GetParameterValue("P_USER_ID"));
//Проверка необходимости отображения последней колонки с объемом
if(ToInt32(Report.GetParameterValue("P_FLAG1"))==0){
Page1.PaperWidth=615;
Cell76.Visible=false;
Cell77.Visible=false;
Cell78.Visible=false;
Cell79.Visible=false;
}
// подзаголовок отчета: период отчета
string sFirstDate = ToString(Report.GetParameterValue("P_FIRSTDATE"));
string sLastDate = ToString(Report.GetParameterValue("P_LASTDATE"));
int iCountDay = (RepConvert.ToSmDate(sLastDate)-RepConvert.ToSmDate(sFirstDate)).Days+1;
sDateName = "с "+sFirstDate+" по "+sLastDate+" ( "+Safe.ToSqlNumber( iCountDay )+" дн. )";
// фильтр по местам хранения
RepOracleRunner.ExecuteProcedure(host.Connection,"Supermag.RepTools.LoadLoc",
Report.GetParameterValue("P_STORED_ALL"),
Report.GetParameterValue("P_STORED_NAME"),
null,
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");
RepOracleRunner.ExecuteProcedure(host.Connection,"supermag.rep_formtemptabletoo.fill_pricecut",
sFirstDate,
sLastDate);
host.TableDataSourcePreInit("MainSQL", qMainSQL);
}
private void ReportSummary1_BeforePrint(object sender, EventArgs e)
{
if(Report.GetTotalValueNullable("TotalSales_TO").ToString()==null){
Cell75.Text="";
}
}
}
}
</ScriptText>