?? addunit.pas
字號:
unit addunit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm_addunit = class(TForm)
Panel1: TPanel;
ListBox1: TListBox;
Label3: TLabel;
Edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
ComboBox1: TComboBox;
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_addunit: TForm_addunit;
implementation
uses dm;
{$R *.dfm}
procedure TForm_addunit.FormShow(Sender: TObject);
begin
with form_dm.ADOTable_employer do
begin
open;
first;
listbox1.Items.Clear;
repeat
listbox1.Items.Add(form_dm.ADOTable_employer.fieldbyname('name').AsString);
form_dm.ADOTable_employer.Next;
until eof;
end;
end;
procedure TForm_addunit.BitBtn1Click(Sender: TObject);
begin
if edit1.text='' then
begin
showmessage('請輸入你要增加的單位(人)!');
edit1.setfocus;
abort;
end;
with form_dm.ADOTable_employer do
begin
open;
if locate('name',edit1.Text,[]) then
begin
showmessage('您要增加的單位(人)已經(jīng)存在!');
edit1.setfocus;
abort;
end;
append;
fieldvalues['name']:=edit1.Text;
fieldvalues['type']:=combobox1.Text;
post;
end;
if combobox1.Text='個人' then
begin
form_dm.ADOCommand1.CommandText:='insert into signers values('''+edit1.Text+''','''+edit1.Text+'''); ';
form_dm.ADOCommand1.Execute;
end;
form_addunit.OnShow(nil);
showmessage('增加成功!');
edit1.Text:='';
combobox1.ItemIndex:=0;
end;
procedure TForm_addunit.BitBtn2Click(Sender: TObject);
begin
if listbox1.ItemIndex<>-1 then
begin
with form_dm.ADOTable_employer do
begin
open;
locate('name',listbox1.Items.Strings[listbox1.ItemIndex],[]);
delete;
end;
form_dm.ADOCommand1.CommandText:='delete from signers where employer='''+listbox1.items.strings[listbox1.itemindex]+'''';
form_dm.ADOCommand1.Execute;
form_addunit.OnShow(nil);
showmessage('刪除成功!');
end
else
begin
showmessage('請在列表中選擇你要刪除的單位(人)!');
abort;
end;
end;
procedure TForm_addunit.BitBtn_cancleClick(Sender: TObject);
begin
close;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -