⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 delphi编的排课管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
     begin
       a2[1]:=99;
       a2[2]:=99;
       a6[2]:=99;
       a7[2]:=99;
     end;
     if t_date['y3']=false then//如果星期三为放假;
     begin
       a3[1]:=99;
       a3[2]:=99;
       a6[3]:=99;
       a7[3]:=99;
     end;
     if t_date['y4']=false then
     begin
       a4[1]:=99;
       a4[2]:=99;
       a6[4]:=99;
       a7[4]:=99;
     end;
     if t_date['y5']=false then
     begin
       a5[1]:=99;
       a5[2]:=99;
       a6[5]:=99;
       a7[5]:=99;
     end;
     //一周的放假信息输入完毕;


     //找出该班级的课程;
     query1.Close;
     query1.SQL.Clear ;
     query1.Params.Clear ;
     query1.SQL.Add('select * from apply where class=:class order by id');
     query1.ParamByName('class').AsString:=class_name;

     query1.open;

     while not query1.Eof  do//按课程按课;
     begin //begin 34
       ready_pk:=query1.FieldValues['ready']; //未排课程数;
       code:=query1.FieldValues['code']; //课程代码
       kc_code:=inttostr(code);     //课程代码string;
       week_times:=query1.FieldValues['week_time'];  //周次数
       lsh:=inttostr(query1.FieldValues['lsh']);  //流水号
       kind:=query1.FieldValues['kind'];   //地点类型;
       sing:=query1.FieldValues['jion_sing']; //加入标志
       tech_code:=query1.FieldValues['tech_code'];//老师代码;
       room_code:=query1.FieldValues['room_code']; //地点代码;

       if sing=true then
       j_class:=inttostr(query1.FieldValues['j_code']);

       //如果学时开始周大于等于正在排课的周,而且学时大于已排的课时,那么;
       if (query1.Fields.FieldByName('star_week').AsInteger <= i ) and (ready_pk > 0 ) then
       begin // 41
         //开始排本课程在本周的排课;

         //首先考虑合上的课程;
         if sing =true then //如果合上的课程标志为真;
         begin
           have_pk.Close;
           have_pk.Filtered :=false;
           have_pk.Filter :='code='+j_class ;
           have_pk.Filtered :=true;
           have_pk.Open;
           if have_pk.RecordCount =0 then //没找到合上的班级;
           begin
            //---------------------------------
              //先排体育课;
             if kind='体育场所' then
             begin
                for l:=1 to 5 do
                begin
                  if week_times>=1 then
                  begin //-----------
                    if a7[l]=0 then
                    begin
                      note:=inttostr(l*4);
                      if can_pk(i,note,tech_code,room_code)=true then
                      begin
                        a7[l]:=code;
                        week_times:= week_times-1;
                        ready_pk:=ready_pk-2;
                      end else continue;
                    end;
                  end
                  else break;
                end;
             end;
             if  week_times>=1 then
             begin //51
               for l:=1 to 2 do
               begin//61
                 if a3[l]=0 then
                 begin //71
                   note:=inttostr(l+8);
                   if can_pk(i,note,tech_code,room_code)=true then
                   begin
                     a3[l]:=code;
                     week_times:=week_times-1;
                     ready_pk:=ready_pk-2;
                     break;
                   end else continue;
                 end ;//end-71
               end;//end-61
             end;  //end-51
             //------------------------
             if week_times>=1 then
             begin
               for l:=1 to 2 do
               begin
                 if a1[l]=0 then
                 begin
                   note:=inttostr(l);
                   if can_pk(i,note,tech_code,room_code)=true then
                   begin
                     a1[l]:=code;
                     week_times:=week_times-1;
                     ready_pk:=ready_pk-2;
                     break;
                   end else continue;
                 end;
               end;
             end;
             //---------------------------------
             if week_times>=1 then
             begin
                for l:=1 to 2 do
                begin
                  if a2[l]=0 then
                  begin
                    note:=inttostr(l+4);
                    if can_pk(i,note,tech_code,room_code)=true then
                    begin
                      a2[l]:=code;
                      week_times:=week_times-1;
                      ready_pk:=ready_pk-2;
                      break;
                    end else continue;
                  end;
                end;
             end;
             //------------------------------
             if week_times>=1 then
             begin
               for l:=1 to 2 do
               begin
                 if a4[l]=0 then
                 begin
                    note:=inttostr(l+12);
                    if can_pk(i,note,tech_code,room_code)=true then
                    begin
                      a4[l]:=code;
                      week_times:=week_times-1;
                      ready_pk:=ready_pk-2;
                      break;
                    end else continue;
                 end;
               end;
             end;
             //----------------------------------
             if week_times>=1 then
             begin
               for l:=1 to 2 do
               begin
                 if a5[l]=0 then
                 begin
                    note:=inttostr(l+16);
                    if can_pk(i,note,tech_code,room_code)=true then
                    begin
                     a5[l]:=code;
                     week_times:=week_times-1;
                     ready_pk:=ready_pk-2;
                     break;
                    end else continue;
                 end;
               end;
             end;
             //-------------------------------------
             if week_times>=1 then
             begin
               for l:=1 to 5 do
               begin
                 if a6[l]=0 then
                 begin
                    note:=inttostr(l*4-1);
                    if can_pk(i,note,tech_code,room_code)=true then
                   begin
                     a6[l]:=code;
                     week_times:=week_times-1;
                     ready_pk:=ready_pk-2;
                     break;
                   end else  continue;

                 end;
               end;
             end;
             //------------------------------------
             if week_times>=1 then
             begin //-----------
               for l:=1 to 5 do
               begin
                 if a7[l]=0 then
                 begin
                    note:=inttostr(l*4) ;
                    if can_pk(i,note,tech_code,room_code)=true then
                    begin
                      a7[l]:=code;
                      week_times:=week_times-1;
                      ready_pk:=ready_pk-2;
                      break;
                    end else continue;
                 end;
               end;
            end;
           end

           else  //合上班级已经排过课了,
           begin
              t_scan.Close;
              t_scan.TableName :='kc'+j_class+'.db';
              t_scan.Open;
              num:=1 ;
              for l:=1 to i-1 do
              num:=num+3;
              t_scan.RecNo :=num;//找到本周的记录;
              //查找,课程在本周内的排课情况;
              if code=t_scan['1'] then begin  a1[1]:=t_scan['1'];ready_pk:=ready_pk-2; week_times:=week_times-1;end;
              if code=t_scan['2'] then begin  a1[2]:=t_scan['2'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['3'] then begin  a6[1]:=t_scan['3'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['4'] then begin  a7[1]:=t_scan['4'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['5'] then begin  a2[1]:=t_scan['5'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['6'] then begin  a2[2]:=t_scan['6'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['7'] then begin  a6[2]:=t_scan['7'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['8'] then begin  a7[2]:=t_scan['8'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['9'] then begin  a3[1]:=t_scan['9'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['10'] then begin a3[2]:=t_scan['10'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['11'] then begin a6[3]:=t_scan['11'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['12'] then begin a7[3]:=t_scan['12'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['13'] then begin a4[1]:=t_scan['13'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['14'] then begin a4[2]:=t_scan['14'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['15'] then begin a6[4]:=t_scan['15'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['16'] then begin a7[4]:=t_scan['16'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['17'] then begin a5[1]:=t_scan['17'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['18'] then begin a5[2]:=t_scan['18'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['19'] then begin a6[5]:=t_scan['19'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
              if code=t_scan['20'] then begin a7[5]:=t_scan['20'];ready_pk:=ready_pk-2;week_times:=week_times-1;end;
           end;
           {//修改ready标志;
           t_edit.close;
           t_edit.Filtered :=false;
           t_edit.Filter :='lsh='+lsh;
           //t_edit.Filter :='code='+kc_code+' and class='+class_name;
           t_edit.Filtered :=true;
           t_edit.Open;
           t_edit.Edit ;
           t_edit['ready']:=ready_pk;
           t_edit.Post ;
           t_edit.Close; //修改完毕;
           query1.Next ; //开始排下一个课程在本周的安排;
           }
         end ;//排完合上的课程;
//*************************************************************************
         //开始排不合上的课程;
         //先排体育课
         if kind='体育场所' then
         begin
            for l:=1 to 5 do
            begin
              if week_times>=1 then
              begin //-----------
                 if a7[l]=0 then
                 begin
                  note:=inttostr(l*4);
                  if can_pk(i,note,tech_code,room_code)=true then
                  begin
                    a7[l]:=code;
                    week_times:= week_times-1;
                    ready_pk:=ready_pk-2;
                  end;
                 end;
              end
              else break;
            end;
         end;
         if  week_times>=1 then
         begin //51
            for l:=1 to 2 do
            begin//61
               if a3[l]=0 then
               begin //71
                 note:=inttostr(l+8);
                 if can_pk(i,note,tech_code,room_code)=true then
                 begin
                   a3[l]:=code;
                   week_times:=week_times-1;
                   ready_pk:=ready_pk-2;
                   break;
                 end;
               end ;//end-71
             end;//end-61
         end;  //end-51
             //------------------------
         if week_times>=1 then
         begin
           for l:=1 to 2 do
           begin
              if a1[l]=0 then
              begin
                   note:=inttostr(l);
                   if can_pk(i,note,tech_code,room_code)=true then
                   begin
                     a1[l]:=code;
                     week_times:=week_times-1;
                     ready_pk:=ready_pk-2;
                     break;
                   end;
              end;
           end;
         end;
             //---------------------------------
         if week_times>=1 then
         begin
           for l:=1 to 2 do
           begin
             if a2[l]=0 then
             begin
                 note:=inttostr(l+4) ;
                 if can_pk(i,note,tech_code,room_code)=true then
                 begin
                   a2[l]:=code;
                   week_times:=week_times-1;
                   ready_pk:=ready_pk-2;
                   break;
                 end;
             end;
           end;
         end;
         //------------------------------
         if week_times>=1 then
         begin
           for l:=1 to 2 do
           begin
              if a4[l]=0 then
              begin
                  note:=inttostr(l+12) ;
                  if can_pk(i,note,tech_code,room_code)=true then
                  begin
                    a4[l]:=code;
                    week_times:=week_times-1;
                    ready_pk:=ready_pk-2;
                    break;
                  end;
              end;
           end;
         end;
         //----------------------------------
         if week_times>=1 then
         begin
           for l:=1 to 2 do
           begin
             if a5[l]=0 then
             begin
                   note:=inttostr(l+16);
                   if can_pk(i,note,tech_code,room_code)=true then
                   begin
                     a5[l]:=code;
                     week_times:=week_times-1;
                     ready_pk:=ready_pk-2;
                     break;
                   end;

             end;
           end;
         end;
         //-------------------------------------
         if week_times>=1 then
         begin
            for l:=1 to 5 do
            begin
              if a6[l]=0 then
              begin
                   note:=inttostr(l*4-1);
                   if can_pk(i,note,tech_code,room_code)=true then
                   begin
                     a6[l]:=code;
                     week_times:=week_times-1;
                     ready_pk:=ready_pk-2;
                     break;
                   end;

              end;
            end;
         end;
             //------------------------------------
         if week_times>=1 then
         begin //-----------
            for l:=1 to 5 do
            begin
              if a7[l]=0 then
              begin
                  note:=inttostr(l*4);
                  if can_pk(i,note,tech_code,room_code)=true then
                  begin
                    a7[l]:=code;
                    week_times:= week_times-1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -