strSql.Append("(SELECT TRUCKNO FROM TMSWLTRUCK WHERE TRUCKNO=A.TRUCKNO) AS TRUCKNO_REF,DRVNAME,");
strSql.Append("(SELECT DRVNAME FROM TMSWLDRIVER WHERE DRVCODE=A.DRVNAME) AS DRVNAME_REF,A.MOBILE,dbo.trimdate(A.ExpDate) ExpDate,A.CONTAINERTYPE,");
strSql.Append("(SELECT CtnName FROM VMSTRUCKCTN WHERE CTNCODE=A.CONTAINERTYPE) AS CONTAINERTYPE_REF,A.CONTAINERQTY,A.VOYVEG, ");
strSql.Append("(SELECT CODEANDNAME FROM VMSTRUCKVOYINFO WHERE VOYCODE=A.VOYVEG) AS VOYVEG_REF,A.ETDATE,A.ENDPORTDATE,A.MBLNO,A.YARDCODE,");
strSql.Append("(SELECT CODEANDNAME FROM VMSTRUCKCLIENT WHERE CUSTCODE=A.YARDCODE) AS YARDCODE_REF,A.YARDNAME,A.RTNYARDCODE, ");
strSql.Append("(SELECT CODEANDNAME FROM VMSTRUCKCLIENT WHERE CUSTCODE=A.RTNYARDCODE) AS RTNYARDCODE_REF,A.RTNYARDNAME,A.BSTYPE,");
strSql.Append("(SELECT ENUMVALUENAME FROM TSYSENUMVALUE WHERE LANGID=0 AND ENUMTYPEID=99025 AND ENUMVALUEID=A.BSTYPE) AS BSTYPE_REF,A.DSTAREA,A.DETINATION,A.FACTORYADDR,A.LINKTEL,A.LINKMAN,A.RATEDMIL,A.RATEDFUEL ");
strSql.Append("(SELECT CODEANDNAME FROM VMSTRUCKUSER WHERE USERCODE=A.DDCODE) AS DDCODE_REF,A.DDNAME,A.RETURNDATE,A.REFBILLNO,A.REMARK,A.ISDOUBLE,A.REFBILLNOSE,A.CONTAINERTYPESE, ");
strSql.Append("(SELECT CODEANDNAME FROM VMSTRUCKCTN WHERE CTNCODE=A.CONTAINERTYPESE) AS CONTAINERTYPESE_REF,A.CONTAINERQTYSE,A.MBLNOSE,A.VOYVEGSE, ");
strSql.Append("(SELECT CODEANDNAME FROM VMSTRUCKVOYINFO WHERE VOYCODE=A.VOYVEGSE) AS VOYVEGSE_REF,A.ETDATESE,A.ENDPORTDATESE,A.YARDCODESE, ");
strSql.Append("(SELECT CODEANDNAME FROM VMSTRUCKCLIENT WHERE CUSTCODE=A.YARDCODESE) AS YARDCODESE_REF,A.YARDNAMESE,A.DSTAREASE,A.FACTORYADDRSE,A.DETINATIONSE,A.LINKMANSE,A.LINKTELSE,A.RTNYARDCODESE, ");
strSql.Append("(SELECT CODEANDNAME FROM VMSTRUCKCLIENT WHERE CUSTCODE=A.RTNYARDCODESE) AS RTNYARDCODESE_REF,A.RTNYARDNAMESE,A.BILLSTATUS, ");
strSql.Append("(SELECT ENUMVALUENAME FROM TSYSENUMVALUE WHERE LANGID=0 AND ENUMTYPEID=99026 AND ENUMVALUEID=A.BILLSTATUS) AS BILLSTATUS_REF,A.FEESTATUS, ");
strSql.Append("(SELECT ENUMVALUENAME FROM TSYSENUMVALUE WHERE LANGID=0 AND ENUMTYPEID=99027 AND ENUMVALUEID=A.FEESTATUS) AS FEESTATUS_REF,A.GID,A.TOTALMIL,A.LOADPLACE,A.LOADFUEL,A.NOLOADFUEL ");
strSql.Append(",B.CUSTCODE,B.CUSTNAME,B.DETINATION,A.CONTAINERNO,A.SEALNO,A.Ton,A.ActualWeight,case A.isdouble when 1 then '是' else '否' end IsDoubleREF ");
strSql.Append("from tMsWlPcHead A,tMsWlBsHead B ");
strSql.Append(" where A.RefBillNo=B.BillNo and B.BSTYPE='7' ");
if(!string.IsNullOrEmpty(condition))
{
strSql.Append(" and "+condition);
}
varsortstring=DatasetSort.Getsortstring(sort);
if(!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by "+sortstring);
}
else{
strSql.Append(" order by A.TRUCKNO,A.LRDATE DESC");
userstr.Append(" select codename from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"') and GID in (select userid from user_baseinfo where DEPTNAME='"+deptname+"')");