绑定下拉框

<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="TranForwardEdit.aspx.cs"
Inherits="HraWeb.TranForwardEdit" %>
<%@ Register TagPrefix="asp" Namespace="WebControls.Web.UI" Assembly="WebControls" %>

<!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>
<style>
.input
{
200px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="easyui-tabs" style=" 800px; height: 600px">
<div title="<%=titleName%>">
<div >
<div class="datagrid-toolbar">
<a href="#" runat="server" id="btn_Save_" iconcls="icon-save" class="button">保存</a>
<a href="#" id="btn_close" iconcls="icon-close" class="button">关闭</a>
<a href="#" runat="server" id="btn_Save_Settings" iconcls="icon-save" class="button">设置为默认配置</a>
</div>
</div>
<div style="overflow: auto">
<asp:BindingControl ID="bpEdit" runat="server">
<ContentTemplate>
<asp:TextBox ID="txt_Id_" runat="server" Style="display: none" CssClass="input datacontrol" />
<asp:TextBox ID="txt_DataType_" runat="server" Style="display: none" CssClass="input datacontrol" />
<table border="0" cellpadding="0" cellspacing="0" class="tableL">
<tr>
<th style=' 10%'>
交易名称:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_Name_" runat="server" CssClass="input datacontrol"></asp:TextBox><span
class="message">*</span>
</td>
<th style=' 10%'>
关联交易:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_LinkedForwardId_" runat="server" CssClass="input datacontrol"></asp:TextBox>
</td>
</tr>
<tr>
<th style=' 10%'>
票据类型:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_InstrumentTypeId_" ReadOnly="True" runat="server" CssClass="input datacontrol hidden"></asp:TextBox>
<asp:TextBox ID="txt_InstrumentTypeName_" ReadOnly="True" runat="server" CssClass="input datacontrol"></asp:TextBox>

<span
class="message">*</span>
</td>
<th style=' 10%'>
衍生品类型:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_DerivativeTypeName_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_DerivativeType_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
交付类型:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_DeliveryTypeName_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_DeliveryType_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
<th>
交易对手:
</th>
<td>
<asp:TextBox ID="txt_Counterparty_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_CounterpartyId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
外部法人:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_ExternalLegalEntity_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_ExternalLegalEntityId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
<th style=' 10%'>
外部业务单位:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_ExternalBusinessUnit_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_ExternalBusinessUnitId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
内部法人:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_InternalLegalEntity_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_InternalLegalEntityId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
<th style=' 10%'>
内部业务单位:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_InternalBusinessUnit_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_InternalBusinessUnitId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
交易席位:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_TradeDesk_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_TradeDeskId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox>
</td>
<th style=' 10%'>
交易组合:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_Portfolio_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_PortfolioId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
交易员:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_Trader_" runat="server" CssClass="input datacontrol" ></asp:TextBox>
<asp:TextBox ID="txt_TraderId_" runat="server" CssClass="input datacontrol hidden" ></asp:TextBox><span
class="message">*</span>
</td>
<th style=' 10%'>
买卖方向:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_DirectionName_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_Direction_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
价格计算模型:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_PricingModel_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_PricingModelId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
<th style=' 10%'>
交易日期:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_TransactionDate_" runat="server" CssClass="input datacontrol Wdate"
Format="{0:yyyy-MM-dd}" onclick="WdatePicker()"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
输入日期:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_InputDate_" runat="server" CssClass="input datacontrol Wdate"
Format="{0:yyyy-MM-dd}" onclick="WdatePicker()"></asp:TextBox><span class="message">*</span>
</td>
<th style=' 10%'>
起效日期:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_EffectiveDate_" runat="server" CssClass="input datacontrol Wdate"
Format="{0:yyyy-MM-dd}" onclick="WdatePicker()"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
终止日期:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_TerminationDate_" runat="server" CssClass="input datacontrol Wdate"
Format="{0:yyyy-MM-dd}" onclick="WdatePicker()"></asp:TextBox><span
class="message">*</span>
</td>
<th style=' 10%'>
协议:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_Agreement_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_AgreementId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr>
<th style=' 10%'>
交易代理:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_BusinessAgent_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_BusinessAgentId_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox>
</td>
<th style=' 10%'>
收取费用:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_Charge_" runat="server" CssClass="input datacontrol"></asp:TextBox>
</td>
</tr>
<tr>
<th style=' 10%'>
费用币种:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_ChargeCurrency_" runat="server" CssClass="input datacontrol"></asp:TextBox>
</td>
<th style=' 10%'>
支付币种:
</th>
<td style=' 40%'>
<asp:TextBox ID="txt_PaymentCurrency_" runat="server" CssClass="input datacontrol"></asp:TextBox>
</td>
</tr>
<tr>
<th style=' 10%'>
交易目的:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_DealEntryTypeName_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_DealEntryType_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
<th style=' 10%'>
交易行为:
</th>
<td style=' 40%'>

<asp:TextBox ID="txt_DealStatusName_" runat="server" CssClass="input datacontrol"></asp:TextBox>
<asp:TextBox ID="txt_DealStatus_" runat="server" CssClass="input datacontrol hidden"></asp:TextBox><span
class="message">*</span>
</td>
</tr>
<tr> <th style='10%'>账户类型:</th>
<td style='40%'>
<asp:DropDownList ID="txt_AccountType_" runat="server" style="210px;" CssClass="input datacontrol"></asp:DropDownList><span class="message">*</span>
</td>
<th style='10%'>账户分类:</th>
<td style='40%'>
<asp:DropDownList ID="txt_AccountRule_" runat="server" style="210px;" CssClass="input datacontrol"></asp:DropDownList><span class="message">*</span>
</td>
</tr>
<tr>
<th style='10%'>交易账户:</th>
<td style='40%'>
<asp:DropDownList ID="txt_TradeFolder_" runat="server" style="210px;" CssClass="input datacontrol"></asp:DropDownList><span class="message">*</span>
</td>
</tr>
</table>
</ContentTemplate>
</asp:BindingControl>
</div>
</div>
<div title="<%=detailName%>">
<iframe name='detail' width="100%" height="600px" frameborder="0" scrolling="auto"
id="detail"></iframe>
</div>
</div>
</form>
<script type="text/javascript">
//$('#id').combogrid('grid').datagrid('selectRecord',idValue)
function PageOnLoad() {
var url = "TranForwardDetailManage.aspx?Id=" + $("#txt_Id_").val();
$("#detail").attr("src", url);
$(".button").linkbutton();
$("#btn_Save_").linkbutton('disable');
// DataGrid.WaitMessage("正在加载数据,请稍后。。");
// window.setTimeout(function () {
// $("#btn_Save_").linkbutton('enable');
// DataGrid.RemoveWaitMessage();
// }, 3000);
$("#btn_close").click(function () {
artDialog.close();
});
InitDrop();
$("#form1").validate(
{
//验证规则
rules: {
txt_Name_: { maxlength: 50, required: true }
, txt_InstrumentType_: { maxlength: 50, required: true }
// , txt_InstrumentTypeName_: { maxlength: 50, combogrid: true }
, txt_DerivativeType_: { maxlength: 50,required:true }
, txt_DeliveryType_: { maxlength: 50, required: true }
, txt_CounterpartyId_: { maxlength: 50, required: true }
, txt_ExternalLegalEntityId_: { maxlength: 50, required: true }
, txt_ExternalBusinessUnitId_: { maxlength: 50, required: true }
, txt_InternalLegalEntityId_: { maxlength: 50, required: true }
, txt_InternalBusinessUnitId_: { maxlength: 50, required: true }
, txt_TradeDeskId_: { maxlength: 50 }
, txt_PortfolioId_: { maxlength: 50, required: true }
, txt_TraderId_: { maxlength: 50, required: true }
, txt_Direction_: { maxlength: 50, required: true }
, txt_PricingModelId_: { maxlength: 50, required: true }
, txt_TransactionDate_: { maxlength: 50, required: true }
, txt_InputDate_: { maxlength: 50, required: true }
, txt_EffectiveDate_: { maxlength: 50, required: true }
, txt_TerminationDate_: { maxlength: 50, required: true }
, txt_AgreementId_: { maxlength: 50, required: true }
, txt_BusinessAgentId_: { maxlength: 50 }
, txt_Charge_: { maxlength: 10, number: true }
, txt_ChargeCurrency_: { maxlength: 50 }
, txt_PaymentCurrency_: { maxlength: 50 }
, txt_DealEntryType_: { maxlength: 50, required: true }
, txt_DealStatus_: { maxlength: 50, required: true }

}
});
//保存操作
$("#btn_Save_").click(function () {

if (!$("#form1").validate().form()) {
return;
}
var obj = setSaveData();
//保存操作页面地址,该方法的参数具体查看/scripts/datagrid.js
JDataGrid.SavePage("/Tran/TranForwardEdit.aspx?_method=Save", obj, function (data) {
if ($("#txt_Id_").val() == "") {
var url = "TranForwardDetailManage.aspx?Id=" + data.Id;
$("#detail").attr("src", url);
}
$("#txt_Id_").val(data.Id);
$.messager.alert('操作提示', UTIL.getMessage("Save_Sucess"), 'info', function () {
artDialog.open.origin.JDataGrid.GridSearch();
});
}, true);
});
//设置默认配置
$("#btn_Save_Settings").click(function () {
var obj = setSaveData();
var url = '/Tran/TranForwardEdit.aspx?_method=SaveSettings&InstrumentTypeId=' + UTIL.getUrlParam("InstrumentTypeId");
JDataGrid.SavePage(url, obj, function (data) {
if (data == "1") {
UTIL.MessageBox("Save_Sucess", 'info');
} else {
UTIL.MessageBox("Save_Fail", 'error', data.Message);
}
});
});
}
function setSaveData() {
var obj = $("#form1").GetPostData();
return obj;

/* var row = $("#txt_DerivativeType_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_DerivativeType_"] = row.Code;
obj["txt_DerivativeTypeName_"] = row.Name;
}
row = $("#txt_DeliveryType_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_DeliveryType_"] = row.Code;
obj["txt_DeliveryTypeName_"] = row.Name;
}

row = $("#txt_Direction_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_Direction_"] = row.Code;
obj["txt_DirectionName_"] = row.Name;
}
row = $("#txt_DealEntryType_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_DealEntryType_"] = row.Code;
obj["txt_DealEntryTypeName_"] = row.Name;
}
row = $("#txt_DealStatus_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_DealStatus_"] = row.Code;
obj["txt_DealStatusName_"] = row.Name;
}
row = $("#txt_ChargeCurrency_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_ChargeCurrency_"] = row.CurrencyCode;
}
row = $("#txt_PaymentCurrency_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_PaymentCurrency_"] = row.CurrencyCode;
}
row = $("#txt_LinkedForwardId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_LinkedForwardId_"] = row.Id;
obj["txt_LinkedForwardName_"] = row.Name;
}
row = $("#txt_ExternalLegalEntityId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_ExternalLegalEntityId_"] = row.Id;
obj["txt_ExternalLegalEntity_"] = row.LegalEntityName;
}
row = $("#txt_InternalLegalEntityId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_InternalLegalEntityId_"] = row.Id;
obj["txt_InternalLegalEntity_"] = row.LegalEntityName;
}
row = $("#txt_ExternalBusinessUnitId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_ExternalBusinessUnitId_"] = row.Id;
obj["txt_ExternalBusinessUnit_"] = row.BusinessUnitName;
}
row = $("#txt_InternalBusinessUnitId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_InternalBusinessUnitId_"] = row.Id;
obj["txt_InternalBusinessUnit_"] = row.BusinessUnitName;
}
row = $("#txt_TradeDeskId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_TradeDeskId_"] = row.Id;
obj["txt_TradeDesk_"] = row.TradeDeskName;
}
row = $("#txt_PricingModelId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_PricingModelId_"] = row.Id;
obj["txt_PricingModel_"] = row.PricingModelName;
}
row = $("#txt_PortfolioId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_PortfolioId_"] = row.Id;
obj["txt_Portfolio_"] = row.PortfolioName;
}
// row = $("#txt_InstrumentTypeId_").combogrid("grid").datagrid("getSelected");
// if (row != null) {
// obj["txt_InstrumentTypeId_"] = row.Id;
// obj["txt_InstrumentTypeName_"] = row.InstrumentTypeName;
// }
row = $("#txt_TraderId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_TraderId_"] = row.Id;
obj["txt_Trader_"] = row.UserName;
}
row = $("#txt_CounterpartyId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_CounterpartyId_"] = row.Id;
obj["txt_Counterparty_"] = row.CounterpartyName;
}

row = $("#txt_BusinessAgentId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_BusinessAgentId_"] = row.Id;
obj["txt_BusinessAgent_"] = row.CounterpartyName;
}

row = $("#txt_AgreementId_").combogrid("grid").datagrid("getSelected");
if (row != null) {
obj["txt_AgreementId_"] = row.Id;
obj["txt_Agreement_"] = row.AgreementName;
}

return obj;*/
}
function InitDrop() {

// $("#txt_InstrumentTypeName_").SetCombo({
// entityType: "BasInstrumentType",
// textField: "InstrumentTypeName",
// panelWidth:500,
// panelHeight:300,
// idFild:"Id",
// valueControl:$("#txt_InstrumentTypeId_"),
// columns:[[
// { field: 'InstrumentTypeName', title: '票据类型名称', 80 },
// { field: 'InstrumentTypeCode', title: '编码', 80, align: 'left' }]]
// });

// $("#txt_DerivativeTypeName_").SetDict({
// valueControl: $("#txt_DerivativeType_"),
// dicType:"DERIVATIVE_TYPE"
// });
// $("#txt_Counterparty_").SetCombo({
// entityType: "BasCounterparty",
// textField: "CounterpartyName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_CounterpartyId_"),
// columns: [[
// { field: 'CounterpartyName', title: '对手名', 100 },
// { field: 'CounterpartyCode', title: '编码', 100}]]
// });
// $("#txt_ExternalLegalEntity_").SetCombo({
// entityType: "BasLegalEntity",
// textField: "LegalEntityName",
// panelWidth: 500,
// panelHeight: 300,
// where: "ExternalFlag=1",
// idFild: "Id",
// valueControl: $("#txt_ExternalLegalEntityId_"),
// columns: [[
// { field: 'LegalEntityName', title: '法人名称', 80 },
// { field: 'LegalEntityCode', title: '法人编码', 80}]]
// });
// $("#txt_ExternalBusinessUnit_").SetCombo({
// entityType: "BasBusinessUnit",
// textField: "BusinessUnitName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_ExternalBusinessUnitId_"),
// columns: [[
// { field: 'BusinessUnitName', title: '名称', 80 },
// { field: 'BusinessUnitCode', title: '编码', 80 }]]
// });
// $("#txt_InternalLegalEntity_").SetCombo({
// entityType: "BasLegalEntity",
// textField: "LegalEntityName",
// panelWidth: 500,
// panelHeight: 300,
// where: "(ExternalFlag is null or ExternalFlag=0)",
// idFild: "Id",
// valueControl: $("#txt_ExternalBusinessUnitId_"),
// columns: [[
// { field: 'LegalEntityName', title: '法人名称', 80 },
// { field: 'LegalEntityCode', title: '法人编码', 80 }]]
// });

// $("#txt_InternalBusinessUnit_").SetCombo({
// entityType: "BasBusinessUnit",
// textField: "BusinessUnitName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_InternalBusinessUnitId_"),
// columns: [[
// { field: 'BusinessUnitName', title: '名称', 80 },
// { field: 'BusinessUnitCode', title: '编码', 80}]]
// });
// $("#txt_TradeDesk_").SetCombo({
// entityType: "BasTradeDesk",
// textField: "TradeDeskName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_TradeDeskId_"),
// columns: [[
// { field: 'TradeDeskName', title: '名称', 80 },
// { field: 'TradeDeskCode', title: '编码', 80}]]
// });

// $("#txt_Portfolio_").SetCombo({
// entityType: "BasPortfolio",
// textField: "PortfolioName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_PortfolioId_"),
// columns: [[
// { field: 'PortfolioName', title: '名称', 80 },
// { field: 'PortfolioCode', title: '编码', 80}]]
// });
// $("#txt_PricingModel_").SetCombo({
// entityType: "BasPricingModel",
// textField: "PricingModelName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_PricingModelId_"),
// columns: [[
// { field: 'PricingModelName', title: '模型名称', 100 },
// { field: 'PricingModelCode', title: '模型编码', 100 }]]
// });

// $("#txt_DealEntryTypeName_").SetDict({
// valueControl: $("#txt_DealEntryType_"),
// dicType: "DEAL_ENTRY_TYPE"
// });
// $("#txt_DealStatusName_").SetDict({
// valueControl: $("#txt_DealStatus_"),
// dicType: "DEAL_STATUS"
// });
// $("#txt_DeliveryTypeName_").SetDict({
// valueControl: $("#txt_DeliveryType_"),
// dicType: "DELIVERY_TYPE"
// });
// $("#txt_DirectionName_").SetDict({
// valueControl: $("#txt_Direction_"),
// dicType: "DIRECTION"
// });
// $("#txt_ChargeCurrency_").SetCombo({
// entityType: "BasCurrency",
// textField: "CurrencyName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "CurrencyCode",
// valueControl: $("#txt_ChargeCurrency_"),
// columns: [[
// { field: 'CurrencyName', title: '货币名称', 80 },
// { field: 'CurrencyCode', title: '编码', 80, align: 'left'}]]
// });
// $("#txt_PaymentCurrency_").SetCombo({
// entityType: "BasCurrency",
// textField: "CurrencyName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "CurrencyCode",
// valueControl: $("#txt_PaymentCurrency_"),
// columns: [[
// { field: 'CurrencyName', title: '货币名称', 80 },
// { field: 'CurrencyCode', title: '编码', 80, align: 'left'}]]
// });
var url = '/common/EntityJsonList.ashx?entityType=BasBusinessPerson&_method=entityTemp&tmp=' + Math.random() + '&queryTextFild=UserName';

url += "&defaultValue=" + escape($("#txt_Trader_").val());

var id = 'Id';

url += "&idFild=" + id;
$.getJSON(url, function (json) {
//
$("#txt_Portfolio_").combogrid({
panelWidth: 500,
panelHeight: 300,
idField: 'Id',
textField: 'UserName',
data: json.Trader,
method: 'get',
delay: 1000,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: 35, //每页显示的记录条数,默认为10
pageList: [35, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表
columns: [[
{ field: 'UserName', title: '名称', 80}]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true, //自
keyHandler: {

query: function (keyword) { //【动态搜索】处理
//设置查询参数
var queryParams = $("#txt_Trader_").combogrid("grid").datagrid('options').queryParams;
queryParams.keyword = keyword;
$("#txt_Trader_").combogrid("grid").datagrid('options').queryParams = queryParams;
//重新加载
$("#txt_Trader_").combogrid("grid").datagrid("reload");
$("#txt_Trader_").combogrid("setValue", keyword);
}
},
mode: 'remote',
fitColumns: true
});
$("#txt_DealEntryTypeName_").combogrid({
panelWidth: 500,
panelHeight: 300,
idField: 'Id',
textField: 'UserName',
data: json.Trader,
method: 'get',
delay: 1000,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: 35, //每页显示的记录条数,默认为10
pageList: [35, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表
columns: [[
{ field: 'UserName', title: '名称', 80}]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true, //自
keyHandler: {

query: function (keyword) { //【动态搜索】处理
//设置查询参数
var queryParams = $("#txt_Trader_").combogrid("grid").datagrid('options').queryParams;
queryParams.keyword = keyword;
$("#txt_Trader_").combogrid("grid").datagrid('options').queryParams = queryParams;
//重新加载
$("#txt_Trader_").combogrid("grid").datagrid("reload");
$("#txt_Trader_").combogrid("setValue", keyword);
}
},
mode: 'remote',
fitColumns: true
});
$("#txt_ChargeCurrency_").combogrid({
panelWidth: 500,
panelHeight: 300,
idField: 'Id',
textField: 'UserName',
data: json.Trader,
method: 'get',
delay: 1000,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: 35, //每页显示的记录条数,默认为10
pageList: [35, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表
columns: [[
{ field: 'UserName', title: '名称', 80}]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true, //自
keyHandler: {

query: function (keyword) { //【动态搜索】处理
//设置查询参数
var queryParams = $("#txt_Trader_").combogrid("grid").datagrid('options').queryParams;
queryParams.keyword = keyword;
$("#txt_Trader_").combogrid("grid").datagrid('options').queryParams = queryParams;
//重新加载
$("#txt_Trader_").combogrid("grid").datagrid("reload");
$("#txt_Trader_").combogrid("setValue", keyword);
}
},
mode: 'remote',
fitColumns: true
});
$("#txt_PaymentCurrency_").combogrid({
panelWidth: 500,
panelHeight: 300,
idField: 'Id',
textField: 'UserName',
data: json.Trader,
method: 'get',
delay: 1000,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: 35, //每页显示的记录条数,默认为10
pageList: [35, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表
columns: [[
{ field: 'UserName', title: '名称', 80}]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true, //自
keyHandler: {

query: function (keyword) { //【动态搜索】处理
//设置查询参数
var queryParams = $("#txt_Trader_").combogrid("grid").datagrid('options').queryParams;
queryParams.keyword = keyword;
$("#txt_Trader_").combogrid("grid").datagrid('options').queryParams = queryParams;
//重新加载
$("#txt_Trader_").combogrid("grid").datagrid("reload");
$("#txt_Trader_").combogrid("setValue", keyword);
}
},
mode: 'remote',
fitColumns: true
});
$("#txt_Agreement_").combogrid({
panelWidth: 500,
panelHeight: 300,
idField: 'Id',
textField: 'UserName',
data: json.Trader,
method: 'get',
delay: 1000,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: 35, //每页显示的记录条数,默认为10
pageList: [35, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表
columns: [[
{ field: 'UserName', title: '名称', 80}]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true, //自
keyHandler: {

query: function (keyword) { //【动态搜索】处理
//设置查询参数
var queryParams = $("#txt_Trader_").combogrid("grid").datagrid('options').queryParams;
queryParams.keyword = keyword;
$("#txt_Trader_").combogrid("grid").datagrid('options').queryParams = queryParams;
//重新加载
$("#txt_Trader_").combogrid("grid").datagrid("reload");
$("#txt_Trader_").combogrid("setValue", keyword);
}
},
mode: 'remote',
fitColumns: true
});
$("#txt_BusinessAgent_").combogrid({
panelWidth: 500,
panelHeight: 300,
idField: 'Id',
textField: 'UserName',
data: json.Trader,
method: 'get',
delay: 1000,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: 35, //每页显示的记录条数,默认为10
pageList: [35, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表
columns: [[
{ field: 'UserName', title: '名称', 80}]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true, //自
keyHandler: {

query: function (keyword) { //【动态搜索】处理
//设置查询参数
var queryParams = $("#txt_Trader_").combogrid("grid").datagrid('options').queryParams;
queryParams.keyword = keyword;
$("#txt_Trader_").combogrid("grid").datagrid('options').queryParams = queryParams;
//重新加载
$("#txt_Trader_").combogrid("grid").datagrid("reload");
$("#txt_Trader_").combogrid("setValue", keyword);
}
},
mode: 'remote',
fitColumns: true
});
$("#txt_Agreement_").combogrid({
panelWidth: 500,
panelHeight: 300,
idField: 'Id',
textField: 'UserName',
data: json.Trader,
method: 'get',
delay: 1000,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: 35, //每页显示的记录条数,默认为10
pageList: [35, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表
columns: [[
{ field: 'UserName', title: '名称', 80}]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true, //自
keyHandler: {

query: function (keyword) { //【动态搜索】处理
//设置查询参数
var queryParams = $("#txt_Trader_").combogrid("grid").datagrid('options').queryParams;
queryParams.keyword = keyword;
$("#txt_Trader_").combogrid("grid").datagrid('options').queryParams = queryParams;
//重新加载
$("#txt_Trader_").combogrid("grid").datagrid("reload");
$("#txt_Trader_").combogrid("setValue", keyword);
}
},
mode: 'remote',
fitColumns: true
});

$("#txt_Trader_").combogrid({
panelWidth: 500,
panelHeight: 300,
idField: 'Id',
textField: 'UserName',
data: json.Trader,
method: 'get',
delay: 1000,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: 35, //每页显示的记录条数,默认为10
pageList: [35, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表
columns: [[
{ field: 'UserName', title: '名称', 80}]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true, //自
keyHandler: {

query: function (keyword) { //【动态搜索】处理
//设置查询参数
var queryParams = $("#txt_Trader_").combogrid("grid").datagrid('options').queryParams;
queryParams.keyword = keyword;
$("#txt_Trader_").combogrid("grid").datagrid('options').queryParams = queryParams;
//重新加载
$("#txt_Trader_").combogrid("grid").datagrid("reload");
$("#txt_Trader_").combogrid("setValue", keyword);
}
},
mode: 'remote',
fitColumns: true
});
});


// $("#txt_Trader_").SetCombo({
// entityType: "BasBusinessPerson",
// textField: "UserName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_TraderId_"),
// columns: [[
// { field: 'UserName', title: '名称', 80}]]
// });
// $("#txt_Agreement_").SetCombo({
// entityType: "BasAgreement",
// textField: "AgreementName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_AgreementId_"),
// columns: [[
// { field: 'AgreementName', title: '协议', 100 }]]
// });
// $("#txt_BusinessAgent_").SetCombo({
// entityType: "BasCounterparty",
// textField: "CounterpartyName",
// panelWidth: 500,
// panelHeight: 300,
// idFild: "Id",
// valueControl: $("#txt_BusinessAgentId_"),
// columns: [[
// { field: 'CounterpartyName', title: '对手名', 100 },
// { field: 'CounterpartyCode', title: '编码', 100}]]
// });

}

</script>
</body>
</html>

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using Contract.Domain;
using WebApp.Common;

namespace HraWeb.Common
{
/// <summary>
/// EntityJsonList 的摘要说明
/// </summary>
public class EntityJsonList : BasePage, IHttpHandler, System.Web.SessionState.IRequiresSessionState
{

public PropertyInfo GetProperyInfo(string Name, PropertyInfo[] ps)
{
PropertyInfo p1 = null;
ps.ToList().ForEach(p =>
{
if (p.Name == Name)
{
p1 = p;
}
});
return p1;
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
switch (context.Request["_method"])
{
case "entityTemp":
Dictionary<string,DataGridJson> combodic=new Dictionary<string, DataGridJson>();
string entityTypeTemp = context.Request["entityType"];
info = new Framework.QueryInfo();
info.QueryObject = entityTypeTemp;
if (!string.IsNullOrEmpty(context.Request["where"]))
{
info.Where.Add("kk", " and " + context.Request["where"]);
}

info = Dao.FindByQueryInfo(info);
Type typeTemp = null;
PropertyInfo[] psTemp = null;
if (info.List != null && info.List.Count > 0)
{
typeTemp = info.List[0].GetType();
psTemp = typeTemp.GetProperties();
}


DataGridJson dTemp = new DataGridJson(info.TotalCount, info.List);
combodic.Add("Trader",dTemp);
HttpContext.Current.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(combodic));
break;
case "entity":
string entityType = context.Request["entityType"];
info = new Framework.QueryInfo();
info.QueryObject = entityType;
if (!string.IsNullOrEmpty(context.Request["where"]))
{
info.Where.Add("kk", " and " + context.Request["where"]);
}
var keyword = context.Request["keyword"] ?? string.Empty;
if (!string.IsNullOrEmpty(keyword))
{
Hashtable aa=new Hashtable();
aa.Add(context.Request["queryTextFild"].ToString()+"_LK",keyword);
info.AddParam(aa);
//info.Where.Add("kk2",string.Format(" and {0} like '%:{1}%'", context.Request["queryTextFild"],keyword));
}
info.PageSize = int.Parse(HttpContext.Current.Request["rows"]);
int pageIndex = int.Parse(HttpContext.Current.Request["page"]);
info.StartRecord = (pageIndex - 1) * info.PageSize;
info.TotalCount = 1;
if (!string.IsNullOrEmpty(context.Request.QueryString["queryFild"]))
{
string[] field = context.Request.QueryString["queryFild"].Split(new char[] { '|' });
foreach (string q in field)
{
info.AddParam(q, context.Request.QueryString["q"], string.Format(" and {0} like '%:{0}%'", q));
}
}
info = Dao.FindByQueryInfo(info);
Type type = null;
PropertyInfo[] ps = null;
if (info.List != null && info.List.Count > 0)
{
type = info.List[0].GetType();
ps = type.GetProperties();
}
bool idBoolean = false;
foreach (var b in info.List)
{

PropertyInfo idFieldInfo = GetProperyInfo(context.Request["idFild"], ps);
string IdFieldValue = Convert.ToString(idFieldInfo.GetValue(b, null));
if (!string.IsNullOrEmpty(context.Request["defaultValue"]))
{
if (IdFieldValue.Equals(context.Request["defaultValue"]))
{
idBoolean = true;
break;
}
}
}
//if (!string.IsNullOrEmpty(context.Request["defaultValue"]))
{
Framework.QueryInfo tmpInfo = new Framework.QueryInfo();
tmpInfo.QueryObject = entityType;
if (!string.IsNullOrEmpty(context.Request["idFild"]))
tmpInfo.AddParam(context.Request["idFild"], context.Request["defaultValue"]);
var list = Dao.FindList(tmpInfo);
foreach (object obj in list)
{
if (!idBoolean)
{
info.List.Add(obj);
}
}
}
DataGridJson d = new DataGridJson(info.TotalCount, info.List);
HttpContext.Current.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(d));
break;
case "dict":
var t = GetDictType(context.Request["dictType"]);
IList<SysDict> dictList= Holworth.Utility.Utility.ListToT<SysDict>(t);
//根据关键词使用linq进行二次过滤
var keyword2 = context.Request["keyword"] ?? string.Empty;
if (!string.IsNullOrEmpty(keyword2))
{
dictList = dictList.Where(x => x.Name.Contains(keyword2)).ToList();
}
string ss = Newtonsoft.Json.JsonConvert.SerializeObject(dictList);
context.Response.Write(ss);
break;
case "aa":
var ts = GetDictType(context.Request["dictType"]);
string sss = Newtonsoft.Json.JsonConvert.SerializeObject(ts);
context.Response.Write(sss);
break;
}
}


public bool IsReusable
{
get
{
return false;
}
}
}
}

原文地址:https://www.cnblogs.com/kexb/p/4665819.html