TG.WXCRM.V4/WEB/Controllers/QH/TranSactionDetailController.cs

109 lines
5.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Web.Mvc;
using WX.CRM.Common;
using WX.CRM.IBLL.QH;
using WX.CRM.Model.Entity;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.QH
{
public class TranSactionDetailController : BaseController
{
//
// GET: /TranSactionDetail/
private IQH_TRANSACTIONDETAIL _iqh_TranSactionDetail;
public TranSactionDetailController(IQH_TRANSACTIONDETAIL iQH_TRANSACTIONDETAIL)
{
this._iqh_TranSactionDetail = iQH_TRANSACTIONDETAIL;
}
[AuthorizeRedirect(Roles = InitRights.CONST_期货客户成交明细列表)]
public ActionResult Index()
{
ToolBar tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights., userRightId);
tool.AllowButton(toolbtn);
tool.AddOtherButton("Other1", "导出", "icon-export", "export_Click", true);
ViewBag.ToolBar = tool;
Pager pager = new Pager() { page = 1, rows = 20 };
string tableId = "tablist";
Table tab = new Table(tableId);
tab.AddHiddenHeadCol("PKID", "PKID");
tab.AddHeadCol("TEAM", "", "所属组");
tab.AddHeadCol("EXCHANGE", "", "交易所");
tab.AddHeadCol("USERACCOUNT", "", "账户");
tab.AddHeadCol("ACCOUNTNAME", "", "账户名");
tab.AddHeadCol("PRODUCTNAME", "", "品种");
tab.AddHeadCol("CONTRACTCODE", "", "合约代码");
tab.AddHeadCol("MM", "", "买卖");
tab.AddHeadCol("KP", "", "开平");
tab.AddHeadCol("CJBH", "", "成交编号");
tab.AddHeadCol("CJJG", "", "成交价格");
tab.AddHeadCol("CJRQ", "", "成交日期");
tab.AddHeadCol("CJSL", "", "成交数量");
tab.AddHeadCol("BDBH", "", "报单编号");
tab.AddHeadCol("TB", "", "投保");
tab.AddHeadCol("ZHSXF", "", "账户手续费");
tab.AddHeadCol("JYSSXF", "", "交易所手续费");
tab.AddHeadRow();
ViewBag.List = tab.GetTable() + Pagination.GetPage(pager, tableId, "10,20,30,50");
return View();
}
public ActionResult GetHtml(Pager pager, string productName, string exChange, string contractCode, string userAccount, string name, string columns)
{
try
{
List<QH_TRANSACTIONDETAIL> list = _iqh_TranSactionDetail.GetList(ref pager, productName, exChange, contractCode, userAccount, name);
Table table = new Table(columns, true);
table.gridPager = pager;
foreach (QH_TRANSACTIONDETAIL model in list)
{
table.AddHiddenCol(model.PKID);
table.AddCol(model.TEAM);
table.AddCol(model.EXCHANGE);
table.AddCol(model.USERACCOUNT);
table.AddCol(model.ACCOUNTNAME);
table.AddCol(model.PRODUCTNAME);
table.AddCol(model.CONTRACTCODE);
table.AddCol(model.MM);
table.AddCol(model.KP);
table.AddCol(model.CJBH);
table.AddCol(model.CJJG);
table.AddCol(model.CJRQ.HasValue ? model.CJRQ.Value.ToString("yyyy-MM-dd HH:mm") : "");
table.AddCol(model.CJSL);
table.AddCol(model.BDBH);
table.AddCol(model.TB);
table.AddCol(model.ZHSXF);
table.AddCol(model.JYSSXF);
table.AddRow();
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return JsonHandler.ManageMessage(ex.Message, false);
}
}
#region
public FileResult Export(string productName, string exChange, string contractCode, string userAccount, string name)
{
string checkedFilds = PageRequest.GetQueryString("checkedFilds");
checkedFilds = checkedFilds.Replace("[]", "");
string checkedTitles = PageRequest.GetQueryString("checkedTitles");
Pager pager = new Pager() { page = 1, rows = int.MaxValue };
List<QH_TRANSACTIONDETAIL> list = _iqh_TranSactionDetail.GetList(ref pager, productName, exChange, contractCode, userAccount, name);
return File(ExcelHelper.ExportListModelToExcel<QH_TRANSACTIONDETAIL>(list, "期货客户成交明细列表", 10000, checkedFilds, checkedTitles, null), "application/ms-excel", PageRequest.GetDlownLoadName("期货客户成交明细列表.xls"));
}
#endregion
}
}