DS7/DSWeb/FeeCodes/InfoShipperAdapter.aspx.cs

120 lines
4.2 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;
namespace DSWeb.FeeCodes
{
public partial class InfoShipperAdapter : System.Web.UI.Page
{
private string strMark;
private string strPos;
private int iPos = 0;
public int iShippertype = 0;
public string strCODENAME = String.Empty;
public string strSHORTNAME = String.Empty;
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["shippertype"] != null)
{
iShippertype = int.Parse(Request.QueryString["shippertype"].ToString());
}
if (Request.QueryString["CODENAME"] != null)
{
strCODENAME = Request.QueryString["CODENAME"].ToString();
}
if (Request.QueryString["SHORTNAME"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strSHORTNAME = unicode.GetString(unicode.GetBytes(Request.QueryString["SHORTNAME"].ToString()));
}
XmlDocument docs = GetDoc();
Response.ContentType = "text/xml";
Response.Write(docs.OuterXml.ToString());
}
}
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 js = "";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
if ((strCODENAME == "" || strCODENAME == "null") && strSHORTNAME!="")
{
DataSet dss = T_ALL_DA.GetInfoClient(" and SHORTNAME='" + strSHORTNAME + "' and ISSTOP='False'");
if (dss != null)
{
strCODENAME = dss.Tables[0].Rows[0]["CODENAME"].ToString().Trim();
}
}
//
js = " and (CODENAME='" + strCODENAME + "' or ISPUBLIC=1) and Shippertype=" + iShippertype;
DataSet ds = T_ALL_DA.GetInfoShipperSQL(js);
if (ds != null)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["shipperID"].ToString().Trim() != "" || dr["SHORTNAME"].ToString().Trim() != "")
{
js = dr["shipperID"].ToString().Trim() + " | " + dr["SHORTNAME"].ToString().Trim();
resultBuilder.AppendFormat("<option value=\"{0}\">{1}</option>", dr["shipperID"].ToString().Trim(), js);//dr["SHORTNAME"].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;
}
}
}