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

📄 priortask_unt.pas

📁 煤矿行业采掘接替计划自动生成系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
                      end;
                 end;
            Base_DataS.DataSet.Post;
            i:=i+1;
            Base_DataS.DataSet.Next;
          end;
  if Base_DataS.DataSet.RecordCount>1 then Base_DataS.DataSet.GotoBookmark(MK);
  Base_DataS.DataSet.FreeBookmark(MK);

end;

procedure TPriorTask_Frm.Insert_Deal; //在当前记录的前一个位置上插入新记录,并且对相关字段值进行调整
var
i,j,r,m1:integer;
Name1:string;
Inf1,Inf:Variant;
InsertLane_Id,InsertPriorTask_Id:integer; //新插入的记录的施工队和工作面的编号
InsertPriorTask_Name,InsertLane_Name:string; //新插入的记录的施工队和工作面的名称
begin
   //................
   if varisnull(Base_DataS.DataSet.FieldByName('Lane_Id').Value) then
     begin
       showmessage('请选择相应的掘进任务!');
       exit;
     end;
   if varisnull(Base_DataS.DataSet.FieldByName('PriorLane_Id').Value) then
     begin
       showmessage('请选择掘进任务对应的前工序!');
       exit;
     end;
   //取得界面给新插入记录指定的值,这些值可能不符合要求,需要进行调整
   InsertLane_Id:=Lane_DataS.DataSet.FieldByName('Lane_Id').AsInteger;
   InsertLane_Name:=Lane_DataS.DataSet.FieldByName('Name').AsString;
   InsertPriorTask_Name:=SelectPriorTask_DataS.DataSet.FieldByName('Name').AsString;
   InsertPriorTask_Id:=SelectPriorTask_DataS.DataSet.FieldByName('Lane_Id').AsInteger;

   //最终确定新插入记录的各个字段值
   with Base_DataS.DataSet do
     begin
       FieldByName('Sequence').AsInteger:=Current.Sequence;
       //判断是否被安排了重复的前工序
       for i:=1 to High(PriorTask) do
         begin
           if(PriorTask[i].Lane_Id=InsertLane_Id)
              and(PriorTask[i].PriorTask_Id=InsertPriorTask_Id) then
             begin
               Inf1:=messagedlg('不能重复指定前工序 "'+InsertPriorTask_Name+'",请重新指定!,继续请按"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:=CurrentBehind[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;
                   DBLookUpComboBox1.Enabled:=false;
                   DBLookUpComboBox2.Enabled:=false;
                   exit;
                 end;
               DBLookUpComboBox1.SetFocus;
               exit;
             end;
         end;
       //根据从界面输入的有关信息,分三种情况来处理插入:
       if (InsertLane_Id=Current.Lane_Id) //给某个掘进任务插入一个前工序
         then
           begin
             FieldByName('Lane_Id').AsInteger:=Current.Lane_Id;
             FieldByName('Id').AsInteger:=Current.Id;
             FieldByName('PriorLane_Name').AsString:=InsertPriorTask_Name;
             FieldByName('PriorLane_Id').AsInteger:=InsertPriorTask_Id;
           end;
       if (InsertLane_Id<>Current.Lane_Id)and(Current.Id=1)and(Current.Sequence<>1) then
           begin
             if InsertLane_Id=CurrentPrior.Lane_Id //为上一个掘进任务的最后一个前工序的后面再插入一个前工序
               then
                 begin
                   //FieldByName('Project_Id').AsInteger:=CurrentPriorRelay.Project_Id;
                   FieldByName('Lane_Id').AsInteger:=CurrentPrior.Lane_Id;
                   //FieldByName('Relay_Route').AsInteger:=CurrentPriorRelay.Relay_Route;
                   FieldByName('Id').AsInteger:=CurrentPrior.Id+1;
                   FieldByName('PriorLane_Name').AsString:=InsertPriorTask_Name;
                   FieldByName('PriorLane_Id').AsInteger:=InsertPriorTask_Id;

                   //EndDay:=trunc(CurrentPriorRelay.E_Date);//得到上一个接替面的结束时间
                   //FieldByName('Begin_Date').AsDateTime:=EndDay+Interv;
                   //FieldByName('End_Date').AsDateTime:=EndDay+Interv+InsertTaskTime;
                 end;
             if InsertLane_Id<>CurrentPrior.Lane_Id then
               begin
                 Inf:=messagedlg('确定在本掘进任务的前面插入新掘进任务来指定前工序吗?若是请按"yes"',mtconfirmation,[mbyes,mbno,mbcancel],0);
                 if Inf=mryes then  //在本掘进任务前面插入一个新的掘进任务来指定前工序
                   begin
                     ///FieldByName('Project_Id').AsInteger:=Current.Project_Id;
                     //判断新插入的记录的掘进任务编号是否重复
                     for i:=1 to High(PriorTask) do
                       begin
                         if(PriorTask[i].Lane_Id=InsertLane_Id)then
                           begin
                             Inf1:=messagedlg('重复安排了 "'+InsertLane_Name+'" ,请重新选择掘进任务!继续请按"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:=CurrentBehind[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;


                                 DBLookUpComboBox1.Enabled:=false;
                                 DBLookUpComboBox2.Enabled:=false;
                                 exit;
                               end;
                             DBLookUpComboBox1.SetFocus;
                             exit;
                           end;
                       end;
                     FieldByName('Lane_Id').AsInteger:=InsertLane_Id;
                     //FieldByName('Relay_Route').AsInteger:=1;
                     FieldByName('Id').AsInteger:=1;
                     FieldByName('PriorLane_Name').AsString:=InsertPriorTask_Name;
                     FieldByName('PriorLane_Id').AsInteger:=InsertPriorTask_Id;
                   end;
                 if Inf=mrcancel then
                   begin
                     Cancel; //取消插入操作
                     InsertMode:=false;
                     //还原对原表中从当前记录到以后的记录所做的临时修改
                     GotoBookmark(Mark);

                     i:=1;
                     while not Eof do
                        begin
                          Edit;
                          FieldByName('Sequence').AsInteger:=CurrentBehind[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;
                     DBLookUpComboBox1.Enabled:=false;
                     DBLookUpComboBox2.Enabled:=false;
                     exit;
                   end;
               end;
           end;
       if (InsertLane_Id<>Current.Lane_Id)and(Current.Id<>1) then
         begin
           if Lane_DataS.DataSet.Locate('Lane_Id',Current.Lane_Id,[locaseinsensitive])
              then
                begin
                  Name1:=Lane_DataS.DataSet.fieldbyname('Name').AsString;
                end;
           if Name1='' then
             begin
               showmessage('数据库有问题:接替表中的施工队与施工队表中的数据不对应!');
               Cancel;
               InsertMode:=false;
               //还原对原表中从当前记录到以后的记录所做的临时修改
               GotoBookmark(Mark);
               i:=1;
               while not Eof do
                  begin
                    Edit;
                    FieldByName('Sequence').AsInteger:=CurrentBehind[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;
               DBLookUpComboBox1.Enabled:=false;
               DBLookUpComboBox2.Enabled:=false;
               exit;
             end;
           Inf1:=messagedlg('只能选择 "'+Name1+'" 来指定前工序,请选择!继续请按"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:=CurrentBehind[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;
               DBLookUpComboBox1.Enabled:=false;
               DBLookUpComboBox2.Enabled:=false;
               exit;
             end;
           DBLookUpComboBox1.SetFocus;
           exit;
         end;
       //FieldByName('Face_Lane').AsInteger:=InsertFace;
     end;

   try
     //记录插入的回采面的开始时间和结束时间
     Base_DataS.DataSet.Post; //更新插入的记录

//记录指针返回到开始插入时的位置,对插入数据后的表进行修正,主要是修正“Sequence”、“Relay_Route”、“Relay_Id”、“Begin_Time”和“End_Time”字段
     Base_DataS.DataSet.GotoBookmark(Mark);

  //------------------test------------------------
    //r:=Base_DataS.DataSet.FieldByName('Lane_Id').AsInteger;
    //showmessage('当前记录的掘进任务编号为: '+inttostr(r));

  //---------------------test------------------
     with Base_DataS.DataSet do
       begin
         if InsertLane_Id=Current.Lane_Id then
           begin
             m1:=Current.Lane_Id;
             for i:=1 to High(CurrentBehind) do
               begin
                 if (CurrentBehind[i].Lane_Id=m1)then
                     begin
                       Edit;
                       FieldByName('Sequence').AsInteger:=CurrentBehind[i].Sequence+1;
                       FieldByName('Id').AsInteger:=CurrentBehind[i].Id+1;
                       Post;
                     end

⌨️ 快捷键说明

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