|
|
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.DAL.MsBaseInfoDAL;
|
|
|
using System.IO;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 欠费报表查询
|
|
|
/// </summary>
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsRptNoTotalController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET: /MvcShipping/MsRptOpProfit
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult DrIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult CrIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult CDIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult ZNJIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult DzlxIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
//
|
|
|
// GET:/RptMng/MsRptPcHeadQry/QryData
|
|
|
|
|
|
public ContentResult BsListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string amendstr = "false")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var NORPTFEESTATUS = MsSysParamSetDAL.GetData("PARAMNAME='NORPTFEESTATUS'");
|
|
|
if (NORPTFEESTATUS.PARAMVALUE == "1") {
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
var PROFITRATEDR = MsSysParamSetDAL.GetData("PARAMNAME='PROFITRATEDR'");
|
|
|
|
|
|
var NORPTSTLDATETYPE = MsSysParamSetDAL.GetData("PARAMNAME='NORPTSTLDATETYPE'");
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("SELECT *,dbo.F_FeeStatusStr(DRFEESTATUS) DRFEESTATUSREF,dbo.F_FeeStatusStr(CRFEESTATUS) CRFEESTATUSREF ");
|
|
|
strSql.Append(",case OPDATE when '' then 0 else case when BALTTLDR<>0 OR BALTTLCR<>0 then DATEDIFF([day],CASE WHEN STLDATE IS NULL THEN OPDATE ELSE STLDATE END,GETDATE()) ");
|
|
|
strSql.Append(" else (DATEDIFF([day],CASE WHEN STLDATE IS NULL THEN OPDATE ELSE STLDATE END,SETTLETIME)) end end AS NODAY");
|
|
|
strSql.Append(" FROM (");
|
|
|
|
|
|
if (amendstr == "true")
|
|
|
{
|
|
|
strSql.Append("SELECT A.BSNO,'' OPTYPE,A.OPLBNAME, A.BSTYPE,A.CUSTOMERNAME, A.CUSTNO, A.MBLNO,A.HBLNO,A.VESSEL,A.VOYNO, A.INPUTBY, A.CREATETIME, A.BSSTATUS, A.SALE, A.OP,A.DOC,A.YARD,A.BLISSUESTATUS,A.BLTYPE,");
|
|
|
strSql.Append("case A.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), A.ETD,23) end as ETD");
|
|
|
strSql.Append(",case A.ETA when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), A.ETA,23) end as ETA,case A.ATD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), A.ATD,23) end as ATD");
|
|
|
if (NORPTSTLDATETYPE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(",CASE WHEN A.CUSTOMERNAME=F.CUSTOMERNAME THEN A.STLNAME ELSE isnull((select top 1 ACCTYPE from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =F.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=A.SALE)) and BGNDATE<=A.OPDATE AND ENDDATE>=A.OPDATE),'现结买单') END STLNAME");
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
strSql.Append(",A.STLNAME STLNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
strSql.Append(",case A.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), A.OPDATE,23) end as OPDATE,A.ENTERP,A.DELIVERYDATE");
|
|
|
strSql.Append(",case A.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), A.CUSTOMDATE,23) end as CUSTOMDATE,A.SERVICECONTRACTNO");
|
|
|
strSql.Append(",A.CUSTSERVICE, A.PORTLOAD, A.PORTDISCHARGE,B.DESTINATION, A.CUSTOMNO, B.ACCDATE,A.CARRIER, A.BSSOURCE,A.BSSOURCEDETAIL,A.LANE, A.FORWARDER,A.NETWEIGHT,A.KGS,A.TEU,A.CNTRTOTAL,A.CORPID");
|
|
|
strSql.Append(",A.CNTR1,A.CNTR2,A.CNTR3,A.CNTR4,A.CNTR5,A.CNTR6,A.CNTR7,A.CNTR8,A.CNTR9,A.CNTR10,A.OTCNTR,A.TRADETYPE,A.GOODSNAME,A.FEESTATUS,A.PKGS,A.CBM,A.ORDERNO,A.SALECORPID,(select [NAME] from [company] where GID=A.SALECORPID) as SALECORP");
|
|
|
strSql.Append(",(CASE A.FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF,A.AGENTID ");
|
|
|
strSql.Append(",F.CUSTOMERNAME AS CUSTNAME ");
|
|
|
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME ");
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
|
|
|
strSql.Append(",case when isnull(SUM(F.AMOUNT),0)<>isnull(SUM(F.SETTLEMENT),0) then (case A.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],A.OPDATE, GETDATE()) end) ");
|
|
|
strSql.Append(" else (case A.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],A.OPDATE, S.SETTLETIME) end) end AS ACTUALDAY,S.SETTLETIME");
|
|
|
|
|
|
if (NORPTSTLDATETYPE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(",[dbo].[GetCustStlDay](A.OPDATE,F.CUSTOMERNAME,A.SALE) AS STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =F.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
strSql.Append(",CASE WHEN A.STLDATE IS NULL THEN A.OPDATE ELSE A.STLDATE END STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =A.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (PROFITRATEDR.PARAMVALUE != "1")
|
|
|
{
|
|
|
strSql.Append(", (CASE WHEN (SUM(G.TTLDR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLDR)) * 100, 10, 2))) END) AS PROFITRATE");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
strSql.Append(", (CASE WHEN (SUM(G.TTLCR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLCR)) * 100, 10, 2))) END) AS PROFITRATE");
|
|
|
|
|
|
//strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else case when isnull(SUM(F.AMOUNT),0)<>isnull(SUM(F.SETTLEMENT),0) then DATEDIFF([day],B.OPDATE,(CASE C.STLNAME WHEN '月结' THEN ");
|
|
|
//strSql.Append("DATEADD(month,1,DATEADD(day,ISNULL(CAST(C.STLDATE AS INT),1),DATEADD(day,-Day(B.OPDATE)+1,B.OPDATE)))");
|
|
|
//strSql.Append("WHEN '半月结' THEN (CASE WHEN DATEPART(DAY, GETDATE())<=15 THEN DATEADD(day,ISNULL(CAST(C.STLFIRSTHALFDATE AS INT),16),DATEADD(Day,-Day(B.OPDATE)+1,B.OPDATE))");
|
|
|
//strSql.Append("ELSE DATEADD(MONTH,1,DATEADD(day,ISNULL(CAST(C.STLMIDDLEDATE AS INT),1),DATEADD(Day,-Day(B.OPDATE)+1,B.OPDATE))) END)");
|
|
|
//strSql.Append("ELSE GETDATE() END)) else (DATEDIFF([day],B.OPDATE, S.SETTLETIME)) end end AS NODAY");
|
|
|
|
|
|
strSql.Append(",'' INVOICENO");
|
|
|
|
|
|
strSql.Append(",dbo.F_GetBillDrFeeStatus(A.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(A.BSNO) CRFEESTATUS");
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN V_OP_BS A ON (A.BSNO=B.PARENTID) ");
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=A.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN info_client C WITH (NOLOCK) ON (C.SHORTNAME=F.CUSTOMERNAME) ");
|
|
|
strSql.Append(" LEFT JOIN V_MAX_SETTLEMENTTIME S ON (S.CUSTOMERNAME=F.CUSTOMERNAME AND S.BSNO=B.BSNO) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY A.BSNO,A.OPLBNAME, A.BSTYPE,A.CUSTOMERNAME, A.CUSTNO, A.MBLNO,A.HBLNO,A.VESSEL, A.VOYNO, A.INPUTBY, A.CREATETIME, A.BSSTATUS, A.SALE, A.OP, A.DOC,A.YARD,A.BLISSUESTATUS,A.BLTYPE,");
|
|
|
strSql.Append(" A.ETD,A.ETA,A.ATD");
|
|
|
strSql.Append(" ,A.OPDATE,A.ENTERP,A.DELIVERYDATE");
|
|
|
strSql.Append(" ,A.CUSTOMDATE,A.SERVICECONTRACTNO");
|
|
|
strSql.Append(" ,A.CUSTSERVICE, A.PORTLOAD, A.PORTDISCHARGE,B.DESTINATION, A.CUSTOMNO, B.ACCDATE,A.CARRIER, A.BSSOURCE,A.BSSOURCEDETAIL, A.LANE, A.FORWARDER,A.NETWEIGHT,A.KGS,A.TEU,A.CNTRTOTAL,A.CORPID");
|
|
|
strSql.Append(" ,A.CNTR1,A.CNTR2,A.CNTR3,A.CNTR4,A.CNTR5,A.CNTR6,A.CNTR7,A.CNTR8,A.CNTR9,A.CNTR10,A.OTCNTR,A.TRADETYPE,A.GOODSNAME,A.FEESTATUS,A.PKGS,A.CBM,A.ORDERNO,A.SALECORPID,A.STLDATE,F.CUSTOMERNAME,C.[DESCRIPTION] ");
|
|
|
|
|
|
strSql.Append(",A.STLNAME, S.SETTLETIME,B.SALE,B.OPDATE,A.AGENTID");
|
|
|
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
strSql.Append("SELECT B.BSNO,B.OPTYPE, B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.BLISSUESTATUS,B.BLTYPE,");
|
|
|
strSql.Append("case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD");
|
|
|
strSql.Append(",case B.ETA when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETA,23) end as ETA,case B.ATD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ATD,23) end as ATD");
|
|
|
if (NORPTSTLDATETYPE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(",CASE WHEN B.CUSTOMERNAME=F.CUSTOMERNAME THEN B.STLNAME ELSE isnull((select top 1 ACCTYPE from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =F.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),'现结买单') END STLNAME");
|
|
|
}
|
|
|
else {
|
|
|
strSql.Append(",B.STLNAME STLNAME");
|
|
|
}
|
|
|
|
|
|
strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE,B.ENTERP,B.DELIVERYDATE");
|
|
|
strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE,B.SERVICECONTRACTNO");
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE,B.BSSOURCEDETAIL, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(",B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS,B.PKGS,B.CBM,B.ORDERNO,B.SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP");
|
|
|
strSql.Append(",(CASE B.FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF,B.AGENTID ");
|
|
|
strSql.Append(",F.CUSTOMERNAME AS CUSTNAME ");
|
|
|
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME ");
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
|
|
|
strSql.Append(",case when isnull(SUM(F.AMOUNT),0)<>isnull(SUM(F.SETTLEMENT),0) then (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, GETDATE()) end) ");
|
|
|
strSql.Append(" else (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, S.SETTLETIME) end) end AS ACTUALDAY,S.SETTLETIME");
|
|
|
|
|
|
if (NORPTSTLDATETYPE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(",[dbo].[GetCustStlDay](B.OPDATE,F.CUSTOMERNAME,B.SALE) AS STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =F.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",CASE WHEN B.STLDATE IS NULL THEN B.OPDATE ELSE B.STLDATE END STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =B.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (PROFITRATEDR.PARAMVALUE != "1")
|
|
|
{
|
|
|
strSql.Append(", (CASE WHEN (SUM(G.TTLDR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLDR)) * 100, 10, 2))) END) AS PROFITRATE");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
strSql.Append(", (CASE WHEN (SUM(G.TTLCR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLCR)) * 100, 10, 2))) END) AS PROFITRATE");
|
|
|
|
|
|
|
|
|
//strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else case when isnull(SUM(F.AMOUNT),0)<>isnull(SUM(F.SETTLEMENT),0) then DATEDIFF([day],B.OPDATE,(CASE C.STLNAME WHEN '月结' THEN ");
|
|
|
//strSql.Append("DATEADD(month,1,DATEADD(day,ISNULL(CAST(C.STLDATE AS INT),1),DATEADD(day,-Day(B.OPDATE)+1,B.OPDATE)))");
|
|
|
//strSql.Append("WHEN '半月结' THEN (CASE WHEN DATEPART(DAY, GETDATE())<=15 THEN DATEADD(day,ISNULL(CAST(C.STLFIRSTHALFDATE AS INT),16),DATEADD(Day,-Day(B.OPDATE)+1,B.OPDATE))");
|
|
|
//strSql.Append("ELSE DATEADD(MONTH,1,DATEADD(day,ISNULL(CAST(C.STLMIDDLEDATE AS INT),1),DATEADD(Day,-Day(B.OPDATE)+1,B.OPDATE))) END)");
|
|
|
//strSql.Append("ELSE GETDATE() END)) else (DATEDIFF([day],B.OPDATE, S.SETTLETIME)) end end AS NODAY");
|
|
|
|
|
|
var FEEDEBITINVISMUST = MsSysParamSetDAL.GetData("PARAMNAME='RPTNOINVOICENO'");
|
|
|
if (FEEDEBITINVISMUST.PARAMVALUE == "1")
|
|
|
{
|
|
|
|
|
|
if (condition.IndexOf("F.FEETYPE=1") >= 0)
|
|
|
{
|
|
|
// strSql.Append(",INVOICENO = stuff ((SELECT distinct INVOICENUM+',' FROM CH_FEE AS t WHERE ISNULL(t.INVOICENUM,'')<>'' AND t .BSNO = B.BSNO and t.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
strSql.Append(",INVOICENO = stuff ((SELECT distinct i.INVOICENO+',' FROM CH_FEE_DO AS t left join ch_fee_invoice i on (i.BILLNO=t.BILLNO) WHERE t.CATEGORY=7 and t .BSNO = B.BSNO and i.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",INVOICENO = stuff ((SELECT distinct BILLNO+',' FROM CH_FEE_DO AS t WHERE t.CATEGORY=4 and t .BSNO = B.BSNO and t.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else strSql.Append(",'' INVOICENO");
|
|
|
|
|
|
|
|
|
strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN info_client C WITH (NOLOCK) ON (C.SHORTNAME=F.CUSTOMERNAME) ");
|
|
|
strSql.Append(" LEFT JOIN V_MAX_SETTLEMENTTIME S ON (S.CUSTOMERNAME=F.CUSTOMERNAME AND S.BSNO=B.BSNO) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY B.BSNO,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.BLISSUESTATUS,B.BLTYPE,");
|
|
|
strSql.Append(" B.ETD,B.ETA,B.ATD");
|
|
|
strSql.Append(" ,B.OPDATE,B.ENTERP,B.DELIVERYDATE");
|
|
|
strSql.Append(" ,B.CUSTOMDATE,B.SERVICECONTRACTNO");
|
|
|
strSql.Append(" ,B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE,B.BSSOURCEDETAIL, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(" ,B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS,B.PKGS,B.CBM,B.ORDERNO,B.SALECORPID,B.STLDATE,F.CUSTOMERNAME,C.[DESCRIPTION] ");
|
|
|
strSql.Append(",B.STLNAME,B.AGENTID");
|
|
|
|
|
|
strSql.Append(" , S.SETTLETIME");
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
strSql.Append(") AS T ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by CUSTNAME,OPDATE,MBLNO ");
|
|
|
//if (amendstr == "true")
|
|
|
// strSql.Append(" order by F.CUSTOMERNAME,A.OPDATE,B.MBLNO ");
|
|
|
//else strSql.Append(" order by F.CUSTOMERNAME,B.OPDATE,B.MBLNO ");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by CUSTNAME,OPDATE,MBLNO ");
|
|
|
//if (amendstr == "true")
|
|
|
// strSql.Append(" order by F.CUSTOMERNAME,A.OPDATE ");
|
|
|
//else strSql.Append(" order by F.CUSTOMERNAME,B.OPDATE ");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult GetSqlStr(string condition)
|
|
|
{
|
|
|
var strDa = GetRangDAStr("index", CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserName(Request), CookieConfig.GetCookie_CompanyId(Request));
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = condition
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
}
|
|
|
//public ActionResult GridExcelExport(string condition, string sort)
|
|
|
//{
|
|
|
// var strSql = new StringBuilder();
|
|
|
// strSql.Append("SELECT F.CUSTOMERNAME AS CUSTNAME,B.OPLBNAME, B.BSTYPE");
|
|
|
// strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE");
|
|
|
// strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE");
|
|
|
|
|
|
// strSql.Append(",B.CUSTOMERNAME, B.CUSTNO,B.ENTERP, B.MBLNO, B.HBLNO");
|
|
|
// strSql.Append(",case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD");
|
|
|
// strSql.Append(",B.VESSEL, B.VOYNO,B.SALE, B.OP");
|
|
|
// strSql.Append(",B.PORTLOAD, B.PORTDISCHARGE,B.ACCDATE,B.CARRIER, B.BSSOURCE,B.TEU,B.KGS");
|
|
|
// strSql.Append(",B.GOODSNAME");
|
|
|
// strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS TTLDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS TTLCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
// strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS BALTTLCR");
|
|
|
|
|
|
// strSql.Append(" FROM CH_FEE F ");
|
|
|
// strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
|
|
|
// if (!string.IsNullOrEmpty(condition))
|
|
|
// {
|
|
|
// strSql.Append(" Where " + condition);
|
|
|
// }
|
|
|
|
|
|
// strSql.Append("GROUP BY F.CUSTOMERNAME,B.OPLBNAME, B.BSTYPE");
|
|
|
// strSql.Append(",B.OPDATE");
|
|
|
// strSql.Append(",B.CUSTOMDATE");
|
|
|
// strSql.Append(",B.CUSTOMERNAME, B.CUSTNO,B.ENTERP, B.MBLNO, B.HBLNO");
|
|
|
// strSql.Append(",B.ETD");
|
|
|
// strSql.Append(",B.VESSEL, B.VOYNO,B.SALE, B.OP");
|
|
|
// strSql.Append(",B.PORTLOAD, B.PORTDISCHARGE,B.ACCDATE,B.CARRIER, B.BSSOURCE,B.TEU,B.KGS");
|
|
|
// strSql.Append(",B.GOODSNAME");
|
|
|
// var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
// if (!string.IsNullOrEmpty(sortstring))
|
|
|
// {
|
|
|
// strSql.Append(" order by " + sortstring);
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
|
|
|
// strSql.Append(" order by F.CUSTOMERNAME,B.OPDATE ");
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
// 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 strHeader = "结算客户\t业务类型\t运输类型\t业务日期\t报关日期\t委托单位\t委托编号\t经营单位\t主提单号\t分提单号\t开船日期\t船名\t航次\t业务员\t操作\t起运港\t目的港"
|
|
|
// +"\t会计期间\t船公司\t业务来源\tTEU\tKGS\tGOODSNAME\tRMB应收\tRMB已收\tRMB未收\tUSD应收\tUSD已收\tUSD未收\t其他币别应收\t其他币别已收\t其他币别未收\t合计应收\t合计已收\t合计未收"
|
|
|
// + "\tRMB应付\tRMB已付\tRMB未付\tUSD应付\tUSD已付\tUSD未付\t其他币别应付\t其他币别已付\t其他币别未付\t合计应付\t合计已付\t合计未付";//中文名称
|
|
|
// var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
|
|
|
|
|
|
|
|
|
// ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
// MemoryStream ms = ExcelDA.RenderToExcel(dbRptResult.DataSet.Tables["Result_Set"], strHeader.Trim());
|
|
|
|
|
|
// var tmpContent = Encoding.UTF8.GetString(ms.ToArray());
|
|
|
// var tmpFileName = "report.xls";
|
|
|
// Response.Write("&lt;script&gt;document.close();&lt;/script&gt;");
|
|
|
// Response.Clear();
|
|
|
// Response.Buffer = true;
|
|
|
// Response.ContentType = "application/vnd.ms-excel";
|
|
|
// Response.AddHeader("Content-Disposition", "attachment;filename=\"" + tmpFileName + "\"");
|
|
|
|
|
|
// Response.Charset = "";
|
|
|
|
|
|
// System.IO.StringWriter tmpSW = new System.IO.StringWriter();
|
|
|
// System.Web.UI.HtmlTextWriter tmpHTW = new System.Web.UI.HtmlTextWriter(tmpSW);
|
|
|
// tmpHTW.WriteLine(tmpContent);
|
|
|
// Response.Write(tmpSW.ToString());
|
|
|
// Response.End();
|
|
|
|
|
|
// return View();
|
|
|
//}
|
|
|
|
|
|
public ContentResult FeeListData(int start, int limit, string condition, string sort, string printstr,string sortstr)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
var NORPTFEESTATUS = MsSysParamSetDAL.GetData("PARAMNAME='NORPTFEESTATUS'");
|
|
|
if (NORPTFEESTATUS.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.BSNO, B.OPLB,B.OPTYPE, B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP,");
|
|
|
strSql.Append("case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD");
|
|
|
strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE,B.ENTERP");
|
|
|
strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE");
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(",B.TRADETYPE,B.GOODSNAME,B.YARD,B.BLISSUESTATUS,B.ORDERNO");
|
|
|
strSql.Append(",F.GID,F.FEETYPE,F.FEENAME,F.FEEDESCRIPTION,F.CUSTOMERNAME AS CUSTNAME,F.UNIT,F.UNITPRICE,F.QUANTITY,F.AMOUNT,F.CURRENCY,F.EXCHANGERATE,F.DEBITNO");
|
|
|
strSql.Append(",F.TAXRATE,F.NOTAXAMOUNT,F.ACCTAXRATE,F.REMARK,F.SETTLEMENT,F.INVOICE,F.ORDERAMOUNT,F.ORDERINVOICE,F.ENTEROPERATOR,F.FEESTATUS,F.AMOUNT-F.SETTLEMENT NOSTLAMOUNT,F.INPUTMODE");
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=F.FeeStatus) as FeeStatus_Ref");
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=F.FeeType) as FeeType_Ref");
|
|
|
strSql.Append(",(select ShowName from [user] where GID=F.EnteroPerator) as ENTEROPERATORREF");
|
|
|
|
|
|
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME,(SELECT TOP 1 INVOICENO FROM ch_fee_invoice WHERE BILLNO IN (SELECT BILLNO FROM CH_FEE_DO WHERE FEEID=F.GID )) INVOICENUM ");
|
|
|
strSql.Append(",cast(round( CASE WHEN ISNULL(ACCTAXRATE,0)=0 THEN ISNULL(AMOUNT,0) ELSE ISNULL(AMOUNT,0)- cast(round((ISNULL(AMOUNT,0)/(1+ACCTAXRATE/100)*ACCTAXRATE/100),2) as numeric(20,2)) END ,2) as numeric(20,2)) AS NOACCTAXAMOUNT");
|
|
|
strSql.Append(",cast(round((ISNULL(AMOUNT,0)/(1+ACCTAXRATE/100)*ACCTAXRATE/100),2) as numeric(20,2)) ACCTAX");
|
|
|
|
|
|
//strSql.Append(",C.ACTUALDAY,C.NODAY");
|
|
|
|
|
|
//strSql.Append(",case when isnull(F.AMOUNT,0)<>isnull(F.SETTLEMENT,0) then (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, GETDATE()) end) ");
|
|
|
//strSql.Append(" else (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, (SELECT MAX(SETTLETIME) FROM v_fee_do_settlement S WHERE S.BSNO=B.BSNO AND S.CUSTOMERNAME=F.CUSTOMERNAME)) end) end AS ACTUALDAY");
|
|
|
|
|
|
//strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else case when isnull(F.AMOUNT,0)<>isnull(F.SETTLEMENT,0) then DATEDIFF([day],B.OPDATE,(CASE C.STLNAME WHEN '月结' THEN ");
|
|
|
//strSql.Append("DATEADD(month,1,DATEADD(day,ISNULL(CAST(C.STLDATE AS INT),1),DATEADD(day,-Day(B.OPDATE)+1,B.OPDATE)))");
|
|
|
//strSql.Append("WHEN '半月结' THEN (CASE WHEN DATEPART(DAY, GETDATE())<=15 THEN DATEADD(day,ISNULL(CAST(C.STLFIRSTHALFDATE AS INT),16),DATEADD(Day,-Day(B.OPDATE)+1,B.OPDATE))");
|
|
|
//strSql.Append("ELSE DATEADD(MONTH,1,DATEADD(day,ISNULL(CAST(C.STLMIDDLEDATE AS INT),1),DATEADD(Day,-Day(B.OPDATE)+1,B.OPDATE))) END)");
|
|
|
//strSql.Append("ELSE GETDATE() END)) else (DATEDIFF([day],B.OPDATE, (SELECT MAX(SETTLETIME) FROM v_fee_do_settlement S WHERE S.BSNO=B.BSNO AND S.CUSTOMERNAME=F.CUSTOMERNAME))) end end AS NODAY");
|
|
|
|
|
|
//strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, GETDATE()) end AS ACTUALDAY");
|
|
|
//strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE,(CASE C.STLNAME WHEN '月结' THEN ");
|
|
|
//strSql.Append("DATEADD(month,1,DATEADD(day,ISNULL(CAST(C.STLDATE AS INT),1),DATEADD(day,-Day(B.OPDATE)+1,B.OPDATE)))");
|
|
|
//strSql.Append("WHEN '半月结' THEN (CASE WHEN DATEPART(DAY, GETDATE())<=15 THEN DATEADD(day,ISNULL(CAST(C.STLFIRSTHALFDATE AS INT),16),DATEADD(Day,-Day(B.OPDATE)+1,B.OPDATE))");
|
|
|
//strSql.Append("ELSE DATEADD(MONTH,1,DATEADD(day,ISNULL(CAST(C.STLMIDDLEDATE AS INT),1),DATEADD(Day,-Day(B.OPDATE)+1,B.OPDATE))) END)");
|
|
|
//strSql.Append("ELSE GETDATE() END)) end AS NODAY");
|
|
|
//strSql.Append(",(SELECT MAX(SETTLETIME) FROM v_fee_do_settlement S WHERE S.BSNO=B.BSNO AND S.CUSTOMERNAME=F.CUSTOMERNAME) AS SETTLEDATE");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
//strSql.Append(" INNER JOIN V_CUSTSTLDATE C ON (C.BSNO=B.BSNO AND C.CUSTNAME=F.CUSTOMERNAME) ");
|
|
|
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=F.CUSTOMERNAME) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by F.CUSTOMERNAME,B.OPDATE,F.SORT");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring + ",F.SORT");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by F.CUSTOMERNAME,B.OPDATE,F.SORT");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult SaleListData(int start, int limit, string condition, string sort, string printstr,string sortstr)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
//20240726 此模块不需要在“合并更改单”的时候变更这个查询条件
|
|
|
condition = condition.Replace(" A.ACCDATE", " B.ACCDATE");
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
var NORPTFEESTATUS = MsSysParamSetDAL.GetData("PARAMNAME='NORPTFEESTATUS'");
|
|
|
if (NORPTFEESTATUS.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
string noDrCr = GetNoDrCr();
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.SALE");
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append(",0 AS RMBDR,0 AS STLRMBDR,0 AS BALRMBDR,0 AS ORDERRMBDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS RMBCR,0 AS STLRMBCR,0 AS BALRMBCR,0 AS ORDERRMBCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
}
|
|
|
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDDR,0 AS STLUSDDR,0 AS BALUSDDR,0 AS ORDERUSDDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDCR,0 AS STLUSDCR,0 AS BALUSDCR,0 AS ORDERUSDCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTDR,0 AS STLOTDR,0 AS BALOTDR,0 AS ORDEROTDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTCR,0 AS STLOTCR,0 AS BALOTCR,0 AS ORDEROTCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLDR,0 AS STLTTLDR,0 AS BALTTLDR,0 AS ORDERTTLDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLCR,0 AS STLTTLCR,0 AS BALTTLCR,0 AS ORDERTTLCR");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
}
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by B.SALE ");
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.SALE");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.SALE");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult CustListData(int start, int limit, string condition, string sort, string printstr,string sortstr)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
//20240726 此模块不需要在“合并更改单”的时候变更这个查询条件
|
|
|
condition = condition.Replace(" A.ACCDATE", " B.ACCDATE");
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var NORPTFEESTATUS = MsSysParamSetDAL.GetData("PARAMNAME='NORPTFEESTATUS'");
|
|
|
if (NORPTFEESTATUS.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
string noDrCr = GetNoDrCr();
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT F.CUSTOMERNAME AS CUSTNAME ");
|
|
|
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME ");
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append(",0 AS RMBDR,0 AS STLRMBDR,0 AS BALRMBDR,0 AS ORDERRMBDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS RMBCR,0 AS STLRMBCR,0 AS BALRMBCR,0 AS ORDERRMBCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
}
|
|
|
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDDR,0 AS STLUSDDR,0 AS BALUSDDR,0 AS ORDERUSDDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDCR,0 AS STLUSDCR,0 AS BALUSDCR,0 AS ORDERUSDCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTDR,0 AS STLOTDR,0 AS BALOTDR,0 AS ORDEROTDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTCR,0 AS STLOTCR,0 AS BALOTCR,0 AS ORDEROTCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLDR,0 AS STLTTLDR,0 AS BALTTLDR,0 AS ORDERTTLDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLCR,0 AS STLTTLCR,0 AS BALTTLCR,0 AS ORDERTTLCR");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
}
|
|
|
strSql.Append(",ISNULL(P.PRMBDR,0) PRMBDR,ISNULL(P.PUSDDR,0) PUSDDR,ISNULL(P.PRMBCR,0) PRMBCR,ISNULL(P.PUSDCR,0) PUSDCR ");
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN info_client C WITH (NOLOCK) ON (C.SHORTNAME=F.CUSTOMERNAME) ");
|
|
|
strSql.Append(" LEFT JOIN (select CUSTOMERNAME,SUM(CASE WHEN FEETYPE=1 AND CURRENCY='RMB' THEN AMOUNT-DOAMOUNT ELSE 0 END) PRMBDR,");
|
|
|
strSql.Append("SUM(CASE WHEN FEETYPE = 1 AND CURRENCY = 'USD' THEN AMOUNT - DOAMOUNT ELSE 0 END) PUSDDR,");
|
|
|
strSql.Append("SUM(CASE WHEN FEETYPE = 2 AND CURRENCY = 'RMB' THEN AMOUNT - DOAMOUNT ELSE 0 END) PRMBCR,");
|
|
|
strSql.Append("SUM(CASE WHEN FEETYPE = 2 AND CURRENCY = 'USD' THEN AMOUNT - DOAMOUNT ELSE 0 END) PUSDCR");
|
|
|
strSql.Append(" from ch_fee_advance_payment where AMOUNT <> DOAMOUNT GROUP BY CUSTOMERNAME ) P ON (P.CUSTOMERNAME=F.CUSTOMERNAME) ");
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by F.CUSTOMERNAME,C.[DESCRIPTION],P.PRMBDR,P.PUSDDR,P.PRMBCR,P.PUSDCR ");
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by F.CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by F.CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult DeptListData(int start, int limit, string condition, string sort, string printstr, string sortstr)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
//20240726 此模块不需要在“合并更改单”的时候变更这个查询条件
|
|
|
condition = condition.Replace(" A.ACCDATE", " B.ACCDATE");
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
var NORPTFEESTATUS = MsSysParamSetDAL.GetData("PARAMNAME='NORPTFEESTATUS'");
|
|
|
if (NORPTFEESTATUS.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
string noDrCr = GetNoDrCr();
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.SALEDEPT ");
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append(",0 AS RMBDR,0 AS STLRMBDR,0 AS BALRMBDR,0 AS ORDERRMBDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS RMBCR,0 AS STLRMBCR,0 AS BALRMBCR,0 AS ORDERRMBCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
}
|
|
|
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDDR,0 AS STLUSDDR,0 AS BALUSDDR,0 AS ORDERUSDDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDCR,0 AS STLUSDCR,0 AS BALUSDCR,0 AS ORDERUSDCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTDR,0 AS STLOTDR,0 AS BALOTDR,0 AS ORDEROTDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTCR,0 AS STLOTCR,0 AS BALOTCR,0 AS ORDEROTCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLDR,0 AS STLTTLDR,0 AS BALTTLDR,0 AS ORDERTTLDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLCR,0 AS STLTTLCR,0 AS BALTTLCR,0 AS ORDERTTLCR");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
}
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by B.SALEDEPT");
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.SALEDEPT");
|
|
|
|
|
|
}
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.SALEDEPT");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult SaleCustListData(int start, int limit, string condition, string sort, string printstr, string sortstr)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
//20240726 此模块不需要在“合并更改单”的时候变更这个查询条件
|
|
|
condition = condition.Replace(" A.ACCDATE", " B.ACCDATE");
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
var NORPTFEESTATUS = MsSysParamSetDAL.GetData("PARAMNAME='NORPTFEESTATUS'");
|
|
|
if (NORPTFEESTATUS.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
string noDrCr = GetNoDrCr();
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.SALE,F.CUSTOMERNAME AS CUSTNAME ");
|
|
|
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME ");
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append(",0 AS RMBDR,0 AS STLRMBDR,0 AS BALRMBDR,0 AS ORDERRMBDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS RMBCR,0 AS STLRMBCR,0 AS BALRMBCR,0 AS ORDERRMBCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
}
|
|
|
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDDR,0 AS STLUSDDR,0 AS BALUSDDR,0 AS ORDERUSDDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDCR,0 AS STLUSDCR,0 AS BALUSDCR,0 AS ORDERUSDCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTDR,0 AS STLOTDR,0 AS BALOTDR,0 AS ORDEROTDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTCR,0 AS STLOTCR,0 AS BALOTCR,0 AS ORDEROTCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLDR,0 AS STLTTLDR,0 AS BALTTLDR,0 AS ORDERTTLDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLCR,0 AS STLTTLCR,0 AS BALTTLCR,0 AS ORDERTTLCR");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
}
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=F.CUSTOMERNAME) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by B.SALE,F.CUSTOMERNAME,C.[DESCRIPTION] ");
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.SALE,F.CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.SALE,F.CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult VesselVoyListData(int start, int limit, string condition, string sort, string printstr,string sortstr)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
//20240726 此模块不需要在“合并更改单”的时候变更这个查询条件
|
|
|
condition = condition.Replace(" A.ACCDATE", " B.ACCDATE");
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
var NORPTFEESTATUS = MsSysParamSetDAL.GetData("PARAMNAME='NORPTFEESTATUS'");
|
|
|
if (NORPTFEESTATUS.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
string noDrCr = GetNoDrCr();
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT B.VESSEL,B.VOYNO ");
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append(",0 AS RMBDR,0 AS STLRMBDR,0 AS BALRMBDR,0 AS ORDERRMBDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS RMBCR,0 AS STLRMBCR,0 AS BALRMBCR,0 AS ORDERRMBCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
}
|
|
|
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDDR,0 AS STLUSDDR,0 AS BALUSDDR,0 AS ORDERUSDDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDCR,0 AS STLUSDCR,0 AS BALUSDCR,0 AS ORDERUSDCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTDR,0 AS STLOTDR,0 AS BALOTDR,0 AS ORDEROTDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTCR,0 AS STLOTCR,0 AS BALOTCR,0 AS ORDEROTCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLDR,0 AS STLTTLDR,0 AS BALTTLDR,0 AS ORDERTTLDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLCR,0 AS STLTTLCR,0 AS BALTTLCR,0 AS ORDERTTLCR");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
}
|
|
|
strSql.Append(" FROM CH_FEE F ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" Group by B.VESSEL,B.VOYNO ");
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.VESSEL,B.VOYNO");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.VESSEL,B.VOYNO");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 ContentResult SumListData(int start, int limit, string condition, string sort)
|
|
|
{
|
|
|
//20230213 用于替换查询语句中 A. 的部分
|
|
|
//因为指定会计期间时,如果选择了“合并更改单”,对会计期间的查询限制应该是 [业务和“更改单所附着的业务(A)”]的会计期间
|
|
|
//condition = condition.Replace(" A.ACCDATE", " B.ACCDATE");
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
var NORPTFEESTATUS = MsSysParamSetDAL.GetData("PARAMNAME='NORPTFEESTATUS'");
|
|
|
if (NORPTFEESTATUS.PARAMVALUE == "1")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = " F.FEESTATUS<>1 ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
string noDrCr = GetNoDrCr();
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT 1,SUM(B.TEU) TEU ");
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append(",0 AS RMBDR,0 AS STLRMBDR,0 AS BALRMBDR,0 AS ORDERRMBDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS RMBCR,0 AS STLRMBCR,0 AS BALRMBCR,0 AS ORDERRMBCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
}
|
|
|
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDDR,0 AS STLUSDDR,0 AS BALUSDDR,0 AS ORDERUSDDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS USDCR,0 AS STLUSDCR,0 AS BALUSDCR,0 AS ORDERUSDCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTDR,0 AS STLOTDR,0 AS BALOTDR,0 AS ORDEROTDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS OTCR,0 AS STLOTCR,0 AS BALOTCR,0 AS ORDEROTCR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
}
|
|
|
|
|
|
if (noDrCr == "10" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLDR,0 AS STLTTLDR,0 AS BALTTLDR,0 AS ORDERTTLDR,");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
}
|
|
|
if (noDrCr == "01" || noDrCr == "11")
|
|
|
strSql.Append("0 AS TTLCR,0 AS STLTTLCR,0 AS BALTTLCR,0 AS ORDERTTLCR");
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
}
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN V_OP_BS A ON (A.BSNO=B.PARENTID) ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
|
|
|
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 ContentResult BsHyfListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string amendstr = "false")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("SELECT *,dbo.F_FeeStatusStr(DRFEESTATUS) DRFEESTATUSREF,dbo.F_FeeStatusStr(CRFEESTATUS) CRFEESTATUSREF ");
|
|
|
strSql.Append(",case OPDATE when '' then 0 else case when BALTTLDR<>0 then DATEDIFF([day],STLDATE,GETDATE()) ");
|
|
|
strSql.Append(" else (DATEDIFF([day],STLDATE,SETTLETIME)) end end AS NODAY");
|
|
|
strSql.Append(" FROM (");
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT B.PARENTID, B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY,MAX(B.CREATETIME) CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.BLISSUESTATUS,B.BLTYPE,");
|
|
|
strSql.Append("case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD");
|
|
|
strSql.Append(",B.STLNAME STLNAME,F.CUSTOMERNAME CUSTNAME");
|
|
|
|
|
|
strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE,B.ENTERP,B.DELIVERYDATE");
|
|
|
strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE");
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO,MAX(B.ACCDATE) ACCDATE,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(",B.TRADETYPE,B.GOODSNAME,B.FEESTATUS,B.PKGS,B.CBM,B.ORDERNO,B.SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP");
|
|
|
strSql.Append(",(CASE B.FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF ");
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE WHEN CURRENCY='USD' AND FEENAME='海运费' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDHYFCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE WHEN CURRENCY='USD' AND FEENAME='海运费' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDHYFCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE WHEN CURRENCY='USD' AND FEENAME='海运费' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDHYFCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("case when isnull(SUM(F.AMOUNT),0)<>isnull(SUM(F.SETTLEMENT),0) then (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, GETDATE()) end) ");
|
|
|
strSql.Append(" else (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, S.SETTLETIME) end) end AS ACTUALDAY,S.SETTLETIME");
|
|
|
|
|
|
strSql.Append(",CASE WHEN B.STLDATE IS NULL THEN B.OPDATE ELSE B.STLDATE END STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =B.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append(",dbo.F_GetBillDrFeeStatus(B.PARENTID) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(B.PARENTID) CRFEESTATUS");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F ");
|
|
|
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN V_MAX_SETTLEMENTTIME S ON (S.CUSTOMERNAME=F.CUSTOMERNAME AND S.BSNO=B.PARENTID) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY B.PARENTID,B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.BLISSUESTATUS,B.BLTYPE,");
|
|
|
strSql.Append(" B.ETD");
|
|
|
strSql.Append(" ,B.OPDATE,B.ENTERP,B.DELIVERYDATE");
|
|
|
strSql.Append(" ,B.CUSTOMDATE");
|
|
|
strSql.Append(" ,B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(" ,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS,B.PKGS,B.CBM,B.ORDERNO,B.SALECORPID,B.STLDATE ");
|
|
|
strSql.Append(",B.STLNAME,F.CUSTOMERNAME");
|
|
|
|
|
|
strSql.Append(" , S.SETTLETIME");
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append(") AS T ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by OPDATE,MBLNO ");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by OPDATE,MBLNO ");
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
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]='modNoTotalreportRange' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
string AUTHORITYID = "";
|
|
|
string visiblerange = "4";
|
|
|
string operaterange = "4";
|
|
|
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 + "' OR B.DOC='" + usercode + "' OR B.CUSTSERVICE='" + usercode + "' OR B.FRCUSTSERVICE='" + usercode + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptid = rangeDa.GetDEPTGID(userid);
|
|
|
//str = " (B.OP in (select showname from vw_user where deptgid='" + deptid + "') OR B.SALE in (select showname from vw_user where deptgid='" + deptid + "') OR B.CUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') "
|
|
|
//+ " OR B.DOC in (select showname from vw_user where deptgid='" + deptid + "') OR B.FRCUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') )";
|
|
|
str = " exists( select 1 from vw_user where deptgid='" + deptid + "' and(showname=B.OP OR showname=B.SALE OR showname=B.CUSTSERVICE OR showname=B.FRCUSTSERVICE OR showname=B.DOC )) ";
|
|
|
}
|
|
|
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 opstr = "";
|
|
|
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()))
|
|
|
{
|
|
|
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
|
|
|
|
|
|
if (opstr == "")
|
|
|
{
|
|
|
opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
|
|
|
if (opstr != "") opstr = opstr + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
if (opstr == "") opstr = "('" + usercode + "')";
|
|
|
str = " (B.OP in " + opstr + " or B.SALE in " + opstr + " or B.CUSTSERVICE IN " + opstr + " or B.DOC IN " + opstr + " or B.FRCUSTSERVICE IN " + opstr + ")";
|
|
|
|
|
|
|
|
|
}
|
|
|
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 费用冲抵列表
|
|
|
|
|
|
|
|
|
public ContentResult FeeCDListData(int start, int limit, string condition, string sort, string printstr, string sortstr)
|
|
|
{
|
|
|
//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 strSql = new StringBuilder();
|
|
|
strSql.Append("select * from (");
|
|
|
strSql.Append(" select PARENTID,CUSTNAME,FEETYPE,CURRENCY,SUM(AMOUNT) AMOUNT,COUNT(GID) FEECOUNT,OPLB,OPLBNAME,BSTYPE,CUSTOMERNAME,MAX(CUSTNO) CUSTNO,MBLNO,HBLNO,VESSEL,VOYNO,MAX(INPUTBY) INPUTBY,BSSTATUS,SALE,OP,DOC,");
|
|
|
strSql.Append(" ETD,CUSTSERVICE,PORTLOAD,PORTDISCHARGE,CUSTOMNO,CARRIER,BSSOURCE,LANE,FORWARDER,NETWEIGHT,KGS,MAX(TEU) TEU,CNTRTOTAL,CORPID");
|
|
|
strSql.Append(" from (select b.bsno,b.PARENTID,f.CUSTOMERNAME CUSTNAME,f.FEETYPE,f.AMOUNT,f.CURRENCY,F.GID,");
|
|
|
strSql.Append(" B.OPLB,B.OPTYPE, B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,");
|
|
|
strSql.Append(" B.ETD,B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(" from ch_fee f left join v_op_bill b on (b.BSNO=f.BSNO) ");
|
|
|
strSql.Append(" where f.FEESTATUS=0 and f.SETTLEMENT=0 and f.ORDERAMOUNT=0 and f.ORDERINVOICE=0 AND ISNULL(F.INVOICE,0)=0 AND F.AMOUNT<>0) as v");
|
|
|
strSql.Append(" group by PARENTID,CUSTNAME,FEETYPE,CURRENCY,OPLB,OPLBNAME,BSTYPE,CUSTOMERNAME,MBLNO,HBLNO,VESSEL,VOYNO,BSSTATUS,SALE,OP,DOC,");
|
|
|
strSql.Append(" ETD,CUSTSERVICE,PORTLOAD,PORTDISCHARGE,CUSTOMNO,CARRIER,BSSOURCE,LANE,FORWARDER,NETWEIGHT,KGS,CNTRTOTAL,CORPID) as vs where AMOUNT=0 AND FEECOUNT>1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" ORDER BY CUSTNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" ORDER BY CUSTNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
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 };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
public ContentResult BsDzlxListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string amendstr = "false")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
//var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]).ToString().Trim(), Convert.ToString(Session["SHOWNAME"]).ToString().Trim(), Convert.ToString(Session["COMPANYID"]).ToString().Trim());
|
|
|
|
|
|
//if (!string.IsNullOrEmpty(strDa))
|
|
|
//{
|
|
|
// if (!string.IsNullOrEmpty(condition))
|
|
|
// {
|
|
|
// condition = condition + " and " + strDa;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// condition = strDa;
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("SELECT * FROM V_DZLX ");
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by OPDATE,MBLNO ");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by OPDATE,MBLNO ");
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
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 };
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 欠费禁止应收应收权限查询
|
|
|
|
|
|
public ContentResult GetNoDrCrAuth()
|
|
|
{
|
|
|
var json = JsonConvert.Serialize(new { Success = true, noDrCr = GetNoDrCr() });
|
|
|
/*
|
|
|
try
|
|
|
{
|
|
|
var isNoDr = MsBaseInfoDAL.GetUserModuleEnable("modMsRptNoTotalNoDr", Convert.ToString(Session["USERID"]));
|
|
|
var isNoCr = MsBaseInfoDAL.GetUserModuleEnable("modMsRptNoTotalNoCr", Convert.ToString(Session["USERID"]));
|
|
|
string flag = "00";//默认都可以看
|
|
|
if (isNoDr == true && isNoCr == true)
|
|
|
flag = "11";//应收应付都禁止
|
|
|
else if (isNoDr == true && isNoCr == false)
|
|
|
flag = "10";//禁止应收
|
|
|
else if (isNoDr == false && isNoCr == true)
|
|
|
flag = "01";//禁止应付
|
|
|
json = JsonConvert.Serialize(new { Success = true, noDrCr = flag });
|
|
|
|
|
|
}
|
|
|
catch (Exception ee)
|
|
|
{
|
|
|
json = JsonConvert.Serialize(new { Success = false, noDrCr = ee.Message });
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public string GetNoDrCr()
|
|
|
{
|
|
|
string noDrCr = "";
|
|
|
try
|
|
|
{
|
|
|
var isNoDr = MsBaseInfoDAL.GetUserModuleEnable("modMsRptNoTotalNoDr", Convert.ToString(Session["USERID"]));
|
|
|
var isNoCr = MsBaseInfoDAL.GetUserModuleEnable("modMsRptNoTotalNoCr", Convert.ToString(Session["USERID"]));
|
|
|
string flag = "00";//默认都可以看
|
|
|
if (isNoDr == true && isNoCr == true)
|
|
|
flag = "11";//应收应付都禁止
|
|
|
else if (isNoDr == true && isNoCr == false)
|
|
|
flag = "10";//禁止应收
|
|
|
else if (isNoDr == false && isNoCr == true)
|
|
|
flag = "01";//禁止应付
|
|
|
noDrCr = flag;
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception ee)
|
|
|
{
|
|
|
noDrCr = ee.Message;
|
|
|
}
|
|
|
|
|
|
return noDrCr;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|