protected void InitBind(int ID) { LabMS.BLL.Student BStudent = new LabMS.BLL.Student(); List<LabMS.Model.Student> list = new List<LabMS.Model.Student>(); list = BStudent.GetModelList("ID="+ID); textboxCode.Text = list[0].Student_Code; textboxName.Text = list[0].Student_Name; ddlSex.SelectedValue = list[0].Student_Sex;//性别 ddlLJ.SelectedValue = list[0].Student_Grade;//年级 ExtendBLL.Class EClass = new ExtendBLL.Class(); if (list[0].Student_Pro!= null&&!string.IsNullOrEmpty(list[0].Student_Pro.Value.ToString())) { textboxMajor.Text = EClass.ProessionalNameByID(int.Parse(list[0].Student_Pro.Value.ToString()));//专业 } if (list[0].ClassID!=null&&!string.IsNullOrEmpty(list[0].ClassID.Value.ToString())) { textboxClass.Text = EClass.GetClassNameByClassID(int.Parse(list[0].ClassID.Value.ToString()));//班级 } if (list[0].Student_EntryDate != null) { tbRXLY.Text = list[0].Student_EntryDate.Value.ToShortDateString(); } tbSum.Text = list[0].Student_Summary; //if (!string.IsNullOrEmpty(list[0].Student_Photo.ToString())) //{ // imgStudent.ImageUrl = list[0].Student_Photo.ToString(); //} }
protected void InitBindFromDB(int ID) { LabMS.BLL.Class BC = new LabMS.BLL.Class(); LabMS.Model.Class MC = new LabMS.Model.Class(); MC = BC.GetModel(ID); tbClassName.Text = MC.Class_Name; tbClassNumber.Text = MC.Class_Code;//班号 ddlClass.SelectedValue = MC.Class_Year; tbNum.Text = MC.Class_StudentNum.Value.ToString(); tb.Text = MC.Class_Professional.Value.ToString();//专业代号 ExtendBLL.Class EC = new ExtendBLL.Class(); tbClassMajor.Text=EC.ProessionalNameByID(int.Parse(tb.Text.Trim())); }
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}"); } }
/// <summary> /// 处理绑定数据 /// </summary> /// <param name="ds"></param> /// <returns></returns> protected DataSet HandleDS(DataSet ds) { //构造: 性别Sex 班级名称ClassName 专业名称ProName 三列 ds.Tables[0].Columns.Add("Sex"); ds.Tables[0].Columns.Add("ClassName"); ds.Tables[0].Columns.Add("ProName"); ExtendBLL.Dictionary EDictionary = new ExtendBLL.Dictionary(); ExtendBLL.Class EClass = new ExtendBLL.Class(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string Student_Sex = ds.Tables[0].Rows[i]["Student_Sex"].ToString(); if (!string.IsNullOrEmpty(Student_Sex)) { string str = "DClass='201' and Code='" + Student_Sex + "'"; ds.Tables[0].Rows[i]["Sex"] = EDictionary.GetModelList(str)[0].Name.ToString(); } if (!string.IsNullOrEmpty(ds.Tables[0].Rows[i]["ClassID"].ToString())) { int ClassID = int.Parse(ds.Tables[0].Rows[i]["ClassID"].ToString()); ds.Tables[0].Rows[i]["ClassName"] = EClass.GetClassNameByClassID(ClassID); } if (!string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Student_Pro"].ToString())) { int Student_Pro = int.Parse(ds.Tables[0].Rows[i]["Student_Pro"].ToString()); ds.Tables[0].Rows[i]["ProName"] = EClass.ProessionalNameByID(Student_Pro); } } return ds; }