f_zpinf.pas
上传用户:lcqxtx
上传日期:2013-02-15
资源大小:530k
文件大小:7k
- unit f_zpinf;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ComCtrls, ToolWin, ImgList, StdCtrls, Grids, DBGrids, DB, ADODB,
- Buttons;
- type
- Tw_zpinf = class(TForm)
- ImageList1: TImageList;
- DBGrid1: TDBGrid;
- gb_1: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- e_name: TEdit;
- ToolBar1: TToolBar;
- tb_add: TToolButton;
- tb_edit: TToolButton;
- tb_del: TToolButton;
- tb_can: TToolButton;
- tb_save: TToolButton;
- tb_exit: TToolButton;
- data_zpinf: TDataSource;
- ado_zpinf: TADOQuery;
- Label4: TLabel;
- ComboBox2: TComboBox;
- ComboBox3: TComboBox;
- ado_zpinfdepart_name: TStringField;
- ado_zpinfdepart_job: TStringField;
- ado_zpinfxl: TStringField;
- ado_zpinfxb: TStringField;
- ado_zpinfdepart_id: TStringField;
- Edit1: TEdit;
- Edit2: TEdit;
- Label5: TLabel;
- SpeedButton1: TSpeedButton;
- SpeedButton2: TSpeedButton;
- procedure tb_addClick(Sender: TObject);
- procedure tb_editClick(Sender: TObject);
- procedure tb_delClick(Sender: TObject);
- procedure tb_canClick(Sender: TObject);
- procedure DBGrid1CellClick(Column: TColumn);
- procedure tb_saveClick(Sender: TObject);
- procedure tb_exitClick(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormCreate(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure SpeedButton1Click(Sender: TObject);
- procedure SpeedButton2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- procedure s_save;
- procedure s_show;
- procedure s_clear(bb:boolean);
- end;
- var
- w_zpinf: Tw_zpinf;
- bsf:string;
- implementation
- uses f_main, f_depart_id;
- {$R *.dfm}
- procedure Tw_zpinf.s_save;
- begin
- ado_zpinf.Edit ;
- ado_zpinf.FieldByName('depart_id').AsString :=trim(edit1.Text);
- ado_zpinf.FieldByName('depart_name').AsString :=trim(edit1.Text);
- ado_zpinf.FieldByName('depart_job').AsString :=trim(e_name.Text);
- ado_zpinf.FieldByName('xl').AsString :=trim(combobox2.Text);
- ado_zpinf.FieldByName('xb').AsString :=trim(combobox3.Text);
- ado_zpinf.Post;
- end;
- procedure Tw_zpinf.s_show;
- begin
- ado_zpinf.Close;
- ado_zpinf.SQL.Clear;
- ado_zpinf.SQL.Add('select * from zpinf');
- ado_zpinf.Open;
- end;
- procedure Tw_zpinf.s_clear(bb:boolean);
- var
- i:integer;
- begin
- edit1.Clear;
- edit2.Clear;
- combobox2.text:='';
- combobox3.text:='';
- e_name.Text:='';
- tb_add.Enabled:=true;
- tb_edit.Enabled :=true;
- tb_del.Enabled :=true;
- tb_save.Enabled :=false;
- tb_can.Enabled :=false;
- tb_exit.Enabled :=true;
- for i:=0 to gb_1.ControlCount-1 do
- begin
- if (gb_1.Controls[i].ClassType=tedit)or (gb_1.Controls[i].ClassType=tcombobox) then
- begin
- if bb=false then
- gb_1.Controls[i].Enabled :=false
- else
- gb_1.Controls[i].Enabled :=true;
- end;
- end;
- end;
- procedure Tw_zpinf.tb_addClick(Sender: TObject);
- var
- ss:boolean;
- begin
- if bsf='xz' then
- ss:=true;
- s_clear(ss);
- edit1.Clear;
- edit2.Clear;
- e_name.Text:='';
- combobox2.text:='';
- combobox3.text:='';
- edit2.SetFocus ;
- tb_add.Enabled :=false;
- tb_edit.Enabled :=false;
- tb_save.Enabled :=true;
- tb_del.Enabled :=false;
- tb_can.Enabled :=true;
- tb_exit.Enabled :=false;
- end;
- procedure Tw_zpinf.tb_editClick(Sender: TObject);
- var
- i:integer;
- begin
- if trim(edit2.text)<>'' then begin
- bsf:='xg';
- for i:=0 to gb_1.ControlCount-1 do
- if (gb_1.Controls[i].ClassType=tedit) or(gb_1.Controls[i].ClassType=tcombobox) then
- gb_1.Controls[i].Enabled :=true;
- tb_add.Enabled :=false;
- tb_save.Enabled :=true;
- tb_del.Enabled :=false;
- tb_can.Enabled :=true;
- tb_exit.Enabled :=false;
- tb_edit.Enabled :=false;
- end
- else
- showmessage('请输入修改值');
- exit;
- end;
- procedure Tw_zpinf.tb_delClick(Sender: TObject);
- var
- bb:boolean;
- begin
- if trim(edit2.Text )<>'' then
- begin
- if MessageDlg('记录是否删除 ?',mtConfirmation, [mbYes, mbNo], 0) = mrYes then
- begin
- ado_zpinf.Delete;
- s_show;
- bb:=false;
- s_clear(bb);
- end
- else
- exit;
- end
- else
- showmessage('请输入删除值!');
- exit;
- end;
- procedure Tw_zpinf.tb_canClick(Sender: TObject);
- var
- bb:boolean;
- begin
- bb:=false;
- s_clear(bb);
- end;
- procedure Tw_zpinf.DBGrid1CellClick(Column: TColumn);
- begin
- if ado_zpinf.RecordCount>0 then
- begin
- edit2.Text:=trim(ado_zpinf.fieldbyname('depart_id').AsString );
- edit1.Text:=trim(ado_zpinf.fieldbyname('depart_name').AsString );
- e_name.Text:=trim(ado_zpinf.fieldbyname('depart_job').AsString );
- combobox2.Text:=trim(ado_zpinf.fieldbyname('xl').AsString );
- combobox3.Text:=trim(ado_zpinf.fieldbyname('xb').AsString );
- end;
- end;
- procedure Tw_zpinf.tb_saveClick(Sender: TObject);
- var
- bb:boolean;
- begin
- if trim(edit1.Text)='' then
- begin
- showmessage('请选入部门名称!');
- exit;
- end;
- if bsf<>'xg' then
- begin
- ado_zpinf.Close;
- ado_zpinf.SQL.clear;
- ado_zpinf.SQL.Add('select * from zpinf where depart_id='+char(39)+trim(edit2.Text)+char(39));
- ado_zpinf.Open;
- end;
- if ado_zpinf.RecordCount <0 then
- begin
- showmessage('请输入值');
- exit;
- end;
- if trim(e_name.Text)='' then
- begin
- showmessage('请输入招聘员工职务');
- exit;
- end;
- if trim(edit2.Text)='' then
- begin
- showmessage('请选入部门编号');
- exit;
- end;
- if trim(combobox2.Text)='' then
- begin
- showmessage('请选择最高学历');
- exit;
- end;
- if trim(combobox3.Text)='' then
- begin
- showmessage('请选择性别限制');
- exit;
- end;
- if MessageDlg('记录是否保存吗 ?',mtConfirmation, [mbYes, mbNo], 0) = mrYes then
- begin
- s_save;
- s_show;
- bb:=false;
- s_clear(bb);
- end
- else
- s_show;
- exit;
- end;
- procedure Tw_zpinf.tb_exitClick(Sender: TObject);
- begin
- close;
- w_main.Enabled:=true;
- end;
- procedure Tw_zpinf.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- w_main.Enabled:=true;
- end;
- procedure Tw_zpinf.FormCreate(Sender: TObject);
- begin
- w_main.Enabled:=false;
- end;
- procedure Tw_zpinf.FormShow(Sender: TObject);
- var
- ss:boolean;
- begin
- ss:=false;
- s_clear(ss);
- end;
- procedure Tw_zpinf.SpeedButton1Click(Sender: TObject);
- begin
- Application.CreateForm(Tw_depart_id, w_depart_id);
- if w_depart_id.ShowModal = mrOk then
- Edit2.Text:=copy(trim(w_depart_id.combobox1.text),1,5);
- end;
- procedure Tw_zpinf.SpeedButton2Click(Sender: TObject);
- begin
- Application.CreateForm(Tw_depart_id, w_depart_id);
- if w_depart_id.ShowModal = mrOk then
- Edit1.Text:=copy(trim(w_depart_id.combobox1.text),10,length(trim(w_depart_id.combobox1.text)));
- end;
- end.