//绑定数据 protected void BindData(int ID) { LabMS.Model.ClassItem model = new LabMS.Model.ClassItem(); LabMS.BLL.Course course = new LabMS.BLL.Course(); LabMS.Model.Course courseModel = new LabMS.Model.Course(); courseModel = course.GetModel(ID); model = GetClassName(ID); CourseCodeTBX.Text = courseModel.Course_Code; CourseNameTBX.Text = courseModel.Course_Name; ProjectName.Text = courseModel.Professional;//专业 ClassTBX.Text = model.ClassItem_Name;//班级 SumTBX.Text = model.ClassItem_Num.ToString();//总人数 if (SubjectDDL.SelectedValue != "") { ExprientHouseTBX.Text = GetExHourByProID(int.Parse(SubjectDDL.SelectedValue));//实验学时 TeacherTBX.Text = GetTeacherByClaIDAndProIDAndCouID(int.Parse(IDHF.Value), int.Parse(SubjectDDL.SelectedValue), int.Parse(ClassDDL.SelectedValue));//授课教师 } }
protected void Save_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tb_CourseCode.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "�γ̱�Ų���Ϊ��"); return; } if (string.IsNullOrEmpty(tb_CourseName.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "�γ�������Ϊ��"); return; } if (ddl_Lab.SelectedValue == "0") { LabMS.Common.JShelper.JSAlert(this, "error", "��ѡ��е��γ̵�ʵ����"); return; } if (string.IsNullOrEmpty(tb_ExpHouse.Text)) { LabMS.Common.JShelper.JSAlert(this, "error", " ʵ��ѧʱ����Ϊ��"); return; } if (string.IsNullOrEmpty(tb_StartWeek.Text)) { LabMS.Common.JShelper.JSAlert(this, "error", "��ʼ�ܴβ���Ϊ����ӦΪ����"); return; } if (!IsNumber(tb_StartWeek.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "��ʼ�ܴβ���Ϊ����ӦΪ����"); return; } if (!IsNumber(tb_EndWeek.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "�����ܴβ���Ϊ����ӦΪ����"); return; } int Num1 = 0; int Num2 = 0; if (int.TryParse(tb_StartWeek.Text, out Num1) && int.TryParse(tb_EndWeek.Text, out Num2)) { if (Num2 < Num1) { LabMS.Common.JShelper.JSAlert(this, "error", "��ʼ�ܴδ��ڽ����ܴ�"); return; } } else { LabMS.Common.JShelper.JSAlert(this, "error", "�ܴβ���Ϊ�գ���Ӧ��Ϊ����"); return; } if (!IsNumber(tb_ComputerTime.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "�ϻ�����Ϊ����ӦΪ����"); return; } if (string.IsNullOrEmpty(tb_Teacher.Text)) { LabMS.Common.JShelper.JSAlert(this, "error", "��ʦ����Ϊ����ӦΪ����"); return; } if (!(Gv_Class.Rows.Count > 0)) { LabMS.Common.JShelper.JSAlert(this, "error", "��ѡ��γ̶�Ӧ�İ༶"); return; } LabMS.BLL.TeachMission TeachMission = new LabMS.BLL.TeachMission(); LabMS.Model.TeachMission model = new LabMS.Model.TeachMission(); model.LabID = Convert.ToInt32(ddl_Lab.SelectedValue.Trim()); model.Ms_CourseCode = (tb_CourseCode.Text); model.Ms_CourseName = tb_CourseName.Text; model.Ms_SubmitTime = DateTime.Now; model.Ms_Teacher = Convert.ToInt32(tb_TeacherID.Text); model.Ms_Conflict = rbl_Conflict.SelectedValue.Trim(); model.Ms_StartWeek = Convert.ToInt32(tb_StartWeek.Text.Trim().ToString()); model.Ms_EndWeek = Convert.ToInt32(tb_EndWeek.Text.Trim().ToString()); model.Ms_CourseHourse = Convert.ToInt32(tb_ExpHouse.Text.Trim()); model.Ms_ComputerHourse = Convert.ToInt32(tb_ComputerTime.Text.Trim()); model.Ms_Year = ddl_Year.SelectedValue; model.Ms_Term = ddl_Season.SelectedValue; int ID = TeachMission.Add(model); string[] array = tb_ClassIDs.Text.Split(','); List<string> lsIDs = new List<string>(); lsIDs.Add(array[0]); foreach (string item in array) { int Count = 0; foreach (string Pr in lsIDs) { if (item != Pr) { Count++; } } if (Count == lsIDs.Count) { lsIDs.Add(item); } } ///�����༶��ѡ�ΰ༶ �Ϳγ̵����� ///\ /// int CourseID = int.Parse(tb_CourseID.Text.Trim()); LabMS.BLL.ClassItem ClassItem = new LabMS.BLL.ClassItem(); LabMS.BLL.Class Class = new LabMS.BLL.Class(); LabMS.Model.Class classModel; LabMS.Model.ClassItem classItemModel; for (int n = 0; n < lsIDs.Count; n++) { classModel = Class.GetModel(Convert.ToInt32(lsIDs[n])); classItemModel = new LabMS.Model.ClassItem(); classItemModel.CourseID = CourseID; classItemModel.ClassItem_Code = classModel.Class_Code; classItemModel.ClassItem_Name = classModel.Class_Name; classItemModel.ClassItem_Num = classModel.Class_StudentNum; classItemModel.ClassItem_Degree = classModel.Class_Year; classItemModel.ClassID = Convert.ToInt32(lsIDs[n]); classItemModel.Time = DateTime.Now; classItemModel.TeachMissionID = ID; int classItemModelID = ClassItem.Add(classItemModel); } //������ʦ�Ϳγ�֮�����ϵ /// ��ʦ��ѡ�� /// LabMS.BLL.TeacherCourse TC = new LabMS.BLL.TeacherCourse(); LabMS.Model.TeacherCourse Model = new LabMS.Model.TeacherCourse(); Model.CourseID = CourseID; Model.TeacherID = Convert.ToInt32(tb_TeacherID.Text.Trim()); int temID = TC.Add(Model); Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('����ɹ���');if(window.confirm('�Ƿ��б�ҳ�棿')){window.location.href='TeachingMissionList.aspx'}else{window.location.href='TeachingMissionPreview.aspx?ID=" + temID + "'};</script>"); }
protected void Save_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tb_CourseCode.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "�γ̱�Ų���Ϊ��"); return; } if (string.IsNullOrEmpty(tb_CourseName.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "�γ�������Ϊ��"); return; } if (ddl_Lab.SelectedValue == "0") { LabMS.Common.JShelper.JSAlert(this, "error", "��ѡ��е��γ̵�ʵ����"); return; } if (string.IsNullOrEmpty(tb_ExpHouse.Text)) { LabMS.Common.JShelper.JSAlert(this, "error", " ʵ��ѧʱ����Ϊ��"); return; } if (string.IsNullOrEmpty(tb_StartWeek.Text)) { LabMS.Common.JShelper.JSAlert(this, "error", "��ʼ�ܴβ���Ϊ����ӦΪ����"); return; } if (!IsNumber(tb_StartWeek.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "��ʼ�ܴβ���Ϊ����ӦΪ����"); return; } if (!IsNumber(tb_EndWeek.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "�����ܴβ���Ϊ����ӦΪ����"); return; } int Num1 = 0; int Num2 = 0; if (int.TryParse(tb_StartWeek.Text, out Num1) && int.TryParse(tb_EndWeek.Text, out Num2)) { if (Num2 < Num1) { LabMS.Common.JShelper.JSAlert(this, "error", "��ʼ�ܴδ��ڽ����ܴ�"); } } else { LabMS.Common.JShelper.JSAlert(this, "error", "�ܴβ���Ϊ�գ���Ӧ��Ϊ����"); return; } if (!IsNumber(tb_ComputerTime.Text.Trim())) { LabMS.Common.JShelper.JSAlert(this, "error", "�ϻ�����Ϊ����ӦΪ����"); return; } if (string.IsNullOrEmpty(tb_Teacher.Text)) { LabMS.Common.JShelper.JSAlert(this, "error", "��ʦ����Ϊ����ӦΪ����"); return; } if (!(Gv_Class.Rows.Count > 0)) { LabMS.Common.JShelper.JSAlert(this, "error", "��ѡ��γ̶�Ӧ�İ༶"); return; } try { LabMS.BLL.TeachMission TeachMission = new LabMS.BLL.TeachMission(); LabMS.Model.TeachMission model = new LabMS.Model.TeachMission(); model = TeachMission.GetModel(QueryString); if (model != null) { model.LabID = Convert.ToInt32(ddl_Lab.SelectedValue.Trim()); model.Ms_CourseCode = (tb_CourseCode.Text); model.Ms_CourseName = tb_CourseName.Text; model.Ms_SubmitTime = DateTime.Now; model.Ms_Teacher = Convert.ToInt32(tb_TeacherID.Text); model.Ms_Conflict = rbl_Conflict.SelectedValue.Trim(); model.Ms_StartWeek = Convert.ToInt32(tb_StartWeek.Text.Trim().ToString()); model.Ms_EndWeek = Convert.ToInt32(tb_EndWeek.Text.Trim().ToString()); model.Ms_CourseHourse = Convert.ToInt32(tb_ExpHouse.Text.Trim()); model.Ms_ComputerHourse = Convert.ToInt32(tb_ComputerTime.Text.Trim()); model.Ms_Term = ddl_Season.SelectedValue; model.Ms_Year = ddl_Year.SelectedValue; TeachMission.Update(model); } } catch (Exception ex) { lb_Error.Text = ex.Message; } string[] array = tb_ClassIDs.Text.Split(','); if (array.Length == 1 && array[0] == "") { return; } List<string> lsIDs = new List<string>(); lsIDs.Add(array[0]); foreach (string item in array) { int Count = 0; foreach (string Pr in lsIDs) { if (item != Pr) { Count++; } } if (Count == lsIDs.Count) { lsIDs.Add(item); } } //��ȡ�б� try { ExtendBLL.ClassItemDelete ClassItemDelete = new ExtendBLL.ClassItemDelete(); int result = ClassItemDelete.Delete(QueryString.ToString()); if (result == 0) { //LabMS.Common.JShelper.JSAlert(this, "error", "��ѯ�ַ�������"); Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>window.location.href='~/err.aspx?Message=��ѯ�ַ�������';<script>"); return; } if (result == 2) { LabMS.Common.JShelper.JSAlert(this, "error", "���´���"); } } catch (Exception ex) { lb_Error.Text = ex.Message; } int CourseID = int.Parse(tb_CourseID.Text.Trim()); LabMS.BLL.ClassItem ClassItem = new LabMS.BLL.ClassItem(); LabMS.BLL.Class Class = new LabMS.BLL.Class(); LabMS.Model.Class classModel; LabMS.Model.ClassItem classItemModel; for (int n = 0; n < lsIDs.Count; n++) { classModel = Class.GetModel(Convert.ToInt32(lsIDs[n])); classItemModel = new LabMS.Model.ClassItem(); classItemModel.CourseID = CourseID; classItemModel.ClassItem_Code = classModel.Class_Code; classItemModel.ClassItem_Name = classModel.Class_Name; classItemModel.ClassItem_Num = classModel.Class_StudentNum; classItemModel.ClassItem_Degree = classModel.Class_Year; classItemModel.ClassID = Convert.ToInt32(lsIDs[n]); classItemModel.Time = DateTime.Now; classItemModel.TeachMissionID = QueryString; int classItemModelID = ClassItem.Add(classItemModel); } LabMS.BLL.TeacherCourse TC = new LabMS.BLL.TeacherCourse(); LabMS.Model.TeacherCourse Model = new LabMS.Model.TeacherCourse(); Model.CourseID = CourseID; Model.TeacherID = Convert.ToInt32(tb_TeacherID.Text.Trim()); TC.Add(Model); Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('�ijɹ�');window.location.href='TeachingMissionList.aspx';</script>"); }
//获取选课班级 总人数 protected LabMS.Model.ClassItem GetClassName(int ID) { LabMS.BLL.ClassItem classItem = new LabMS.BLL.ClassItem(); List<LabMS.Model.ClassItem> classItemModel = new List<LabMS.Model.ClassItem>(); LabMS.Model.ClassItem cIModel = new LabMS.Model.ClassItem(); string str; cIModel.ClassItem_Name = ""; cIModel.ClassItem_Num = 0; classItemModel = classItem.GetModelList("CourseID=" + ID); for (int i = 0; i < classItemModel.Count; i++) { cIModel.ClassItem_Name += classItemModel[i].ClassItem_Name+","; cIModel.ClassItem_Num += classItemModel[i].ClassItem_Num; } str = cIModel.ClassItem_Name; cIModel.ClassItem_Name = str.Substring(0, str.Length - 1); return cIModel; }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.ClassItem GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,ClassItem_Code,ClassItem_Name,ClassItem_Num,ClassItem_Degree,ClassID,CourseID,TeachMissionID,Time from ClassItem "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4)}; parameters[0].Value = ID; LabMS.Model.ClassItem model=new LabMS.Model.ClassItem(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["ID"].ToString()!="") { model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } model.ClassItem_Code=ds.Tables[0].Rows[0]["ClassItem_Code"].ToString(); model.ClassItem_Name=ds.Tables[0].Rows[0]["ClassItem_Name"].ToString(); if(ds.Tables[0].Rows[0]["ClassItem_Num"].ToString()!="") { model.ClassItem_Num=int.Parse(ds.Tables[0].Rows[0]["ClassItem_Num"].ToString()); } model.ClassItem_Degree=ds.Tables[0].Rows[0]["ClassItem_Degree"].ToString(); if(ds.Tables[0].Rows[0]["ClassID"].ToString()!="") { model.ClassID=int.Parse(ds.Tables[0].Rows[0]["ClassID"].ToString()); } if(ds.Tables[0].Rows[0]["CourseID"].ToString()!="") { model.CourseID=int.Parse(ds.Tables[0].Rows[0]["CourseID"].ToString()); } if(ds.Tables[0].Rows[0]["TeachMissionID"].ToString()!="") { model.TeachMissionID=int.Parse(ds.Tables[0].Rows[0]["TeachMissionID"].ToString()); } if(ds.Tables[0].Rows[0]["Time"].ToString()!="") { model.Time=DateTime.Parse(ds.Tables[0].Rows[0]["Time"].ToString()); } return model; } else { return null; } }