📄 txgl.pas
字号:
unit txgl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, Buttons, Mask, DBCtrls, DB, ADODB;
type
Tfrmtxgl = class(TForm)
GroupBox1: TGroupBox;
okbtn: TBitBtn;
exitbtn: TBitBtn;
GroupBox2: TGroupBox;
edgl: TEdit;
edjj: TEdit;
edgz: TEdit;
edposition: TEdit;
Label4: TLabel;
Label5: TLabel;
Label2: TLabel;
Label1: TLabel;
Label3: TLabel;
adgzffbzqry: TADOQuery;
DataSource1: TDataSource;
Label6: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
DBGrid1: TDBGrid;
procedure FormCreate(Sender: TObject);
procedure exitbtnClick(Sender: TObject);
procedure okbtnClick(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmtxgl: Tfrmtxgl;
implementation
uses datarsgl;
{$R *.dfm}
procedure Tfrmtxgl.FormCreate(Sender: TObject);
var txtime,s1,s2:string; //customer datetime param
begin
txtime:=datetostr(date);
with dmrsgl.adtxtimeqry do
begin
close;
sql.Clear;
sql.Add('select * from txtime');
open;
s1:=datetimetostr(fieldbyname('txdate1').AsDateTime);
s2:=datetimetostr(fieldbyname('txdate2').AsDateTime);
if (txtime<>s1)or(txtime<>s2) then
begin
messagedlg('很抱歉还没到调薪时间,请到调薪时间再作业.',mterror,[mbyes],0);
combobox1.Enabled:=false;
edposition.Enabled:=false;
edjj.Enabled:=false;
edgz.Enabled:=false;
edgl.Enabled:=false;
okbtn.Enabled:=false;
edit1.Enabled:=false;
end
else
with dmrsgl.ygjbzlqry do
begin
close;
sql.Clear;
sql.Add('select * from employeer');
open;
first;
while not eof do
begin
combobox1.Items.Add(fieldbyname('number').AsString);
next;
end;
end;
adgzffbzqry.Connection:=dmrsgl.adorsgl;
adgzffbzqry.close;
adgzffbzqry.sql.Clear;
adgzffbzqry.sql.Add('select * from gzffbz');
adgzffbzqry.open;
datasource1.DataSet:=adgzffbzqry;
dbgrid1.DataSource:=datasource1;
dbgrid1.Columns[0].Field:=datasource1.DataSet.FieldByName('number');
dbgrid1.Columns[0].Width:=datasource1.DataSet.Fields[0].DisplayWidth+20;
dbgrid1.Columns[1].Field:=datasource1.DataSet.FieldByName('ygbm');
dbgrid1.Columns[1].Width:=datasource1.DataSet.Fields[1].DisplayWidth+20;
dbgrid1.Columns[2].Field:=datasource1.DataSet.FieldByName('position');
dbgrid1.Columns[2].Width:=datasource1.DataSet.Fields[2].DisplayWidth+20;
dbgrid1.Columns[3].Field:=datasource1.DataSet.FieldByName('work_time');
dbgrid1.Columns[3].Width:=datasource1.DataSet.Fields[3].DisplayWidth+20;
dbgrid1.Columns[4].Field:=datasource1.DataSet.FieldByName('yggz');
dbgrid1.Columns[4].Width:=datasource1.DataSet.Fields[4].DisplayWidth+20;
dbgrid1.Columns[5].Field:=datasource1.DataSet.FieldByName('ygjj');
dbgrid1.Columns[5].Width:=datasource1.DataSet.Fields[5].DisplayWidth+20;
end;
end;
procedure Tfrmtxgl.exitbtnClick(Sender: TObject);
begin
close;
end;
procedure Tfrmtxgl.okbtnClick(Sender: TObject);
begin
try
if combobox1.Text<>'' then
begin
adgzffbzqry.Connection:=dmrsgl.adorsgl;
adgzffbzqry.Close;
adgzffbzqry.SQL.Clear;
adgzffbzqry.SQL.add('select * from gzffbz');
adgzffbzqry.Open;
adgzffbzqry.Edit;
adgzffbzqry.FieldByName('number').AsString:=trim(combobox1.Text);
adgzffbzqry.FieldByName('ygbm').AsString:=trim(edit1.Text);
adgzffbzqry.FieldByName('position').AsString:=trim(edposition.Text);
adgzffbzqry.FieldByName('work_time').AsInteger:=strtoint(trim(edgl.Text));
adgzffbzqry.FieldByName('yggz').AsInteger:=strtoint(trim(edgz.Text));
adgzffbzqry.FieldByName('ygjj').AsInteger:=strtoint(trim(edjj.Text));
if messagedlg('保存修改好的数据资料吗?',mtconfirmation,[mbyes,mbno],0)=mryes then
begin
adgzffbzqry.Post;
edit1.Text:='';
edgz.Text:='';
edgl.Text:='';
edposition.Text:='';
edjj.Text:='';
combobox1.Text:='';
combobox1.SetFocus;
end
else
begin
messagedlg('修改操作已经取消,请重新修改.',mtinformation,[mbyes],0);
adgzffbzqry.Cancel;
edit1.Text:='';
edgz.Text:='';
edgl.Text:='';
edposition.Text:='';
edjj.Text:='';
combobox1.Text:='';
combobox1.SetFocus;
end;
end
else //采用异常处理,可避免系统终止
showmessage('请填写完整部门资料.');
except
on edatabaseerror do
close;
end;
end;
procedure Tfrmtxgl.ComboBox1Change(Sender: TObject);
begin
adgzffbzqry.Connection:=dmrsgl.adorsgl; //读去该部门的数据资料
adgzffbzqry.Close;
adgzffbzqry.SQL.Clear;
adgzffbzqry.SQL.add('select * from gzffbz where number='+quotedstr(combobox1.Text));
adgzffbzqry.Open;
if adgzffbzqry.RecordCount<>0 then
begin
edit1.Text:=adgzffbzqry.fieldbyname('ygbm').AsString;
edposition.Text:=adgzffbzqry.fieldbyname('position').AsString;
edgz.Text:=inttostr(adgzffbzqry.FieldByName('yggz').AsInteger);
edjj.Text:=inttostr(adgzffbzqry.FieldByName('ygjj').AsInteger);
edgl.Text:=inttostr(adgzffbzqry.FieldByName('work_time').AsInteger);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -