P
pantera
Unregistered / Unconfirmed
GUEST, unregistred user!
请看如下代码:
Procedure TForm_Main.AddRecord;
//每月第一次使用时,自动根据上月的记录重建本月记录
begin
//检查如果数据库中上月记录为0,则不能自动添加记录,需手动添加记录
If Query1.RecordCount = 0 Then
begin
MessageDlg('数据库中没有上月的数据记录,' + #10#13 + '请手动添加记录!', mtInformation, [mbOK], 0);
Exit;
end;
With Query1 do
begin
First;
While not Eof do
begin
With QueryAMD DO
begin
Active := True;
//Append;
Insert;
Fields[0].Value := YearMonth + Copy(Query1.Fields[0].Value, 7, 4);
Fields[1].Value := Query1.Fields[1].Value;
Fields[2].Value := Query1.Fields[2].Value;
Fields[6].Value := Query1.Fields[6].Value;
Fields[3].Value := 0;
Fields[5].Value := 0;
Fields[4].Value := Date;
Fields[7].Value := '';
end;
Query1.Next;
end;
With QueryAMD do
begin
UpdateRecord;
ApplyUpdates;
Active := False;
end;
end;
end;
执行的结果,系统老是要添加一条空记录,这是为何?????请达人解答!!!!
Procedure TForm_Main.AddRecord;
//每月第一次使用时,自动根据上月的记录重建本月记录
begin
//检查如果数据库中上月记录为0,则不能自动添加记录,需手动添加记录
If Query1.RecordCount = 0 Then
begin
MessageDlg('数据库中没有上月的数据记录,' + #10#13 + '请手动添加记录!', mtInformation, [mbOK], 0);
Exit;
end;
With Query1 do
begin
First;
While not Eof do
begin
With QueryAMD DO
begin
Active := True;
//Append;
Insert;
Fields[0].Value := YearMonth + Copy(Query1.Fields[0].Value, 7, 4);
Fields[1].Value := Query1.Fields[1].Value;
Fields[2].Value := Query1.Fields[2].Value;
Fields[6].Value := Query1.Fields[6].Value;
Fields[3].Value := 0;
Fields[5].Value := 0;
Fields[4].Value := Date;
Fields[7].Value := '';
end;
Query1.Next;
end;
With QueryAMD do
begin
UpdateRecord;
ApplyUpdates;
Active := False;
end;
end;
end;
执行的结果,系统老是要添加一条空记录,这是为何?????请达人解答!!!!