unit8.pas

来自「是关于SQL的一些程序 很好很经典的~大家又兴趣的可以学习下」· PAS 代码 · 共 82 行

PAS
82
字号
unit Unit8;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  Taddleaveform = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  addleaveform: Taddleaveform;

implementation

{$R *.dfm}
uses unit3,unit2;
procedure Taddleaveform.Button1Click(Sender: TObject);
begin
  with  mydata.Query2 do
  begin
    close;
    with  sql do
    begin
      clear;
      //先查询输入的类型名是否已经存在
      add('select * from 请假类型表 where 类型名=:type');
      ParamByName('type').AsString:=trim(edit1.Text);
    end;
    open;
    if  findlast() then
    begin
      showmessage('该类型已经存在');
    end else //如果不存在,则执行插入操作
    begin
      with  sql do
      begin
      //设置执行插入操作的SQL语句
        add('insert into 请假类型表 values(:type,:salary)');
        ParamByName('type').AsString:=trim(edit1.Text);
        ParamByName('salary').AsFloat:=strtofloat(trim(edit2.Text));
      end;
      execsql;
      close;
      //更新主窗体显示的数据
      main.oninit1();
    end;
  end;
  close;
end;

procedure Taddleaveform.Button2Click(Sender: TObject);
begin
  with  mydata.Query2 do
  begin
    close;
    with  sql do
    begin
      clear;
      add('select * from 上下班时间表');
    end;
    main.oninit1();
  end;
  close;
end;

end.

⌨️ 快捷键说明

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