📄 drillworkpriortask_unt.pas
字号:
Base_DataS.DataSet.FieldByName('Sequence').AsInteger:=i+1;
if Current.Id=1 //删除的记录是某施工队的第一个接替任务,其后的起始时间不变,可以通过修改功能来改变
then
begin
if(s=Current.DrillTask_Id)then
begin
k:=k+1;
Base_DataS.DataSet.FieldByName('Id').AsInteger:=k;
end;
end
else
begin
if(s=Current.DrillTask_Id)then
begin
Base_DataS.DataSet.FieldByName('Id').AsInteger:=j+1;
j:=j+1;
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 TDrillWorkPriorTask_Frm.Insert_Deal; //在当前记录的前一个位置上插入新记录,并且对相关字段值进行调整
var
i,j,r,m1:integer;
Name1:string;
Inf1,Inf:Variant;
InsertTask_Id,InsertPriorTask_Id:integer; //新插入的记录的施工队和工作面的编号
InsertPriorTask_Name,InsertTask_Name:string; //新插入的记录的施工队和工作面的名称
begin
//................
if varisnull(Base_DataS.DataSet.FieldByName('DrillTask_Id').Value) then
begin
showmessage('请选择相应的掘进工作任务!');
exit;
end;
if varisnull(Base_DataS.DataSet.FieldByName('PriorTask_Id').Value) then
begin
showmessage('请选择对应的前工序!');
exit;
end;
//取得界面给新插入记录指定的值,这些值可能不符合要求,需要进行调整
InsertTask_Id:=DrillWorkTask_DataS.DataSet.FieldByName('Id').AsInteger;
InsertTask_Name:=DrillWorkTask_DataS.DataSet.FieldByName('Name').AsString;
InsertPriorTask_Name:=SelectPriorTask_DataS.DataSet.FieldByName('Name').AsString;
InsertPriorTask_Id:=SelectPriorTask_DataS.DataSet.FieldByName('Id').AsInteger;
//最终确定新插入记录的各个字段值
with Base_DataS.DataSet do
begin
FieldByName('Sequence').AsInteger:=Current.Sequence;
//判断是否被安排了重复的前工序
for i:=1 to High(PriorTask) do
begin
if(PriorTask[i].DrillTask_Id=InsertTask_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 (InsertTask_Id=Current.DrillTask_Id) //给某个掘进任务插入一个前工序
then
begin
FieldByName('DrillTask_Id').AsInteger:=Current.DrillTask_Id;
FieldByName('Id').AsInteger:=Current.Id;
FieldByName('PriorTask_Name').AsString:=InsertPriorTask_Name;
FieldByName('PriorTask_Id').AsInteger:=InsertPriorTask_Id;
end;
if (InsertTask_Id<>Current.DrillTask_Id)and(Current.Id=1)and(Current.Sequence<>1) then
begin
if InsertTask_Id=CurrentPrior.DrillTask_Id //为上一个掘进任务的最后一个前工序的后面再插入一个前工序
then
begin
FieldByName('DrillTask_Id').AsInteger:=CurrentPrior.DrillTask_Id;
FieldByName('Id').AsInteger:=CurrentPrior.Id+1;
FieldByName('PriorTask_Name').AsString:=InsertPriorTask_Name;
FieldByName('PriorTask_Id').AsInteger:=InsertPriorTask_Id;
end;
if InsertTask_Id<>CurrentPrior.DrillTask_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].DrillTask_Id=InsertTask_Id)then
begin
Inf1:=messagedlg('重复安排了 "'+InsertTask_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('DrillTask_Id').AsInteger:=InsertTask_Id;
//FieldByName('Relay_Route').AsInteger:=1;
FieldByName('Id').AsInteger:=1;
FieldByName('PriorTask_Name').AsString:=InsertPriorTask_Name;
FieldByName('PriorTask_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 (InsertTask_Id<>Current.DrillTask_Id)and(Current.Id<>1) then
begin
if DrillWorkTask_DataS.DataSet.Locate('Id',Current.DrillTask_Id,[locaseinsensitive])
then
begin
Name1:=DrillWorkTask_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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -