using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; 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 DSWeb.Models; using DSWeb.EntityDA; using System.Text; namespace DSWeb.FeeCodes { public partial class FeeCodeCtnService : System.Web.UI.Page { private string strHandle; private string strUserID;//操作人GID private string strBSNO;//委托编号 protected void Page_Load(object sender, EventArgs e) { if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString(); } if (Request.QueryString["handle"] != null) { strHandle = Request.QueryString["handle"].ToString().Trim().ToLower(); } if (Request.QueryString["bsno"] != null) { strBSNO = Request.QueryString["bsno"].ToString(); } if (strHandle != null) { if (strHandle == "getctnunit" && strBSNO != null) { //获取海运出口委托集装箱信息,返回JSON数据源 Response.Write(GetOpSeaeCtnInfo(strBSNO)); } if (strHandle == "getcrmctn" && strBSNO != null) { Response.Write(GetCrmCtnInfo(strBSNO)); } if(strHandle == "getallctn") { Response.Write(getAllCtn()); } } } #region 获取销售订舱集装箱信息 /// /// 获取销售订舱集装箱信息 /// /// 销售订舱BSNO /// 返回JSON集装箱数据集 private string GetCrmCtnInfo(string tempBSNO) { //获取销售订舱相关的集装箱信息 IList crmSeaeOrderCtnEntities = new List(); CrmSeaeorderctnDA crmSeaeorderctnDA = new CrmSeaeorderctnDA(); crmSeaeOrderCtnEntities = crmSeaeorderctnDA.GetCrmSeaeOrderCtnByOrdNo(tempBSNO); StringBuilder sourceBuilder = new StringBuilder(); StringBuilder itemBuilder = new StringBuilder(); sourceBuilder.Append("{"); sourceBuilder.Append("ctns:["); if (crmSeaeOrderCtnEntities.Count > 0) { foreach (CrmSeaeorderctnEntity crmCtnEntity in crmSeaeOrderCtnEntities) { itemBuilder.Append("{name:\"" + crmCtnEntity.CTNALL + "\","); itemBuilder.Append("num:" + crmCtnEntity.CTNNUM + ""); itemBuilder.Append("},"); } if (itemBuilder.ToString().EndsWith(",")) { sourceBuilder.Append(itemBuilder.ToString().Trim().Substring(0, itemBuilder.ToString().Trim().Length - 1)); } else { sourceBuilder.Append(itemBuilder.ToString()); } } else { itemBuilder.Append("{name:\"\","); itemBuilder.Append("num:0"); itemBuilder.Append("}"); } sourceBuilder.Append("]"); sourceBuilder.Append("}"); return sourceBuilder.ToString(); } #endregion #region 根据BSNO获取海运出口委托集装箱(op_ctn)信息,返回JSON数据源 /// /// 根据BSNO获取海运出口委托集装箱(op_ctn)信息,返回JSON数据源 /// /// 委托BSNO /// 返回JSON数据源 private string GetOpSeaeCtnInfo(string tempBSNO) { //获取委托相关的集装箱信息,根据BSNO获取op_ctn信息TopCtnEntity集 IList topCtnEntities = new List(); TopCtnDA topCtnDA = new TopCtnDA(); topCtnEntities = topCtnDA.GetID(tempBSNO); StringBuilder sourceBuilder = new StringBuilder(); StringBuilder itemBuilder = new StringBuilder(); sourceBuilder.Append("{"); sourceBuilder.Append("ctns:["); if (topCtnEntities.Count > 0) { foreach (TopCtnEntity ctnEntity in topCtnEntities) { itemBuilder.Append("{name:\"" + ctnEntity.CTNALL + "\","); itemBuilder.Append("num:" + ctnEntity.CTNNUM + ""); itemBuilder.Append("},"); } if (itemBuilder.ToString().EndsWith(",")) { sourceBuilder.Append(itemBuilder.ToString().Trim().Substring(0, itemBuilder.ToString().Trim().Length - 1)); } else { sourceBuilder.Append(itemBuilder.ToString()); } } else { itemBuilder.Append("{name:\"\","); itemBuilder.Append("num:0"); itemBuilder.Append("}"); } sourceBuilder.Append("]"); sourceBuilder.Append("}"); return sourceBuilder.ToString(); } #endregion /// /// 获取所有集装箱型信息 /// /// 返回所有集装箱型号 private string getAllCtn() { IList codeCtnSetEntities = new List(); CodeCtnSetDA codeCtnSetDA = new CodeCtnSetDA(); codeCtnSetEntities = codeCtnSetDA.GetAllCodeCtnSet(); StringBuilder sourceBuilder = new StringBuilder(); StringBuilder itemBuilder = new StringBuilder(); sourceBuilder.Append("{"); sourceBuilder.Append("ctns:["); if (codeCtnSetEntities.Count > 0) { foreach (CodeCtnSetEntity codeCtnSetEntity in codeCtnSetEntities) { itemBuilder.Append("{name:\"" + codeCtnSetEntity.CTN + "\""); itemBuilder.Append("},"); } if (itemBuilder.ToString().EndsWith(",")) { sourceBuilder.Append(itemBuilder.ToString().Trim().Substring(0, itemBuilder.ToString().Trim().Length - 1)); } else { sourceBuilder.Append(itemBuilder.ToString()); } } else { itemBuilder.Append("{name:\"\""); itemBuilder.Append("}"); } sourceBuilder.Append("]"); sourceBuilder.Append("}"); return sourceBuilder.ToString(); } } }