@"insert into ch_fee_invoiceapplication_detail (GID,BILLSTATUS,LINKGID,CUSTOMERNAME,INVOICECUSTNAME,AMOUNT,CURRENCY,REMARK,CUSTRATENO,CUSTADDRTEL,CUSTBANK,CUSTTEL,CUSTADDR,EMAIL,GOODSNAME)
@"insert into ch_fee_invoiceapplication_detail (GID,BILLSTATUS,LINKGID,CUSTOMERNAME,INVOICECUSTNAME,AMOUNT,CURRENCY,REMARK,CUSTRATENO,CUSTADDRTEL,CUSTBANK,CUSTTEL,CUSTADDR,EMAIL,GOODSNAME,INVOICELINE)
@"update ch_fee_invoiceapplication_detail set CUSTOMERNAME=@CUSTOMERNAME,INVOICECUSTNAME=@INVOICECUSTNAME,AMOUNT=@AMOUNT,CURRENCY=@CURRENCY,REMARK=@REMARK,CUSTRATENO=@CUSTRATENO
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
strSql.Append(" LEFT JOIN v_op_gain_cust_sum g ON (g.BSNO=B.BSNO and g.CUSTOMERNAME=f.CUSTOMERNAME) ");
strSql.Append(" left join ch_dui_detail d on (d.CH_ID=f.GID) WHERE D.DUINO='"+duino+"' AND ISNULL(D.INVNO,'')='' ");
strSql.Append(" and f.ISINVOICE<>1 and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(" and (f.AMOUNT-f.ORDERAMOUNT)<>0 and f.ISINVOICE<>1 and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
strSql.Append(" LEFT JOIN v_op_gain_cust_sum g ON (g.BSNO=B.BSNO and g.CUSTOMERNAME=f.CUSTOMERNAME) ");
strSql.Append(" where f.ISINVOICE<>1 and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(" where (f.AMOUNT-f.ORDERAMOUNT)<>0 and f.ISINVOICE<>1 and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
strSql.Append(" left join ch_dui_detail d on (d.CH_ID=f.GID) WHERE D.DUINO='"+duino+"' AND ISNULL(D.INVNO,'')='' ");
strSql.Append(" and f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(" and (f.AMOUNT-f.ORDERAMOUNT)<>0 and f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append("SELECT COUNT(*) FROM (select b.BSNO,f.CUSTOMERNAME ");
strSql.Append(" FROM CH_FEE f ");
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
strSql.Append(" where f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(" where (f.AMOUNT-f.ORDERAMOUNT)<>0 and f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(",(select ShowName from [user] where GID=f.EnteroPerator) as OpName");
strSql.Append(",f.INPUTMODE,f.UNIT,f.UNITPRICE,f.QUANTITY,d.DEBITAMOUNT from ch_fee f ");
strSql.Append(" left join ch_dui_detail d on (d.CH_ID=f.GID) WHERE D.DUINO='"+duino+"' AND ISNULL(D.INVNO,'')='' ");
strSql.Append(" and f.ISINVOICE<>1 and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(" and (f.AMOUNT-f.ORDERAMOUNT)<>0 and f.ISINVOICE<>1 and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(",f.feeName,f.customerName,f.amount,f.amount-isnull(f.INVOICE,0)-isnull(f.ORDERINVOICE,0)+isnull(f.ORDERINVSETTLEMENT,0) as balamount,f.currency,f.exChangerate,f.AccTaxRate,f.remark");
strSql.Append(",(select ShowName from [user] where GID=f.EnteroPerator) as OpName");
strSql.Append(",f.INPUTMODE,f.UNIT,f.UNITPRICE,f.QUANTITY,0 DEBITAMOUNT from ch_fee f ");
strSql.Append(" where f.ISINVOICE<>1 and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
strSql.Append(" where (f.AMOUNT-f.ORDERAMOUNT)<>0 and f.ISINVOICE<>1 and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) and ISNULL(f.INVLINKGID,'')='' ");
tempstr+=GetSpaceStr(bill.CONTRACTNO,10);//10//Service Contract #//C//X(10)//31//40//Applicable to US shipments only//"mandtory for US shpts---Service Contract Nbr/TAA Nbr"//美国线的S/C,TAA//服务合同#//只适用于美国装运
tempstr+=GetSpaceStr(bill.SERVICECONTRACTNO,10);//10//Service Contract #//C//X(10)//31//40//Applicable to US shipments only//"mandtory for US shpts---Service Contract Nbr/TAA Nbr"//美国线的S/C,TAA//服务合同#//只适用于美国装运
}
else
{
tempstr+=GetSpaceStr(bill.CONTRACTNO,10);//10//Service Contract #//C//X(10)//31//40//Applicable to US shipments only//"mandtory for US shpts---Service Contract Nbr/TAA Nbr"//美国线的S/C,TAA//服务合同#//只适用于美国装运
tempstr+=GetSpaceStr(bill.SERVICECONTRACTNO,10);//10//Service Contract #//C//X(10)//31//40//Applicable to US shipments only//"mandtory for US shpts---Service Contract Nbr/TAA Nbr"//美国线的S/C,TAA//服务合同#//只适用于美国装运
}
tempstr+=GetSpaceStr("",5);//11//Prepaid at (Port code)//M//X(5)//41//45//Ocean Freight Payment Location//预付(港码)//海运付款地点
tempstr+=GetSpaceStr("",5);//12//Payable at (Port Code)//M//X(5)//46//50//1st Collect Charge Payment Location//按(港口代码)支付//第一收取缴费地点