am_dz_cxs.pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:6k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit am_dz_cxs;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Buttons, StdCtrls, Mask, DBCtrlsEh, ExtCtrls, DB, DBClient;
- type
- Tam_dz_cx = class(TForm)
- Panel1: TPanel;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- ComboBox1: TComboBox;
- ComboBox2: TComboBox;
- DBDateTimeEditEh1: TDBDateTimeEditEh;
- ComboBox3: TComboBox;
- Edit1: TEdit;
- Edit2: TEdit;
- Panel2: TPanel;
- BitBtn2: TSpeedButton;
- BitBtn1: TSpeedButton;
- SpeedButton1: TSpeedButton;
- SpeedButton2: TSpeedButton;
- ClientDataSet1: TClientDataSet;
- procedure BitBtn2Click(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormCreate(Sender: TObject);
- procedure SpeedButton2Click(Sender: TObject);
- procedure SpeedButton1Click(Sender: TObject);
- procedure ComboBox1Change(Sender: TObject);
- procedure ComboBox2Change(Sender: TObject);
- procedure ComboBox3Change(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- am_dz_cx: Tam_dz_cx;
- str,s_zdm,s_logic,s_tj:string;//查找字符串,字段名
- Const ss:array [0..7] of string=('dz_dm','dz_xm','dz_dw','dz_lxdh','dz_lxdz','zjlb_mc','dz_zjh','dz_djsj');
- implementation
- uses DMs;
- {$R *.dfm}
- procedure Tam_dz_cx.BitBtn2Click(Sender: TObject);
- begin
- close;
- end;
- procedure Tam_dz_cx.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- action:=cafree;
- am_dz_cx:=nil;
- end;
- procedure Tam_dz_cx.FormCreate(Sender: TObject);
- begin
- Combobox1.Clear;
- Combobox1.Items.add('读者代码');
- Combobox1.Items.add('姓名');
- Combobox1.Items.add('读者单位');
- Combobox1.Items.add('联系电话');
- Combobox1.Items.add('联系地址');
- Combobox1.Items.add('证件类别');
- Combobox1.Items.add('证件号');
- Combobox1.Items.add('登记时间');
- end;
- procedure Tam_dz_cx.SpeedButton2Click(Sender: TObject);
- begin
- combobox1.ItemIndex:=-1;
- combobox2.ItemIndex:=-1;
- edit1.Text:='';
- combobox3.ItemIndex:=-1;
- edit2.text:='';
- end;
- procedure Tam_dz_cx.SpeedButton1Click(Sender: TObject);
- begin
- s_logic:='';
- if trim(Combobox1.Text)='' then
- begin
- application.MessageBox('字段名称不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- if trim(Combobox2.Text)='' then
- begin
- application.MessageBox('条件不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- //有效性验证
- case combobox3.ItemIndex of
- 0: s_logic:=' and ';
- 1: s_logic:=' or ';
- end;
- if Combobox2.Text='模糊查询' then
- Edit2.Text:=Edit2.Text+s_zdm+' '+' like '+' '+''''+trim(edit1.Text)+'%'+''''+' '+s_logic+' '
- else if combobox1.Text='登记时间' then
- begin
- Edit2.Text:=Edit2.Text+s_zdm+' '+combobox2.Text+' '+''''+DBDateTimeEditEh1.Text+''''+' '+s_logic+' '; end
- else
- Edit2.Text:=Edit2.Text+s_zdm+' '+combobox2.Text+' '+''''+trim(edit1.Text)+''''+' '+s_logic+' ';
- combobox1.ItemIndex:=-1;
- combobox2.ItemIndex:=-1;
- edit1.Text:='';
- combobox3.ItemIndex:=-1;
- SpeedButton1.Enabled:=false;
- end;
- procedure Tam_dz_cx.ComboBox1Change(Sender: TObject);
- begin
- s_zdm:=ss[combobox1.itemindex];//以上是获得下拉框中的值
- if combobox1.Text='登记时间' then
- begin
- combobox2.Clear;
- combobox2.Items.Add('=');
- combobox2.Items.Add('<>');
- combobox2.Items.Add('<');
- combobox2.Items.Add('>');
- combobox2.Items.Add('>=');
- combobox2.Items.Add('<=');
- end
- else
- begin
- combobox2.Clear;
- combobox2.Items.Add('=');
- combobox2.Items.Add('<>');
- combobox2.Items.Add('模糊查询');
- end;
- end;
- procedure Tam_dz_cx.ComboBox2Change(Sender: TObject);
- begin
- if combobox1.Text='登记时间' then
- begin
- DBDateTimeEditEh1.Visible:=true;
- edit1.Visible:=false;
- end
- else
- begin
- DBDateTimeEditEh1.Visible:=false;
- edit1.Visible:=true;
- end;
- end;
- procedure Tam_dz_cx.ComboBox3Change(Sender: TObject);
- begin
- if trim(Combobox1.Text)='' then
- begin
- application.MessageBox('字段名称不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- if trim(Combobox2.Text)='' then
- begin
- application.MessageBox('条件不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- s_logic:='';
- case combobox3.ItemIndex of
- 0: s_logic:=' and ';
- 1: s_logic:=' or ';
- end;
- SpeedButton1.Enabled:=true;
- end;
- procedure Tam_dz_cx.BitBtn1Click(Sender: TObject);
- var S_Edit,Hint:string;
- begin
- S_Edit:=Edit2.Text;
- if trim(Combobox1.Text)='' then
- begin
- application.MessageBox('字段名称不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- if trim(Combobox2.Text)='' then
- begin
- application.MessageBox('条件不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- //----------------------------------
- if trim(Edit2.Text)='' then
- begin
- if Combobox2.Text='模糊查询' then
- str:=s_zdm+' '+' like '+' '+''''+trim(edit1.Text)+'%'+''''
- else
- str:=s_zdm+' '+combobox2.Text+' '+''''+trim(edit1.Text)+'''';
- end
- else
- begin
- if Combobox2.Text='模糊查询' then
- str:=s_Edit+s_zdm+' '+' like '+' '+''''+trim(edit1.Text)+'%'+''''
- else if combobox1.Text='登记时间' then
- str:=s_Edit+s_zdm+' '+combobox2.Text+' '+''''+DBDateTimeEditEh1.Text+''''
- else
- str:=s_Edit+s_zdm+' '+combobox2.Text+' '+''''+trim(edit1.Text)+'''';
- end;
- //---------------------------------
- ClientDataSet1.Close;
- ClientDataSet1.CommandText:='select * from V_DZ where '+str;
- ClientDataSet1.Open;
- dm.v_dz.active:=false;
- dm.v_dz.active:=true;
- dm.V_DZ.Data:=ClientDataSet1.Data;
- if Clientdataset1.RecordCount=0 then
- application.MessageBox('没有找到符合条件的纪录','提示',mb_ok+mb_iconinformation)
- else
- begin
- Hint:='当前表中有'+IntToStr(Clientdataset1.RecordCount)+'条记录符合条件';
- application.MessageBox(Pchar(hint),'提示',mb_ok+mb_iconinformation);
- end;
- end;
- end.