using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
//********************************************************
//创建日期: 2009-03-10
//作 者: Oloen
//內容说明: 自动完成后台查询页面
// Type:pssale 合同查询
// Type:psunit 房间查询
//********************************************************
///
/// 自动完成后台查询页面
/// public partial class Common_AutoComplete : System.Web.UI.Page
{
const string tbStyle = @"color:#F7922E""";
///
/// 过滤条件
/// string Filter = string.Empty;
///
/// 查询值
/// string InputValue = string.Empty;
///
/// 自动完成类别
/// Type:pssale 合同查询
/// Type:psunit 房间查询
/// string Type = string.Empty;
///
/// 返回结果字符
/// string ReturnStr = string.Empty;
private void Page_Load(object sender, System.EventArgs e)
{
switch (Type.ToLower())
{
case "pssale":
case "psunit":
default:
AutoPSUnitNo();
break;
}
Response.Clear();
Response.ContentType = "text/xml";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.Write(ReturnStr);
Response.End();
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Filter = Request.QueryString["Filter"] ?? "1=1";
InputValue = Request.QueryString["InputValue"] ?? "";
InputValue.Replace("'","''");
Type = Request.QueryString["Type"] ?? "";
}
///
/// 售楼系统房间编号自动完成
/// void AutoPSUnitNo()
{
if (!string.IsNullOrEmpty(InputValue))
{
ReturnStr = @"
";
string Sql = string.Format(@"SELECT TOP 10 UnitID,UnitNo,ProjectNo,PhaseNo,BlockNo FROM View_PS_Unit WHERE UnitNo LIKE '%{0}%' AND {1}", InputValue, Filter);
if (Type.ToLower().Equals("pssale"))
Sql = string.Format(@"SELECT TOP 10 SaleID,UnitID,UnitNo,ContractNo,Name,SaleDate,SellingPrice,ProjectNo FROM View_PS_Sale_Unit WHERE UnitNo LIKE '%{0}%' AND {1}", InputValue, Filter);
using (SqlDataReader sdr = DataAccessHelper.ExecuteReader(Sql) as SqlDataReader)
{
if (sdr == null || !sdr.HasRows)
{
ReturnStr = string.Empty;
return;
}
while (sdr.Read())
{
string td = string.Format(@"{0} | ", sdr["ProjectNo"].ToString());
//td += string.Format(@"{0} | ", sdr["PhaseNo"].ToString());
//td += string.Format(@"{0} | ", sdr["BlockNo"].ToString());
td += string.Format(@"{0} | ", sdr["UnitNo"].ToString(), tbStyle);
if (Type.ToLower().Equals("pssale"))
{
ReturnStr += string.Format(@"{7}
",
sdr["SaleID"].ToString(), sdr["UnitID"].ToString(),
sdr["UnitNo"].ToString(), sdr["ContractNo"].ToString(),
sdr["Name"].ToString(), sdr["SaleDate"].ToString(),
sdr["SellingPrice"].ToString(), td);
}
else
ReturnStr += string.Format(@"{2}
", sdr["UnitID"].ToString(), sdr["UnitNo"].ToString(), td);
}
}
ReturnStr += @"
";
}
}
}