【delphi开源代码栏目提醒】:以下是网学会员为您推荐的delphi开源代码-bjclsc.pas,希望本篇文章对您学习有所帮助。
unit bjclsc;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, Grids, DBGrids, ExtCtrls;
type
TForm15 = class(TForm)
Panel2: TPanel;
Label3: TLabel;
Panel1: TPanel;
Label1: TLabel;
SpeedButton1: TSpeedButton;
ComboBox1: TComboBox;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Panel3: TPanel;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
procedure FormShow(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form15: TForm15;
implementation
uses DataModal;
{$R *.dfm}
procedure TForm15.FormShow(Sender: TObject);
begin
ComboBox1.Clear;
DataSource1.DataSet := Nil;
with Data.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select Distinct 报警处理 from 报警处理表');
Open;
end;
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;
end;
procedure TForm15.BitBtn2Click(Sender: TObject);
begin
if Application.MessageBox('确实要删除当前数据吗?','提示',mb_YesNo)= ID_Yes then
begin
Try
Data.ADOQuery2.Delete;
Application.MessageBox('删除成功.','提示',64);
OnShow(Sender);
Except
Application.MessageBox('系统出错.','提示',64);
End;
end;
end;
procedure TForm15.SpeedButton1Click(Sender: TObject);
begin
if Trim(ComboBox1.Text)='' then
begin
Application.MessageBox('请设置查询条件.','提示',64);
Exit;
end;
with Data.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 报警处理表 where 报警处理 = :a');
Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
Open;
end;
if Data.ADOQuery2.RecordCount>0 then
begin
DataSource1.DataSet := Data.ADOQuery2;
BitBtn2.Enabled := True;
BitBtn2.SetFocus;
end
else
begin
DataSource1.DataSet := Nil;
BitBtn2.Enabled := False;
end;
end;
procedure TForm15.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = vk_Return)and(Trim(ComboBox1.Text)<>'')then
SpeedButton1.OnClick(Sender);
end;
end.