Am_GdAjCxs.pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:7k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Am_GdAjCxs;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, DB, DBClient, Buttons, StdCtrls, Mask, DBCtrlsEh, ExtCtrls;
- type
- Tam_gdAjcx = 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 SpeedButton1Click(Sender: TObject);
- procedure SpeedButton2Click(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure ComboBox1Change(Sender: TObject);
- procedure ComboBox3Change(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure ComboBox2Change(Sender: TObject);
- procedure Edit1KeyPress(Sender: TObject; var Key: Char);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- am_gdAjcx: Tam_gdAjcx;
- str,s_zdm,s_logic,s_tj:string;//查找字符串,字段名
- Const ss:array [0..16] of string=('ajzt_mc','ajlb_mc','aj_ndh','user_name','mj_mc','bgqx_mc','aj_dh',
- 'aj_bzqsrq','aj_bzjsrq','aj_gdqsrq','aj_gdjsrq','aj_ljr','aj_jcr','aj_wsh','aj_kwmc','aj_ztc','aj_bmmc');
- implementation
- uses am_dz_ajxzs, am_gdaj_cxs, DMs;
- {$R *.dfm}
- procedure Tam_gdAjcx.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='编制起始日期')or(combobox1.Text='编制结束日期')
- or(combobox1.Text='归档起始日期')or(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_gdAjcx.SpeedButton2Click(Sender: TObject);
- begin
- combobox1.ItemIndex:=-1;
- combobox2.ItemIndex:=-1;
- edit1.Text:='';
- combobox3.ItemIndex:=-1;
- edit2.text:='';
- end;
- procedure Tam_gdAjcx.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='编制起始日期')or(combobox1.Text='编制结束日期')
- or(combobox1.Text='归档起始日期')or(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_Ajgd where '+str;
- Clientdataset1.Open;
- //dm.V_AJGD.Data:=Clientdataset1.Data;
- am_gdaj_cx.ClientDataSet1.data:=Clientdataset1.Data;
- if Clientdataset1.RecordCount=0 then
- application.MessageBox('没有找到符合条件的纪录','提示',mb_ok+mb_iconinformation)
- else
- begin
- //Hint:='当前表中有'+IntToStr(dm.V_Ajgd.RecordCount)+'条记录符合条件';
- Hint:='当前表中有'+IntToStr(ClientDataSet1.RecordCount)+'条记录符合条件';
- application.MessageBox(Pchar(hint),'提示',mb_ok+mb_iconinformation);
- end;
- end;
- procedure Tam_gdAjcx.BitBtn2Click(Sender: TObject);
- begin
- close;
- end;
- procedure Tam_gdAjcx.ComboBox1Change(Sender: TObject);
- begin
- s_zdm:=ss[combobox1.itemindex];//以上是获得下拉框中的值
- if (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_gdAjcx.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_gdAjcx.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('编制起始日期');
- combobox1.Items.Add('编制结束日期');
- 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_gdAjcx.ComboBox2Change(Sender: TObject);
- begin
- if (combobox1.Text='编制起始日期')or(combobox1.Text='编制结束日期')
- or(combobox1.Text='归档起始日期')or(combobox1.Text='归档结束日期') then
- begin
- DBDateTimeEditEh1.Visible:=true;
- edit1.Visible:=false;
- end
- else
- begin
- DBDateTimeEditEh1.Visible:=false;
- edit1.Visible:=true;
- end;
- end;
- procedure Tam_gdAjcx.Edit1KeyPress(Sender: TObject; var Key: Char);
- begin
- if combobox1.Text='年代号' then
- begin
- if not(key in ['0'..'9',#8,#13]) then
- begin
- key:=#0;
- application.MessageBox('请输入整数','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- end;
- end;
- procedure Tam_gdAjcx.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- action:=cafree;
- am_gdajcx:=Nil;
- Clientdataset1.Active:=false;
- end;
- end.