<!-- 获取机会点名称列表 -->
<script>
function initOpportunityNameFuzzyQuery() {
$('#jihuidianmingcheng').combobox({
prompt: '智能查询机会点名称,输入后请空格',
required: false,
mode: 'remote',
url: '/Handler/GetOpportunityNameHandler.ashx',
editable: true,
valueField: 'CrmOppportunity_Name',
textField: 'CrmOppportunity_Name',
hasDownArrow: false,
onBeforeLoad: function (param) {
if (param == null || param.q == null || param.q.replace(/ /g, '') == '') {
var value = $(this).combobox('getValue');
if (value) {// 修改的时候才会出现q为空而value不为空
param.id = value;
return true;
}
return false;
}
}
});
}
</script>
/// <summary>
/// GetOpportunityNameHandler 的摘要说明
/// </summary>
public class GetOpportunityNameHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
StringBuilder result = new StringBuilder();
string headString=context.Request.Form["q"].Trim();
List<string> opportunityCodeList = BLL.CrmOppportunity.GetOpportunityCodeByFuzzySearch(headString);
if(opportunityCodeList.Count>0){
string fengefu = "";
result.Append("[");
foreach (string item in opportunityCodeList)
{
result.Append(fengefu + "{"CrmOppportunity_Code":""+item+""}");
fengefu = ",";
}
result.Append("]");
}
context.Response.Write(result.ToString());
}
/// <summary>
/// 根据公机会点名称字符,模糊搜索机会点名称
/// </summary>
/// <param name="headString">机会点名称字符</param>
public static List<string> GetOpportunityNameByFuzzySearch(string headString)
{
List<string> result = new List<string>();
if (headString.Trim() != "")
{
StringBuilder sql = new StringBuilder();
sql.Append(" select distinct CrmOppportunity_Name from [dbo].[CrmOppportunity] where CrmOppportunity_Name like '%" + headString + "%' order by CrmOppportunity_Name ");
DataTable temp = DbHelperSQL.Query(sql.ToString()).Tables[0];
foreach (DataRow row in temp.Rows)
{
result.Add(row["CrmOppportunity_Name"].ToString());
}
}
return result;
}