sb_azjl_cxs.pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:19k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit sb_azjl_cxs;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Buttons, Mask, DBCtrlsEh, StdCtrls, ExtCtrls, DB, DBClient;
- type
- Tam_Ajcx = class(TForm)
- Panel1: TPanel;
- GroupBox1: TGroupBox;
- GroupBox2: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- ComboBox1: TComboBox;
- ComboBox2: TComboBox;
- ComboBox3: TComboBox;
- ComboBox5: TComboBox;
- ComboBox7: TComboBox;
- ComboBox4: TComboBox;
- ComboBox6: TComboBox;
- ComboBox8: TComboBox;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Edit4: TEdit;
- DBDateTimeEditEh2: TDBDateTimeEditEh;
- DBDateTimeEditEh3: TDBDateTimeEditEh;
- DBDateTimeEditEh4: TDBDateTimeEditEh;
- ComboBox9: TComboBox;
- ComboBox10: TComboBox;
- ComboBox11: TComboBox;
- DBDateTimeEditEh1: TDBDateTimeEditEh;
- GroupBox3: TGroupBox;
- BitBtn1: TSpeedButton;
- BitBtn2: TSpeedButton;
- ClientDataSet1: TClientDataSet;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure quitClick(Sender: TObject);
- procedure Edit1Change(Sender: TObject);
- procedure Edit2Change(Sender: TObject);
- procedure Edit3Change(Sender: TObject);
- procedure Edit4Change(Sender: TObject);
- procedure ComboBox9Change(Sender: TObject);
- procedure DBDateTimeEditEh1Change(Sender: TObject);
- procedure ComboBox8Change(Sender: TObject);
- procedure ComboBox6Change(Sender: TObject);
- procedure ComboBox4Change(Sender: TObject);
- procedure ComboBox2Change(Sender: TObject);
- procedure ComboBox10Change(Sender: TObject);
- procedure ComboBox11Change(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure ComboBox1Change(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure ComboBox3Change(Sender: TObject);
- procedure ComboBox5Change(Sender: TObject);
- procedure ComboBox7Change(Sender: TObject);
- procedure DBDateTimeEditEh4Change(Sender: TObject);
- procedure DBDateTimeEditEh3Change(Sender: TObject);
- procedure DBDateTimeEditEh2Change(Sender: TObject);
- procedure Edit1KeyPress(Sender: TObject; var Key: Char);
- procedure Edit2KeyPress(Sender: TObject; var Key: Char);
- procedure Edit3KeyPress(Sender: TObject; var Key: Char);
- procedure Edit4KeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- am_Ajcx: Tam_Ajcx;
- Str1,Str3,Str5,Str7:string;//查询变量
- i1,i3,i5,i7:string;//取下拉框中的值
- Const s_logic1:array[0..5] of string=('=','<>','>','<','>=','<=');
- const s_logic2:array[0..2] of string=('=','<>','like');
- const s_zdz:array[0..16] of string=('aj_dm','bgqx_mc','mj_mc','ajlb_mc'
- ,'aj_ndh','aj_dh','aj_ys','aj_bzqsrq','aj_bzjsrq','aj_gdqsrq','aj_gdjsrq','aj_ljr'
- ,'aj_jcr','aj_ztc','user_name','aj_wsh','aj_bmmc');
- implementation
- uses mainfrms, am_ajjss;
- {$R *.dfm}
- procedure Tam_Ajcx.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- Clientdataset1.Active:=false;
- action:=cafree;
- am_ajcx:=nil;
- end;
- procedure Tam_Ajcx.quitClick(Sender: TObject);
- begin
- close;
- end;
- procedure Tam_Ajcx.Edit1Change(Sender: TObject);
- begin
- if trim(edit1.Text)<>'' then
- begin
- combobox9.Enabled:=true;
- end
- else
- combobox9.Enabled:=false;
- end;
- procedure Tam_Ajcx.Edit2Change(Sender: TObject);
- begin
- str3:='';
- if trim(edit2.Text)<>'' then
- begin
- combobox10.Enabled:=true;
- end
- else
- begin
- combobox10.Enabled:=false;
- end;
- if combobox4.Text='模糊查询'then
- begin
- str3:=str3+i3+' '+' like '+' '+''''+trim(edit2.Text)+'%'+'''';
- end
- else
- begin
- str3:=str3+i3+' '+trim(combobox4.Text)+' '+''''+trim(edit2.text)+'''';
- end;
- end;
- procedure Tam_Ajcx.Edit3Change(Sender: TObject);
- begin
- if trim(edit3.Text)<>'' then
- begin
- combobox11.Enabled:=true;
- end
- else
- begin
- combobox11.Enabled:=false;
- end;
- str5:='';
- if combobox6.Text='模糊查询'then
- begin
- str5:=str5+i5+' '+' like '+' '+''''+trim(edit3.Text)+'%'+'''';
- end
- else
- begin
- str5:=str5+i5+' '+trim(combobox6.Text)+' '+''''+trim(edit3.text)+'''';
- end;
- end;
- procedure Tam_Ajcx.Edit4Change(Sender: TObject);
- begin
- str7:=' ';
- if combobox8.Text='模糊查询'then
- begin
- str7:=str7+i7+' '+' like '+' '+''''+trim(edit4.Text)+'%'+'''';
- end
- else
- begin
- str7:=str7+i7+' '+trim(combobox8.Text)+' '+''''+trim(edit4.text)+'''';
- end;
- end;
- procedure Tam_Ajcx.ComboBox9Change(Sender: TObject);
- begin
- COMBOBOX3.Enabled:=TRUE;combobox1.Enabled:=false;combobox2.Enabled:=false;
- edit1.Enabled:=false;dbdatetimeediteh1.Enabled:=false;combobox9.Enabled:=false;
- end;
- procedure Tam_Ajcx.DBDateTimeEditEh1Change(Sender: TObject);
- begin
- combobox9.Enabled:=true;
- end;
- procedure Tam_Ajcx.ComboBox8Change(Sender: TObject);
- begin
- edit4.Text:='';
- if (combobox7.text='编制起始日期')or(combobox7.text='归档起始日期') or
- (combobox7.text='编制结束日期')or(combobox7.text='归档结束日期') then
- begin
- dbdatetimeediteh4.Enabled:=true;
- dbdatetimeediteh4.Visible:=true;
- edit4.Visible:=false;
- dbdatetimeediteh4.Text:=' - - ';
- end
- else
- begin
- edit4.Enabled:=true;
- edit4.Text:='';
- dbdatetimeediteh4.Visible:=false;
- dbdatetimeediteh4.Text:=' - - ';
- end;
- end;
- procedure Tam_Ajcx.ComboBox6Change(Sender: TObject);
- begin
- combobox11.Clear;
- combobox11.Items.Add('并且');
- combobox11.Items.Add('或者');
- edit3.Text:='';
- if (combobox5.text='编制起始日期')or(combobox5.text='归档起始日期') or
- (combobox5.text='编制结束日期')or (combobox5.text='归档结束日期') then
- begin
- dbdatetimeediteh3.Enabled:=true;
- dbdatetimeediteh3.Visible:=true;
- edit3.Visible:=false;
- dbdatetimeediteh3.Text:=' - - ';
- end
- else
- begin
- edit3.Enabled:=true;
- edit3.Text:='';
- dbdatetimeediteh3.Visible:=false;
- dbdatetimeediteh3.Text:=' - - ';
- end;
- end;
- procedure Tam_Ajcx.ComboBox4Change(Sender: TObject);
- begin
- combobox10.Clear;
- combobox10.Items.Add('并且');
- combobox10.Items.Add('或者');
- edit2.Text:='';
- if (combobox3.text='编制起始日期')or(combobox3.text='归档起始日期') or
- (combobox3.text='编制结束日期')or(combobox3.text='归档结束日期') then
- begin
- dbdatetimeediteh2.Enabled:=true;
- dbdatetimeediteh2.Visible:=true;
- edit2.Visible:=false;
- dbdatetimeediteh2.Text:=' - - ';
- end
- else
- begin
- edit2.Enabled:=true;
- edit2.Text:='';
- dbdatetimeediteh2.Visible:=false;
- dbdatetimeediteh2.Text:=' - - ';
- end;
- end;
- procedure Tam_Ajcx.ComboBox2Change(Sender: TObject);
- begin
- combobox9.Clear;
- combobox9.Items.Add('并且');
- combobox9.Items.Add('或者');
- if (combobox1.text='编制起始日期')or(combobox1.text='归档起始日期') or
- (combobox1.text='编制结束日期')or(combobox1.text='归档结束日期') then
- begin
- dbdatetimeediteh1.Enabled:=true;
- dbdatetimeediteh1.Visible:=true;
- edit1.Visible:=false;
- dbdatetimeediteh1.Text:=' - - ';
- end
- else
- begin
- edit1.Enabled:=true;
- edit1.Text:='';
- dbdatetimeediteh1.Visible:=false;
- dbdatetimeediteh1.Text:=' - - ';
- end;
- end;
- procedure Tam_Ajcx.ComboBox10Change(Sender: TObject);
- begin
- combobox5.enabled:=true;combobox3.Enabled:=false;combobox4.enabled:=false;
- edit2.Enabled:=false;dbdatetimeediteh2.Enabled:=false;combobox10.Enabled:=false;
- //设置查询条件
- str3:=' ';
- if combobox4.Text='模糊查询' then
- begin
- str3:=i3+' '+' like '+' '+''''+trim(edit2.Text)+'%'+'''';
- end
- else
- begin
- str3:=i3+' '+trim(combobox4.Text)+' '+''''+trim(edit2.Text)+'''';
- end;
- if (combobox3.text='编制起始日期')or (combobox3.text='归档起始日期') or
- (combobox3.text='编制结束日期')or (combobox3.text='归档结束日期') then
- begin
- str3:=i3+' '+trim(combobox4.Text)+' '+''''+trim(dbdatetimeediteh2.Text)+'''';
- end;
- case combobox10.ItemIndex of
- 0: str3:=str3+' and ';
- 1: str3:=STR3+' OR ';
- END;
- end;
- procedure Tam_Ajcx.ComboBox11Change(Sender: TObject);
- begin
- combobox7.enabled:=true;combobox5.enabled:=false;combobox6.enabled:=false;
- edit3.Enabled:=false;dbdatetimeediteh3.Enabled:=false;combobox11.Enabled:=false;
- str5:=' ';
- if combobox6.Text='模糊查询' then
- begin
- str5:=i5+' '+' like '+' '+''''+trim(edit3.Text)+'%'+'''';
- end
- else
- begin
- str5:=i5+' '+trim(combobox6.Text)+' '+''''+trim(edit3.Text)+'''';
- end;
- if (combobox5.text='编制起始日期')or(combobox5.text='归档起始日期') or
- (combobox5.text='编制结束日期')or (combobox5.text='归档结束日期') then
- begin
- str5:=i5+' '+trim(combobox6.Text)+' '+''''+trim(dbdatetimeediteh3.Text)+'''';
- end;
- case combobox11.ItemIndex of
- 0: str5:=str5+' and ';
- 1: str5:=STR5+' OR ';
- END;
- end;
- procedure Tam_Ajcx.BitBtn1Click(Sender: TObject);
- var k:string;
- begin
- if (combobox1.Text='') then
- begin
- application.MessageBox('请输入查询条件','提示!',mb_ok);
- exit;
- end;
- if (combobox9.Text<>'')and((combobox3.Text='')or (combobox4.text=''))then
- begin
- application.MessageBox('不符合多条查询的条件','提示!',mb_ok);
- exit;
- end;//---------------
- if (combobox10.Text<>'')and((combobox5.Text='')or (combobox6.text=''))then
- begin
- application.MessageBox('不符合多条查询的条件','提示!',mb_ok);
- exit;
- end;//----------
- if (combobox11.Text<>'')and ((combobox7.Text='')or (combobox8.Text=''))then
- begin
- application.MessageBox('不符合多条查询的条件','提示!',mb_ok);
- exit;
- end;//-------------
- //----------------------------------------
- if (combobox1.Text<>'') and
- ((trim(edit1.Text)='') and (dbdatetimeediteh1.Text=' - - '))then
- begin
- application.MessageBox('查询条件不完全,请输入查询条件','提示!',mb_ok);
- exit;
- end;//---------------------------------------------------------------------
- if (combobox3.Text<>'') and
- ((trim(edit2.Text)='') and (dbdatetimeediteh2.Text=' - - '))then
- begin
- application.MessageBox('查询条件不完全,请输入查询条件','提示!',mb_ok);
- exit;
- end;//---------------------------------------------------------------------
- if (combobox5.Text<>'') and
- ((trim(edit3.Text)='') and (dbdatetimeediteh3.Text=' - - '))then
- begin
- application.MessageBox('查询条件不完全,请输入查询条件','提示!',mb_ok);
- exit;
- end;
- if (combobox7.Text<>'') and
- ((trim(edit4.Text)='') and (dbdatetimeediteh4.Text=' - - '))then
- begin
- application.MessageBox('查询条件不完全,请输入查询条件','提示!',mb_ok);
- exit;
- end;
- //-----------------------------------------------------------------------------
- str1:=' '; k:=' ';
- if combobox2.Text='模糊查询' then
- begin
- str1:=i1+' '+' like '+' '+''''+trim(edit1.Text)+'%'+'''';
- end
- else
- begin
- str1:=i1+' '+trim(combobox2.Text)+' '+''''+trim(edit1.Text)+'''';
- end;
- if (combobox1.text='编制起始日期')or(combobox1.text='归档起始日期') or
- (combobox1.text='编制结束日期')or (combobox1.text='归档结束日期') then
- begin
- str1:=i1+' '+trim(combobox2.Text)+' '+''''+trim(dbdatetimeediteh1.Text)+'''';
- end;
- case combobox9.ItemIndex of
- 0: str1:=str1+' and ';
- 1: str1:=STR1+' or ';
- end;//-----------------------
- k:=str1+' '+str3+' '+str5+' '+str7;
- ClientDataSet1.close;//好像只能查一遍
- ClientDataSet1.CommandText:='select * from v_ajgl where '+ k;
- ClientDataSet1.Open;
- if ClientDataSet1.RecordCount=0 then
- begin
- if application.MessageBox('没有找到符合条件的记录'+#13#10+'是否重新搜索?','询问?',mb_okcancel+mb_iconquestion)=idok then
- begin
- Combobox1.ItemIndex:=-1;combobox3.ItemIndex:=-1;combobox5.ItemIndex:=-1;combobox7.ItemIndex:=-1;
- combobox3.Enabled:=false;combobox5.Enabled:=false;combobox7.Enabled:=false;
- //-----------------------------------------------------------------------------
- combobox2.Enabled:=false;combobox4.Enabled:=false;combobox6.Enabled:=false;combobox8.Enabled:=false;
- combobox2.Clear;combobox4.Clear;combobox6.Clear;combobox8.Clear;
- //--------------------------------------------------------------------------
- edit1.Text:='';edit2.Text:='';edit3.Text:='';edit4.Text:='';
- edit1.Visible:=true;edit2.Visible:=true;edit3.Visible:=true;edit4.Visible:=true;
- edit1.Enabled:=false;edit2.Enabled:=false;edit3.Enabled:=false;edit4.Enabled:=false;
- //-----------------------------------------------------------------------------
- dbdatetimeediteh1.Visible:=false;dbdatetimeediteh2.Visible:=false;
- dbdatetimeediteh3.Visible:=false;dbdatetimeediteh4.Visible:=false;
- dbdatetimeediteh1.Text:=' - - ';dbdatetimeediteh2.Text:=' - - ';
- dbdatetimeediteh3.Text:=' - - ';dbdatetimeediteh4.Text:=' - - ';
- //------------------------------------------------------------------------------
- combobox9.Enabled:=false;combobox10.Enabled:=false;combobox11.Enabled:=false;
- combobox9.Clear;combobox10.Clear;combobox11.Clear;
- //---------------------------------------------------------------------------
- str1:='';str3:='';str5:='';str7:='';
- i1:='';i3:='';i5:='';i7:='';
- combobox1.Enabled:=true;
- exit;
- end
- else close;
- end else
- begin
- am_ajjs.ClientDataSet1.Data:=Clientdataset1.Data;
- am_ajjs.StatusBar1.Panels[0].Text:='符合条件的记录有:'+inttostr(ClientDataSet1.RecordCount)+'条';
- close;
- end;
- end;
- procedure Tam_Ajcx.BitBtn2Click(Sender: TObject);
- begin
- close;
- end;
- procedure Tam_Ajcx.ComboBox1Change(Sender: TObject);
- begin
- i1:=s_zdz[combobox1.itemindex];//以上是获得下拉框中的值=
- dbdatetimeediteh1.Visible:=false;
- edit1.visible:=true; combobox2.Enabled:=true;
- if (combobox1.text='编制起始日期')or(combobox1.text='归档起始日期')or(combobox1.text='页数')
- or(combobox1.text='编制结束日期')or (combobox1.text='归档结束日期')or(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_Ajcx.FormCreate(Sender: TObject);
- begin
- str1:=' ';str3:=' ';str5:=' ';str7:=' ';//连接字符串置为空
- i1:=' ';i3:=' ';i5:=' ';i7:=' ';//字段名置为空
- end;
- procedure Tam_Ajcx.ComboBox3Change(Sender: TObject);
- begin
- i3:=s_zdz[combobox3.itemindex];//以上是获得下拉框中的值=
- dbdatetimeediteh2.Visible:=false;
- edit2.visible:=true;combobox4.Enabled:=true;
- if (combobox3.text='编制起始日期')or(combobox3.text='归档起始日期')or(combobox3.text='序号')
- or(combobox3.text='编制结束日期')or (combobox3.text='归档结束日期')or(combobox3.Text='年代号') then
- begin
- combobox4.Clear;
- combobox4.Items.Add('=');
- combobox4.Items.Add('<>');
- combobox4.Items.Add('>');
- combobox4.Items.Add('<');
- combobox4.Items.Add('>=');
- combobox4.Items.Add('<=');
- end
- else
- begin
- combobox4.Clear;
- combobox4.Items.Add('=');
- combobox4.Items.Add('<>');
- combobox4.Items.Add('模糊查询');
- end;
- end;
- procedure Tam_Ajcx.ComboBox5Change(Sender: TObject);
- begin
- i5:=s_zdz[combobox5.itemindex];//以上是获得下拉框中的值=
- dbdatetimeediteh3.Visible:=false;
- edit3.visible:=true;combobox6.Enabled:=true;
- if (combobox5.text='编制起始日期')or(combobox5.text='归档起始日期')or(combobox5.text='页数')
- or(combobox5.text='编制结束日期')or (combobox5.text='归档结束日期')or(combobox5.Text='年代号') then
- begin
- combobox6.Clear;
- combobox6.Items.Add('=');
- combobox6.Items.Add('<>');
- combobox6.Items.Add('>');
- combobox6.Items.Add('<');
- combobox6.Items.Add('>=');
- combobox6.Items.Add('<=');
- end
- else
- begin
- combobox6.Clear;
- combobox6.Items.Add('=');
- combobox6.Items.Add('<>');
- combobox6.Items.Add('模糊查询');
- end;
- end;
- procedure Tam_Ajcx.ComboBox7Change(Sender: TObject);
- begin
- i7:=s_zdz[combobox7.itemindex];//以上是获得下拉框中的值=
- dbdatetimeediteh4.Visible:=false;
- edit4.visible:=true;combobox8.Enabled:=true;
- if (combobox7.text='编制起始日期')or(combobox7.text='归档起始日期')or(combobox7.text='页数')
- or(combobox7.text='编制结束日期')or (combobox7.text='归档结束日期')or(combobox7.Text='年代号') then
- begin
- combobox8.Clear;
- combobox8.Items.Add('=');
- combobox8.Items.Add('<>');
- combobox8.Items.Add('>');
- combobox8.Items.Add('<');
- combobox8.Items.Add('>=');
- combobox8.Items.Add('<=');
- end
- else
- begin
- combobox8.Clear;
- combobox8.Items.Add('=');
- combobox8.Items.Add('<>');
- combobox8.Items.Add('模糊查询');
- end;
- end;
- procedure Tam_Ajcx.DBDateTimeEditEh4Change(Sender: TObject);
- begin
- str7:='';
- if (pos('日期',combobox7.Text)>0) then
- begin
- if dbdatetimeediteh4.Text<>' - - 'then
- str7:=str7+i7+' '+trim(combobox8.Text)+' '+''''+trim(DBDateTimeEditEh4.Text)+''''
- else
- str7:=str7+i7+' '+trim(combobox8.Text)+' '+'''';
- end;
- end;
- procedure Tam_Ajcx.DBDateTimeEditEh3Change(Sender: TObject);
- begin
- str5:='';
- combobox11.Enabled:=true;
- if (pos('日期',combobox5.Text)>0) then
- begin
- if dbdatetimeediteh3.Text<>' - - 'then
- str5:=str5+i5+' '+trim(combobox6.Text)+' '+''''+trim(dbdatetimeediteh3.Text)+''''
- else
- str5:=str5+i5+' '+trim(combobox6.Text)+' '+'''';
- end;
- end;
- procedure Tam_Ajcx.DBDateTimeEditEh2Change(Sender: TObject);
- begin
- str3:='';
- combobox10.Enabled:=true;combobox4.Enabled:=false;
- if (pos('日期',combobox3.Text)>0) then
- begin
- if dbdatetimeediteh2.Text<>' - - ' then //trim(combobox4.Text)
- str3:=str3+i3+' '+trim(combobox4.Text)+' '+''''+trim(dbdatetimeediteh2.Text)+''''
- else
- str3:=str3+i3+' '+trim(combobox4.Text)+' '+'''';
- end;
- end;
- procedure Tam_Ajcx.Edit1KeyPress(Sender: TObject; var Key: Char);
- begin
- if (combobox1.Text='页数')or(combobox1.Text='年代号') then
- if not (key in ['0'..'9',#8,#13]) then
- begin
- key:=#0;
- messagebeep(1);
- application.MessageBox('请输入数字!','提示',mb_ok);
- end;
- end;
- procedure Tam_Ajcx.Edit2KeyPress(Sender: TObject; var Key: Char);
- begin
- if (combobox3.Text='页数')or(combobox3.Text='年代号') then
- if not (key in ['0'..'9',#8,#13]) then
- begin
- key:=#0;
- messagebeep(1);
- application.MessageBox('请输入数字!','提示',mb_ok);
- end;
- end;
- procedure Tam_Ajcx.Edit3KeyPress(Sender: TObject; var Key: Char);
- begin
- if (combobox5.Text='页数')or(combobox5.Text='年代号') then
- if not (key in ['0'..'9',#8,#13]) then
- begin
- key:=#0;
- messagebeep(1);
- application.MessageBox('请输入数字!','提示',mb_ok);
- end;
- end;
- procedure Tam_Ajcx.Edit4KeyPress(Sender: TObject; var Key: Char);
- begin
- if (combobox7.Text='页数')or(combobox7.Text='年代号') then
- if not (key in ['0'..'9',#8,#13]) then
- begin
- key:=#0;
- messagebeep(1);
- application.MessageBox('请输入数字!','提示',mb_ok);
- end;
- end;
- end.