⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addunit.pas

📁 管理车队用车记录
💻 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('您要增加的单位(人)已经存在!');
    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.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -