You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
4.0 KiB
C#

12 months ago
using System;
using System.Data;
using System.Data.SqlClient;
using WebSqlHelper;
namespace DSWeb.EntityDA
{
public class ReportDA
{
private const string SQL_SELECT_OP_SEAE_TOTAL = " SELECT * FROM "
+ " (SELECT TOP 100 PERCENT newid() as GID,YEARINT,MONTHINT,SUM(TEU) AS TOTALTEU,COUNT(BSNO) AS TOTALOFFER,SUM(TTLPROFIT) AS TOTALPROFIT FROM "
+ " ( "
+ " SELECT A.BSNO,DATEPART(year,BSDATE) AS YEARINT,DATEPART(month,BSDATE) AS MONTHINT,TEU,TTLPROFIT FROM op_seae AS A INNER JOIN "
+ " fee_gain as B ON A.BSNO = B.BSNO LEFT JOIN company AS C ON A.CORPID = C.GID "
+ " WHERE 1 > 0 {0} "
+ " ) AS D GROUP BY YEARINT,MONTHINT ORDER BY YEARINT,MONTHINT ASC) AS E {1}";
private const string SQL_SELECT_MULTIPLE_BUSINESS_TOTAL = " SELECT newid(),'海运出口'AS TYPENAME,COUNT(A.BSNO) AS COUNTTOTAL,"
+ " SUM(ISNULL(B.USDDR,0)) AS SUSDDR,SUM(ISNULL(B.STLDRUSD,0)) AS SSTLDRUSD,SUM(ISNULL(B.USDDR,0) - ISNULL(B.STLDRUSD,0)) AS SUNSTLDRUSD,"
+ " SUM(ISNULL(B.RMBDR,0)) AS SRMBDR,SUM(ISNULL(B.STLDRRMB,0)) AS SSTLDRRMB,SUM(ISNULL(B.RMBDR,0) - ISNULL(B.STLDRRMB,0)) AS SUNSTLDRRMB,"
+ " SUM(ISNULL(B.DRTTL,0)) AS SDRTTL,SUM(ISNULL(B.STLDRTTL,0)) AS SSTLDRTTL,SUM(ISNULL(B.DRTTL,0) - ISNULL(B.STLDRTTL,0)) AS SUNSTLDRTTL,"
+ " SUM(ISNULL(B.USDCR,0)) AS SUSDCR,SUM(ISNULL(B.STLCRUSD,0)) AS SSTLCRUSD,SUM(ISNULL(B.USDCR,0) - ISNULL(B.STLCRUSD,0)) AS SUNSTLCRUSD,"
+ " SUM(ISNULL(B.RMBCR,0)) AS SRMBCR,SUM(ISNULL(B.STLCRRMB,0)) AS SSTLCRRMB,SUM(ISNULL(B.RMBCR,0) - ISNULL(B.STLCRRMB,0)) AS SUNSTLCRRMB,"
+ " SUM(ISNULL(B.CRTTL,0)) AS SCRTTL,SUM(ISNULL(B.STLCRTTL,0)) AS SSTLCRTTL,SUM(ISNULL(B.CRTTL,0) - ISNULL(B.STLCRTTL,0)) AS SUNSTLCRTTL,"
+ " SUM(ISNULL(B.USDPROFIT,0)) AS SUSDPROFIT,SUM(ISNULL(B.RMBPROFIT,0)) AS SRMBPROFIT,SUM(ISNULL(B.TTLPROFIT,0)) AS STTLPROFIT "
+ " FROM op_seae AS A LEFT JOIN fee_gain AS B ON A.BSNO = B.BSNO "
+ " WHERE 1 > 0 {0} ";
/// <summary>
/// 根据SQL语句获取数据集
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public DataSet GetDataSetBySql(string strSql)
{
DataSet userSet = new DataSet();
userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
return userSet;
}
/// <summary>
/// 通过查询条件获取数据集
/// </summary>
/// <param name="tempCondition"></param>
/// <returns></returns>
public DataTable GetDataTableSourceByCondtion(ReportType tempReportType,string tempCondition,string tempSortCondition)
{
string tempSql = "";
switch (tempReportType)
{
case ReportType.OPSEAETOTAL:
tempSql = String.Format(SQL_SELECT_OP_SEAE_TOTAL, tempCondition, tempSortCondition);
break;
case ReportType.MULTIPLEBUSINESSTOTAL:
tempSql = String.Format(SQL_SELECT_MULTIPLE_BUSINESS_TOTAL, tempCondition);
break;
}
return GetDataSetBySql(tempSql).Tables[0];
}
}
public enum ReportType
{
OPSEAETOTAL = 1,
MULTIPLEBUSINESSTOTAL = 2
}
}