📄 priortask_unt.pas
字号:
else
begin
Edit;
FieldByName('Sequence').AsInteger:=CurrentBehind[i].Sequence+1;
Post;
end;
next;
end;
end;
if (InsertLane_Id<>Current.Lane_Id)and(Current.Id=1) then
begin
if InsertLane_Id=CurrentPrior.Lane_Id then //插入的是上一个掘进任务的最后一个前工序
begin
for i:=1 to High(CurrentBehind) do
begin
Edit;
FieldByName('Sequence').AsInteger:=CurrentBehind[i].Sequence+1;
Post;
next;
end;
end;
if InsertLane_Id<>CurrentPrior.Lane_Id then
begin
if Inf=mryes then //插入的记录是原当前记录(插入之前,指针指向的记录)所在的掘进任务的第一个前工序,插入的是一个新掘进任务的第一个前工序
begin
for i:=1 to High(CurrentBehind) do
begin
Edit;
FieldByName('Sequence').AsInteger:=CurrentBehind[i].Sequence+1;
Post;
next;
end;
end;
end;
end;
end;
//把插入并更新后的接替表关闭后再打开,以显现出插入后的效果
Base_DataS.DataSet.Close;
Base_DataS.DataSet.Open;
Base_DataS.DataSet.GotoBookmark(Mark);
Base_DataS.DataSet.FreeBookmark(Mark);
except
Base_DataS.DataSet.Cancel; //取消表的插入状态
showmessage('插入操作更新没有成功!');
end;
//插入并更新成功后进行善后处理
InsertMode:=false;//更新成功或者更新没有成功都取消界面的插入状态
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;
BitBtn1.SetFocus;
end;
procedure TPriorTask_Frm.BitBtn9Click(Sender: TObject);
var
CurrentRecNo,LastRecNo,i,m:integer;
begin
//在当前记录的前面插入一条新记录,
InsertMode:=true;
if Base_DataS.DataSet.RecordCount=0 then
begin
showmessage('不能在空表中插入!');
exit;
end;
BitBtn3.Enabled:=true;
BitBtn1.Enabled:=false;
BitBtn2.Enabled:=false;
BitBtn4.Enabled:=false;
BitBtn5.Enabled:=false;
BitBtn6.Enabled:=false;
BitBtn7.Enabled:=false;
BitBtn8.Enabled:=false;
BitBtn9.Enabled:=false;
DBGrid1.ReadOnly:=false;
DBGrid1.Enabled:=false;
//读取当前记录的信息
with Base_DataS.DataSet do
begin
Current.Sequence:=FieldByName('Sequence').AsInteger;
Current.Lane_Id:=FieldByName('Lane_Id').AsInteger;
Current.Id:=FieldByName('Id').AsInteger;
Current.PriorTask_Name:=FieldByName('PriorLane_Name').AsString;
Current.PriorTask_Id:=FieldByName('PriorLane_Id').AsInteger;
end;
if Current.Sequence=1 then
begin
showmessage('不能在第一条记录前插入记录,请重新选择插入位置!');
Base_DataS.DataSet.Cancel; //取消插入操作
InsertMode:=false;
BitBtn3.Enabled:=false;
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;
//读取当前记录的前面一条信息
Base_DataS.DataSet.Prior;
with Base_DataS.DataSet do
begin
CurrentPrior.Sequence:=FieldByName('Sequence').AsInteger;
CurrentPrior.Lane_Id:=FieldByName('Lane_Id').AsInteger;
CurrentPrior.Id:=FieldByName('Id').AsInteger;
CurrentPrior.PriorTask_Name:=FieldByName('PriorLane_Name').AsString;
CurrentPrior.PriorTask_Id:=FieldByName('PriorLane_Id').AsInteger;
end;
Base_DataS.DataSet.Next; //返回原位置
//确定当前记录及其以后的记录数目
CurrentRecNo:=Base_DataS.DataSet.RecNo;
Mark:=Base_DataS.DataSet.GetBookmark;
Base_DataS.DataSet.Last;
LastRecNo:=Base_DataS.DataSet.RecNo;
m:=LastRecNo-CurrentRecNo+1;
Setlength(CurrentBehind,m+1);
//读取当前记录及其以后的所有记录信息
Base_DataS.DataSet.GotoBookmark(Mark); //返回原位置
i:=1;
if Base_DataS.DataSet.Eof then
begin
with Base_DataS.DataSet do
begin
CurrentBehind[i].Sequence:=FieldByName('Sequence').AsInteger;
CurrentBehind[i].Lane_Id:=FieldByName('Lane_Id').AsInteger;
CurrentBehind[i].Id:=FieldByName('Id').AsInteger;
CurrentBehind[i].PriorTask_Name:=FieldByName('PriorLane_Name').AsString;
CurrentBehind[i].PriorTask_Id:=FieldByName('PriorLane_Id').AsInteger;
end;
end;
while not Base_DataS.DataSet.Eof do
begin
with Base_DataS.DataSet do
begin
CurrentBehind[i].Sequence:=FieldByName('Sequence').AsInteger;
CurrentBehind[i].Lane_Id:=FieldByName('Lane_Id').AsInteger;
CurrentBehind[i].Id:=FieldByName('Id').AsInteger;
CurrentBehind[i].PriorTask_Name:=FieldByName('PriorLane_Name').AsString;
CurrentBehind[i].PriorTask_Id:=FieldByName('PriorLane_Id').AsInteger;
next;
i:=i+1;
end;
end;
//读取表中的所有信息存入数组PriorTask中,以便在需要的时候进行数据比较和检查等处理
with Base_DataS.DataSet do
begin
setlength(PriorTask,RecordCount+1);
first;
i:=1;
while not eof do
begin
PriorTask[i].Sequence:=FieldByName('Sequence').AsInteger;
PriorTask[i].Lane_Id:=FieldByName('Lane_Id').AsInteger;
PriorTask[i].Id:=FieldByName('Id').AsInteger;
PriorTask[i].PriorTask_Name:=FieldByName('PriorLane_Name').AsString;
PriorTask[i].PriorTask_Id:=FieldByName('PriorLane_Id').AsInteger;
next;
i:=i+1;
end;
end;
Base_DataS.DataSet.GotoBookmark(Mark);
//暂时修改当前和以后的记录的Sequence字段值为从-1开始的负值,在插入的记录更新后,再指定相应的值
//以便新插入的记录的Sequence字段可以指定为当前记录的该字段的值
i:=-1;
while not Base_DataS.DataSet.Eof do
begin
Base_DataS.DataSet.Edit;
Base_DataS.DataSet.FieldByName('Sequence').AsInteger:=i;
Base_DataS.DataSet.Post; //更新后表的指针仍然指向当前记录,但是,当关闭再打开该表后,该当前记录的Sequence字段值若仍然为-1,则指针指向的记录将发生变化
Base_DataS.DataSet.Next;
i:=i-1;
end;
Base_DataS.DataSet.GotoBookmark(Mark);
Base_DataS.DataSet.Insert;
DBLookUpComboBox1.Enabled:=true;
DBLookUpComboBox2.Enabled:=true;
DBLookUpComboBox1.SetFocus;
end;
procedure TPriorTask_Frm.FormCreate(Sender: TObject);
begin
inherited;
InsertMode:=false;
Modify:=false;
with Lane_AdoQ do
begin
close;
sql.Clear;
sql.Add('select * from 巷道f');
sql.Add('where State<>:v1');
sql.Add('order by Lane_Id asc');
Parameters.ParamByName('v1').Value:='已完工';
ExecSQL;
open;
end;
DBLookUpComboBox1.ListSource:=Lane_DataS;
DBLookUpComboBox1.ListField:='Name';
DBLookUpComboBox1.KeyField:='Lane_Id';
end;
procedure TPriorTask_Frm.DBLookupComboBox1Click(Sender: TObject);
var
str1,str2,Area,Face:string;
i,j,Area_Id:integer;
IsFirstFace:boolean;
begin
//列出DBLookupComboBox1对应的掘进任务可能的前工序
//判断掘进任务所在的采区的状态,以判断首采面
str1:=DBLookUpComboBox1.Text;
if str1='' then exit; //若str1不为空,则已经在Base_DataS的数据集中定位了str1对应的记录
Area:=Lane_DataS.DataSet.FieldByName('Area').AsString;
Face:=Lane_DataS.DataSet.FieldByName('Face').AsString;
Data_Frm.Area_AdoTab.Locate('Area_Name',Area,[locaseinsensitive]);
IsFirstFace:=false;
if Data_Frm.Area_AdoTab.FieldByName('State').AsString='准备采区' then IsFirstFace:=true;
if (Face<>'')and(not IsFirstFace) then
begin
with SelectPriorTask_AdoQ do
begin
close;
sql.Clear;
sql.Add('select * from 巷道f');
sql.Add('where Face=:v1');
sql.Add('order by Lane_Id asc');
Parameters.ParamByName('v1').Value:=Face;
ExecSQL;
open;
end;
end;
if(Face<>'')and(IsFirstFace) then
begin //找到该掘进任务所在的回采面对应的采区的开拓、准备巷道任务,以及该回采面的回采巷道任务,排除掉该掘进任务所在采区的其它回采面的回采巷道任务
with SelectPriorTask_AdoQ do
begin
close;
sql.Clear;
sql.Add('select * from 巷道f');
sql.Add('where (Area=:v1)and((Face=:v2)or(Face=:v3))');
sql.Add('order by Lane_Id asc');
Parameters.ParamByName('v1').Value:=Area;
Parameters.ParamByName('v2').Value:='';
Parameters.ParamByName('v3').Value:=Face;
ExecSQL;
open;
end;
end;
if Face='' then
begin
with SelectPriorTask_AdoQ do
begin
close;
sql.Clear;
sql.Add('select * from 巷道f');
sql.Add('where (Area=:v1)and(Property<>:v2)');
sql.Add('order by Lane_Id asc');
Parameters.ParamByName('v1').Value:=Area;
Parameters.ParamByName('v2').Value:='回采巷道';
ExecSQL;
open;
end;
end;
DBLookUpComboBox2.ListSource:=SelectPriorTask_DataS;
DBLookUpComboBox2.ListField:='Name';
DBLookUpComboBox2.KeyField:='Lane_Id';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -