using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Linq ;
using System.Text ;
using System.Web ;
using System.Web.Mvc ;
using DSWeb.MvcShipping.Helper ;
using DSWeb.MvcShipping.Comm.Cookie ;
using DSWeb.Areas.CommMng.DAL ;
using DSWeb.Areas.RptMng.Comm ;
using HcUtility.Comm ;
using HcUtility.Core ;
using Microsoft.Practices.EnterpriseLibrary.Data ;
using DSWeb.EntityDA ;
using DSWeb.Areas.CommMng.Models ;
using DSWeb.MvcShipping.DAL.MsSysParamSet ;
using DSWeb.MvcShipping.Models.MsTemplet ;
namespace DSWeb.MvcShipping.Controllers
{
/// <summary>
/// 业务比例图表分析
/// </summary>
[JsonRequestBehavior]
public class MsRptOpProfitPerCentController : Controller
{
/ /
// GET: /MvcShipping/MsRptOpProfit
public ActionResult Index ( )
{
return View ( ) ;
}
/ /
// GET: /RptMng/MsRptPcHeadQry/QryData
/ /
// GET: /
public ActionResult LayShow ( )
{
string id = "" ;
string url = "" ;
string gid = Request . QueryString [ "gid" ] ; //模板ID
string mid = Request . QueryString [ "mid" ] ; //MODULEID
//string id = Request.QueryString["id"];//模块ID
//根据模板gid判断加载的页面templet url
var list = GetTempletURL ( gid , mid , Session [ "USERID" ] . ToString ( ) ) ;
foreach ( var listStr in list )
{
id + = listStr . GID ;
url = listStr . LINKURL ;
}
Response . Redirect ( "../MsTemplet/" + url + "?id=" + id + "&cid=" + Session [ "COMPANYID" ] . ToString ( ) + "&tid=" + gid + "&t=0&p=1" ) ;
return View ( ) ;
}
#region 查询模板地址
public static List < MsTempletStructure > GetTempletURL ( string gid , string mid , string userid )
{
List < MsTempletStructure > list = new List < MsTempletStructure > ( ) ;
StringBuilder sql = new StringBuilder ( ) ;
sql . AppendLine ( "select distinct B.GID,A.TEMPLETURL " ) ;
sql . AppendLine ( "from templet as A " ) ;
sql . AppendLine ( "left join user_templet as B on A.TEMPLETID=B.TEMPLETID " ) ;
sql . AppendLine ( "where A.USERID='" + userid + "' and B.USERID='" + userid + "' " ) ;
sql . AppendLine ( "and A.TEMPLETID='" + gid + "' and B.PARENTID='" + mid + "' " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , sql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
MsTempletStructure data = new MsTempletStructure ( ) ;
data . GID = Convert . ToString ( reader [ "GID" ] ) ;
data . LINKURL = Convert . ToString ( reader [ "TEMPLETURL" ] ) ;
list . Add ( data ) ;
}
reader . Close ( ) ;
}
return list ;
}
# endregion
#region 小窗口查询
public ContentResult DataListForTable ( string condition , string objname , string sumfieldtype )
{
//解析condition,objname,sumfieldtype
switch ( condition )
{
case "thMonth" :
DateTime dateCondition = DateTime . Now ;
DateTime startMonth = dateCondition . AddDays ( 1 - dateCondition . Day ) ; //本月月初
DateTime endMonth = startMonth . AddMonths ( 1 ) . AddDays ( - 1 ) ; //本月月末
condition = "B.OPDATE>='" + startMonth + "' AND B.OPDATE<='" + endMonth + "' " ;
break ;
case "thWeek" :
dateCondition = DateTime . Now ;
DateTime startWeek = dateCondition . AddDays ( 1 - Convert . ToInt32 ( dateCondition . DayOfWeek . ToString ( "d" ) ) ) ; //本周周一
DateTime endWeek = startWeek . AddDays ( 6 ) ; //本周周日
condition = "B.OPDATE>='" + startWeek + "' AND B.OPDATE<='" + endWeek + "' " ;
break ;
case "prMonth" :
dateCondition = DateTime . Now ;
DateTime prStartMonth = dateCondition . AddDays ( 1 - dateCondition . Day ) . AddMonths ( - 1 ) ; //上月月初
DateTime prEndMonth = dateCondition . AddDays ( 1 - dateCondition . Day ) . AddDays ( - 1 ) ; //上月月末
condition = "B.OPDATE>='" + prStartMonth + "' AND B.OPDATE<='" + prEndMonth + "' " ;
break ;
case "thYear" :
dateCondition = DateTime . Now ;
DateTime startYear = new DateTime ( dateCondition . Year , 1 , 1 ) ; //本年年初
DateTime endYear = new DateTime ( dateCondition . Year , 12 , 31 ) ; //本年年末
condition = "B.OPDATE>='" + startYear + "' AND B.OPDATE<='" + endYear + "' " ;
break ;
case "thYearToPrMonth" :
dateCondition = DateTime . Now ;
DateTime startDateTime = new DateTime ( dateCondition . Year , 1 , 1 ) ; //本年年初
DateTime endDateTime = dateCondition . AddDays ( 1 - dateCondition . Day ) . AddDays ( - 1 ) ; //上月月末
condition = "B.OPDATE>='" + startDateTime + "' AND B.OPDATE<='" + endDateTime + "' " ;
break ;
}
switch ( objname )
{
case "bssource" :
objname = "B.BSSOURCE" ;
break ;
case "line" :
objname = "B.LANE" ;
break ;
case "sale" :
objname = "B.SALE" ;
break ;
case "way" :
objname = "B.BSTYPE" ;
break ;
case "customer" :
objname = "B.CUSTOMERNAME" ;
break ;
case "carrier" :
objname = "B.CARRIER" ;
break ;
}
switch ( sumfieldtype )
{
case "profit" :
sumfieldtype = "利润" ;
break ;
case "arrearage" :
sumfieldtype = "欠费" ;
break ;
case "teu" :
sumfieldtype = "TEU" ;
break ;
}
var strDa = GetRangDAStr ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( ! string . IsNullOrEmpty ( strDa ) )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and " + strDa ;
}
else
{
condition = strDa ;
}
}
var RPTPRNOCANCEL = MsSysParamSetDAL . GetData ( "PARAMNAME='RPTPRNOCANCEL'" ) ;
if ( RPTPRNOCANCEL . PARAMVALUE = = "1" )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) " ;
}
else
{
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) " ;
}
}
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT " + objname + " AS OBJNAME " ) ;
if ( sumfieldtype = = "利润" )
strSql . Append ( ",SUM(G.TTLDR-G.TTLCR) AS OBJNUM " ) ;
if ( sumfieldtype = = "欠费" )
strSql . Append ( ",SUM(G.TTLDR-G.STLTTLDR) AS OBJNUM " ) ;
if ( sumfieldtype = = "TEU" )
strSql . Append ( ",SUM(B.TEU) AS OBJNUM " ) ;
if ( sumfieldtype = = "毛重" )
strSql . Append ( ",SUM(B.KGS) AS OBJNUM " ) ;
if ( sumfieldtype = = "计费重" )
strSql . Append ( ",SUM(B.FEEKGS) AS OBJNUM " ) ;
strSql . Append ( " FROM V_OP_BILL B " ) ;
strSql . Append ( "LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) " ) ;
strSql . Append ( " WHERE 1=1 " ) ;
if ( ! string . IsNullOrEmpty ( condition ) )
{
strSql . Append ( " AND " + condition ) ;
}
if ( sumfieldtype = = "利润" )
strSql . Append ( " AND (G.TTLDR-G.TTLCR)<>0 " ) ;
if ( sumfieldtype = = "欠费" )
strSql . Append ( " AND (G.TTLDR-G.STLTTLDR)<>0 " ) ;
if ( sumfieldtype = = "TEU" )
strSql . Append ( " AND (B.TEU)<>0 " ) ;
if ( sumfieldtype = = "毛重" )
strSql . Append ( " AND (B.KGS)<>0 " ) ;
if ( sumfieldtype = = "计费重" )
strSql . Append ( " AND (B.FEEKGS)<>0 " ) ;
strSql . Append ( " Group by " + objname ) ;
strSql . Append ( " order by OBJNUM desc " ) ;
var dbparams = new List < CustomDbParamter > ( ) ;
var paramps_sSQL = new CustomDbParamter ( ) ;
paramps_sSQL . ParameterName = "@sSQL" ;
paramps_sSQL . DbType = DbType . String ;
paramps_sSQL . Direction = ParameterDirection . Input ;
paramps_sSQL . Value = strSql . ToString ( ) ;
dbparams . Add ( paramps_sSQL ) ;
var dbRptResult = PubSysDAL . GetMsSqlPrcDataSet ( "sMsExesqlQry" , dbparams , "Result_Set" ) ;
var json = RptHelper . GetRptJsonResult ( dbRptResult , "Result_Set" ) ;
json = json . Substring ( json . IndexOf ( "[" ) - 1 ) ;
json = json . Substring ( 0 , json . Length - 3 ) ;
json = json . Replace ( "\r" , "" ) ;
json = json . Replace ( "\n" , "" ) ;
return new ContentResult ( ) { Content = json } ;
}
# endregion
public static string GetRangDAStrWeb ( string tb , string userid , string usercode , string companyid )
{
string str = "" ;
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT " ) ;
strSql . Append ( " VISIBLERANGE,OPERATERANGE " ) ;
strSql . Append ( " from VW_User_Authority " ) ;
strSql . Append ( " where [NAME]='modProfitCompareRange' and USERID='" + userid + "' and ISDELETE=0" ) ;
string visiblerange = "4" ;
string operaterange = "4" ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
visiblerange = Convert . ToString ( reader [ "VISIBLERANGE" ] ) ;
operaterange = Convert . ToString ( reader [ "OPERATERANGE" ] ) ;
break ;
}
reader . Close ( ) ;
}
if ( visiblerange = = "4" )
{
str = "1=2" ;
}
else if ( visiblerange = = "3" )
{
str = " (A.OP='" + usercode + "' OR A.SALE='" + usercode + "')" ;
}
else if ( visiblerange = = "2" )
{
if ( tb = = "index" )
{
var rangeDa = new RangeDA ( ) ;
var deptname = rangeDa . GetDEPTNAME ( userid ) ;
var userstr = new StringBuilder ( ) ;
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 + "')" ) ;
Database userdb = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = userdb . ExecuteReader ( CommandType . Text , userstr . ToString ( ) ) )
{
str = "" ;
while ( reader . Read ( ) )
{
if ( str = = "" )
{
str = " (A.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR A.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
}
else
{
str = str + " or A.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR A.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
} ;
}
str = str + ")" ;
reader . Close ( ) ;
}
}
else
{
str = " UPPER(A.Corpid)='" + companyid + "'" ;
}
}
else if ( visiblerange = = "1" )
{
str = " UPPER(A.Corpid)='" + companyid + "'" ;
}
return str ;
}
public static string GetRangDAStrTEUWeb ( string tb , string userid , string usercode , string companyid )
{
string str = "" ;
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT " ) ;
strSql . Append ( " VISIBLERANGE,OPERATERANGE " ) ;
strSql . Append ( " from VW_User_Authority " ) ;
strSql . Append ( " where [NAME]='modProfitCompareRange' and USERID='" + userid + "' and ISDELETE=0" ) ;
string visiblerange = "4" ;
string operaterange = "4" ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
visiblerange = Convert . ToString ( reader [ "VISIBLERANGE" ] ) ;
operaterange = Convert . ToString ( reader [ "OPERATERANGE" ] ) ;
break ;
}
reader . Close ( ) ;
}
if ( visiblerange = = "4" )
{
str = "1=2" ;
}
else if ( visiblerange = = "3" )
{
str = " (OP='" + usercode + "' OR SALE='" + usercode + "')" ;
}
else if ( visiblerange = = "2" )
{
if ( tb = = "index" )
{
var rangeDa = new RangeDA ( ) ;
var deptname = rangeDa . GetDEPTNAME ( userid ) ;
var userstr = new StringBuilder ( ) ;
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 + "')" ) ;
Database userdb = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = userdb . ExecuteReader ( CommandType . Text , userstr . ToString ( ) ) )
{
str = "" ;
while ( reader . Read ( ) )
{
if ( str = = "" )
{
str = " (OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
}
else
{
str = str + " or OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
} ;
}
str = str + ")" ;
reader . Close ( ) ;
}
}
else
{
str = " UPPER(Corpid)='" + companyid + "'" ;
}
}
else if ( visiblerange = = "1" )
{
str = " UPPER(Corpid)='" + companyid + "'" ;
}
return str ;
}
/// <summary>
/// 业务来源 利润
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareSourceGainInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND , string sortstr )
{
string dataList = GetCompareSourceGainInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND , sortstr ) ;
return dataList ;
}
private string GetCompareSourceGainInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND , string sortstr )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.RMBCR) AS RMBAMOUNT, " ) ;
//RMB利润合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.BSSOURCE is not NULL and B1.RMBDR is not NULL and B1.RMBCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefinestrOPd" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.USDCR) AS USDAMOUNT, " ) ;
//USD利润合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.BSSOURCE is not NULL and B2.USDDR is not NULL and B2.USDCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.OTCR) AS OTAMOUNT, " ) ;
//OT合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.BSSOURCE is not NULL and B4.OTDR is not NULL and B4.OTCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.TTLCR) AS TTLAMOUNT, " ) ;
//TTL合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.BSSOURCE is not NULL and B3.TTLDR is not NULL and B3.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.BSSOURCE is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
if ( sortstr ! = "" )
strSql . AppendLine ( "order by " + sortstr ) ;
else
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLCR:\"" + Convert.ToString(reader["TTLCR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",RMBDR:\"" + Convert.ToString(reader["RMBDR"]) + "\",RMBCR:\"" + Convert.ToString(reader["RMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",USDDR:\"" + Convert.ToString(reader["USDDR"]) + "\",USDCR:\"" + Convert.ToString(reader["USDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",DOC:\"" + Convert . ToString ( reader [ "DOC" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 业务来源 欠费
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareSourceArrearageInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareSourceArrearageInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareSourceArrearageInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, " ) ;
//RMB欠费合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.BSSOURCE is not NULL and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.STLUSDDR) AS USDAMOUNT, " ) ;
//USD欠费合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.BSSOURCE is not NULL and B2.USDDR is not NULL and B2.STLUSDDR is not NULL " ) ; //and A2.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.STLOTDR) OTAMOUNT, " ) ;
//OT欠费合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.BSSOURCE is not NULL and B4.OTDR is not NULL and B4.STLOTDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.STLTTLDR) TTLAMOUNT, " ) ;
//TTL欠费合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.BSSOURCE is not NULL and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL " ) ; //and A3.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.BSSOURCE is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR<>0 " ) ; //and B.TTLDR-B.STLTTLDR>0
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + objName + "' " ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",STLTTLDR:\"" + Convert.ToString(reader["STLTTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",STLRMBDR:\"" + Convert.ToString(reader["STLRMBDR"]) + "\",STLRMBCR:\"" + Convert.ToString(reader["STLRMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",STLUSDDR:\"" + Convert.ToString(reader["STLUSDDR"]) + "\",STLUSDCR:\"" + Convert.ToString(reader["STLUSDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 业务来源 TEU
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareSourceTEUInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareSourceTEUInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareSourceTEUInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrTEUWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, " ) ;
/ * strSql . AppendLine ( "BSSOURCE, " ) ;
strSql . AppendLine ( "TEU, " ) ; * /
strSql . AppendLine ( "CUSTOMERNAME, " ) ;
strSql . AppendLine ( "CNTRTOTAL, " ) ;
strSql . AppendLine ( "PORTDISCHARGE, " ) ;
strSql . AppendLine ( "OP, " ) ;
strSql . AppendLine ( "SALE, " ) ;
strSql . AppendLine ( "BSSOURCE, " ) ;
strSql . AppendLine ( "BSTYPE, " ) ;
strSql . AppendLine ( "LANE, " ) ;
strSql . AppendLine ( "TEU, " ) ;
strSql . AppendLine ( "INPUTBY, " ) ;
strSql . AppendLine ( "(select SUM(TEU) from v_op_bill " ) ;
strSql . AppendLine ( "where BSSOURCE is not NULL " ) ;
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and BSSOURCE='" + objName + "'" ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as TEUAMOUNT " ) ;
strSql . AppendLine ( "from v_op_bill " ) ;
strSql . AppendLine ( "where BSSOURCE is not NULL " ) ; // and BSSOURCE <> ''
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and BSSOURCE='" + objName + "'" ) ; }
else if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and ='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 7),TEU " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",TEU:\"" + Convert . ToString ( reader [ "TEU" ] ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\",TEUAMOUNT:\"" + Convert . ToString ( reader [ "TEUAMOUNT" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 揽货人 利润
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareSaleGainInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareSaleGainInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareSaleGainInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.RMBCR) AS RMBAMOUNT, " ) ;
//RMB利润合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.SALE is not NULL and B1.RMBDR is not NULL and B1.RMBCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefinestrOPd" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.USDCR) AS USDAMOUNT, " ) ;
//USD利润合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.SALE is not NULL and B2.USDDR is not NULL and B2.USDCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.OTCR) AS OTAMOUNT, " ) ;
//OT合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.SALE is not NULL and B4.OTDR is not NULL and B4.OTCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.TTLCR) AS TTLAMOUNT, " ) ;
//TTL合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.SALE is not NULL and B3.TTLDR is not NULL and B3.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.SALE is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLCR:\"" + Convert.ToString(reader["TTLCR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",RMBDR:\"" + Convert.ToString(reader["RMBDR"]) + "\",RMBCR:\"" + Convert.ToString(reader["RMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",USDDR:\"" + Convert.ToString(reader["USDDR"]) + "\",USDCR:\"" + Convert.ToString(reader["USDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 揽货人 欠费
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareSaleArrearageInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareSaleArrearageInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareSaleArrearageInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, " ) ;
//RMB欠费合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.SALE is not NULL and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.STLUSDDR) AS USDAMOUNT, " ) ;
//USD欠费合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.SALE is not NULL and B2.USDDR is not NULL and B2.STLUSDDR is not NULL " ) ; //and A2.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.STLOTDR) OTAMOUNT, " ) ;
//OT欠费合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.SALE is not NULL and B4.OTDR is not NULL and B4.STLOTDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.STLTTLDR) TTLAMOUNT, " ) ;
//TTL欠费合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.SALE is not NULL and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL " ) ; //and A3.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.SALE is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR<>0 " ) ; //and B.TTLDR-B.STLTTLDR>0
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + objName + "' " ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",STLTTLDR:\"" + Convert.ToString(reader["STLTTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",STLRMBDR:\"" + Convert.ToString(reader["STLRMBDR"]) + "\",STLRMBCR:\"" + Convert.ToString(reader["STLRMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",STLUSDDR:\"" + Convert.ToString(reader["STLUSDDR"]) + "\",STLUSDCR:\"" + Convert.ToString(reader["STLUSDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 揽货人 TEU
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareSaleTEUInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareSaleTEUInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareSaleTEUInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrTEUWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, " ) ;
/ * strSql . AppendLine ( "TEU, " ) ;
strSql . AppendLine ( "SALE " ) ; * /
strSql . AppendLine ( "CUSTOMERNAME, " ) ;
strSql . AppendLine ( "CNTRTOTAL, " ) ;
strSql . AppendLine ( "PORTDISCHARGE, " ) ;
strSql . AppendLine ( "OP, " ) ;
strSql . AppendLine ( "SALE, " ) ;
strSql . AppendLine ( "BSSOURCE, " ) ;
strSql . AppendLine ( "BSTYPE, " ) ;
strSql . AppendLine ( "LANE, " ) ;
strSql . AppendLine ( "TEU, " ) ;
strSql . AppendLine ( "INPUTBY, " ) ;
strSql . AppendLine ( "(select SUM(TEU) from v_op_bill " ) ;
strSql . AppendLine ( "where SALE is not NULL " ) ;
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and SALE='" + objName + "'" ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as TEUAMOUNT " ) ;
strSql . AppendLine ( "from v_op_bill " ) ;
strSql . AppendLine ( "where SALE is not NULL " ) ; // and SALE <> ''
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and SALE='" + objName + "'" ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 7),TEU " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",TEU:\"" + Convert . ToString ( reader [ "TEU" ] ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\",TEUAMOUNT:\"" + Convert . ToString ( reader [ "TEUAMOUNT" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 运输方式 利润
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareBsTypeGainInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareBsTypeGainInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareBsTypeGainInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.RMBCR) AS RMBAMOUNT, " ) ;
//RMB利润合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.BSTYPE is not NULL and B1.RMBDR is not NULL and B1.RMBCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefinestrOPd" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.USDCR) AS USDAMOUNT, " ) ;
//USD利润合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.BSTYPE is not NULL and B2.USDDR is not NULL and B2.USDCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.OTCR) AS OTAMOUNT, " ) ;
//OT合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.BSTYPE is not NULL and B4.OTDR is not NULL and B4.OTCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.TTLCR) AS TTLAMOUNT, " ) ;
//TTL合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.BSTYPE is not NULL and B3.TTLDR is not NULL and B3.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.BSTYPE is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLCR:\"" + Convert.ToString(reader["TTLCR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",RMBDR:\"" + Convert.ToString(reader["RMBDR"]) + "\",RMBCR:\"" + Convert.ToString(reader["RMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",USDDR:\"" + Convert.ToString(reader["USDDR"]) + "\",USDCR:\"" + Convert.ToString(reader["USDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 运输方式 欠费
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareBsTypeArrearageInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareBsTypeArrearageInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareBsTypeArrearageInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, " ) ;
//RMB欠费合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.BSTYPE is not NULL and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.STLUSDDR) AS USDAMOUNT, " ) ;
//USD欠费合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.BSTYPE is not NULL and B2.USDDR is not NULL and B2.STLUSDDR is not NULL " ) ; //and A2.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.STLOTDR) OTAMOUNT, " ) ;
//OT欠费合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.BSTYPE is not NULL and B4.OTDR is not NULL and B4.STLOTDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.STLTTLDR) TTLAMOUNT, " ) ;
//TTL欠费合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.BSTYPE is not NULL and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL " ) ; //and A3.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.BSTYPE is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR<>0 " ) ; //and B.TTLDR-B.STLTTLDR>0
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + objName + "' " ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",STLTTLDR:\"" + Convert.ToString(reader["STLTTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",STLRMBDR:\"" + Convert.ToString(reader["STLRMBDR"]) + "\",STLRMBCR:\"" + Convert.ToString(reader["STLRMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",STLUSDDR:\"" + Convert.ToString(reader["STLUSDDR"]) + "\",STLUSDCR:\"" + Convert.ToString(reader["STLUSDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 运输方式 TEU
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareBsTypeTEUInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareBsTypeTEUInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareBsTypeTEUInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrTEUWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, " ) ;
/ * strSql . AppendLine ( "BSTYPE,TEU, " ) ;
strSql . AppendLine ( "INPUTBY " ) ; * /
strSql . AppendLine ( "CUSTOMERNAME, " ) ;
strSql . AppendLine ( "CNTRTOTAL, " ) ;
strSql . AppendLine ( "PORTDISCHARGE, " ) ;
strSql . AppendLine ( "OP, " ) ;
strSql . AppendLine ( "SALE, " ) ;
strSql . AppendLine ( "BSSOURCE, " ) ;
strSql . AppendLine ( "BSTYPE, " ) ;
strSql . AppendLine ( "LANE, " ) ;
strSql . AppendLine ( "TEU, " ) ;
strSql . AppendLine ( "INPUTBY, " ) ;
strSql . AppendLine ( "(select SUM(TEU) from v_op_bill " ) ;
strSql . AppendLine ( "where BSTYPE is not NULL " ) ;
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and BSTYPE='" + objName + "'" ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as TEUAMOUNT " ) ;
strSql . AppendLine ( "from v_op_bill " ) ;
strSql . AppendLine ( "where BSTYPE is not NULL " ) ; // and BSTYPE <> ''
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and BSTYPE='" + objName + "'" ) ; }
else if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 7),TEU " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",TEU:\"" + Convert . ToString ( reader [ "TEU" ] ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\",TEUAMOUNT:\"" + Convert . ToString ( reader [ "TEUAMOUNT" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 委托单位 利润
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareCustomerGainInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareCustomerGainInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareCustomerGainInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.RMBCR) AS RMBAMOUNT, " ) ;
//RMB利润合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.CUSTOMERNAME is not NULL and B1.RMBDR is not NULL and B1.RMBCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefinestrOPd" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.USDCR) AS USDAMOUNT, " ) ;
//USD利润合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.CUSTOMERNAME is not NULL and B2.USDDR is not NULL and B2.USDCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.OTCR) AS OTAMOUNT, " ) ;
//OT合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.CUSTOMERNAME is not NULL and B4.OTDR is not NULL and B4.OTCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.TTLCR) AS TTLAMOUNT, " ) ;
//TTL合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.CUSTOMERNAME is not NULL and B3.TTLDR is not NULL and B3.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.CUSTOMERNAME is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLCR:\"" + Convert.ToString(reader["TTLCR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",RMBDR:\"" + Convert.ToString(reader["RMBDR"]) + "\",RMBCR:\"" + Convert.ToString(reader["RMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",USDDR:\"" + Convert.ToString(reader["USDDR"]) + "\",USDCR:\"" + Convert.ToString(reader["USDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 委托单位 欠费
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareCustomerArrearageInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareCustomerArrearageInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareCustomerArrearageInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, " ) ;
//RMB欠费合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.CUSTOMERNAME is not NULL and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.STLUSDDR) AS USDAMOUNT, " ) ;
//USD欠费合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.CUSTOMERNAME is not NULL and B2.USDDR is not NULL and B2.STLUSDDR is not NULL " ) ; //and A2.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
//if (objName != "undefined" && objName != null && objName != "null" ) { strSql.AppendLine("and A2.LANE='" + objName + "' "); }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.STLOTDR) OTAMOUNT, " ) ;
//OT欠费合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.CUSTOMERNAME is not NULL and B4.OTDR is not NULL and B4.STLOTDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
//if (objName != "undefined" && objName != null && objName != "null" ) { strSql.AppendLine("and A4.LANE='" + objName + "' "); }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.STLTTLDR) TTLAMOUNT, " ) ;
//TTL欠费合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.CUSTOMERNAME is not NULL and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL " ) ; //and A3.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
//if (objName != "undefined" && objName != null && objName != "null" ) { strSql.AppendLine("and A3.LANE='" + objName + "' "); }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.CUSTOMERNAME is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR<>0 " ) ; //and B.TTLDR-B.STLTTLDR>0
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + objName + "' " ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
string _sumttlamount = "" ;
string _sumotamount = "" ;
string _sumusdamount = "" ;
string _sumrmbamount = "" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",STLTTLDR:\"" + Convert.ToString(reader["STLTTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",STLRMBDR:\"" + Convert.ToString(reader["STLRMBDR"]) + "\",STLRMBCR:\"" + Convert.ToString(reader["STLRMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",STLUSDDR:\"" + Convert.ToString(reader["STLUSDDR"]) + "\",STLUSDCR:\"" + Convert.ToString(reader["STLUSDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
_sumrmbamount = Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) ;
if ( _sumrmbamount = = "" ) { _sumrmbamount = "0" ; }
_sumusdamount = Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) ;
if ( _sumusdamount = = "" ) { _sumusdamount = "0" ; }
_sumotamount = Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) ;
if ( _sumotamount = = "" ) { _sumotamount = "0" ; }
_sumttlamount = Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ;
if ( _sumttlamount = = "" ) { _sumttlamount = "0" ; }
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + _sumrmbamount + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + _sumusdamount + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + _sumotamount + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( _sumttlamount ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 委托单位 TEU
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareCustomerTEUInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareCustomerTEUInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareCustomerTEUInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrTEUWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, " ) ;
/ * strSql . AppendLine ( "CUSTOMERNAME,TEU, " ) ;
strSql . AppendLine ( "INPUTBY " ) ; * /
strSql . AppendLine ( "CUSTOMERNAME, " ) ;
strSql . AppendLine ( "CNTRTOTAL, " ) ;
strSql . AppendLine ( "PORTDISCHARGE, " ) ;
strSql . AppendLine ( "OP, " ) ;
strSql . AppendLine ( "SALE, " ) ;
strSql . AppendLine ( "BSSOURCE, " ) ;
strSql . AppendLine ( "BSTYPE, " ) ;
strSql . AppendLine ( "LANE, " ) ;
strSql . AppendLine ( "TEU, " ) ;
strSql . AppendLine ( "INPUTBY, " ) ;
strSql . AppendLine ( "(select SUM(TEU) from v_op_bill " ) ;
strSql . AppendLine ( "where CUSTOMERNAME is not NULL " ) ;
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and CUSTOMERNAME='" + objName + "'" ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as TEUAMOUNT " ) ;
strSql . AppendLine ( "from v_op_bill " ) ;
strSql . AppendLine ( "where CUSTOMERNAME is not NULL " ) ; // and CUSTOMERNAME <> ''
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and CUSTOMERNAME='" + objName + "'" ) ; }
else if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 7),TEU " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",TEU:\"" + Convert . ToString ( reader [ "TEU" ] ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\",TEUAMOUNT:\"" + Convert . ToString ( reader [ "TEUAMOUNT" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 航线 利润
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareLaneGainInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareLaneGainInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareLaneGainInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.RMBCR) AS RMBAMOUNT, " ) ;
//RMB利润合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.RMBCR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.LANE is not NULL and B1.RMBDR is not NULL and B1.RMBCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefinestrOPd" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.USDCR) AS USDAMOUNT, " ) ;
//USD利润合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.USDCR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.LANE is not NULL and B2.USDDR is not NULL and B2.USDCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.OTCR) AS OTAMOUNT, " ) ;
//OT合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.OTCR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.LANE is not NULL and B4.OTDR is not NULL and B4.OTCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.TTLCR) AS TTLAMOUNT, " ) ;
//TTL合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.TTLCR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.LANE is not NULL and B3.TTLDR is not NULL and B3.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.LANE is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.TTLCR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.RMBCR,B.USDDR,B.USDCR,B.OTDR,B.OTCR,B.TTLDR,B.TTLCR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLCR:\"" + Convert.ToString(reader["TTLCR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",RMBDR:\"" + Convert.ToString(reader["RMBDR"]) + "\",RMBCR:\"" + Convert.ToString(reader["RMBCR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",USDDR:\"" + Convert.ToString(reader["USDDR"]) + "\",USDCR:\"" + Convert.ToString(reader["USDCR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 航线 欠费
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareLaneArrearageInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareLaneArrearageInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareLaneArrearageInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15),A.OPDATE, 111), 1, 10) MONTHNAME,A.MBLNO, " ) ;
strSql . AppendLine ( "A.CUSTOMERNAME, " ) ;
strSql . AppendLine ( "A.CNTRTOTAL, " ) ;
strSql . AppendLine ( "A.PORTDISCHARGE, " ) ;
strSql . AppendLine ( "A.OP, " ) ;
strSql . AppendLine ( "A.SALE, " ) ;
strSql . AppendLine ( "A.BSSOURCE, " ) ;
strSql . AppendLine ( "A.BSTYPE, " ) ;
strSql . AppendLine ( "A.LANE, " ) ;
strSql . AppendLine ( "(B.RMBDR-B.STLRMBDR) AS RMBAMOUNT, " ) ;
//RMB欠费合计
strSql . AppendLine ( "(select SUM(B1.RMBDR-B1.STLRMBDR) from v_op_bill as A1 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B1 on A1.BSNO=B1.BSNO " ) ;
strSql . AppendLine ( "where A1.LANE is not NULL and B1.RMBDR is not NULL and B1.STLRMBDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A1.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A1.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A1.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A1.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A1.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A1.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A1.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A1.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A1.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A1.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A1.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMRMBAMOUNT, " ) ;
strSql . AppendLine ( "(B.USDDR-B.STLUSDDR) AS USDAMOUNT, " ) ;
//USD欠费合计
strSql . AppendLine ( "(select SUM(B2.USDDR-B2.STLUSDDR) from v_op_bill as A2 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B2 on A2.BSNO=B2.BSNO " ) ;
strSql . AppendLine ( "where A2.LANE is not NULL and B2.USDDR is not NULL and B2.STLUSDDR is not NULL " ) ; //and A2.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A2.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A2.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A2.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A2.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A2.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A2.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A2.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A2.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A2.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A2.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A2.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMUSDAMOUNT, " ) ;
strSql . AppendLine ( "(B.OTDR-B.STLOTDR) OTAMOUNT, " ) ;
//OT欠费合计
strSql . AppendLine ( "(select SUM(B4.OTDR-B4.STLOTDR) from v_op_bill as A4 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B4 on A4.BSNO=B4.BSNO " ) ;
strSql . AppendLine ( "where A4.LANE is not NULL and B4.OTDR is not NULL and B4.STLOTDR is not NULL " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A4.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A4.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A4.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A4.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A4.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A4.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A4.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A4.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A4.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A4.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A4.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMOTAMOUNT, " ) ;
strSql . AppendLine ( "(B.TTLDR-B.STLTTLDR) TTLAMOUNT, " ) ;
//TTL欠费合计
strSql . AppendLine ( "(select SUM(B3.TTLDR-B3.STLTTLDR) from v_op_bill as A3 " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B3 on A3.BSNO=B3.BSNO " ) ;
strSql . AppendLine ( "where A3.LANE is not NULL and B3.TTLDR is not NULL and B3.STLTTLDR is not NULL " ) ; //and A3.LANE=''");
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A3.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A3.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A3.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A3.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A3.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A3.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A3.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A3.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A3.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A3.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A3.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as SUMTTLAMOUNT, " ) ;
strSql . AppendLine ( "A.INPUTBY " ) ;
strSql . AppendLine ( "from v_op_bill as A " ) ;
strSql . AppendLine ( "left join v_op_gain_sum as B on A.BSNO=B.BSNO " ) ;
strSql . AppendLine ( "where A.LANE is not NULL " ) ; // and A.LANE <> ''
strSql . AppendLine ( "and B.TTLDR is not NULL and B.STLTTLDR is not NULL and B.TTLDR-B.STLTTLDR<>0 " ) ; //and B.TTLDR-B.STLTTLDR>0
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and A.OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and A.ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and A.CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and A.SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and A.OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and A.DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and A.BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and A.OPLBNAME='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and A.VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and A.VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and A.LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and A.BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY A.OPDATE,A.MBLNO,A.CUSTOMERNAME,A.CNTRTOTAL,A.PORTDISCHARGE,A.OP,A.SALE,A.BSSOURCE,A.BSTYPE,A.LANE,A.OPDATE,B.RMBDR,B.STLRMBDR,B.USDDR,B.STLUSDDR,B.OTDR,B.STLOTDR,B.TTLDR,B.STLTTLDR,A.INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), A.OPDATE, 111), 1, 10),TTLAMOUNT " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",STLTTLDR:\"" + Convert.ToString(reader["STLTTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",RMBDR:\"" + Convert.ToString(reader["RMBDR"]) + "\",STLRMBDR:\"" + Convert.ToString(reader["STLRMBDR"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\", SUMRMBAMOUNT:\"" + Convert.ToString(reader["SUMRMBAMOUNT"]) + "\",USDDR:\"" + Convert.ToString(reader["USDDR"]) + "\",STLUSDDR:\"" + Convert.ToString(reader["STLUSDDR"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",SUMUSDAMOUNT:\"" + Convert.ToString(reader["SUMUSDAMOUNT"]) + "\",TTLDR:\"" + Convert.ToString(reader["TTLDR"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",SUMTTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["SUMTTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",RMBAMOUNT:\"" + Convert . ToString ( reader [ "RMBAMOUNT" ] ) + "\",SUMRMBAMOUNT:\"" + Convert . ToString ( reader [ "SUMRMBAMOUNT" ] ) + "\",USDAMOUNT:\"" + Convert . ToString ( reader [ "USDAMOUNT" ] ) + "\",SUMUSDAMOUNT:\"" + Convert . ToString ( reader [ "SUMUSDAMOUNT" ] ) + "\",OTAMOUNT:\"" + Convert . ToString ( reader [ "OTAMOUNT" ] ) + "\",SUMOTAMOUNT:\"" + Convert . ToString ( reader [ "SUMOTAMOUNT" ] ) + "\",TTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "TTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",SUMTTLAMOUNT:\"" + Math . Round ( decimal . Parse ( Convert . ToString ( reader [ "SUMTTLAMOUNT" ] ) ) , 2 , MidpointRounding . AwayFromZero ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
/// <summary>
/// 航线 TEU
/// </summary>
/// <param name="strYear"></param>
/// <param name="strMonth"></param>
/// <returns></returns>
public string GetCompareLaneTEUInfo ( string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
string dataList = GetCompareLaneTEUInfoList ( Convert . ToString ( Session [ "COMPANYID" ] ) , objName , strOPLB , strBSTYPE , strSALES , strOP , strDOC , strCUSTOMER , strBSSOURCE , strBSSOURCEDETAIL , strVESSEL , strVOYNO , strEXPDATEBGN , strEXPDATEEND , strETDDATEBGN , strETDDATEEND , strACCDATEBGN , strACCDATEEND ) ;
return dataList ;
}
private string GetCompareLaneTEUInfoList ( string companyID , string objName , string strOPLB , string strBSTYPE , string strSALES , string strOP , string strDOC , string strCUSTOMER , string strBSSOURCE , string strBSSOURCEDETAIL , string strVESSEL , string strVOYNO , string strEXPDATEBGN , string strEXPDATEEND , string strETDDATEBGN , string strETDDATEEND , string strACCDATEBGN , string strACCDATEEND )
{
var strSql = new StringBuilder ( ) ;
//var strDa = "1=1";// GetRangDAStrWeb("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var strDa = GetRangDAStrTEUWeb ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
strSql . AppendLine ( "select SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10) MONTHNAME,MBLNO, " ) ;
/ * strSql . AppendLine ( "LANE,TEU, " ) ;
strSql . AppendLine ( "INPUTBY " ) ; * /
strSql . AppendLine ( "CUSTOMERNAME, " ) ;
strSql . AppendLine ( "CNTRTOTAL, " ) ;
strSql . AppendLine ( "PORTDISCHARGE, " ) ;
strSql . AppendLine ( "OP, " ) ;
strSql . AppendLine ( "SALE, " ) ;
strSql . AppendLine ( "BSSOURCE, " ) ;
strSql . AppendLine ( "BSTYPE, " ) ;
strSql . AppendLine ( "LANE, " ) ;
strSql . AppendLine ( "TEU, " ) ;
strSql . AppendLine ( "INPUTBY, " ) ;
strSql . AppendLine ( "(select SUM(TEU) from v_op_bill " ) ;
strSql . AppendLine ( "where LANE is not NULL " ) ;
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = "null" & & objName ! = null ) { strSql . AppendLine ( "and LANE='" + objName + "'" ) ; }
else if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
strSql . AppendLine ( ") as TEUAMOUNT " ) ;
strSql . AppendLine ( "from v_op_bill " ) ;
strSql . AppendLine ( "where LANE is not NULL " ) ; // and LANE <> ''
strSql . AppendLine ( "and TEU is not NULL and TEU<>'' " ) ;
if ( strEXPDATEBGN ! = "" & & strEXPDATEBGN ! = "undefined" & & strEXPDATEBGN ! = "null" ) { strSql . AppendLine ( "and OPDATE>='" + strEXPDATEBGN + "'" ) ; }
if ( strEXPDATEEND ! = "" & & strEXPDATEEND ! = "undefined" & & strEXPDATEEND ! = "null" ) { strSql . AppendLine ( "and OPDATE<='" + strEXPDATEEND + " 23:59:59'" ) ; }
if ( strETDDATEBGN ! = "" & & strETDDATEBGN ! = "undefined" & & strETDDATEBGN ! = "null" ) { strSql . AppendLine ( "and ETD>='" + strETDDATEBGN + "'" ) ; }
if ( strETDDATEEND ! = "" & & strETDDATEEND ! = "undefined" & & strETDDATEEND ! = "null" ) { strSql . AppendLine ( "and ETD<='" + strETDDATEEND + " 23:59:59'" ) ; }
if ( strACCDATEBGN ! = "" & & strACCDATEBGN ! = "undefined" & & strACCDATEBGN ! = "null" ) { strSql . AppendLine ( "and ACCDATE>='" + strACCDATEBGN + "'" ) ; }
if ( strACCDATEEND ! = "" & & strACCDATEEND ! = "undefined" & & strACCDATEEND ! = "null" ) { strSql . AppendLine ( "and ACCDATE<='" + strACCDATEEND + " 23:59:59'" ) ; }
if ( strCUSTOMER ! = "" & & strCUSTOMER ! = "undefined" & & strCUSTOMER ! = "null" ) { strSql . AppendLine ( "and CUSTOMERNAME='" + strCUSTOMER + "'" ) ; }
if ( strSALES ! = "" & & strSALES ! = "undefined" & & strSALES ! = "null" ) { strSql . AppendLine ( "and SALE='" + strSALES + "'" ) ; }
if ( strOP ! = "" & & strOP ! = "undefined" & & strOP ! = "null" ) { strSql . AppendLine ( "and OP='" + strOP + "'" ) ; }
if ( strDOC ! = "" & & strDOC ! = "undefined" & & strDOC ! = "null" ) { strSql . AppendLine ( "and DOC='" + strDOC + "'" ) ; }
if ( strBSTYPE ! = "" & & strBSTYPE ! = "undefined" & & strBSTYPE ! = "null" ) { strSql . AppendLine ( "and BSTYPE='" + strBSTYPE + "'" ) ; }
if ( strOPLB ! = "" & & strOPLB ! = "undefined" & & strOPLB ! = "null" ) { strSql . AppendLine ( "and OPLB='" + strOPLB + "'" ) ; }
if ( strVESSEL ! = "" & & strVESSEL ! = "undefined" & & strVESSEL ! = "null" ) { strSql . AppendLine ( "and VESSEL='" + strVESSEL + "'" ) ; }
if ( strVOYNO ! = "" & & strVOYNO ! = "undefined" & & strVOYNO ! = "null" ) { strSql . AppendLine ( "and VOYNO='" + strVOYNO + "'" ) ; }
if ( objName ! = "undefined" & & objName ! = null & & objName ! = "null" ) { strSql . AppendLine ( "and LANE='" + objName + "' " ) ; }
if ( strBSSOURCE ! = "" & & strBSSOURCE ! = "undefined" & & strBSSOURCE ! = "null" ) { strSql . AppendLine ( "and BSSOURCE='" + strBSSOURCE + "'" ) ; }
if ( strBSSOURCEDETAIL ! = "" & & strBSSOURCEDETAIL ! = "undefined" & & strBSSOURCEDETAIL ! = "null" ) { strSql . AppendLine ( "and BSSOURCEDETAIL='" + strBSSOURCEDETAIL + "'" ) ; }
if ( ! string . IsNullOrEmpty ( strDa ) )
{
strSql . AppendLine ( "and " + strDa ) ;
}
//strSql.AppendLine("GROUP BY MBLNO,CUSTOMERNAME,CNTRTOTAL,PORTDISCHARGE,OP,SALE,BSSOURCE,BSTYPE,LANE,OPDATE,TEU,INPUTBY ");
strSql . AppendLine ( "order by SUBSTRING(CONVERT(char(15), OPDATE, 111), 1, 10),TEU " ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
string evList = string . Empty ;
evList = "[" ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
var i = 1 ;
while ( reader . Read ( ) )
{
evList + = "{" ;
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",TEU:\"" + Convert.ToString(reader["TEU"]) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
evList + = "MONTHNAME:\"" + Convert . ToString ( reader [ "MONTHNAME" ] ) + "\",MBLNO:\"" + Convert . ToString ( reader [ "MBLNO" ] ) + "\",CUSTOMERNAME:\"" + Convert . ToString ( reader [ "CUSTOMERNAME" ] ) + "\",CNTRTOTAL:\"" + Convert . ToString ( reader [ "CNTRTOTAL" ] ) + "\",PORTDISCHARGE:\"" + Convert . ToString ( reader [ "PORTDISCHARGE" ] ) + "\",OP:\"" + Convert . ToString ( reader [ "OP" ] ) + "\",SALE:\"" + Convert . ToString ( reader [ "SALE" ] ) + "\",BSSOURCE:\"" + Convert . ToString ( reader [ "BSSOURCE" ] ) + "\",BSTYPE:\"" + Convert . ToString ( reader [ "BSTYPE" ] ) + "\",LANE:\"" + Convert . ToString ( reader [ "LANE" ] ) + "\",TEU:\"" + Convert . ToString ( reader [ "TEU" ] ) + "\",INPUTBY:\"" + Convert . ToString ( reader [ "INPUTBY" ] ) + "\",TEUAMOUNT:\"" + Convert . ToString ( reader [ "TEUAMOUNT" ] ) + "\"" ;
evList + = "}," ;
i = i + 1 ;
}
reader . Close ( ) ;
}
evList = evList . Substring ( 0 , evList . Length - 1 ) ;
evList + = "]" ;
return evList ;
}
public ContentResult SumListData ( int start , int limit , string condition , string sort , string printstr , string objname , string sumfieldtype , string topnum )
{
var strDa = GetRangDAStr ( "index" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( ! string . IsNullOrEmpty ( strDa ) )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and " + strDa ;
}
else
{
condition = strDa ;
}
}
var RPTPRNOCANCEL = MsSysParamSetDAL . GetData ( "PARAMNAME='RPTPRNOCANCEL'" ) ;
if ( RPTPRNOCANCEL . PARAMVALUE = = "1" )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) " ;
}
else
{
condition = " (B.ISCANCEL IS NULL OR B.ISCANCEL=0 ) " ;
}
}
var strSql = new StringBuilder ( ) ;
if ( topnum = = "0" )
strSql . Append ( "SELECT " + objname + " AS OBJNAME " ) ;
else
strSql . Append ( "SELECT TOP " + topnum + " " + objname + " AS OBJNAME " ) ;
if ( sumfieldtype = = "利润" )
strSql . Append ( ",SUM(G.TTLDR-G.TTLCR) AS OBJNUM,SUM(G.RMBDR-G.RMBCR) AS OBJNUMRMB,SUM(G.USDDR-G.USDCR) AS OBJNUMUSD " ) ;
if ( sumfieldtype = = "欠费" )
{
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=1 THEN (AMOUNT-SETTLEMENT)*EXCHANGERATE ELSE 0 END) AS OBJNUM " ) ;
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=1 AND F.CURRENCY='RMB' THEN (AMOUNT-SETTLEMENT) ELSE 0 END) AS OBJNUMRMB " ) ;
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=1 AND F.CURRENCY='USD' THEN (AMOUNT-SETTLEMENT) ELSE 0 END) AS OBJNUMUSD " ) ;
}
if ( sumfieldtype = = "TEU" )
strSql . Append ( ",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) AS OBJNUM,0 AS OBJNUMRMB,0 AS OBJNUMUSD " ) ;
if ( sumfieldtype = = "毛重" )
strSql . Append ( ",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) AS OBJNUM,0 AS OBJNUMRMB,0 AS OBJNUMUSD " ) ;
if ( sumfieldtype = = "计费重" )
strSql . Append ( ",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.FEEKGS ELSE 0 END) AS OBJNUM,0 AS OBJNUMRMB,0 AS OBJNUMUSD " ) ;
if ( sumfieldtype = = "票数" )
strSql . Append ( ",SUM(case WHEN B.OPTYPE='普通货' THEN 1 ELSE 0 END) AS OBJNUM,0 AS OBJNUMRMB,0 AS OBJNUMUSD " ) ;
if ( sumfieldtype = = "应收" )
{
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=1 THEN AMOUNT*EXCHANGERATE ELSE 0 END) AS OBJNUM " ) ;
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=1 AND F.CURRENCY='RMB' THEN AMOUNT ELSE 0 END) AS OBJNUMRMB " ) ;
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=1 AND F.CURRENCY='USD' THEN AMOUNT ELSE 0 END) AS OBJNUMUSD " ) ;
}
if ( sumfieldtype = = "应付" )
{
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=2 THEN AMOUNT*EXCHANGERATE ELSE 0 END) AS OBJNUM " ) ;
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=2 AND F.CURRENCY='RMB' THEN AMOUNT ELSE 0 END) AS OBJNUMRMB " ) ;
strSql . Append ( ",SUM(CASE WHEN F.FEETYPE=2 AND F.CURRENCY='USD' THEN AMOUNT ELSE 0 END) AS OBJNUMUSD " ) ;
}
strSql . Append ( " FROM V_OP_BILL B " ) ;
strSql . Append ( "LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) " ) ;
if ( sumfieldtype = = "应收" | | sumfieldtype = = "应付" | | sumfieldtype = = "欠费" )
{
var NORPTFEESTATUS = MsSysParamSetDAL . GetData ( "PARAMNAME='NORPTFEESTATUS'" ) ;
if ( NORPTFEESTATUS . PARAMVALUE = = "1" )
strSql . Append ( "LEFT JOIN ch_fee F ON (F.BSNO=B.BSNO and F.FEESTATUS<>1) " ) ;
else
strSql . Append ( "LEFT JOIN ch_fee F ON (F.BSNO=B.BSNO) " ) ;
}
strSql . Append ( " WHERE 1=1 " ) ;
if ( ! string . IsNullOrEmpty ( condition ) )
{
strSql . Append ( " AND " + condition ) ;
}
if ( sumfieldtype = = "利润" )
strSql . Append ( " AND (G.TTLDR-G.TTLCR)<>0 " ) ;
if ( sumfieldtype = = "欠费" )
strSql . Append ( " AND (CASE WHEN F.FEETYPE=1 THEN (AMOUNT-SETTLEMENT)*EXCHANGERATE ELSE 0 END)<>0 " ) ;
if ( sumfieldtype = = "TEU" )
strSql . Append ( " AND (B.TEU)<>0 " ) ;
if ( sumfieldtype = = "毛重" )
strSql . Append ( " AND (B.KGS)<>0 " ) ;
if ( sumfieldtype = = "计费重" )
strSql . Append ( " AND (B.FEEKGS)<>0 " ) ;
if ( sumfieldtype = = "应收" )
strSql . Append ( " AND (CASE WHEN F.FEETYPE=1 THEN AMOUNT*EXCHANGERATE ELSE 0 END)<>0 " ) ;
if ( sumfieldtype = = "应付" )
strSql . Append ( " AND (CASE WHEN F.FEETYPE=2 THEN AMOUNT*EXCHANGERATE ELSE 0 END)<>0 " ) ;
strSql . Append ( " Group by " + objname ) ;
var sortstring = DatasetSort . Getsortstring ( sort ) ;
if ( ! string . IsNullOrEmpty ( sortstring ) )
{
strSql . Append ( " order by " + sortstring ) ;
}
else
{
strSql . Append ( " order by OBJNUM desc " ) ;
}
if ( ( ! string . IsNullOrEmpty ( printstr ) ) & & ( printstr = = "true" ) )
{
var jsonRespose = new JsonResponse
{
Success = true ,
Message = "完成" ,
Data = strSql . ToString ( )
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var dbparams = new List < CustomDbParamter > ( ) ;
var paramps_sSQL = new CustomDbParamter ( ) ;
paramps_sSQL . ParameterName = "@sSQL" ;
paramps_sSQL . DbType = DbType . String ;
paramps_sSQL . Direction = ParameterDirection . Input ;
paramps_sSQL . Value = strSql . ToString ( ) ;
dbparams . Add ( paramps_sSQL ) ;
var dbRptResult = PubSysDAL . GetMsSqlPrcDataSet ( "sMsExesqlQry" , dbparams , "Result_Set" ) ;
var json = RptHelper . GetRptJsonResult ( start , limit , dbRptResult , "Result_Set" , true ) ;
return new ContentResult ( ) { Content = json } ;
}
}
public static string GetRangDAStr ( string tb , string userid , string usercode , string companyid )
{
string str = "" ;
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT " ) ;
strSql . Append ( " VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL " ) ;
strSql . Append ( " from VW_User_Authority " ) ;
strSql . Append ( " where [NAME]='modProfitpercentRange' and USERID='" + userid + "' and ISDELETE=0" ) ;
string visiblerange = "4" ;
string operaterange = "4" ;
string AUTHORITYID = "" ;
string VSSQL = "" ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
visiblerange = Convert . ToString ( reader [ "VISIBLERANGE" ] ) ;
operaterange = Convert . ToString ( reader [ "OPERATERANGE" ] ) ;
AUTHORITYID = Convert . ToString ( reader [ "AUTHORITYID" ] ) ;
VSSQL = Convert . ToString ( reader [ "VSSQL" ] ) ;
break ;
}
reader . Close ( ) ;
}
if ( visiblerange = = "4" )
{
str = "1=2" ;
}
else if ( visiblerange = = "3" )
{
str = " (B.OP='" + usercode + "' OR B.SALE='" + usercode + "')" ;
}
else if ( visiblerange = = "2" )
{
if ( tb = = "index" )
{
var rangeDa = new RangeDA ( ) ;
var deptname = rangeDa . GetDEPTNAME ( userid ) ;
var userstr = new StringBuilder ( ) ;
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 + "')" ) ;
Database userdb = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = userdb . ExecuteReader ( CommandType . Text , userstr . ToString ( ) ) )
{
str = "" ;
while ( reader . Read ( ) )
{
if ( str = = "" )
{
str = " (B.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
}
else
{
str = str + " or B.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
} ;
}
str = str + ")" ;
reader . Close ( ) ;
}
}
else
{
str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') " ;
}
}
else if ( visiblerange = = "5" )
{
var userstr = new StringBuilder ( ) ;
userstr . Append ( " select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1" ) ;
Database userdb = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = userdb . ExecuteReader ( CommandType . Text , userstr . ToString ( ) ) )
{
str = "" ;
while ( reader . Read ( ) )
{
if ( str = = "" )
{
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 ( ) ;
}
}
else if ( visiblerange = = "6" )
{
var userstr = new StringBuilder ( ) ;
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" ) ;
Database userdb = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = userdb . ExecuteReader ( CommandType . Text , userstr . ToString ( ) ) )
{
str = "" ;
while ( reader . Read ( ) )
{
if ( str = = "" )
{
str = " (B.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
}
else
{
str = str + " or B.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
} ;
}
str = str + ")" ;
reader . Close ( ) ;
}
}
else if ( visiblerange = = "1" )
{
str = " (UPPER(B.Corpid)='" + companyid + "' or B.SALECORPID='" + companyid + "') " ;
}
VSSQL = VSSQL . Trim ( ) ;
if ( ! string . IsNullOrEmpty ( VSSQL ) )
{
if ( ! string . IsNullOrEmpty ( str ) )
{
str = str + " and (" + VSSQL + ") " ;
}
else
{
str = " (" + VSSQL + ") " ;
}
}
return str ;
}
#region 参照部分
# endregion
}
}