You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Controllers/MsRptCustDrCrController.cs

152 lines
5.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
using DSWeb.SoftMng.Filter;
namespace DSWeb.MvcShipping.Controllers
{
/// <summary>
/// 客户应收应付总账查询
/// </summary>
[JsonRequestBehavior]
public class MsRptCustDrCrController : Controller
{
//
// GET: /MvcShipping/MsRptInvTotal
public ActionResult Index()
{
return View();
}
//
// GET/RptMng/MsRptPcHeadQry/QryData
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult CustListData(int start, int limit, string condition,string groupfield, string sort, string printstr)
{
var strSql = new StringBuilder();
strSql.Append("SELECT YEAR ACCYEAR,MONTH ACCMONTH,F." + groupfield + " AS CUSTNAME,CURRENCY ");
strSql.Append(",SUM(UPMONTHDRBAL) UPMONTHDRBAL,SUM(MONTHDR) MONTHDR,SUM(MONTHDRSTL) MONTHDRSTL,SUM(MONTHDRBAL) MONTHDRBAL");
strSql.Append(",SUM(UPMONTHTTLDRBAL) UPMONTHTTLDRBAL,SUM(MONTHTTLDR) MONTHTTLDR,SUM(MONTHTTLDRSTL) MONTHTTLDRSTL,SUM(MONTHTTLDRBAL) MONTHTTLDRBAL");
strSql.Append(",SUM(UPMONTHCRBAL) UPMONTHCRBAL,SUM(MONTHCR) MONTHCR,SUM(MONTHCRSTL) MONTHCRSTL,SUM(MONTHCRBAL) MONTHCRBAL");
strSql.Append(",SUM(UPMONTHTTLCRBAL) UPMONTHTTLCRBAL,SUM(MONTHTTLCR) MONTHTTLCR,SUM(MONTHTTLCRSTL) MONTHTTLCRSTL,SUM(MONTHTTLCRBAL) MONTHTTLCRBAL");
strSql.Append(" FROM ch_custbalance F ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" Group by YEAR,MONTH,F." + groupfield + ",CURRENCY");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
sortstring = sortstring.Replace("CUSTNAME", groupfield);
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by F."+groupfield);
}
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 };
}
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult SumListData(int start, int limit, string condition, string sort)
{
var strSql = new StringBuilder();
strSql.Append("SELECT CURRENCY ");
strSql.Append(",SUM(UPMONTHDRBAL) UPMONTHDRBAL,SUM(MONTHDR) MONTHDR,SUM(MONTHDRSTL) MONTHDRSTL,SUM(MONTHDRBAL) MONTHDRBAL");
strSql.Append(",SUM(UPMONTHTTLDRBAL) UPMONTHTTLDRBAL,SUM(MONTHTTLDR) MONTHTTLDR,SUM(MONTHTTLDRSTL) MONTHTTLDRSTL,SUM(MONTHTTLDRBAL) MONTHTTLDRBAL");
strSql.Append(",SUM(UPMONTHCRBAL) UPMONTHCRBAL,SUM(MONTHCR) MONTHCR,SUM(MONTHCRSTL) MONTHCRSTL,SUM(MONTHCRBAL) MONTHCRBAL");
strSql.Append(",SUM(UPMONTHTTLCRBAL) UPMONTHTTLCRBAL,SUM(MONTHTTLCR) MONTHTTLCR,SUM(MONTHTTLCRSTL) MONTHTTLCRSTL,SUM(MONTHTTLCRBAL) MONTHTTLCRBAL");
strSql.Append(" FROM ch_custbalance F ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" Group by F.CURRENCY ");
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
}
}