📄 drilltask_unt.pas
字号:
InsertMode:=true;
if Base_DataS.DataSet.RecordCount=0 then exit;
BK:=Base_DataS.DataSet.GetBookmark;
//Base_DataS.DataSet.Next;
//确定当前记录及其以后的记录数目
//CurrentProject:=Base_DataS.DataSet.FieldByName('Project_Id').AsInteger;
CurrentRecNo:=Base_DataS.DataSet.RecNo;
InsertRecNo:=CurrentRecNo;//记录插入记录的标号
CurrentType:=Base_DataS.DataSet.FieldByName('Type').AsString;
if CurrentRecNo>1 then
begin
Base_DataS.DataSet.Prior;
PriorType:=Base_DataS.DataSet.FieldByName('Type').AsString;
end;
Base_DataS.DataSet.Last;
LastRecNo:=Base_DataS.DataSet.RecNo;
m:=LastRecNo-CurrentRecNo+1;
Setlength(BehindSequence,m+1);
//读取当前记录及其以后的所有记录的序号信息Lane_Id
Base_DataS.DataSet.GotoBookmark(BK); //返回原位置
with Base_DataS.DataSet do
begin
i:=1;
while not eof do
begin
BehindSequence[i]:=FieldByName('Id').AsInteger;
next;
i:=i+1;
end;
end;
Base_DataS.DataSet.GotoBookmark(BK); //返回原位置
{//读取当前记录之前的记录
setlength(CurrentBeforeTask,CurrentRecNo);
with Base_DataS.DataSet do
begin
first;
i:=1;
while RecNo<CurrentRecNo do
begin
CurrentBeforeTask[i].Id:=FieldByName('Id').AsInteger;
CurrentBeforeTask[i].Name:=FieldByName('Name').AsString;
CurrentBeforeTask[i].TaskType:=FieldByName('Type').AsString;
next;
i:=i+1;
end;
end;
//将获取的记录的名称显示在DBComboBox1的列表中
DBComboBox2.Items.Clear;
for i:=1 to High(CurrentBeforeTask) do
begin
DBComboBox2.Items.Add(CurrentBeforeTask[i].Name);
end; }
//把插入位置以后的记录的序号暂时变为从-1开始的负值
with Base_DataS.DataSet do
begin
//i:=1;
j:=-1;
while not eof do
begin
edit;
FieldByName('Id').AsInteger:=j;
post;
next;
//i:=i+1;
j:=j-1;
end;
end;
Base_DataS.DataSet.GotoBookmark(BK); //返回原位置
Base_DataS.DataSet.Insert;
//把插入记录的序号改为插入时的当前记录的序号
Base_DataS.DataSet.FieldByName('Id').AsInteger:=BehindSequence[1];
//Base_DataS.DataSet.FieldByName('Project_Id').AsInteger:=CurrentProject;
Base_DataS.DataSet.Post;//此时,这个插入的记录被更新到最后一个记录
Base_DataS.DataSet.GotoBookmark(BK); //返回原位置
//把插入位置以后的记录的暂时变为从-1开始的负值的序号再进行修正
with Base_DataS.DataSet do
begin
i:=1;
while RecNo<=LastRecNo do
begin
edit;
FieldByName('Id').AsInteger:=BehindSequence[i]+1;
post;
next;
i:=i+1;
//j:=j-1;
end;
end;
Base_DataS.DataSet.Close;
Base_DataS.DataSet.Open;
Base_DataS.DataSet.First;
//找到新插入的记录,然后具体填写记录的信息
while not Base_DataS.DataSet.Eof do
begin
if Base_DataS.DataSet.RecNo=InsertRecNo then break;
Base_DataS.DataSet.Next;
end;
Base_DataS.DataSet.Edit;
BitBtn3.Enabled:=true;
DBGrid1.ReadOnly:=false;
//DBGrid1.Enabled:=false;
BitBtn1.Enabled:=false;
BitBtn2.Enabled:=false;
BitBtn4.Enabled:=false;
BitBtn5.Enabled:=false;
BitBtn6.Enabled:=false;
BitBtn7.Enabled:=false;
BitBtn8.Enabled:=false;
BitBtn10.Enabled:=false;
BitBtn11.Enabled:=false;
//ModifyRec(Base_DataS.DataSet);
for i:=1 to Panel2.ControlCount do
begin
if (Panel2.Controls[i-1].Tag>=0)and(Panel2.Controls[i-1].ClassType<>TLabel)
and(Panel2.Controls[i-1].ClassType<>TDBGrid)and(Panel2.Controls[i-1].ClassType<>TBitBtn) then
Panel2.Controls[i-1].Enabled:=true;
end;
//方案编号不允许修改,插入记录的方案编号必须和当前记录相同
//DBLookUpComboBox1.Enabled:=false;
DBEdit1.SetFocus;
end;
procedure TDrillTask_Frm.FormCreate(Sender: TObject);
begin
inherited;
InsertMode:=false;
AddMode:=false;
end;
procedure TDrillTask_Frm.BitBtn10Click(Sender: TObject);
var
CurrentRec,CurrentPriorRec:TDrillTaskInfo;
begin
if Base_DataS.DataSet.RecordCount=0 then exit;
with Base_DataS.DataSet do
begin
CurrentRec.Id:=FieldByName('Id').AsInteger;
CurrentRec.Name:=FieldByName('Name').AsString;
CurrentRec.TaskType:=FieldByName('Type').AsString;
end;
if CurrentRec.Id=1 then exit;
Base_DataS.DataSet.Prior;
With Base_DataS.DataSet do
begin
CurrentPriorRec.Id:=FieldByName('Id').AsInteger;
CurrentPriorRec.Name:=FieldByName('Name').AsString;
CurrentPriorRec.TaskType:=FieldByName('Type').AsString;
end;
Base_DataS.DataSet.Next;//返回原位置
if CurrentPriorRec.TaskType<>CurrentRec.TaskType then exit; //不是同一个类型不能移动
//把当前记录变为当前记录的前一条记录
With Base_DataS.DataSet do
begin
Edit;
FieldByName('Name').AsString:=CurrentPriorRec.Name;
FieldByName('Type').AsString:=CurrentPriorRec.TaskType;
Post;
end;
Base_DataS.DataSet.Prior; //到当前记录的前一条记录
//把当前记录的前一条记录变为当前记录
With Base_DataS.DataSet do
begin
Edit;
FieldByName('Name').AsString:=CurrentRec.Name;
FieldByName('Type').AsString:=CurrentRec.TaskType;
Post;
end;
end;
procedure TDrillTask_Frm.BitBtn11Click(Sender: TObject);
var
CurrentRec,CurrentNextRec:TDrillTaskInfo;
CurrentRecNo,LastRecNo:integer;
MK:Tbookmark;
begin
if Base_DataS.DataSet.RecordCount=0 then exit;
CurrentRecNo:=Base_DataS.DataSet.RecNo;
MK:=Base_DataS.DataSet.GetBookmark;
Base_DataS.DataSet.Last;
LastRecNo:=Base_DataS.DataSet.RecNo;
Base_DataS.DataSet.GotoBookmark(MK);
if CurrentRecNo=LastRecNo then exit;//如果是最后一条记录
//读取当前记录的信息
with Base_DataS.DataSet do
begin
CurrentRec.Id:=FieldByName('Id').AsInteger;
CurrentRec.Name:=FieldByName('Name').AsString;
CurrentRec.TaskType:=FieldByName('Type').AsString;
end;
Base_DataS.DataSet.Next;
//读取当前记录的下一条记录的信息
with Base_DataS.DataSet do
begin
CurrentNextRec.Id:=FieldByName('Id').AsInteger;
CurrentNextRec.Name:=FieldByName('Name').AsString;
CurrentNextRec.TaskType:=FieldByName('Type').AsString;
end;
Base_DataS.DataSet.Prior;//返回原位置
if CurrentNextRec.TaskType<>CurrentRec.TaskType then exit;
//把当前记录变为当前记录的下一条记录
With Base_DataS.DataSet do
begin
Edit;
FieldByName('Name').AsString:=CurrentNextRec.Name;
FieldByName('Type').AsString:=CurrentNextRec.TaskType;
Post;
end;
Base_DataS.DataSet.Next;
//把当前记录的下一条记录变为当前记录
With Base_DataS.DataSet do
begin
Edit;
FieldByName('Name').AsString:=CurrentRec.Name;
FieldByName('Type').AsString:=CurrentRec.TaskType;
Post;
end;
end;
procedure TDrillTask_Frm.BitBtn8Click(Sender: TObject);
//var
//CurrentRecNo,i:integer;
//BK:TBookMark;
begin
//BK:=Base_DataS.DataSet.GetBookmark;
//CurrentRecNo:=Base_DataS.DataSet.RecNo;
{//读取当前记录之前的记录
setlength(CurrentBeforeTask,CurrentRecNo);
with Base_DataS.DataSet do
begin
first;
i:=1;
while RecNo<CurrentRecNo do
begin
CurrentBeforeTask[i].Id:=FieldByName('Id').AsInteger;
CurrentBeforeTask[i].Name:=FieldByName('Name').AsString;
CurrentBeforeTask[i].TaskType:=FieldByName('Type').AsString;
next;
i:=i+1;
end;
end;
//将获取的记录的名称显示在DBComboBox1的列表中
DBComboBox2.Items.Clear;
for i:=1 to High(CurrentBeforeTask) do
begin
DBComboBox2.Items.Add(CurrentBeforeTask[i].Name);
end; }
//Base_DataS.DataSet.GotoBookmark(BK);
inherited;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -