1.前台
<%-- builed by manage.aspx.cmt [ver:2018.25.11] at 2018/4/11 15:25:43 --%>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TranProfitLossImpactManage.aspx.cs" Inherits="HraWeb.TranProfitLossImpactManage" %>
<%@ Register Assembly="Trirand.Web" TagPrefix="asp" Namespace="Trirand.Web.UI.WebControls" %>
<%@ Register Src="~/Contols/Manage.ascx" TagName="Manage" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="toolbar" class="datagrid-toolbar">
<div class="panel-body" style="border: none; background: none; padding: 5px 20px;">
<div class="pull-right">
<div class="btn-group btn-group-sm">
<div class="input-group input-group-sm" style="width: 300px">
<div class="input-group-addon">名称</div>
<input type="text" id="txt_Name_LK_" name="txt_Name_LK_" class="datacontrol form-control" style="border-radius: 0px" />
<span class="input-group-btn">
<button class="btn btn-default " id="btn_search" type="button"><i class="fa fa-search"></i>查询</button>
</span>
</div>
</div>
</div>
</div>
</div>
<div class='jdataGrid'>
<table id="jq">
</table>
<div id="jq_pager">
</div>
<%-- <table id="jq_t">
</table>
<div id="jq_pgr">
</div>--%>
</div>
</form>
<script type="text/javascript">
function bindSubGrid(subgrid_id, asofdate) {
var subgrid_table_id;
subgrid_table_id = subgrid_id + "_t"; // (3)根据subgrid_id定义对应的子表格的table的id
var subgrid_pager_id;
subgrid_pager_id = subgrid_id + "_pgr" // (4)根据subgrid_id定义对应的子表格的pager的id
// (5)动态添加子报表的table和pager
$("#" + subgrid_id)
.html(
"<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + subgrid_pager_id + "' class='scroll'></div>");
// (6)创建jqGrid对象
$("#" + subgrid_table_id)
.jqGrid(
{
url: 'TranProfitLossImpactManage.aspx?_method=loadbydate&asofdate=' + asofdate, // (7)子表格数据对应的url,注意传入的contact.id参数
datatype: "json",
page: 1,
colNames: [ "合约号码", "合约名称", "计算方法", "计价货币", "上一日盯市价值", "当日盯市价值", "交易损益", "损益解释水平", "损益解释百分比", "总方差水平", "总方差百分比", "价格重估值", "利率重估值", "汇率重估值", "时间重估值", "关联度重估值", "价格归因", "利率归因", "汇率归因", "时间归因", "价格差值", "波动率差值", "利率差值", "汇率差值", "VEGAGAMMA归因", "交叉GAMMA归因", "交叉VEGAGAMMA归因", "DELTAVEGA归因", "波动率重估值", "波动率偏差重估值", "价格波动率重估值", "波动率归因", "波动率偏差归因", "价格波动率归因", "关联度归因", "价格方差", "波动率方差", "波动率偏差方差", "价格波动率方差", "利率方差", "汇率方差", "关联度方差", "时间方差", "新交易归因", "交易结算归因", "交易撤销归因", "交易修订归因", "价格重置归因", "期权执行归因", "DELTA归因", "GAMMA归因", "VEGA归因", "THETA归因", "RHO归因", "ETA归因", "Id"],
colModel: [
{
"name": "TransactionId",
"superFilterColumn": "TransactionId",
"searchoptions": {
},
"index": "TransactionId"
},
{
"name": "TransactionName",
"superFilterColumn": "TransactionName",
"searchoptions": {
},
"index": "TransactionName"
},
{
"name": "ComputeMethodId",
"superFilterColumn": "ComputeMethodId",
"searchoptions": {
},
"index": "ComputeMethodId"
},
{
"name": "ValueCurrencyName",
"superFilterColumn": "ValueCurrencyName",
"searchoptions": {
},
"index": "ValueCurrencyName"
},
{
"name": "PriorMtmValue",
"superFilterColumn": "PriorMtmValue",
"searchoptions": {
},
"index": "PriorMtmValue"
},
{
"name": "CurrMtmValue",
"superFilterColumn": "CurrMtmValue",
"searchoptions": {
},
"index": "CurrMtmValue"
},
{
"name": "ProfitLossValue",
"superFilterColumn": "ProfitLossValue",
"searchoptions": {
},
"index": "ProfitLossValue"
},
{
"name": "PnlExplainedLevel",
"superFilterColumn": "PnlExplainedLevel",
"searchoptions": {
},
"index": "PnlExplainedLevel"
},
{
"name": "PnlExplainedPercent",
"superFilterColumn": "PnlExplainedPercent",
"searchoptions": {
},
"index": "PnlExplainedPercent"
},
{
"name": "TotalVarianceLevel",
"superFilterColumn": "TotalVarianceLevel",
"searchoptions": {
},
"index": "TotalVarianceLevel"
},
{
"name": "TotalVariancePercent",
"superFilterColumn": "TotalVariancePercent",
"searchoptions": {
},
"index": "TotalVariancePercent"
},
{
"name": "PriceRevaluation",
"superFilterColumn": "PriceRevaluation",
"searchoptions": {
},
"index": "PriceRevaluation"
},
{
"name": "IrRateRevaluation",
"superFilterColumn": "IrRateRevaluation",
"searchoptions": {
},
"index": "IrRateRevaluation"
},
{
"name": "FxRateRevaluation",
"superFilterColumn": "FxRateRevaluation",
"searchoptions": {
},
"index": "FxRateRevaluation"
},
{
"name": "TimeRevaluation",
"superFilterColumn": "TimeRevaluation",
"searchoptions": {
},
"index": "TimeRevaluation"
},
{
"name": "CorrRevaluation",
"superFilterColumn": "CorrRevaluation",
"searchoptions": {
},
"index": "CorrRevaluation"
},
{
"name": "PriceImpact",
"superFilterColumn": "PriceImpact",
"searchoptions": {
},
"index": "PriceImpact"
},
{
"name": "IrRateImpact",
"superFilterColumn": "IrRateImpact",
"searchoptions": {
},
"index": "IrRateImpact"
},
{
"name": "FxRateImpact",
"superFilterColumn": "FxRateImpact",
"searchoptions": {
},
"index": "FxRateImpact"
},
{
"name": "TimeImpact",
"superFilterColumn": "TimeImpact",
"searchoptions": {
},
"index": "TimeImpact"
},
{
"name": "PriceDifferential",
"superFilterColumn": "PriceDifferential",
"searchoptions": {
},
"index": "PriceDifferential"
},
{
"name": "VolatilityDifferential",
"superFilterColumn": "VolatilityDifferential",
"searchoptions": {
},
"index": "VolatilityDifferential"
},
{
"name": "IrRateDifferential",
"superFilterColumn": "IrRateDifferential",
"searchoptions": {
},
"index": "IrRateDifferential"
},
{
"name": "FxRateDifferential",
"superFilterColumn": "FxRateDifferential",
"searchoptions": {
},
"index": "FxRateDifferential"
},
{
"name": "VegaGammaImpact",
"superFilterColumn": "VegaGammaImpact",
"searchoptions": {
},
"index": "VegaGammaImpact"
},
{
"name": "CrossGammaImpact",
"superFilterColumn": "CrossGammaImpact",
"searchoptions": {
},
"index": "CrossGammaImpact"
},
{
"name": "CrossVegaGammaImpact",
"superFilterColumn": "CrossVegaGammaImpact",
"searchoptions": {
},
"index": "CrossVegaGammaImpact"
},
{
"name": "DeltaVegaImpact",
"superFilterColumn": "DeltaVegaImpact",
"searchoptions": {
},
"index": "DeltaVegaImpact"
},
{
"name": "VolatilityRevaluation",
"superFilterColumn": "VolatilityRevaluation",
"searchoptions": {
},
"index": "VolatilityRevaluation"
},
{
"name": "VolSkewRevaluation",
"superFilterColumn": "VolSkewRevaluation",
"searchoptions": {
},
"index": "VolSkewRevaluation"
},
{
"name": "PriceVolRevaluation",
"superFilterColumn": "PriceVolRevaluation",
"searchoptions": {
},
"index": "PriceVolRevaluation"
},
{
"name": "VolatilityImpact",
"superFilterColumn": "VolatilityImpact",
"searchoptions": {
},
"index": "VolatilityImpact"
},
{
"name": "VolSkewImpact",
"superFilterColumn": "VolSkewImpact",
"searchoptions": {
},
"index": "VolSkewImpact"
},
{
"name": "PriceVolImpact",
"superFilterColumn": "PriceVolImpact",
"searchoptions": {
},
"index": "PriceVolImpact"
},
{
"name": "CorrImpact",
"superFilterColumn": "CorrImpact",
"searchoptions": {
},
"index": "CorrImpact"
},
{
"name": "PriceVariance",
"superFilterColumn": "PriceVariance",
"searchoptions": {
},
"index": "PriceVariance"
},
{
"name": "VolatilityVariance",
"superFilterColumn": "VolatilityVariance",
"searchoptions": {
},
"index": "VolatilityVariance"
},
{
"name": "VolSkewVariance",
"superFilterColumn": "VolSkewVariance",
"searchoptions": {
},
"index": "VolSkewVariance"
},
{
"name": "PriceVolVariance",
"superFilterColumn": "PriceVolVariance",
"searchoptions": {
},
"index": "PriceVolVariance"
},
{
"name": "IrRateVariance",
"superFilterColumn": "IrRateVariance",
"searchoptions": {
},
"index": "IrRateVariance"
},
{
"name": "FxRateVariance",
"superFilterColumn": "FxRateVariance",
"searchoptions": {
},
"index": "FxRateVariance"
},
{
"name": "CorrVariance",
"superFilterColumn": "CorrVariance",
"searchoptions": {
},
"index": "CorrVariance"
},
{
"name": "TimeVariance",
"superFilterColumn": "TimeVariance",
"searchoptions": {
},
"index": "TimeVariance"
},
{
"name": "NewTranImpact",
"superFilterColumn": "NewTranImpact",
"searchoptions": {
},
"index": "NewTranImpact"
},
{
"name": "SettledTranImpact",
"superFilterColumn": "SettledTranImpact",
"searchoptions": {
},
"index": "SettledTranImpact"
},
{
"name": "CancelledTranImpact",
"superFilterColumn": "CancelledTranImpact",
"searchoptions": {
},
"index": "CancelledTranImpact"
},
{
"name": "AmendedtranImpact",
"superFilterColumn": "AmendedtranImpact",
"searchoptions": {
},
"index": "AmendedtranImpact"
},
{
"name": "PriceResetImpact",
"superFilterColumn": "PriceResetImpact",
"searchoptions": {
},
"index": "PriceResetImpact"
},
{
"name": "OptionExerciseImpact",
"superFilterColumn": "OptionExerciseImpact",
"searchoptions": {
},
"index": "OptionExerciseImpact"
},
{
"name": "DeltaImpact",
"superFilterColumn": "DeltaImpact",
"searchoptions": {
},
"index": "DeltaImpact"
},
{
"name": "GammaImpact",
"superFilterColumn": "GammaImpact",
"searchoptions": {
},
"index": "GammaImpact"
},
{
"name": "VegaImpact",
"superFilterColumn": "VegaImpact",
"searchoptions": {
},
"index": "VegaImpact"
},
{
"name": "ThetaImpact",
"superFilterColumn": "ThetaImpact",
"searchoptions": {
},
"index": "ThetaImpact"
},
{
"name": "RhoImpact",
"superFilterColumn": "RhoImpact",
"searchoptions": {
},
"index": "RhoImpact"
},
{
"name": "EtaImpact",
"superFilterColumn": "EtaImpact",
"searchoptions": {
},
"index": "EtaImpact"
},
{
"superFilterColumn": "Id",
"name": "Id",
"searchoptions": {
"searchhidden": true
},
"hidden": true,
"key": true,
"index": "Id"
}
],
viewrecords: true,
scrollrows: false,
styleUI: 'Bootstrap',
jsonReader: { id: "Id" },
rowList : [ 10, 20, 30 ],
rowNum: 10,
sortorder: 'asc',
hidegrid: false,
height: ComputGridHeight(320),
autowidth: true,
headertitles: true,
rownumbers: true,
shrinkToFit: false,
pager: jQuery('#' + subgrid_pager_id),
viewsortcols: [false, 'vertical', true]
});
$("#"+subgrid_id).setGridWidth($(window).width() - 1);
}
function PageOnLoad() {
jQuery('#jq').jqGrid({
url: '/Tran/TranProfitLossImpactManage.aspx?_method=loadDate',
editurl: '/Tran/TranProfitLossImpactManage.aspx?_menuId=17264&jqGridID=jq&editMode=1',
datatype: 'json',
page: 1,
colNames: ["运行日期"],
pageSize: 20000,
colModel: [
{
width: $(window).width() *0.9,
"name": "AsOfDate",
"formatter": getDate,
"index": "AsOfDate",
}
],
viewrecords: true,
scrollrows: false,
styleUI: 'Bootstrap',
jsonReader: { id: "Id" },
rowNum: 20000,
sortorder: 'asc',
hidegrid: false,
width:800,
height: ComputGridHeight(180),
autowidth: true,
headertitles: true,
rownumbers: true,
shrinkToFit: false,
//pager: jQuery('#jq_pager'),
viewsortcols: [false, 'vertical', true],
loadComplete: JDataGrid.loadComplete,
subGrid: true,//开启子表格支持
//子表格的id;当子表格展开的时候,在主表格中会创建一个div元素用来容纳子表格,subgrid_id就是这个div的id
subGridRowExpanded: function (subgrid_id, row_id) {//子表格容器的id和需要展开子表格的行id
var obj = $("#jq").jqGrid('getRowData', row_id);
bindSubGrid(subgrid_id, obj.AsOfDate);
}
//,ondblClickRow: JDataGrid.rowDoubleClick
});
$("#jq").setGridWidth($(window).width() - 1);
//控件按钮设置
$(".button").linkbutton({ plain: true });
//参数说明:控件Id,查询地址,编辑页面的宽度,高度,编辑页面标题,新增按钮,编辑按钮,删除按钮,查询按钮,查询回调函数
JDataGrid.InitGrid("jq", "/TranProfitLossImpact/TranProfitLossImpactEdit.aspx", 600, 400, "交易合约损益归因分析菜单管理", $("#btn_add"), $("#btn_edit"), $("#btn_del"), $("#btn_search"));
}
</script>
</body>
</html>
2.后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HraWeb.Common;
using WebApp.Common;
using Contract.Domain;
using System.Collections;
using Framework;
using NHibernate.Linq;
namespace HraWeb
{
public partial class TranProfitLossImpactManage : JQEntityManage<Contract.Domain.TranProfitLossImpact>
{
protected override void Page_Load(object sender, EventArgs e)
{
//给基类服务接口复制,可不付
//base.svc = Psvc;
if (!IsPostBack)
{
}
switch (Request["_method"])
{
case "loadDate":
var mRows = Dao.GetCurrentSession().QueryOver<TranProfitLossImpact>().List().Distinct(new TranProfitLossImpactDateDistinct()).ToList();
int count = mRows.Count;
JGridJson d = new JGridJson(1, mRows, 1, count);
var json= Newtonsoft.Json.JsonConvert.SerializeObject(d);
Response.Write(json);
Response.End();
break;
case "loadbydate":
DateTime asofDate = DateTime.Parse(Request["asofdate"]);
int pageIndex = int.Parse(Request["page"]);
int pageSize = int.Parse(Request["rows"]);
var totalInfo = new QueryInfo();
totalInfo.CustomSQL = "select count(1) from tran_profit_loss_impact t where t.as_of_date=:as_of_date";
totalInfo.Parameters.Add("as_of_date", asofDate);
int totalRecordCount = 0;
int.TryParse(Dao.ExecuteScare(totalInfo).ToString(), out totalRecordCount);
var mchildRows = Dao.GetCurrentSession().Query<TranProfitLossImpact>()
.Where(x=>x.AsOfDate==asofDate)
.Skip((pageIndex-1)*pageSize)
.Take(pageSize)
.ToList();
int totalPage = ((totalRecordCount - 1) / pageSize) + 1;
int mchildcount = mchildRows.Count;
JGridJson cd = new JGridJson(totalPage, mchildRows, pageIndex, totalRecordCount);
var cjson = Newtonsoft.Json.JsonConvert.SerializeObject(cd);
Response.Write(cjson);
Response.End();
break;
default:
break;
}
base.Page_Load(sender, e);
}
}
}