varpaylist=ChpayapplicationDAL.GetDataList(0,1000,"BILLNO IN ('"+bills.Replace(",","','")+"')",Convert.ToString(Session["USERID"]),Convert.ToString(Session["CODENAME"]),Convert.ToString(Session["COMPANYID"]));
strSql.Append(" SELECT '' GID,'' BSNO,'' FEEID,'' FEENAME,'' CURRENCY,sum(ISNULL((case when c.ORIGCURRENCY='RMB' THEN case when c.FEETYPE=1 THEN ORIGAMOUNT ELSE -ORIGAMOUNT END ELSE 0 END),0)) AMOUNT,0 DOAMOUNT");
strSql.Append(",'' ORIGCURRENCY,sum(ISNULL((case when c.ORIGCURRENCY!='RMB' THEN case when c.FEETYPE=1 THEN ORIGAMOUNT ELSE -ORIGAMOUNT END ELSE 0 END),0)) ORIGAMOUNT,0 ORIGSTLAMOUNT,0 EXCHANGERATE,0 ORIGEXCHANGERATE ");
strSql.Append(",1 FEETYPE,'' FEEOBJNAME,'收' AS FEETYPEREF");
str=" (OP='"+username+"' OR CREATEUSER='"+userid+"' OR SALE='"+username+"' OR CUSTSERVICE='"+username+"')";
str=" (OP='"+username+"' OR CREATEUSER='"+userid+"' OR SALE='"+username+"' OR CUSTSERVICE='"+username+"' OR FRCUSTSERVICE='" +username+"')";
}
elseif(visiblerange=="3")
{
str=" (OP='"+username+"' OR CREATEUSER='"+userid+"' OR SALE='"+username+"' OR CUSTSERVICE='"+username+"')";
str=" (OP='"+username+"' OR CREATEUSER='"+userid+"' OR SALE='"+username+"' OR CUSTSERVICE='"+username+"' OR FRCUSTSERVICE='" +username+"')";
}
elseif(visiblerange=="2")
{
varrangeDa=newRangeDA();
vardeptname=rangeDa.GetDEPTNAME(userid);
str=" (OP in (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+"'))"
+" OR CREATEUSER in (select GID from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"') and GID in (select userid from user_baseinfo where DEPTNAME='"+deptname+"')))";
vardeptid=rangeDa.GetDEPTGID(userid);
str=$" exists(select 1 from vw_user where deptgid='{deptid}' and SHOWNAME in(op_other.OP,op_other.SALE,op_other.CUSTSERVICE,op_other.FRCUSTSERVICE,op_other.DOC)) ";
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");
//userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
//str = " (OP in " + opstr + " or CREATEUSER in " + opstr + " or CUSTSERVICE IN " + opstr + " or SALE IN " + opstr + " )";
str=" EXISTS (select 1 from user_authority_range_op P left join [user] u on (u.GID=P.OPID) where (op_other.OP=U.SHOWNAME OR op_other.SALE=U.SHOWNAME OR op_other.CUSTSERVICE=U.SHOWNAME OR op_other.DOC=U.SHOWNAME OR op_other.FRCUSTSERVICE=U.SHOWNAME) AND P.userid='"+userid+"' and P.AUTHORITYID='"+AUTHORITYID+"' and P.VISIBLERANGE=1) ";
sql=sql+getAndConSql(sql,CUSTNO," ob.GID in(select LINKGID from op_blissuelist_Detail where BSNO in(select BSNO from v_op_blissue_bill where CUSTNO like '%"+CUSTNO+"%')) ");
varOP=form.findField('OP').getValue();
sql=sql+getAndConSql(sql,OP," ob.GID in(select LINKGID from op_blissuelist_Detail where BSNO in(select BSNO from v_op_blissue_bill where OP='"+OP+"')) ");
strSql.Append("SELECT NO,PKGS,KGS,CBM,NETWEIGHT,FEEKGS,CTNALL,CTNNUM,TEU FROM (");
strSql.Append("SELECT '1' as NO,件数 PKGS,重量 KGS,尺码 CBM,重量 AS NETWEIGHT,计价重量 AS FEEKGS,");
strSql.Append("'' as CTNALL,0 AS CTNNUM,0 AS TEU ");
strSql.Append(",isnull((select sum(数量) from t_op_ctn where 编号=t_op_seae.编号),0) 总箱数 ");
// strSql.Append(",isnull((select sum(ctnrCount) from t_op_txxp_log where 编号=t_op_seae.编号),0)-isnull((select sum(数量) from t_op_ctn where 编号=t_op_seae.编号),0) 超额小票数 ");
strSql.Append(" from t_op_seae ");
strSql.Append(" where 编号='"+BSNO+"'");
strSql.Append(") AS T ");
strSql.Append(" union ");
strSql.Append("SELECT '2' AS NO,0 AS PKGS,0 AS KGS,0 AS CBM,0 AS NETWEIGHT,0 AS FEEKGS,");
strSql.Append("P.表现形式 CTNALL,SUM(P.数量) AS CTNNUM,SUM(P.TEU) AS TEU");
strSql.Append(" from t_op_ctn P ");
strSql.Append(" where p.编号='"+BSNO+"'");
strSql.Append(" GROUP BY P.表现形式 order by PKGS desc");