?? friendsunit.pas
字號:
unit FriendsUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, ToolWin, ComCtrls, Buttons;
type
TFriendsForm = class(TForm)
StatusBar1: TStatusBar;
CoolBar1: TCoolBar;
DBGrid1: TDBGrid;
AddButton: TSpeedButton;
EditButton: TSpeedButton;
DeleteButton: TSpeedButton;
SearchButton: TSpeedButton;
RefreshButton: TSpeedButton;
ExitButton: TSpeedButton;
procedure DeleteButtonClick(Sender: TObject);
procedure AddButtonClick(Sender: TObject);
procedure EditButtonClick(Sender: TObject);
procedure SearchButtonClick(Sender: TObject);
procedure ExitButtonClick(Sender: TObject);
procedure RefreshButtonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FriendsForm: TFriendsForm;
implementation
uses DataUnit,PublicUnit,FriendsAddUnit,FriendsEditUnit,FriendsQryUnit;
{$R *.dfm}
procedure TFriendsForm.DeleteButtonClick(Sender: TObject);
var
DelName,DelId,SQLText:string;
begin
If Trim(DBGrid1.Fields[0].AsString) = '' then Exit;
DelId := DataForm.qrySource.FieldByName('Id').AsString;
DelName := Trim(DataForm.qrySource.FieldByName('Name').AsString);
SQLText := DataForm.qrySource.SQL.Text;
If MessageDlg('確實要刪除“'+DelName+'”的信息嗎?',mtConfirmation,[mbyes,mbno],0) = mryes then
begin
ExecSQL(DataForm.qryEdit,'Delete From myfriends Where Id = '+DelId+'');
OpenSQL(DataForm.qrySource,SQLText);
StatusBar1.Panels[1].Text := IntToStr(DataForm.qrySource.RecordCount);
end;
end;
procedure TFriendsForm.AddButtonClick(Sender: TObject);
begin
Application.CreateForm(TFriendsAddForm,FriendsAddForm);
try
FriendsAddForm.ShowModal;
finally
FriendsAddForm.Free;
end;
StatusBar1.Panels[1].Text := IntToStr(DataForm.qrySource.RecordCount);
end;
procedure TFriendsForm.EditButtonClick(Sender: TObject);
begin
if DBGrid1.Fields[0].AsString = '' then Exit;
Application.CreateForm(TFriendsEditForm,FriendsEditForm);
try
FriendsEditForm.ShowModal;
finally
FriendsEditForm.Free;
end;
end;
procedure TFriendsForm.SearchButtonClick(Sender: TObject);
begin
Application.CreateForm(TFriendsQryForm,FriendsQryForm);
try
FriendsQryForm.ShowModal;
finally
FriendsQryForm.Free;
end;
StatusBar1.Panels[1].Text := IntToStr(DataForm.qrySource.RecordCount);
end;
procedure TFriendsForm.ExitButtonClick(Sender: TObject);
begin
close;
end;
procedure TFriendsForm.RefreshButtonClick(Sender: TObject);
var
SQLText:String;
begin
SQLText := 'Select * From myfriends Order by Id DESC';
OpenSQL(DataForm.qrySource,SQLText);
StatusBar1.Panels[1].Text := IntToStr(DataForm.qrySource.RecordCount);
end;
procedure TFriendsForm.FormShow(Sender: TObject);
begin
RefreshButton.Click;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -