凌寒飘香

____成风破浪会有时,直把云帆济沧海!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

        function onNodeClick(data) {
            //只能选择体检分组
            if (data.GroupType == 1) {
                $("#<%=hidOrgId.ClientID%>").val(data.Id);
                $("#<%=hidOrgName.ClientID%>").val(data.Text);
                $("#<%=txtGroup.ClientID%>").val(data.Text);
                $("#divCheckUpTree").dialog("close");


                $("#<%=ddlDrs.ClientID %>").html("");
                var url = "AjaxHelper.ashx?validatorType=GetDoctorByOrgId&orgID=" + data.Id;
                $.getJSON(url, function (json) {
                    //debugger
                    if (json != null) {
                        $.each(json, function (i) {
                            $("#<%=ddlDrs.ClientID %>").append($("<option></option>").val(json[i].DrID).html(json[i].DrName))
                        });
                    }

                });

                $("#<%=ddlDrs.ClientID %>").append($("<option selected='true'></option>").val("-1").html("请选择"))
//                $("<option></option>").val("").html("").appendTo("#<%=ddlDrs.ClientID %>");

            }
        }

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Xys.Remp.Enterprise.Services.Interface;
using Xys.Remp.Enterprise.Entity;
using Xys.Remp.Core;
using Xys.Remp.Security;
using System.Web.SessionState;
using Xys.Remp.Enterprise.Common;
using RempWeb = Xys.Remp.Web;
using System.Text;
using Xys.Remp.Serialize.Json;
namespace Xys.Stroke.Web.Archives
{
    public class AjaxHelper : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            string validatorType = RempWeb.ComUtils.GetQueryStringToString("validatorType");
            if (validatorType != string.Empty)
            {
                if (validatorType == "GetDoctorByOrgId")
                {
                    int? orgID = RempWeb.ComUtils.GetQueryStringToInt("orgID");
                    if (orgID.HasValue)
                    {
                        OrganizationInfo orgInfo = ServiceFactory.GetService<IOpenOrganizationService>().GetFirstParentOrgByGroupId((int)orgID);
                        if (orgInfo != null)
                        {
                            List<DoctorInfo> doctorList = ServiceFactory.GetService<IOpenDoctorService>().GetDoctorListAndUnderByOrgId((int)orgInfo.OrgID, true);
                            if (doctorList.Count > 0)
                            {
                                //StringBuilder sb = new StringBuilder();
                                //sb.Append("[");
                                //foreach (DoctorInfo doctor in doctorList)
                                //{
                                //    sb.Append("{\"ID\":\"" + doctor.ID + "\",\"Name\":\"" + doctor.DrName + "\"},");
                                //}

                                //sb.Remove(sb.Length - 1, 1);
                                //sb.Append("]");
                               
                                ResponseValidatorValue(context,doctorList.JsonSerialize());
                            }
                            else
                            {
                                ResponseValidatorValue(context, "");
                            }
                        }
                    }
                }
                //else if (validatorType == "")
                //{
                //}

            }
        }

        public void ResponseValidatorValue(HttpContext context, string validatorValue)
        {
            context.Response.Expires = 0;
            context.Response.Buffer = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.CacheControl = "no-cache";
            context.Response.ClearContent();
            context.Response.ContentType = ("text/plain");
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.Write(validatorValue);
            context.Response.Flush();
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

posted on 2014-02-10 16:12  凌寒飘香  阅读(448)  评论(0编辑  收藏  举报