You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/FeeCodes/TCodeDisportAdapter2.aspx.cs

141 lines
4.7 KiB
C#

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Xml;
using DSWeb.Models;
using DSWeb.EntityDA;
using WebSqlHelper;
namespace DSWeb.FeeCodes
{
public partial class TCodeDisportAdapter2 : System.Web.UI.Page
{
private string strMark;
private string strPos;
private int iPos = 0;
private string strPortName = "";
private string strSel="";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strPost = Request.Url.ToString();
if (Request.QueryString["mask"] != null)
{
strMark = Request.QueryString["mask"].ToString();
}
if (Request.QueryString["pos"] != null)
{
strPos = Request.QueryString["pos"].ToString();
iPos = int.Parse(strPos);
}
if (Request.QueryString["strSel"] != null)
{
strSel = Request.QueryString["strSel"].ToString();
}
if (Request.QueryString["port"] != null)
{
string strPORT = Request.QueryString["port"].ToString();
getlanegid(strPORT);
return;
}
if (Request.QueryString["edicode"] != null)
{
string strPORT = Request.QueryString["edicode"].ToString();
getedicode(strPORT);
return;
}
XmlDocument docs = GetDoc();
Response.ContentType = "text/xml";
Response.Write(docs.OuterXml.ToString());
}
}
protected void getedicode(string strPORT)
{
strPortName = "";
if (strPORT != "" && strPORT != "null")
{
strPortName = T_ALL_DA.GetStrSQL("EDICODE", "SELECT EDICODE FROM code_disport where PORT = '" + strPORT + "'");
}
Response.Write(strPortName);
}
protected void getlanegid(string strPORT)
{
strPortName = "";
if (strPORT != "" && strPORT != "null")
{
strPortName = T_ALL_DA.GetStrSQL("LANE", "SELECT code_lanes.LANE FROM code_lanes INNER JOIN code_disport ON code_lanes.GID = code_disport.LANEGID WHERE (code_disport.PORT = '" + strPORT + "')");
}
Response.Write(strPortName);
}
public string BuildXML()
{
StringBuilder resultBuilder = new StringBuilder();
resultBuilder.Append("<?xml version=\"1.0\" ?>");
resultBuilder.AppendFormat("<complete{0}>", iPos == 0 ? string.Empty : " add=\"true\"");
if (!string.IsNullOrEmpty(strMark))
{
string str="";
if (strSel == "")
{
str = "select top 50 * from code_disport order by PORT";
}
else
{
str = "select * from code_disport where PORT like '" + strSel + "%' order by PORT";
}
DataTable dt = BaseClass.db.GetSqlStrTable(str);
foreach (DataRow dr in dt.Rows)
{
if (dr["PORT"].ToString().Trim() != "")
{
resultBuilder.AppendFormat("<option value=\"{0}\">{1}</option>", dr["PORTID"].ToString().Trim(), dr["PORT"].ToString().Trim());
// resultBuilder.AppendFormat("<option value=\"{0}\">{1}</option>", dr["PORTID"].ToString().Trim(), dr["PORT"].ToString().Trim() + "-" + dr["cname"].ToString().Trim());
}
}
}
resultBuilder.AppendFormat("<option value=\"{0}\">{1}</option>", "", "");
resultBuilder.Append("</complete>");
return resultBuilder.ToString().Replace("&", "&amp;");
}
public XmlDocument GetDoc()
{
XmlDocument xmldoc = new XmlDocument();
string content = BuildXML();
try
{
xmldoc.LoadXml(content);
}
catch (Exception)
{
}
return xmldoc;
}
}
}