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/OA/Controllers/ChfeeListController.cs

131 lines
6.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using DSWeb.Areas.OA.Models.ChfeeList;
using DSWeb.TruckMng.Helper;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.SoftMng.Filter;
namespace DSWeb.Areas.OA.Controllers
{
/// <summary>
/// 应收应付明细
/// </summary>
public class ChfeeListController : Controller
{
//
// GET: /Import/RptImportFeedetail/
public ActionResult Index()
{
return View();
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = GetDataList(condition);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
private static List<ChfeeList> GetDataList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append(" select * into #T1 from(SELECT f.GId,f.BsNo,f.FeeStatus, ");
strSql.Append(" (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=f.FeeStatus) as FeeStatus_Ref, ");
strSql.Append(" (select NAME from vMsTruckFeeType where NAME=f.FeeName) as FeeName_Ref, ");
strSql.Append(" (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=f.FeeType) as FeeType_Ref ");
strSql.Append(" ,f.BXGID,f.enterdate,f.CustomerName as CustomerName_Ref,f.Unit,f.UnitPrice,f.Quantity, ");
strSql.Append(" case f.feetype when 1 then f.Amount else 0 end amount_ys, ");
strSql.Append(" case f.feetype when 1 then 0 else f.Amount end amount_yf, ");
strSql.Append(" case f.feetype when 1 then f.Amount*f.exchangerate else 0 end amount_rmbys, ");
strSql.Append(" case f.feetype when 1 then 0 else f.Amount*f.exchangerate end amount_rmbyf, ");
strSql.Append(" f.Currency,f.ExChangerate,f.Remark,vs.MBLNO,vs.customername buyer,vs.Vessel,vs.Voyno, ");
strSql.Append(" (select showname from [user] where gid=f.enteroperator) createuser, ");
strSql.Append(" dbo.f_danhao(f.gid,4) AC,dbo.f_danhao(f.gid,5) AD,dbo.f_danhao(f.gid,9) CR,dbo.f_danhao(f.gid,1) DR, ");
strSql.Append(" f.ACCDATE,f.ISVOU,f.VOUCHERNO,f.AUDITDATE,(select showname from [user] where gid=f.auditoperator) auditoperator ");
strSql.Append(" ,dbo.f_VOUNO(f.gid) VOUNO ");
strSql.Append(" from ch_fee f ");
strSql.Append(" left join vw_settlement vs on (f.bsno=vs.bsno) ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" )tt ");
strSql.Append(" select * from #T1 ");
strSql.Append(" union all ");
strSql.Append(" select '','zzzzzzzz',0,'','','','','','','',0,0, ");
strSql.Append(" sum(amount_ys),sum(amount_yf),sum(amount_rmbys),sum(amount_rmbyf), ");
strSql.Append(" '',0,'','','','','', ");
strSql.Append(" '','','','','', ");
strSql.Append(" '','','','','','' ");
strSql.Append(" from #T1 order by bsno,FeeType_Ref,FeeName_Ref,customername_Ref,enterdate ");
strSql.Append(" drop table #T1 ");
return SetData(strSql);
}
private static List<ChfeeList> SetData(StringBuilder strSql)
{
var headList = new List<ChfeeList>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new ChfeeList();
#region Set DB data to Object
data.GId = Convert.ToString(reader["GId"]);
data.BSNO = Convert.ToString(reader["BSNO"]);
data.FeeStatus = Convert.ToString(reader["FeeStatus"]);
data.FeeStatus_Ref = Convert.ToString(reader["FeeStatus_Ref"]);
data.FeeName_Ref = Convert.ToString(reader["FeeName_Ref"]);
data.FeeType_Ref = Convert.ToString(reader["FeeType_Ref"]);
data.BXGID = Convert.ToString(reader["BXGID"]);
data.EnterDate = Convert.ToString(reader["EnterDate"]);
data.CustomerName_Ref = Convert.ToString(reader["CustomerName_Ref"]);
data.Unit = Convert.ToString(reader["Unit"]);
data.UnitPrice = Convert.ToDecimal(reader["UnitPrice"]);
data.Quantity = Convert.ToDecimal(reader["Quantity"]);
data.Amount_YS = Convert.ToString(reader["Amount_YS"]);
data.Amount_YF = Convert.ToString(reader["Amount_YF"]);
data.Amount_RMBYS = Convert.ToString(reader["Amount_RMBYS"]);
data.Amount_RMBYF = Convert.ToString(reader["Amount_RMBYF"]);
data.Currency = Convert.ToString(reader["Currency"]);
data.ExChangerate = Convert.ToString(reader["ExChangerate"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.MBLNO = Convert.ToString(reader["MBLNO"]);
data.buyer = Convert.ToString(reader["buyer"]);
data.Vessel = Convert.ToString(reader["Vessel"]);
data.Voyage = Convert.ToString(reader["Voyage"]);
data.CreateUser = Convert.ToString(reader["CreateUser"]);
data.AC = Convert.ToString(reader["AC"]);
data.AD = Convert.ToString(reader["AD"]);
data.CR = Convert.ToString(reader["CR"]);
data.DR = Convert.ToString(reader["DR"]);
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
data.ISVOU = Convert.ToString(reader["ISVOU"]);
data.VOUCHERNO = Convert.ToString(reader["VOUCHERNO"]);
data.VOUNO = Convert.ToString(reader["VOUNO"]);
data.AUDITOPERATOR = Convert.ToString(reader["AUDITOPERATOR"]);
data.AUDITDATE = Convert.ToString(reader["AUDITDATE"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
}
}