【delphi开源代码栏目提醒】:网学会员在delphi开源代码频道为大家收集整理了Bjxmxg.pas提供大家参考,希望对大家有所帮助!
unit Bjxmsc;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, DBGrids, ExtCtrls, DB;
type
TForm7 = class(TForm)
Panel2: TPanel;
Label3: TLabel;
Panel1: TPanel;
Label1: TLabel;
DBGrid1: TDBGrid;
Panel3: TPanel;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
SpeedButton1: TSpeedButton;
ComboBox1: TComboBox;
DataSource1: TDataSource;
procedure OnShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
uses DataModal;
{$R *.dfm}
procedure TForm7.OnShow(Sender: TObject);
begin
with Data.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select Distinct 项目名称 from 报警项目表');
Open;
end;
ComboBox1.Clear;
if Data.ADOQuery1.RecordCount>0 then
begin
while Not Data.ADOQuery1.Eof do
begin
ComboBox1.Items.Add(Data.ADOQuery1.Fields[0].Value);
Data.ADOQuery1.Next;
end;
end;
ComboBox1.ItemIndex := 0;
DataSource1.DataSet := Nil;
end;
procedure TForm7.SpeedButton1Click(Sender: TObject);
begin
if Trim(ComboBox1.Text)<>'' then
begin
with Data.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Select * from 报警项目表 where 项目名称 = :a');
Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
Open;
end;
if Data.ADOQuery1.RecordCount>0 then
begin
BitBtn2.Enabled := True;
DataSource1.DataSet := Data.ADOQuery1;
end
else
begin
BitBtn2.Enabled := False;
DataSource1.DataSet := Nil;
end;
end;
end;
procedure TForm7.BitBtn2Click(Sender: TObject);
begin
if Application.MessageBox('确实要删除当前记录吗?','提示',mb_YesNo)= ID_Yes then
Try
Data.ADOQuery1.Delete;
Application.MessageBox('删除成功.','提示',64);
Self.OnShow(Sender);
BitBtn2.Enabled := False;
Except
Application.MessageBox('系统出错.','提示',64);
End;
end;
procedure TForm7.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = vk_Return then
SpeedButton1.OnClick(Sender);
end;
end.
上一篇:
FrmBandwidth.frm
下一篇:
法律专业开题报告范文