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 TopCtnAdapter : System.Web.UI.Page { private string strMark; private string strPos; private int iPos = 0; public string strPortName = ""; 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["ddl"] != null) { string strddl = Request.QueryString["ddl"].ToString(); XmlDocument docs = BuildXML(); Response.ContentType = "text/xml"; Response.Write(docs.OuterXml.ToString()); //return; } if (Request.QueryString["cntr"] != null) { //string strCNTR = Request.QueryString["cntr"].ToString(); Response.Write(getCNTR()); //return; } if (Request.QueryString["ctn"] != null) { string strCTN = Request.QueryString["ctn"].ToString(); Response.Write(getCTN(strCTN)); //return; } if (Request.QueryString["kindpkgs"] != null) { string strKINDPKGS = Request.QueryString["kindpkgs"].ToString(); Response.Write(getKINDPKGS(strKINDPKGS)); //return; } //Response.Write(""); } } public string getCNTR() { CodeCtnDispDA CodeCtnDispDA = new CodeCtnDispDA(); CodeCtnDispEntity CodeCtnDispEntity = new CodeCtnDispEntity(); CodeCtnDispEntity = CodeCtnDispDA.GetAllCodeCtnDisp(); StringBuilder ctnBuilder = new StringBuilder(); if (CodeCtnDispEntity != null) { #region //if (CodeCtnDispEntity.CTN1.Trim().Equals("null") || CodeCtnDispEntity.CTN1.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN1.Trim()+"&&"; //} //// //if (CodeCtnDispEntity.CTN2.Trim().Equals("null") || CodeCtnDispEntity.CTN2.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN2.Trim() + "&&"; //} //// //if (CodeCtnDispEntity.CTN3.Trim().Equals("null") || CodeCtnDispEntity.CTN3.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN3.Trim() + "&&"; //} //// //if (CodeCtnDispEntity.CTN4==null || CodeCtnDispEntity.CTN4.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN4.Trim() + "&&"; //} //// //if (CodeCtnDispEntity.CTN5 == null || CodeCtnDispEntity.CTN5.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN5.Trim() + "&&"; //} //// //if (CodeCtnDispEntity.CTN6 == null || CodeCtnDispEntity.CTN6.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN6.Trim() + "&&"; //} //// //if (CodeCtnDispEntity.CTN7 == null || CodeCtnDispEntity.CTN7.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN7.Trim() + "&&"; //} //// //if (CodeCtnDispEntity.CTN8 == null || CodeCtnDispEntity.CTN8.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN8.Trim() + "&&"; //} //// //if (CodeCtnDispEntity.CTN9 == null || CodeCtnDispEntity.CTN9.Trim().Equals("")) //{ // strPortName += "0&&"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN9.Trim() + "&&"; //} //// //if (CodeCtnDispEntity.CTN10 == null || CodeCtnDispEntity.CTN10.Trim().Equals("")) //{ // strPortName += "0"; //} //else //{ // strPortName += CodeCtnDispEntity.CTN10.Trim(); //} #endregion if (CodeCtnDispEntity.ID != null) { ctnBuilder.Append("{"); ctnBuilder.Append("\"ctns\":"); ctnBuilder.Append("["); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN1 == null ? "" : CodeCtnDispEntity.CTN1) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN2 == null ? "" : CodeCtnDispEntity.CTN2) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN3 == null ? "" : CodeCtnDispEntity.CTN3) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN4 == null ? "" : CodeCtnDispEntity.CTN4) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN5 == null ? "" : CodeCtnDispEntity.CTN5) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN6 == null ? "" : CodeCtnDispEntity.CTN6) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN7 == null ? "" : CodeCtnDispEntity.CTN7) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN8 == null ? "" : CodeCtnDispEntity.CTN8) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN9 == null ? "" : CodeCtnDispEntity.CTN9) + "\"},"); ctnBuilder.Append("{\"ctn\":\"" + (CodeCtnDispEntity.CTN10 == null ? "" : CodeCtnDispEntity.CTN10) + "\"}"); ctnBuilder.Append("]"); ctnBuilder.Append("}"); } else { ctnBuilder.Append("{"); ctnBuilder.Append("\"ctns\":"); ctnBuilder.Append("["); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"},"); ctnBuilder.Append("{\"ctn\":\"\"}"); ctnBuilder.Append("]"); ctnBuilder.Append("}"); } } return ctnBuilder.ToString(); } public string getCTN(string strCTN) { T_ALL_DA T_ALL_DA = new T_ALL_DA(); strPortName = T_ALL_DA.GetStrSQL("ctn", "select ctn from code_ctn where ctn='" + strCTN + "' or EDICODE='" + strCTN + "'"); return strPortName; } public string getKINDPKGS(string strKINDPKGS) { T_ALL_DA T_ALL_DA = new T_ALL_DA(); strPortName = T_ALL_DA.GetStrSQL("PKGS", "select * from code_package where PKGS='" + strKINDPKGS + "' order by PKGS"); return strPortName; } public XmlDocument BuildXML() { StringBuilder resultBuilder = new StringBuilder(); resultBuilder.Append(""); resultBuilder.AppendFormat("", iPos == 0 ? string.Empty : " add=\"true\""); if (!string.IsNullOrEmpty(strMark)) { T_ALL_DA T_ALL_DA = new T_ALL_DA(); DataSet ds = T_ALL_DA.GetTCodeCtn(); if (ds != null) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["CTN"].ToString().Trim() != "") { resultBuilder.AppendFormat("", dr["CTN"].ToString().Trim(), dr["CTN"].ToString().Trim()); } } } } resultBuilder.AppendFormat("", "", ""); resultBuilder.Append(""); XmlDocument xmldoc = new XmlDocument(); try { xmldoc.LoadXml(resultBuilder.ToString().Replace("&", "&")); } catch (Exception) { } return xmldoc; } } }