strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",SUM(ISNULL(G.USDDR-G.USDCR,0)) AS USDPROFIT,SUM(ISNULL(G.RMBDR-G.RMBCR,0)) AS RMBPROFIT,SUM(ISNULL(G.OTDR-G.OTCR,0)) AS OTPROFIT,SUM(ISNULL(G.TTLDR-G.TTLCR,0)) AS TTLPROFIT ");
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (SUM(G.TTLDR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLDR)) * 100, 10, 2))) END) AS PROFITRATE");
}
else
strSql.Append(", (CASE WHEN (SUM(G.TTLCR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLCR)) * 100, 10, 2))) END) AS PROFITRATE");
strSql.Append(",SUM(ISNULL(G.RMBDR-G.STLRMBDR,0)) AS RMBNODR,SUM(ISNULL(G.USDDR-G.STLUSDDR,0)) AS USDNODR,SUM(ISNULL(G.OTDR-G.STLOTDR,0)) AS OTNODR,SUM(ISNULL(G.TTLDR-G.STLTTLDR,0)) AS TTLNODR");
strSql.Append(",SUM(ISNULL(G.RMBCR-G.STLRMBCR,0)) AS RMBNOCR,SUM(ISNULL(G.USDCR-G.STLUSDCR,0)) AS USDNOCR,SUM(ISNULL(G.OTCR-G.STLOTCR,0)) AS OTNOCR,SUM(ISNULL(G.TTLCR-G.STLTTLCR,0)) AS TTLNOCR");
strSql.Append(",SUM(G.NOTAXOTCR) NOTAXOTCR,SUM(G.NOTAXTTLDR) NOTAXTTLDR,SUM(G.NOTAXTTLCR) NOTAXTTLCR,SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT");
strSql.Append(",SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
strSql.Append(",SUM(G.NOACCTAXOTCR) NOACCTAXOTCR,SUM(G.NOACCTAXTTLDR) NOACCTAXTTLDR,SUM(G.NOACCTAXTTLCR) NOACCTAXTTLCR,SUM(G.NOACCTAXUSDDR-G.NOACCTAXUSDCR) AS NOACCTAXUSDPROFIT");
strSql.Append(",SUM(G.NOACCTAXRMBDR-G.NOACCTAXRMBCR) AS NOACCTAXRMBPROFIT,SUM(G.NOACCTAXOTDR-G.NOACCTAXOTCR) AS NOACCTAXOTPROFIT,SUM(G.NOACCTAXTTLDR-G.NOACCTAXTTLCR) AS NOACCTAXTTLPROFIT ");
strSql.Append(",SUM(G.NOACCTAXTTLDR) AS TTLACCTAXDR,SUM(G.NOACCTAXTTLCR) AS TTLACCTAXCR,SUM(G.NOACCTAXTTLDR-G.NOACCTAXTTLCR) AS TTLACCTAXPROFIT");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",SUM(ISNULL(G.USDDR-G.USDCR,0)) AS USDPROFIT,SUM(ISNULL(G.RMBDR-G.RMBCR,0)) AS RMBPROFIT,SUM(ISNULL(G.OTDR-G.OTCR,0)) AS OTPROFIT,SUM(ISNULL(G.TTLDR-G.TTLCR,0)) AS TTLPROFIT ");
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (SUM(G.TTLDR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLDR)) * 100, 10, 2))) END) AS PROFITRATE");
}
else
strSql.Append(", (CASE WHEN (SUM(G.TTLCR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLCR)) * 100, 10, 2))) END) AS PROFITRATE");
strSql.Append(",SUM(ISNULL(G.RMBDR-G.STLRMBDR,0)) AS RMBNODR,SUM(ISNULL(G.USDDR-G.STLUSDDR,0)) AS USDNODR,SUM(ISNULL(G.OTDR-G.STLOTDR,0)) AS OTNODR,SUM(ISNULL(G.TTLDR-G.STLTTLDR,0)) AS TTLNODR");
strSql.Append(",SUM(ISNULL(G.RMBCR-G.STLRMBCR,0)) AS RMBNOCR,SUM(ISNULL(G.USDCR-G.STLUSDCR,0)) AS USDNOCR,SUM(ISNULL(G.OTCR-G.STLOTCR,0)) AS OTNOCR,SUM(ISNULL(G.TTLCR-G.STLTTLCR,0)) AS TTLNOCR");
strSql.Append(",SUM(G.NOTAXOTCR) NOTAXOTCR,SUM(G.NOTAXTTLDR) NOTAXTTLDR,SUM(G.NOTAXTTLCR) NOTAXTTLCR,SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT");
strSql.Append(",SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
strSql.Append(",SUM(G.NOACCTAXOTCR) NOACCTAXOTCR,SUM(G.NOACCTAXTTLDR) NOACCTAXTTLDR,SUM(G.NOACCTAXTTLCR) NOACCTAXTTLCR,SUM(G.NOACCTAXUSDDR-G.NOACCTAXUSDCR) AS NOACCTAXUSDPROFIT");
strSql.Append(",SUM(G.NOACCTAXRMBDR-G.NOACCTAXRMBCR) AS NOACCTAXRMBPROFIT,SUM(G.NOACCTAXOTDR-G.NOACCTAXOTCR) AS NOACCTAXOTPROFIT,SUM(G.NOACCTAXTTLDR-G.NOACCTAXTTLCR) AS NOACCTAXTTLPROFIT ");
strSql.Append(",SUM(G.NOACCTAXTTLDR) AS TTLACCTAXDR,SUM(G.NOACCTAXTTLCR) AS TTLACCTAXCR,SUM(G.NOACCTAXTTLDR-G.NOACCTAXTTLCR) AS TTLACCTAXPROFIT");
strSql.Append(" FROM V_OP_BILL B ");
strSql.Append("LEFT JOIN v_op_gain_sum_tax G ON (G.BSNO=B.BSNO) ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE){
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXRMBDR-G.NOTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXUSDDR-G.NOTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXOTDR-G.NOTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
}
else
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLDR-G.NOTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOTAXTTLCR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
}
}
elseif(feetype=="2")
{
if(Fieldset.RMBDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXRMBDR-G.NOACCTAXRMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXUSDDR-G.NOACCTAXUSDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXOTDR-G.NOACCTAXOTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
}
else
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLDR-G.NOACCTAXTTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.NOACCTAXTTLCR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
}
}
else
{
if(Fieldset.RMBDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBDR ");
if(Fieldset.RMBCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBCR ");
if(Fieldset.USDDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15),B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDDR ");
if(Fieldset.USDCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDCR ");
if(Fieldset.OTDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTDR ");
if(Fieldset.OTCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTCR ");
if(Fieldset.TTLDR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLDR ");
if(Fieldset.TTLCR)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLCR ");
if(Fieldset.RMBPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.RMBDR-G.RMBCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"RMBPROFIT ");
if(Fieldset.USDPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.USDDR-G.USDCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"USDPROFIT ");
if(Fieldset.OTPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.OTDR-G.OTCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"OTPROFIT ");
if(Fieldset.TTLPROFIT)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TTLPROFIT ");
if(Fieldset.PROFITRATE)
{
if(PROFITRATEDR.PARAMVALUE!="1")
{
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
}
else
strSql.Append(", (CASE WHEN (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)= 0) THEN 0 ELSE");
strSql.Append(" CONVERT(NUMERIC(18,2),ltrim(str((sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLDR-G.TTLCR else 0 end)) / (sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then G.TTLCR else 0 end)) * 100, 10, 2))) END) AS ZL"+enumValue.MONTHNO.ToString()+"PROFITRATE");
}
}
if(Fieldset.TEU)
strSql.Append(",sum(case when SUBSTRING(CONVERT(char(15), B."+datetype+", 111), 1, 7)='"+enumValue.MONTHFIELDNAME+"' then B.TEU else 0 end) as ZL"+enumValue.MONTHNO.ToString()+"TEU ");
str=" (B.OP='"+usercode+"' OR B.SALE='"+usercode+"')";
}
elseif(visiblerange=="2")
{
if(tb=="index")
{
varrangeDa=newRangeDA();
vardeptname=rangeDa.GetDEPTNAME(userid);
varuserstr=newStringBuilder();
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"') and GID in (select userid from user_baseinfo where DEPTNAME='"+deptname+"')");
str=" (B.Corpid='"+Convert.ToString(reader["COMPANYID"])+"' or B.SALECORPID='"+Convert.ToString(reader["COMPANYID"])+"' ";
}
else
{
str=str+" or B.Corpid='"+Convert.ToString(reader["COMPANYID"])+"' or B.SALECORPID='"+Convert.ToString(reader["COMPANYID"])+"'";
};
}
str=str+")";
reader.Close();
}
}
elseif(visiblerange=="6")
{
varuserstr=newStringBuilder();
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='"+userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1");
strSql.Append("SELECT GID,RMBDR,RMBCR,USDDR,USDCR,OTDR,OTCR,TTLDR,TTLCR,RMBPROFIT,USDPROFIT,OTPROFIT,TTLPROFIT,TEU,PROFITRATE from sys_profitfieldset");
strSql.Append(" Where COMPANYID='"+companyid+"'");