?? addoilspot.pas
字號:
unit addoilspot;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm_addoilspot = class(TForm)
Panel1: TPanel;
ListBox1: TListBox;
Label3: TLabel;
Edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn_cancle: TBitBtn;
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn_cancleClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_addoilspot: TForm_addoilspot;
implementation
uses dm;
{$R *.dfm}
procedure TForm_addoilspot.FormShow(Sender: TObject);
begin
edit1.Text:='';
with form_dm.ADOTable_oilspot do
begin
open;
first;
listbox1.Items.Clear;
repeat
listbox1.Items.Add(fieldbyname('name').AsString);
Next;
until eof;
end;
end;
procedure TForm_addoilspot.BitBtn1Click(Sender: TObject);
begin
if edit1.text='' then
begin
showmessage('請輸入你要增加的加油站!');
edit1.setfocus;
abort;
end;
with form_dm.ADOTable_oilspot do
begin
open;
if locate('name',edit1.Text,[]) then
begin
showmessage('您要增加的加油站已經存在!');
edit1.setfocus;
abort;
end;
append;
fieldvalues['name']:=edit1.Text;
post;
end;
form_addoilspot.OnShow(nil);
showmessage('增加成功!');
end;
procedure TForm_addoilspot.BitBtn2Click(Sender: TObject);
begin
if listbox1.ItemIndex<>-1 then
begin
with form_dm.ADOTable_oilspot do
begin
open;
locate('name',listbox1.Items.Strings[listbox1.ItemIndex],[]);
delete;
end;
form_addoilspot.OnShow(nil);
showmessage('刪除成功!');
end
else
begin
showmessage('請選擇要刪除的加油站!');
abort;
end;
end;
procedure TForm_addoilspot.BitBtn_cancleClick(Sender: TObject);
begin
close;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -