strSql.Append("COUNT(DISTINCT B.BSNO) AS BLCOUNT,sum(OPXS) OPXS");
strSql.Append(",SUM(B.NETWEIGHT) AS NETWEIGHT,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) AS TEU,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) AS CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) AS CNTR2,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) AS CNTR3,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) AS CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) AS CNTR5,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) AS CNTR6,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) AS CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) AS CNTR8,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) AS CNTR9,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) AS CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) AS OTCNTR");
strSql.Append(",(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",(B.NETWEIGHT) NETWEIGHT,(B.KGS) KGS,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME ");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(" FROM V_OP_BS B ");
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=B.CUSTOMERNAME) ");
if(!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where "+condition);
}
strSql.Append(" Group by B.CUSTOMERNAME,C.[DESCRIPTION] "+bstype);
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT U.DEPTNAME SALEDEPT ");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(" FROM V_OP_BS B ");
strSql.Append(" LEFT JOIN VW_user U ON (U.SHOWNAME=B.SALE) ");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT B.OP, B.BSTYPE");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT B.CUSTSERVICE, B.BSTYPE");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(" FROM V_OP_BS B ");
if(!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where "+condition);
}
strSql.Append(" Group by B.CUSTSERVICE, B.BSTYPE ");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT B.BSSOURCE");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(" FROM V_OP_BS B ");
if(!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where "+condition);
}
strSql.Append(" Group by B.BSSOURCE,B.BSSOURCEDETAIL ");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT B.LANE");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT B.DESTINATIONID,CASE WHEN P.PORT='' THEN DESTINATIONID ELSE P.PORT END DESTINATION");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(" FROM V_OP_BS B ");
strSql.Append(" left join code_disport p on (p.EDICODE=B.DESTINATIONID) ");
if(!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where "+condition);
}
strSql.Append(" Group by B.DESTINATIONID,p.PORT ");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT ");
strSql.Append("COUNT(DISTINCT B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(B.NETWEIGHT) AS NETWEIGHT,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) AS TEU,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) AS CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) AS CNTR2,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) AS CNTR3,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) AS CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) AS CNTR5,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) AS CNTR6,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) AS CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) AS CNTR8,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) AS CNTR9,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) AS CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) AS OTCNTR");
str=" (B.OP='"+usercode+"' OR B.SALE='"+usercode+"' OR B.CUSTSERVICE='"+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.OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"'";
}
else
{
str=str+" or B.OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' ";
};
}
str=str+")";
reader.Close();
}
}
else
{
str=" UPPER(B.Corpid)='"+companyid+"'";
}
}
elseif(visiblerange=="5")
{
varuserstr=newStringBuilder();
userstr.Append(" select COMPANYID from user_authority_range_company where userid='"+userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1");
str=str+" or B.Corpid='"+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");
str=" (B.OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"'";
}
else
{
str=str+" or B.OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"'";