Exemplo n.º 1
0
 /// <summary>
 /// 获得记录条数
 /// </summary>
 /// <param name="Cou_ID"></param>
 /// <returns></returns>
 public int GetListCount(int Cou_ID)
 {
     string str = "Cou_ID="+Cou_ID;
     LabMS.BLL.ProCourse bProCourse = new LabMS.BLL.ProCourse();
     List<LabMS.Model.ProCourse> list = new List<LabMS.Model.ProCourse>();
     list=bProCourse.GetModelList(str);
     return list.Count;
 }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                if (string.IsNullOrEmpty(context.Request.QueryString["ID"].ToString()))
                {
                    context.Response.ContentType = "application/json";
                    context.Response.Write("{error: true}");
                }

                string courseID = context.Request.QueryString["ID"];

                LabMS.Model.CourseJson json = new LabMS.Model.CourseJson();
                json.ID = int.Parse(courseID);

                LabMS.BLL.ProCourse BProCourse = new LabMS.BLL.ProCourse();
                ExtendBLL.Class eClass = new ExtendBLL.Class();

                List<LabMS.Model.ProCourse> listPC = new List<LabMS.Model.ProCourse>();
                listPC = BProCourse.GetModelList("Cou_ID=" + courseID);

                foreach (LabMS.Model.ProCourse proCourse in listPC)
                {
                    LabMS.Model.MajorJson major = new LabMS.Model.MajorJson();
                    major.ID = proCourse.ProID.Value;
                    major.Name = eClass.ProessionalNameByID(major.ID);

                    json.Majors.Add(major);
                }

                string strJson = Newtonsoft.Json.JavaScriptConvert.SerializeObject(json);//序列化,把JSON转化为string类型

                context.Response.ContentType = "application/json";
                context.Response.Write(strJson);

                /*
                System.Text.StringBuilder sb = new System.Text.StringBuilder();

                sb.Append("{Majors: [");
                //sb.Append("{");
                //sb.Append("ID: ");
                //JSON格式为:{Majors:[{ID:1231,Name:'sfsds'},{ID:1111,Name:'lkjo'}]}
                for (int i = 0; i < listPC.Count; i++)
                {
                    int Pid = int.Parse(listPC[i].ProID.Value.ToString());
                    string PName = eClass.ProessionalNameByID(Pid);

                    sb.Append("{");
                    sb.Append("ID: ");
                    sb.Append(Pid);
                    sb.Append(",");
                    sb.Append("Name: ");
                    sb.Append(PName);
                    if (i != listPC.Count - 1)
                    {
                        sb.Append(",");
                    }
                    else
                    {
                        sb.Append("}");
                        sb.Append("]");
                        sb.Append("}");
                    }
                }

                //sb.Append("'1231'");
                //sb.Append(",");
                //sb.Append("Name: ");
                //sb.Append("'sfsds'");
                //sb.Append("}");

                //sb.Append(",");

                //sb.Append("{");
                //sb.Append("ID: ");
                //sb.Append("'1111'");
                //sb.Append(",");
                //sb.Append("Name: ");
                //sb.Append("'lkjo'");
                //sb.Append("}");

                //sb.Append("]}");

                context.Response.ContentType = "application/json";
                context.Response.Write(sb.ToString()); //返回值*/
            }
            catch
            {
                context.Response.ContentType = "application/json";
                context.Response.Write("{error: true}");
            }
        }