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

📄 lcxxsc.pas

📁 企业安防管理系统
💻 PAS
字号:
unit lcxxsc;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Grids, DBGrids, ExtCtrls, DB;

type
  TForm12 = class(TForm)
    Panel2: TPanel;
    Label3: TLabel;
    Panel1: TPanel;
    Label1: TLabel;
    SpeedButton1: TSpeedButton;
    Label4: TLabel;
    ComboBox1: TComboBox;
    Edit3: TEdit;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    DBGrid1: TDBGrid;
    Panel3: TPanel;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    DataSource1: TDataSource;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit3KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form12: TForm12;

implementation
  uses Datamodal;
{$R *.dfm}

procedure TForm12.SpeedButton1Click(Sender: TObject);
begin
 if (CheckBox1.Checked = False)and(CheckBox2.Checked = False) then
  begin
    Application.MessageBox('请选择查询条件.','提示',64);
    Exit;
  end;
  if (CheckBox1.Checked = True)and(Trim(ComboBox1.Text)='') then
  begin
    Application.MessageBox('请选择楼层名称.','提示',64);
    ComboBox1.SetFocus;
    Exit;
  end;
  if (CheckBox2.Checked = True)and(Trim(Edit3.Text)='') then
  begin
    Application.MessageBox('请输入楼层.','提示',64);
    Edit3.SetFocus;
    Exit;
  end;
  with Data.ADOQuery2 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 楼层信息表 where ');
    if (CheckBox1.Checked)and(Not CheckBox2.Checked) then
    begin
      SQL.Add('楼层名称 = :a');
      Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
    end
    else if (Not CheckBox1.Checked)and(CheckBox2.Checked)then
    begin
      SQL.Add('楼层 = :a');
      Parameters.ParamByName('a').Value := StrToInt(Edit3.Text);      
    end
    else
    begin
      SQL.Add('楼层名称 = :a and 楼层 = :b');
      Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
      Parameters.ParamByName('b').Value := StrToInt(Edit3.Text);
    end; 
    Open;
    if RecordCount>0 then
    begin
      DataSource1.DataSet := Data.ADOQuery2;
      BitBtn2.Enabled := True;
      BitBtn2.SetFocus;
    end
    else
    begin
      DataSource1.DataSet := Nil;
      BitBtn2.Enabled := False;
      Application.MessageBox('没有符合条件的记录.','提示',64);
    end;      
  end;
end;

procedure TForm12.FormShow(Sender: TObject);
begin
  ComboBox1.Clear;
  with Data.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('Select Distinct 楼层名称 from 楼层信息表');
    Open;
  end;
  if Data.ADOQuery1.RecordCount>0 then
    while Not Data.ADOQuery1.Eof  do
    begin
      ComboBox1.Items.Add(Data.ADOQuery1.FieldByName('楼层名称').Value);
      Data.ADOQuery1.Next;
    end;
end;

procedure TForm12.BitBtn2Click(Sender: TObject);
var
  bh: String;
begin
  bh := Data.ADOQuery2.FieldByName('楼层编号').Value;
  if Application.MessageBox(Pchar('确实要删除楼层编号为'+bh +'的楼层信息吗?'),'提示',mb_YesNo)=Id_Yes then
  begin
    Try
      Data.ADOQuery2.Delete;
      Application.MessageBox('删除成功.','提示',64);
      OnShow(Sender);
      BitBtn2.Enabled := False;
    Except
      Application.MessageBox('系统出错.','提示',64);
    End;
  end;
end;

procedure TForm12.ComboBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = vk_Return then
    Edit3.SetFocus;
end;

procedure TForm12.Edit3KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = vk_Return then
    SpeedButton1.OnClick(Sender);
end;

end.

⌨️ 快捷键说明

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