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 ");
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+"')");