/// <summary> /// 获取教师课表 /// </summary> public DtMatrix <IList <EnLsnAct> > GetTchMatrix(EnTeacher teacher) { DtMatrix <IList <EnLsnAct> > Result = new DtMatrix <IList <EnLsnAct> >(DataRule.Solution); foreach (SqdSchedule sch in SqdScheduleList.Values) { if (sch.Teaches.Contains(teacher)) { foreach (VcTime time in sch.Matrix.eachTime()) { if (sch.Matrix[time].LsnAct != null && sch.Matrix[time].LsnAct.ClsLesson.Teacher == teacher) { if (Result[time] == null) { Result[time] = new List <EnLsnAct>(); } Result[time].Add(sch.Matrix[time].LsnAct); } } } } return(Result); }
public void SetLastTch(EnTeacher tch, VcTime time) { if (VC2WinFmApp.TopFm != null && !VC2WinFmApp.TopFm.IsDisposed) { VC2WinFmApp.TopFm.LastTch = tch; VC2WinFmApp.TopFm.LastTime = time; } }
public void SetTeacher(FcClsLesson ClsLsn, EnTeacher Tch) { if (ClsLsn.teacher != Tch) { ClsLsn.teacher = Tch; this.Modify = true; } }
public EnTeacher SaveExistMbr(EnTeacher Value) { EnTeacher Result = ThisModule.Dac.Tch.MbrDAC.SaveExist(Value); ThisModule.SendDataChanged(); return(Result); }
public void DeleteMbr(EnTeacher mbr) { //教师删除后对应的课务安排会被设置为无授课/辅导教师 ThisModule.Lsn.TeacherIsDelete(mbr); ThisModule.Dac.Rule.DeleteRuleOfEty(mbr); ThisModule.Dac.Tch.DeleteMbr(mbr); ThisModule.SendDataChanged(); }
public void TeacherIsDelete(EnTeacher teacher) { foreach (EnClsLesson clsLsn in eachClsLesson()) { if (clsLsn.Teacher != null && clsLsn.Teacher.Id == teacher.Id) { clsLsn.Teacher = null; ThisModule.Dac.Lsn.SaveClsLesson(clsLsn); } } }
public void SetFocusTch(EnTeacher tch) { if (VC2WinFmApp.TopFm != null && !VC2WinFmApp.TopFm.IsDisposed) { if (tch == VC2WinFmApp.TopFm.LastTch) { VC2WinFmApp.TopFm.FocusTch = null; } else { VC2WinFmApp.TopFm.FocusTch = tch; } } }
public static Boolean TeacherSelect(ref EnTeacher select) { MbrSelectFmSingle Fm = new MbrSelectFmSingle(); Fm.btNull.Text = "无教师"; Fm.btNull.Visible = true; Fm.MbrSelect = new IGrpMbrBizFacadeToIMbrSelect(VC2WinFmApp.DataFacade.Tch); Fm.SelectEty = select == null ? OldTch : select; if (Fm.ShowDialog() == DialogResult.OK) { select = Fm.SelectEty as EnTeacher; OldTch = select; return(true); } else { return(false); } }
private void grdSqdLesson_DoubleClick(object sender, EventArgs e) { if (grdSqdLesson.SelectedCells.Count != 1) { return; } DataGridViewCell Cell = grdSqdLesson.SelectedCells[0]; if (grdSqdLesson.Columns[Cell.ColumnIndex].Name != "Teacher") { return; } EnTeacher Tch = (GrdSqdBind.Current as FcClsLesson).teacher; if (!SelectTeacher(ref Tch)) { return; } Biz.SetTeacher(GrdSqdBind.Current as FcClsLesson, Tch); GrdSqdBind.Refresh(); }
public static Boolean WizardAddTeacher(ref Int32 AddCount) { AddCount = 0; WizardTeacherFm fm = new WizardTeacherFm(); if (fm.ShowDialog() != DialogResult.OK) { return(false); } foreach (String s in fm.listBox1.Items) { String name = s.Trim(); if (String.IsNullOrEmpty(name)) { continue; } if (fm.cbIfExistThenIgnore.Checked && VC2WinFmApp.DataRule.Tch.MbrNameExist(null, name)) { continue; } EnTeacher tch = new EnTeacher(); tch.Name = name; if (VC2WinFmApp.DataRule.Tch.SaveNewMbr(tch) == null) { break; } AddCount++; } return(AddCount > 0); }
public bool MbrNameExist(EnTeacher mbr, string Name) { return(ThisModule.Dac.Tch.MbrDAC.NameExist(mbr, Name)); }
public void ScheduleUpdate(eScheduleUpdateKind Kind) { switch (Kind) { case eScheduleUpdateKind.RefreshMatrix: MatrixLast.Solution = VC2WinFmApp.DataRule.Solution; MatrixFocus.Solution = VC2WinFmApp.DataRule.Solution; break; //特别的响应,即使RefreshRule也要更新课表,为处理调课完成后 case eScheduleUpdateKind.RefreshAct: var mtxLast = VC2WinFmApp.Engine.GetTchMatrix(this._LastTch); var mtxFocus = VC2WinFmApp.Engine.GetTchMatrix(this._FocusTch); foreach (VcTime time in mtxLast.eachTime()) { MatrixLast[time].Acts = mtxLast[time]; MatrixFocus[time].Acts = mtxFocus[time]; } break; case eScheduleUpdateKind.RefreshRule: foreach (TchScheduleCell cell in MatrixLast.eachCell()) { cell.Rule = eRule.common; } foreach (TchScheduleCell cell in MatrixFocus.eachCell()) { cell.Rule = eRule.common; } var SlnMatrix = new DtMatrix <bool>(VC2WinFmApp.DataRule.Solution); var ruleS = VC2WinFmApp.DataRule.Rule.GetRules(this._LastTch); var ruleT = VC2WinFmApp.DataRule.Rule.GetRules(this._FocusTch); foreach (var rls in ruleS) { if (SlnMatrix.TestTime(rls.Time)) { MatrixLast[rls.Time].Rule = rls.Rule; } } foreach (var rls in ruleT) { if (SlnMatrix.TestTime(rls.Time)) { MatrixFocus[rls.Time].Rule = rls.Rule; } } break; case eScheduleUpdateKind.Invalidate: if (_LastTch != null && !VC2WinFmApp.Engine.EntityIsEnabled(_LastTch)) { LastTch = null; } if (_FocusTch != null && !VC2WinFmApp.Engine.EntityIsEnabled(_FocusTch)) { FocusTch = null; } break; } }
public void AddMember(EnTeacherGroup grp, EnTeacher mbr) { ThisModule.Dac.Tch.CreateRelation(grp, mbr); ThisModule.SendDataChanged(); }
public IList <EnTeacherGroup> GetGroups(EnTeacher mbr) { return(ThisModule.Dac.Tch.GetGroups(mbr)); }
/// <summary> /// 获取交换时优势 /// </summary> public DtMatrix <eRule> GetActChangeRule(EnSquad squad, EnLsnAct sAct, VcTime sTime) { Debug.Assert(sAct != null, "为简化程序逻辑,空课不可拖。"); //这个方法是本程序中最复杂的逻辑 //步骤: //一、获得所有位置当前优势 //二、获得sAct当前优势 //三、获得所有位置的Act移动到sTime的优势值 //四、获得sAct移动到所有位置的优势值 //五、比较当前优势和移动后的优势,获得交换的价值 SqdSchedule NowSch = SqdScheduleList[squad]; //一、获得所有位置当前优势 DtMatrix <eRule> NowRules = this.GetSqdRule(squad); //二、获得sAct当前优势 eRule sActNowRule; if (NowRules.TestTime(sTime)) { sActNowRule = NowRules[sTime]; } else { sActNowRule = eRule.common; //未排 } //三、获得所有位置的Act移动到sTime的优势值 DtMatrix <eRule> FutureRules = new DtMatrix <eRule>(DataRule.Solution); if (FutureRules.TestTime(sTime)) { IList <EnTeacher> sTimeTchs = new List <EnTeacher>(); foreach (SqdSchedule sch in this.SqdScheduleList.Values) { if (sch != NowSch && sch.Matrix[sTime].LsnAct != null) { EnLsnAct act = sch.Matrix[sTime].LsnAct; if (act.ClsLesson.Teacher != null && !sTimeTchs.Contains(act.ClsLesson.Teacher)) { sTimeTchs.Add(act.ClsLesson.Teacher); } } } foreach (VcTime time in FutureRules.eachTime()) { if (NowSch.Matrix[time].LsnAct != null) { EnLsnAct act = NowSch.Matrix[time].LsnAct; if (act.ClsLesson.Teacher != null && sTimeTchs.Contains(act.ClsLesson.Teacher)) { FutureRules[time] = eRule.crisscross; //此课程移到sTime后导致教师冲突 } else { FutureRules[time] = ClsLsnRuleList[act.ClsLesson][sTime]; //移到sTime后的优势 } } } } else { //所有Act移动到未排,则优势一定是eRule.common foreach (VcTime time in FutureRules.eachTime()) { FutureRules[time] = eRule.common; } } //四、获得sAct移动到所有位置的优势值 DtMatrix <eRule> sActFutureRules = new DtMatrix <eRule>(DataRule.Solution); DtMatrix <eRule> TmpRules = ClsLsnRuleList[sAct.ClsLesson]; foreach (VcTime time in TmpRules.eachTime()) { sActFutureRules[time] = TmpRules[time]; } //检测课程冲突 if (sAct.ClsLesson.Teacher != null) { EnTeacher NowTch = sAct.ClsLesson.Teacher; DtMatrix <IList <EnLsnAct> > sTchLsns = this.GetTchMatrix(NowTch); foreach (VcTime time in sTchLsns.eachTime()) { if (sTchLsns[time] != null && sTchLsns[time].Count > 0) { foreach (EnLsnAct act in sTchLsns[time]) { if (act != NowSch.Matrix[time].LsnAct && //当前课表的,会被移走 act.ClsLesson.Teacher == NowTch) { sActFutureRules[time] = eRule.crisscross; //sAct移到time后将导致冲突 break; } } } } } //五、比较当前优势和移动后的优势,获得交换的价值矩阵 DtMatrix <eRule> Result = new DtMatrix <eRule>(DataRule.Solution); //NowRules、sActNowRule、FutureRules、sActFutureRules //所有位置当前优势\拖动源当前优势\所有位置在拖动源的优势\拖动源拖到所有位置的优势 foreach (VcTime time in Result.eachTime()) { if (NowSch.Matrix[time].LsnAct != null && NowSch.Matrix[time].LsnAct.ClsLesson == sAct.ClsLesson) { Result[time] = eRule.crisscross; //同样的课移动没意义的 continue; } Result[time] = ComparerActChangeRule(NowRules[time], sActNowRule, FutureRules[time], sActFutureRules[time]); } return(Result); }
public PrtMatrixTch(EnTeacher tch) { teacher = tch; }
public void RemoveMember(EnTeacherGroup grp, EnTeacher mbr) { ThisModule.Dac.Tch.ReleaseRelation(grp, mbr); ThisModule.SendDataChanged(); }
private Boolean SelectTeacher(ref EnTeacher Tch) { return(SelectIF.TeacherSelect(ref Tch)); }
public EnTeacher SaveNewMbr(EnTeacher Value) { return(ThisModule.Dac.Tch.MbrDAC.SaveNew(Value)); }