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

📄 drillrelay_unt.pas

📁 煤矿行业采掘接替计划自动生成系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:

                   j:=1;
                   while not Eof do
                      begin
                        Edit;
                        FieldByName('Sequence').AsInteger:=BehindRelay[j].Sequence;
                        Post; //更新后表的指针仍然指向当前记录,但是,当关闭再打开该表后,该当前记录的Sequence字段值若仍然为-1,则指针指向的记录将发生变化
                        Next;
                        j:=j+1;
                      end;
                   GotoBookmark(Mark);
                   DBGrid1.ReadOnly:=true;
                   DBGrid1.Enabled:=true;
                   BitBtn1.Enabled:=true;
                   BitBtn2.Enabled:=true;
                   BitBtn4.Enabled:=true;
                   BitBtn5.Enabled:=true;
                   BitBtn6.Enabled:=true;
                   BitBtn7.Enabled:=true;
                   BitBtn8.Enabled:=true;
                   BitBtn9.Enabled:=true;
                   BitBtn10.Enabled:=true;
                   BitBtn11.Enabled:=true;
                   BitBtn12.Enabled:=true;
                   BitBtn13.Enabled:=true;

                   DBLookUpComboBox1.Enabled:=false;
                   ComboBox1.Enabled:=false;
                   DBLookUpComboBox2.Enabled:=false;
                   DBLookUpComboBox3.Enabled:=false;
                   DBLookUpListBox1.Enabled:=false;
                   Label5.Caption:='';
                   exit;
                 end;
               DBLookUpListBox1.SetFocus;
               exit;
             end;
         end;
       //根据从界面输入的有关信息,分三种情况来处理插入:
       if (InsertWorkGroup=Current.WorkGroup) //给某个掘进队插入一个掘进任务
         then
           begin
             FieldByName('Project_Id').AsInteger:=Current.Project_Id;
             FieldByName('WorkGroup').AsInteger:=Current.WorkGroup;
             FieldByName('Relay_Route').AsInteger:=Current.Relay_Route;
             FieldByName('Relay_Id').AsInteger:=Current.Relay_Id;
             if Current.Relay_Id=1
               then
                 begin
                 //确定该掘进任务的开始时间
                   //通过界面输入该掘进队的第一个掘进任务的开始时间
                   TimePara_Frm:=TTimePara_Frm.Create(self);
                   TimePara_Frm.ShowModal;
                   BeginDay:=TimePara_Frm.BeginTime;
                   TimePara_Frm.Free;
                   TimePara_Frm:=nil;
                   FieldByName('Begin_Date').AsDateTime:=BeginDay;
                   FieldByName('End_Date').AsDateTime:=BeginDay+InsertTaskTime;
                 end;
             if Current.Relay_Id<>1 then
                 begin
                   EndDay:=trunc(CurrentPriorRelay.E_Date);//得到上一个接替任务的结束时间
                   FieldByName('Begin_Date').AsDateTime:=EndDay+Interv;
                   FieldByName('End_Date').AsDateTime:=EndDay+Interv+InsertTaskTime;
                 end;
           end;
       if (InsertWorkGroup<>Current.WorkGroup)and(Current.Relay_Id=1)and(Current.Sequence<>1) then
           begin
             if InsertWorkGroup=CurrentPriorRelay.WorkGroup //为上一个掘进队的最后一个接替任务的后面再插入一个接替任务
               then
                 begin
                   FieldByName('Project_Id').AsInteger:=CurrentPriorRelay.Project_Id;
                   FieldByName('WorkGroup').AsInteger:=CurrentPriorRelay.WorkGroup;
                   FieldByName('Relay_Route').AsInteger:=CurrentPriorRelay.Relay_Route;
                   FieldByName('Relay_Id').AsInteger:=CurrentPriorRelay.Relay_Id+1;

                   EndDay:=trunc(CurrentPriorRelay.E_Date);//得到上一个接替任务的结束时间
                   FieldByName('Begin_Date').AsDateTime:=EndDay+Interv;
                   FieldByName('End_Date').AsDateTime:=EndDay+Interv+InsertTaskTime;
                 end;
             if InsertWorkGroup<>CurrentPriorRelay.WorkGroup then
               begin
                 Inf:=messagedlg('确定在本方案第一个掘进队的前面插入新掘进队吗?若是请按"yes",若插入上一个方案的最后一个掘进队请按"no"!',mtconfirmation,[mbyes,mbno,mbcancel],0);
                 if Inf=mryes then  //在本方案的第一个掘进队前面插入一个新的掘进队
                   begin
                     FieldByName('Project_Id').AsInteger:=Current.Project_Id;
                     //判断新插入的记录的掘进队在本方案中(插入前的当前记录所在的方案)是否重复
                     for i:=1 to High(Relay) do
                       begin
                         if (Relay[i].Project_Id=Current.Project_Id)
                             and(Relay[i].WorkGroup=InsertWorkGroup)then
                           begin
                             Inf1:=messagedlg('方案 '+inttostr(Current.Project_Id)+' 中重复安排了 "'+InsertWorkGroupName+'" 掘进队,请重新指定掘进队!继续请按"yes"!',mtconfirmation,[mbyes,mbno],0);
                             if Inf1=mrno then
                               begin
                                 Cancel; //取消插入操作
                                 InsertMode:=false;
                                 //还原对原表中从当前记录到以后的记录所做的临时修改
                                 GotoBookmark(Mark);

                                 j:=1;
                                 while not Eof do
                                    begin
                                      Edit;
                                      FieldByName('Sequence').AsInteger:=BehindRelay[j].Sequence;
                                      Post; //更新后表的指针仍然指向当前记录,但是,当关闭再打开该表后,该当前记录的Sequence字段值若仍然为-1,则指针指向的记录将发生变化
                                      Next;
                                      j:=j+1;
                                    end;
                                 GotoBookmark(Mark);
                                 DBGrid1.ReadOnly:=true;
                                 DBGrid1.Enabled:=true;
                                 BitBtn1.Enabled:=true;
                                 BitBtn2.Enabled:=true;
                                 BitBtn4.Enabled:=true;
                                 BitBtn5.Enabled:=true;
                                 BitBtn6.Enabled:=true;
                                 BitBtn7.Enabled:=true;
                                 BitBtn8.Enabled:=true;
                                 BitBtn9.Enabled:=true;
                                 BitBtn10.Enabled:=true;
                                 BitBtn11.Enabled:=true;
                                 BitBtn12.Enabled:=true;
                                 BitBtn13.Enabled:=true;

                                 DBLookUpComboBox1.Enabled:=false;
                                 ComboBox1.Enabled:=false;
                                 DBLookUpComboBox2.Enabled:=false;
                                 DBLookUpComboBox3.Enabled:=false;
                                 DBLookUpListBox1.Enabled:=false;
                                 Label5.Caption:='';
                                 exit;
                               end;
                             DBLookUpComboBox2.SetFocus;
                             exit;
                           end;
                       end;
                     FieldByName('WorkGroup').AsInteger:=InsertWorkGroup;
                     FieldByName('Relay_Route').AsInteger:=1;
                     FieldByName('Relay_Id').AsInteger:=1;

                     //确定该掘进任务的开始时间
                     //通过界面输入该掘进队的第一个掘进任务的开始时间
                     TimePara_Frm:=TTimePara_Frm.Create(self);
                     TimePara_Frm.ShowModal;
                     BeginDay:=TimePara_Frm.BeginTime;
                     TimePara_Frm.Free;
                     TimePara_Frm:=nil;
                     FieldByName('Begin_Date').AsDateTime:=BeginDay;
                     FieldByName('End_Date').AsDateTime:=BeginDay+InsertTaskTime;
                     //---------------------------
                   end;
                 if Inf=mrno then //插入上一个方案的最后一个掘进队
                   begin
                     FieldByName('Project_Id').AsInteger:=CurrentPriorRelay.Project_Id;
                     //判断新插入的记录的掘进队在上个方案中(插入前的当前记录的前一条记录所在的方案)是否重复
                     for i:=1 to High(Relay) do
                       begin
                         if (Relay[i].Project_Id=CurrentPriorRelay.Project_Id)
                             and(Relay[i].WorkGroup=InsertWorkGroup)then
                           begin
                             Inf1:=messagedlg('方案 '+inttostr(CurrentPriorRelay.Project_Id)+' 中重复安排了 "'+InsertWorkGroupName+'" 掘进队,请重新指定掘进队!继续请按"yes"!',mtconfirmation,[mbyes,mbno],0);
                             if Inf1=mrno then
                               begin
                                 Cancel; //取消插入操作
                                 InsertMode:=false;
                                 //还原对原表中从当前记录到以后的记录所做的临时修改
                                 GotoBookmark(Mark);

                                 j:=1;
                                 while not Eof do
                                    begin
                                      Edit;
                                      FieldByName('Sequence').AsInteger:=BehindRelay[j].Sequence;
                                      Post; //更新后表的指针仍然指向当前记录,但是,当关闭再打开该表后,该当前记录的Sequence字段值若仍然为-1,则指针指向的记录将发生变化
                                      Next;
                                      j:=j+1;
                                    end;
                                 GotoBookmark(Mark);
                                 DBGrid1.ReadOnly:=true;
                                 DBGrid1.Enabled:=true;
                                 BitBtn1.Enabled:=true;
                                 BitBtn2.Enabled:=true;
                                 BitBtn4.Enabled:=true;
                                 BitBtn5.Enabled:=true;
                                 BitBtn6.Enabled:=true;
                                 BitBtn7.Enabled:=true;
                                 BitBtn8.Enabled:=true;
                                 BitBtn9.Enabled:=true;
                                 BitBtn10.Enabled:=true;
                                 BitBtn11.Enabled:=true;
                                 BitBtn12.Enabled:=true;
                                 BitBtn13.Enabled:=true;

                                 DBLookUpComboBox1.Enabled:=false;
                                 ComboBox1.Enabled:=false;
                                 DBLookUpComboBox2.Enabled:=false;
                                 DBLookUpComboBox3.Enabled:=false;
                                 DBLookUpListBox1.Enabled:=false;
                                 Label5.Caption:='';
                                 exit;
                               end;
                             DBLookUpComboBox2.SetFocus;
                             exit;
                           end;
                       end;
                     FieldByName('WorkGroup').AsInteger:=InsertWorkGroup;
                     FieldByName('Relay_Route').AsInteger:=CurrentPriorRelay.Relay_Route+1;
                     FieldByName('Relay_Id').AsInteger:=1;
                     //确定该掘进任务的开始时间
                     //通过界面输入该掘进队的第一个掘进任务的开始时间
                     TimePara_Frm:=TTimePara_Frm.Create(self);
                     TimePara_Frm.ShowModal;
                     BeginDay:=TimePara_Frm.BeginTime;
                     TimePara_Frm.Free;
                     TimePara_Frm:=nil;
                     FieldByName('Begin_Date').AsDateTime:=BeginDay;
                     FieldByName('End_Date').AsDateTime:=BeginDay+InsertTaskTime;
                   end;
                 if Inf=mrcancel then
                   begin
                     Cancel; //取消插入操作
                     InsertMode:=false;
                     //还原对原表中从当前记录到以后的记录所做的临时修改
                     GotoBookmark(Mark);

                     i:=1;
                     while not Eof do
                        begin
                          Edit;
                          FieldByName('Sequence').AsInteger:=BehindRelay[i].Sequence;
                          Post; //更新后表的指针仍然指向当前记录,但是,当关闭再打开该表后,该当前记录的Sequence字段值若仍然为-1,则指针指向的记录将发生变化
                          Next;
                          i:=i+1;
                        end;
                     GotoBookmark(Mark);
                     DBGrid1.ReadOnly:=true;
                     DBGrid1.Enabled:=true;
                     BitBtn1.Enabled:=true;
                     BitBtn2.Enabled:=true;
                     BitBtn4.Enabled:=true;
                     BitBtn5.Enabled:=true;
                     BitBtn6.Enabled:=true;
                     BitBtn7.Enabled:=true;
                     BitBtn8.Enabled:=true;
                     BitBtn9.Enabled:=true;
                     BitBtn10.Enabled:=true;
                     BitBtn11.Enabled:=true;
                     BitBtn12.Enabled:=true;
                     BitBtn13.Enabled:=true;

                     DBLookUpComboBox1.Enabled:=false;
                     ComboBox1.Enabled:=false;
                     DBLookUpComboBox2.Enabled:=false;
                     DBLookUpComboBox3.Enabled:=false;
                     DBLookUpListBox1.Enabled:=false;
                     Label5.Caption:='';
                     exit;
                   end;
               end;
           end;
       if (InsertWorkGroup<>Current.WorkGroup)and(Current.Relay_Id<>1) then
         begin
           if Worker_DataS.DataSet.Locate('WorkGroup_Id',Current.WorkGroup,[locaseinsensitive])
              then
                begin
                  Name1:=Worker_DataS.DataSet.fieldbyname('WorkGroup_Name').AsString;
                end;
           if Name1='' then
             begin
               showmessage('数据库有问题:接替表中的施工队与施工队表中的数据不对应!');
               Cancel;
               InsertMode:=false;
               //还原对原表中从当前记录到以后的记录所做的临时修改
               GotoBookmark(Mark);
               i:=1;
               while not Eof do
                  begin
                    Edit;
                    FieldByName('Sequence').AsInteger:=BehindRelay[i].Sequence;
                    Post; //更新后表的指针仍然指向当前记录,但是,当关闭再打开该表后,该当前记录的Sequence字段值若仍然为-1,则指针指向的记录将发生变化
                    Next;
                    i:=i+1;
                  end;
               DBGrid1.ReadOnly:=true;
               DBGrid1.Enabled:=true;
               BitBtn1.Enabled:=true;
               BitBtn2.Enabled:=true;
               BitBtn4.Enabled:=true;
               BitBtn5.Enabled:=true;
               BitBtn6.Enabled:=true;
               BitBtn7.Enabled:=true;
               BitBtn8.Enabled:=true;
               BitBtn9.Enabled:=true;
               BitBtn10.Enabled:=true;
               BitBtn11.Enabled:=true;
               BitBtn12.Enabled:=true;
               BitBtn13.Enabled:=true;

⌨️ 快捷键说明

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