看着视频教学里的内容学写程序,但到中间那块就写不下去了,因为此句过长,视频里容不下,后面的省略了,我也不知怎么写,是个菜鸟。请帮忙,谢谢。
这是一个可以添加、修改、删除、查询的通讯录程序:
全部程序如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, DBTables;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
Table1: TTable;
DBGrid1: TDBGrid;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
try
Table1.Edit;
finally
Table1.Post;
Table1.Refresh;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if Table1.RecordCount>0
then if application.MessageBox('确认要删除本条记录吗','确定',MB_YESNOC………………这里应该是怎么继续写的?请高手们指教,谢谢先。
then Table1.Delete;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
var
mystring:string;
YesorNo:boolean;
begin
mystring:= '';
YesOrNo :=InputQuery('','',mystring);
if YesOrNo then
begin
Table1.Filter:='Name='+''''mystring+'''';
Table1.Filtered:=true;
end
else
begin
Table1.Filter:='';
Table1.Filtered:=False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Table1.Open;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
try
Table1.Append;
finally
Table1.Post;
Table1.Refresh;
end;
end.
[此贴子已经被作者于2007-9-15 7:37:13编辑过]