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(); //} }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Save_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbClassNumber.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "班号不能为空!"); tbClassNumber.Focus(); } else if (string.IsNullOrEmpty(tbClassName.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "班级名称不能为空!"); tbClassName.Focus(); } else if (string.IsNullOrEmpty(tbNum.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "班级人数不能为空!"); tbNum.Focus(); } else if (string.IsNullOrEmpty(tbClassMajor.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "所属专业不能为空!"); tbClassMajor.Focus(); } else { LabMS.Model.Class cclass = new LabMS.Model.Class(); ExtendBLL.Class extendclass = new ExtendBLL.Class(); if(extendclass.IsExistClass(tbClassNumber.Text.Trim())==1) { Common.JShelper.JSAlert(this.Page,"","该班级编号已经存在!"); tbClassNumber.Text=""; tbClassNumber.Focus(); } else { cclass.Class_Professional =int.Parse(tb.Text.Trim());//专业 cclass.Class_Code = tbClassNumber.Text.Trim();//班级编号 cclass.Class_Name = tbClassName.Text.Trim();//班级名称 cclass.Class_Year = ddlClass.SelectedValue;//年级 cclass.Class_StudentNum =int.Parse(tbNum.Text.Trim());//人数 int a=extendclass.Add(cclass); if (a > 0) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('新增成功!');window.opener.location.href=window.opener.location.href;self.close();</script>"); } else { Common.JShelper.JSAlert(this.Page,"","新增失败!"); } } } }
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())); }
//获取班级列表 protected DataSet GetClassList(string Week, int WeekDay, int Lession, int LocationID) { ExtendBLL.Class cla = new ExtendBLL.Class(); DataSet ds = new DataSet(); ds = cla.GetClassInfoByArrangement(Week, WeekDay, Lession, LocationID); return ds; }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Save_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbClassNumber.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "班号不能为空!"); tbClassNumber.Focus(); } else if (string.IsNullOrEmpty(tbClassName.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "班级名称不能为空!"); tbClassName.Focus(); } else if (string.IsNullOrEmpty(tbNum.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "班级人数不能为空!"); tbNum.Focus(); } else if (string.IsNullOrEmpty(tbClassMajor.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "所属专业不能为空!"); tbClassMajor.Focus(); } else { LabMS.Model.Class cclass = new LabMS.Model.Class(); ExtendBLL.Class extendclass = new ExtendBLL.Class(); cclass.Class_Professional = int.Parse(tb.Text.Trim());//专业 cclass.Class_Code = tbClassNumber.Text.Trim();//班级编号 cclass.Class_Name = tbClassName.Text.Trim();//班级名称 cclass.Class_Year = ddlClass.SelectedValue;//年级 cclass.Class_StudentNum = int.Parse(tbNum.Text.Trim());//人数 cclass.ID = int.Parse(Request.QueryString["ID"].ToString()); try { extendclass.Update(cclass); Common.JShelper.JSAlertAndRedirect(this.Page, "", "更新成功!", "ClassData.aspx"); } catch { Common.JShelper.JSAlert(this.Page, "", "更新失败!"); } } }
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; }