public void MakePlacement(PlacementConfig config) { try { dtClasses = helper.getDs(strSelect_Class_Data, "Classes_Data").Tables[0]; dtTeachers = helper.getDs(strSelect_Teachers_Data, "Teachers_Data").Tables[0]; dtTeachers = dtTeachers.Select("IsSupervisor=False").CopyToDataTable(); dtSupervisor = helper.getDs(strSelect_Teachers_Data, "Teachers_Data").Tables[0]; dtSupervisor = dtSupervisor.Select("IsSupervisor=True").CopyToDataTable(); dtSpareTime = helper.getDs(strSelect_SpareTime_Data, "SpaerTime_Data").Tables[0]; dtPlacement = helper.getDs(strSelect_Placement_Data, "Placement_Data").Tables[0]; for (Week = config.Cbegin_week; Week < 19; Week++) { UpdataWeek(dtSupervisor); if (CheckWeekPeo(Week) >= config.Cnumpeo_min) { SelectSameDay(config, Week); } else { continue; } } UpdateALL(); } catch (System.Exception ex) { MessageBox.Show("排课失败" + ex.ToString()); } }
public void RePlacement(PlacementConfig config) { string deletecommand = "delete * from Placement_Data"; helper.Oledbcommand(deletecommand); dtTeachers = helper.getDs(strSelect_Teachers_Data, "Teachers_Data").Tables[0]; for (int i = 0; i < dtTeachers.Rows.Count; i++) { dtTeachers.Rows[i][7] = 0; dtTeachers.Rows[i][8] = 0; dtTeachers.Rows[i][9] = 0; dtTeachers.Rows[i][10] = 0; } System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString()); dtSpareTime = helper.getDs(strSelect_SpareTime_Data, "SpareTime").Tables[0]; DataRow[] DrIsAssigned = dtSpareTime.Select("IsAssigned='" + "true" + "'"); for (int i = 0; i < DrIsAssigned.Length; i++) { DrIsAssigned[i]["IsAssigned"] = false; } daSpareTime = helper.adapter(strSelect_SpareTime_Data); daSpareTime.Update(dtSpareTime); daTeacher = helper.adapter(strSelect_Teachers_Data); daTeacher.Update(dtTeachers); MakePlacement(config); }
private void SelectSameDay(PlacementConfig config, int week) { for (Day = config.Cbegin_day; Day < 6; Day++) { int weekplacement = dtPlacement.Select("Class_week= '" + week + "'").Length; if (CheckDayPeo(Day) >= config.Cnumpeo_min && weekplacement <= config.Cnumclass_week - 1) { UpdataDay(dtSupervisor); SelectSameClass(config); } else { continue; } } }
private void SelectSameClass(PlacementConfig config) { for (Index = 0; Index < 15; Index++) { supervisor.Clear(); Supervisors = ""; drSpareTimeClass = dtSpareTimeDay.Select("Spare_Number= '" + spareclass[Index] + "'"); drClasses = ContorlProportion(config.Proportion); drSupervisor = dtSupervisor.Select("Class_WeekNumber<2 and Class_DayNumber = 0", "Class_Totality asc"); drTeacher = dtTeachers.Select("Accept_ClassNumber=0"); int count = Supervisor(drSpareTimeClass, drSupervisor).Count; if (count < config.Cnumpeo_min) { break; } else if (count >= config.Cnumpeo_min && count <= config.Cnumpeo_max) { foreach (string dr in supervisor) { Supervisors = Supervisors + "," + dr; } WritePlacement(Supervisors, Teacher(drClasses, drTeacher)); } else if (count > config.Cnumpeo_max) { for (int i = 0; i < config.Cnumpeo_max; i++) { Supervisors = Supervisors + "," + supervisor[i]; } WritePlacement(Supervisors, Teacher(drClasses, drTeacher)); } else { break; } } }
private void SelectSameDay(PlacementConfig config,int week) { for (Day =config.Cbegin_day ; Day < 6; Day++) { int weekplacement = dtPlacement.Select("Class_week= '" + week + "'").Length; if(CheckDayPeo(Day)>=config.Cnumpeo_min &&weekplacement<=config.Cnumclass_week-1){ UpdataDay(dtSupervisor); SelectSameClass(config); }else{ continue; } } }
private void SelectSameClass(PlacementConfig config) { for (Index = 0; Index < 15; Index++) { supervisor.Clear(); Supervisors = ""; drSpareTimeClass = dtSpareTimeDay.Select("Spare_Number= '" + spareclass[Index] + "'"); drClasses = ContorlProportion(config.Proportion); drSupervisor = dtSupervisor.Select("Class_WeekNumber<2 and Class_DayNumber = 0", "Class_Totality asc"); drTeacher = dtTeachers.Select("Accept_ClassNumber=0"); int count = Supervisor(drSpareTimeClass,drSupervisor).Count; if(count<config.Cnumpeo_min){ break; } else if (count >= config.Cnumpeo_min && count <= config.Cnumpeo_max) { foreach (string dr in supervisor) { Supervisors = Supervisors + "," + dr; } WritePlacement(Supervisors,Teacher(drClasses,drTeacher)); } else if (count > config.Cnumpeo_max) { for (int i = 0; i < config.Cnumpeo_max; i++) { Supervisors = Supervisors + "," + supervisor[i]; } WritePlacement(Supervisors, Teacher(drClasses, drTeacher)); } else { break; } } }
public void RePlacement(PlacementConfig config) { string deletecommand = "delete * from Placement_Data"; helper.Oledbcommand(deletecommand); dtTeachers = helper.getDs(strSelect_Teachers_Data, "Teachers_Data").Tables[0]; for (int i = 0; i < dtTeachers.Rows.Count;i++ ) { dtTeachers.Rows[i][7] = 0; dtTeachers.Rows[i][8] = 0; dtTeachers.Rows[i][9] = 0; dtTeachers.Rows[i][10] = 0; } System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString()); dtSpareTime = helper.getDs(strSelect_SpareTime_Data, "SpareTime").Tables[0]; DataRow[] DrIsAssigned = dtSpareTime.Select("IsAssigned='"+"true"+"'"); for (int i = 0; i < DrIsAssigned.Length; i++) { DrIsAssigned[i]["IsAssigned"] = false; } daSpareTime = helper.adapter(strSelect_SpareTime_Data); daSpareTime.Update(dtSpareTime); System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString()); daTeacher = helper.adapter(strSelect_Teachers_Data); daTeacher.Update(dtTeachers); MakePlacement(config); }
private void buttonX1_Click(object sender, EventArgs e) { SqlHelper help = new SqlHelper(); DataTable dtsparetime = help.getDs("select * from SpareTime_Data", "SpareTime_Data").Tables[0]; DataTable dtclass = help.getDs("select * from Classes_Data", "Classes_Data").Tables[0]; DataTable dtteacher = help.getDs("select * from Teachers_Data", "Teachers_Data").Tables[0]; if (checkType()) { if (cnumpeo_max >= cnumpeo_min) { if (dtsparetime.Rows.Count != 0 && dtclass.Rows.Count != 0 && dtteacher.Rows.Count != 0) { Main.fm.SetStatusText("正在工作中,请耐心等待~~", 1); //MessageBox.Show("OK"); PlacementConfig pc = new PlacementConfig(cbegin_week, cbegin_day, cnumclass_week, cnumpeo_max, cnumpeo_min, proportion); Placement doplacement = new Placement(); doplacement.MakePlacement(pc); } else { MessageBox.Show("请导入数据后重试"); } } else { MessageBox.Show("最大人数不能小于最小人数"); } } }