|
|
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 System.IO;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 发票统计报表查询
|
|
|
/// </summary>
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsRptInvTotalController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET: /MvcShipping/MsRptInvTotal
|
|
|
[ValidateInput(false)]
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:/RptMng/MsRptPcHeadQry/QryData
|
|
|
[ValidateInput(false)]
|
|
|
public ContentResult BsListData(int start, int limit, string condition,string feerang, string sort, string printstr)
|
|
|
|
|
|
{
|
|
|
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 B.BSNO, 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("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.FEESTATUS,B.REMARK");
|
|
|
strSql.Append(",(CASE B.FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF ");
|
|
|
strSql.Append(",F.CUSTOMERNAME AS CUSTNAME ");
|
|
|
strSql.Append(",isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END),0) AS TTLRMB,");
|
|
|
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 'RMB' THEN ISNULL(AMOUNT-ISNULL(INVOICE,0),0) ELSE 0 END),0) AS BALINVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END),0) AS STLRMB,");
|
|
|
// strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE 0 END,0) ELSE 0 END),0) AS INVNOSTLRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0) ELSE 0 END),0) AS INVNOSTLRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0) ELSE 0 END),0) AS STLNOINVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END),0) AS TTLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-ISNULL(INVOICE,0),0) ELSE 0 END),0) AS BALINVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END),0) AS STLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='USD' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0) ELSE 0 END),0) AS INVNOSTLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='USD' AND ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0) ELSE 0 END),0) AS STLNOINVUSD,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0)),0) AS TTL,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(INVOICE,0) * ISNULL(EXCHANGERATE,0)),0) AS TTLINV,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(AMOUNT-ISNULL(INVOICE,0),0) * ISNULL(EXCHANGERATE,0)),0) AS BALINVTTL,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0)),0) AS STLTTL,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0)* ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS INVNOSTL,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0)* ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS STLNOINV");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F ");
|
|
|
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) where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(feerang))
|
|
|
{
|
|
|
if (feerang == "1")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>0 ");
|
|
|
}
|
|
|
else if (feerang == "2")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>F.AMOUNT and ISNULL(F.ISINVOICE,0)=0 ");
|
|
|
}
|
|
|
else if (feerang == "3")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>0 AND ((F.AMOUNT>0 and ISNULL(F.INVOICE,0)>ISNULL(F.SETTLEMENT,0)) or (F.AMOUNT<0 and ISNULL(F.INVOICE,0)<ISNULL(F.SETTLEMENT,0))) ");
|
|
|
}
|
|
|
else if (feerang == "4")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)<>0 and ISNULL(F.ISINVOICE,0)=0 AND ((F.AMOUNT>0 and ISNULL(F.SETTLEMENT,0)>ISNULL(F.INVOICE,0)) or (F.AMOUNT<0 and ISNULL(F.SETTLEMENT,0)<ISNULL(F.INVOICE,0))) ");
|
|
|
}
|
|
|
else if (feerang == "5")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)=0 and ISNULL(F.ISINVOICE,0)=0 AND ISNULL(F.INVOICE,0)=0 and ISNULL(F.ORDERINVOICE,0)=0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
else if (feerang == "6")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)<>0 AND ISNULL(F.INVOICE,0)<>0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
else if (feerang == "7")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)=0 AND ISNULL(F.INVOICE,0)=0 and ISNULL(F.ISINVOICE,0)=0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY B.BSNO,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");
|
|
|
strSql.Append(" ,B.OPDATE,B.ENTERP");
|
|
|
strSql.Append(" ,B.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.FEESTATUS,B.REMARK,F.CUSTOMERNAME");
|
|
|
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
strSql.Append(" order by F.CUSTOMERNAME,B.OPDATE ");
|
|
|
|
|
|
}
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
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", 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 jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = condition
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
|
}
|
|
|
|
|
|
[ValidateInput(false)]
|
|
|
public ContentResult SaleListData(int start, int limit, string condition, string feerang, string sort, string printstr)
|
|
|
{
|
|
|
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 B.SALE");
|
|
|
strSql.Append(",CASE F.FEETYPE WHEN 1 THEN '收' WHEN 2 THEN '付' ELSE '' END AS FEETYPEREF");
|
|
|
strSql.Append(",isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END),0) AS TTLRMB,");
|
|
|
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 'RMB' THEN ISNULL(AMOUNT-ISNULL(INVOICE,0),0) ELSE 0 END),0) AS BALINVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END),0) AS STLRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0) ELSE 0 END),0) AS INVNOSTLRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0) ELSE 0 END),0) AS STLNOINVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END),0) AS TTLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-ISNULL(INVOICE,0),0) ELSE 0 END),0) AS BALINVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END),0) AS STLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='USD' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0) ELSE 0 END),0) AS INVNOSTLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='USD' AND ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0) ELSE 0 END),0) AS STLNOINVUSD,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0)),0) AS TTL,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(INVOICE,0) * ISNULL(EXCHANGERATE,0)),0) AS TTLINV,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(AMOUNT-ISNULL(INVOICE,0),0) * ISNULL(EXCHANGERATE,0)),0) AS BALINVTTL,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0)),0) AS STLTTL,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0)* ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS INVNOSTL,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0)* ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS STLNOINV");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(feerang))
|
|
|
{
|
|
|
if (feerang == "1")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>0 ");
|
|
|
}
|
|
|
else if (feerang == "2")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>F.AMOUNT and ISNULL(F.ISINVOICE,0)=0 ");
|
|
|
}
|
|
|
else if (feerang == "3")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>0 AND ((F.AMOUNT>0 and ISNULL(F.INVOICE,0)>ISNULL(F.SETTLEMENT,0)) or (F.AMOUNT<0 and ISNULL(F.INVOICE,0)<ISNULL(F.SETTLEMENT,0))) ");
|
|
|
}
|
|
|
else if (feerang == "4")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)<>0 and ISNULL(F.ISINVOICE,0)=0 AND ((F.AMOUNT>0 and ISNULL(F.SETTLEMENT,0)>ISNULL(F.INVOICE,0)) or (F.AMOUNT<0 and ISNULL(F.SETTLEMENT,0)<ISNULL(F.INVOICE,0))) ");
|
|
|
}
|
|
|
else if (feerang == "5")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)=0 and ISNULL(F.ISINVOICE,0)=0 AND ISNULL(F.INVOICE,0)=0 and ISNULL(F.ORDERINVOICE,0)=0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
else if (feerang == "6")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)<>0 AND ISNULL(F.INVOICE,0)<>0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
else if (feerang == "7")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)=0 AND ISNULL(F.INVOICE,0)=0 and ISNULL(F.ISINVOICE,0)=0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
strSql.Append(" Group by B.SALE,F.FEETYPE ");
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by B.SALE");
|
|
|
|
|
|
}
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
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 };
|
|
|
}
|
|
|
}
|
|
|
[ValidateInput(false)]
|
|
|
public ContentResult CustListData(int start, int limit, string condition, string feerang, string sort, string printstr)
|
|
|
{
|
|
|
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 F.CUSTOMERNAME");
|
|
|
strSql.Append(",CASE F.FEETYPE WHEN 1 THEN '收' WHEN 2 THEN '付' ELSE '' END AS FEETYPEREF");
|
|
|
strSql.Append(",isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END),0) AS TTLRMB,");
|
|
|
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 'RMB' THEN ISNULL(AMOUNT-ISNULL(INVOICE,0),0) ELSE 0 END),0) AS BALINVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END),0) AS STLRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0) ELSE 0 END),0) AS INVNOSTLRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0) ELSE 0 END),0) AS STLNOINVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END),0) AS TTLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-ISNULL(INVOICE,0),0) ELSE 0 END),0) AS BALINVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END),0) AS STLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='USD' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0) ELSE 0 END),0) AS INVNOSTLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='USD' AND ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0) ELSE 0 END),0) AS STLNOINVUSD,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0)),0) AS TTL,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(INVOICE,0) * ISNULL(EXCHANGERATE,0)),0) AS TTLINV,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(AMOUNT-ISNULL(INVOICE,0),0) * ISNULL(EXCHANGERATE,0)),0) AS BALINVTTL,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0)),0) AS STLTTL,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0)* ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS INVNOSTL,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0)* ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS STLNOINV");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(feerang))
|
|
|
{
|
|
|
if (feerang == "1")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>0 ");
|
|
|
}
|
|
|
else if (feerang == "2")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>F.AMOUNT and ISNULL(F.ISINVOICE,0)=0 ");
|
|
|
}
|
|
|
else if (feerang == "3")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>0 AND ((F.AMOUNT>0 and ISNULL(F.INVOICE,0)>ISNULL(F.SETTLEMENT,0)) or (F.AMOUNT<0 and ISNULL(F.INVOICE,0)<ISNULL(F.SETTLEMENT,0))) ");
|
|
|
}
|
|
|
else if (feerang == "4")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)<>0 and ISNULL(F.ISINVOICE,0)=0 AND ((F.AMOUNT>0 and ISNULL(F.SETTLEMENT,0)>ISNULL(F.INVOICE,0)) or (F.AMOUNT<0 and ISNULL(F.SETTLEMENT,0)<ISNULL(F.INVOICE,0))) ");
|
|
|
}
|
|
|
else if (feerang == "5")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)=0 and ISNULL(F.ISINVOICE,0)=0 AND ISNULL(F.INVOICE,0)=0 and ISNULL(F.ORDERINVOICE,0)=0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
else if (feerang == "6")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)<>0 AND ISNULL(F.INVOICE,0)<>0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
else if (feerang == "7")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)=0 AND ISNULL(F.INVOICE,0)=0 and ISNULL(F.ISINVOICE,0)=0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
}
|
|
|
strSql.Append(" Group by F.CUSTOMERNAME,F.FEETYPE ");
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by F.CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
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 };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[ValidateInput(false)]
|
|
|
public ContentResult SumListData(int start, int limit, string condition, string feerang, string sort)
|
|
|
{
|
|
|
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 1 AS NO");
|
|
|
strSql.Append(",CASE F.FEETYPE WHEN 1 THEN '收' WHEN 2 THEN '付' ELSE '' END AS FEETYPEREF");
|
|
|
strSql.Append(",isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END),0) AS TTLRMB,");
|
|
|
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 'RMB' THEN ISNULL(AMOUNT-ISNULL(INVOICE,0),0) ELSE 0 END),0) AS BALINVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END),0) AS STLRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0) ELSE 0 END),0) AS INVNOSTLRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='RMB' AND ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0) ELSE 0 END),0) AS STLNOINVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END),0) AS TTLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-ISNULL(INVOICE,0),0) ELSE 0 END),0) AS BALINVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END),0) AS STLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='USD' AND ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0) ELSE 0 END),0) AS INVNOSTLUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN CURRENCY='USD' AND ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0) ELSE 0 END),0) AS STLNOINVUSD,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0)),0) AS TTL,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(INVOICE,0) * ISNULL(EXCHANGERATE,0)),0) AS TTLINV,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(AMOUNT-ISNULL(INVOICE,0),0) * ISNULL(EXCHANGERATE,0)),0) AS BALINVTTL,");
|
|
|
strSql.Append("isnull(SUM(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0)),0) AS STLTTL,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN ISNULL(INVOICE,0)<>0 THEN ISNULL(CASE WHEN INVOICE>ISNULL(SETTLEMENT,0) THEN INVOICE-ISNULL(SETTLEMENT,0) ELSE INVOICE-ISNULL(SETTLEMENT,0) END,0)* ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS INVNOSTL,");
|
|
|
strSql.Append("isnull(SUM(CASE WHEN ISNULL(SETTLEMENT,0)<>0 THEN ISNULL(CASE WHEN SETTLEMENT>ISNULL(INVOICE,0) THEN SETTLEMENT-ISNULL(INVOICE,0) ELSE 0 END,0)* ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS STLNOINV");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F ");
|
|
|
strSql.Append("INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) where 1=1 ");
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" and " + condition);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(feerang))
|
|
|
{
|
|
|
if (feerang == "1")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>0 ");
|
|
|
}
|
|
|
else if (feerang == "2")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>F.AMOUNT and ISNULL(F.ISINVOICE,0)=0 ");
|
|
|
}
|
|
|
else if (feerang == "3")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.INVOICE,0)<>0 AND ((F.AMOUNT>0 and ISNULL(F.INVOICE,0)>ISNULL(F.SETTLEMENT,0)) or (F.AMOUNT<0 and ISNULL(F.INVOICE,0)<ISNULL(F.SETTLEMENT,0))) ");
|
|
|
}
|
|
|
else if (feerang == "4")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)<>0 and ISNULL(F.ISINVOICE,0)=0 AND ((F.AMOUNT>0 and ISNULL(F.SETTLEMENT,0)>ISNULL(F.INVOICE,0)) or (F.AMOUNT<0 and ISNULL(F.SETTLEMENT,0)<ISNULL(F.INVOICE,0))) ");
|
|
|
}
|
|
|
else if (feerang == "5")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)=0 and ISNULL(F.ISINVOICE,0)=0 AND ISNULL(F.INVOICE,0)=0 and ISNULL(F.ORDERINVOICE,0)=0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
else if (feerang == "6")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)<>0 AND ISNULL(F.INVOICE,0)<>0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
else if (feerang == "7")
|
|
|
{
|
|
|
strSql.Append(" and ISNULL(F.SETTLEMENT,0)=0 AND ISNULL(F.INVOICE,0)=0 and ISNULL(F.ISINVOICE,0)=0 and F.FEETYPE=1 ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
strSql.Append(" Group by F.FEETYPE ");
|
|
|
|
|
|
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]='modInvTotalreportRange' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
string operaterange = "4";
|
|
|
string AUTHORITYID = "";
|
|
|
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 + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
var userstr = new StringBuilder();
|
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str =str+ ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " UPPER(B.Corpid)='" + 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"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or b.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "6")
|
|
|
{
|
|
|
|
|
|
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()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (b.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR b.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR b.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR b.INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or b.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR b.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR b.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR b.INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "1")
|
|
|
{
|
|
|
str = " UPPER(B.Corpid)='" + companyid + "'";
|
|
|
}
|
|
|
VSSQL = VSSQL.Trim();
|
|
|
if (!string.IsNullOrEmpty(VSSQL))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
{
|
|
|
str = str + " and (" + VSSQL + ") ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " (" + VSSQL + ") ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|