📄 ryxxgl.pas
字号:
unit ryxxgl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, mp, ComCtrls, StdCtrls, ExtCtrls, Buttons, CheckLst, DB, Grids,
DBGrids;
type
TForm77 = class(TForm41)
GroupBox1: TGroupBox;
CheckBox1: TCheckBox;
Label10: TLabel;
CheckBox2: TCheckBox;
Label11: TLabel;
CheckBox3: TCheckBox;
Label12: TLabel;
CheckBox4: TCheckBox;
Label13: TLabel;
GroupBox2: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label6: TLabel;
Label4: TLabel;
Edit3: TEdit;
ComboBox1: TComboBox;
Edit2: TEdit;
Label1: TLabel;
Label8: TLabel;
Label7: TLabel;
Label9: TLabel;
DateTimePicker2: TDateTimePicker;
Edit4: TEdit;
ComboBox2: TComboBox;
Edit1: TEdit;
GroupBox3: TGroupBox;
Label5: TLabel;
Label14: TLabel;
ComboBox3: TComboBox;
Edit5: TEdit;
Label15: TLabel;
Edit7: TEdit;
Panel2: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
ComboBox4: TComboBox;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ListBox1: TListBox;
procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BitBtn1Click(Sender: TObject);
Procedure FindNextCtrl;
Procedure EditClear;
procedure Edit1Change(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormShow(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBGrid1DblClick(Sender: TObject);
procedure DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit5KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form77: TForm77;
aa: Boolean = False ;//设置保存按钮是否可用
implementation
uses Dataa;
{$R *.dfm}
procedure TForm77.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
inherited;
TBitBtn(Sender).Font.Color := clRed;
end;
procedure TForm77.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
inherited;
TBitBtn(Sender).Font.Color := clBlue;
end;
procedure TForm77.BitBtn1Click(Sender: TObject);
var
s,m: String;
i: integer;
begin
EditClear;
aa := True;
s:= 'Y'+ FormatDateTime('yyyymmdd',Now());
With Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select max(员工编号) as ss From 员工基础信息表 ');
Open;
end;
If Data3.ADOQuery1.FieldByName('ss').Value = null then
s := s + '001'
else
begin
m:= Trim(Data3.ADOQuery1.FieldByName('ss').Value) ;
i:= StrToInt(Trim(Copy(m,10,5))) ;
if i<9 then
s:= s + '00'+ InttoStr(i +1)
else if i<99 then
s:= s + '0'+ InttoStr(i +1)
else
s:= s +InttoStr(i +1);
end;
Edit1.Text := Trim(s);
Edit2.SetFocus;
end;
procedure TForm77.Edit1Change(Sender: TObject);
begin
inherited;
if (Trim(Edit1.Text)<>'')and (Trim(Edit2.Text)<>'')and(Trim(ComboBox1.Text)<>'')and(Trim(ComboBox2.Text)<>'')and
(Trim(Edit3.Text)<>'')and(Trim(Edit4.Text)<>'')and(Trim(Edit5.Text)<>'')and
(Trim(ComboBox3.Text)<>'')and(Trim(ComboBox4.Text)<>'')and(aa = True)then
BitBtn2.Enabled := True
else
BitBtn2.Enabled := False;
end;
procedure TForm77.BitBtn2Click(Sender: TObject);
begin
inherited;
With Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 员工基础信息表 where 员工编号 = :a');
Parameters.ParamByName('a').Value := Trim(Edit1.Text);
Open;
end;
if Data3.ADOQuery1.RecordCount > 0 then
begin
Application.MessageBox('该员工已经存在。','提示',0+64);
Exit;
end;
Try
With Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert 员工基础信息表 values ( :a,:b,:c,:d,:e,:f,:h,default,:j,:k,:l,:m,:n,:o,:p)');
Parameters.ParamByName('a').Value := Trim(Edit1.Text);
Parameters.ParamByName('b').Value := Trim(Edit2.Text);
Parameters.ParamByName('c').Value := Trim(ComboBox1.Text);
Parameters.ParamByName('d').Value := Trim(ComboBox2.Text);
Parameters.ParamByName('e').Value := Trim(Edit4.Text);
Parameters.ParamByName('f').Value := Trim(Edit3.Text);
Parameters.ParamByName('h').Value := Trim(ComboBox4.Text);
//零表示没有停发工资,由于是添加操作员,所以该选项不可用
Parameters.ParamByName('j').Value := 0;
//0表示计税,1表示不计税
if CheckBox2.Checked = True then
Parameters.ParamByName('k').Value := 0
else
Parameters.ParamByName('k').Value := 1;
if CheckBox3.Checked = True then
Parameters.ParamByName('l').Value := 0
else
Parameters.ParamByName('l').Value := 1;
Parameters.ParamByName('m').Value := 0;
Parameters.ParamByName('n').Value := Trim(ComboBox3.Text);
Parameters.ParamByName('o').Value := Trim(Edit5.Text);
Parameters.ParamByName('p').Value := Edit7.Text;
ExecSQL;
end;
Application.MessageBox('保存成功。','提示',0+64);
BitBtn3.OnClick(Sender);
Except
Application.MessageBox('系统出错。','提示',0+64);
Close;
end;
end;
procedure TForm77.FindNextCtrl;
begin
if FindnextControl(activeControl,True,true,False)is TEdit then
TEdit(FindnextControl(activeControl,True,true,False)).SetFocus
else if FindnextControl(activeControl,True,true,False)is TComboBox then
TComboBox(FindnextControl(activeControl,True,true,False)).SetFocus
else if FindnextControl(activeControl,True,true,False)is TDateTimePicker then
TDateTimePicker(FindnextControl(activeControl,True,true,False)).SetFocus;
end;
procedure TForm77.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key = VK_Shift then
FindNextCtrl;
end;
procedure TForm77.FormShow(Sender: TObject);
begin
inherited;
ComboBox1.ItemIndex := 0;
ComboBox2.ItemIndex := 0;
ComboBox3.Clear;
DataSource1.DataSet := Nil;
DBGrid1.Visible := False;
ListBox1.Visible := False;
with Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 银行信息表');
Open;
end;
if Data3.ADOQuery1.RecordCount<1 then
begin
Application.MessageBox('银行信息表为空,请添加银行信息。','提示',64);
Exit;
end
else
while Not Data3.ADOQuery1.Eof do
begin
ComboBox3.Items.Add(Data3.ADOQuery1.FieldByName('银行名称').Value);
Data3.ADOQuery1.Next;
end;
ComboBox4.Clear;
with Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 人员类别表');
Open;
end;
if Data3.ADOQuery1.RecordCount<1 then
begin
Application.MessageBox('人员类别表为空,请添加人员类别。','提示',64);
Exit;
end
else
while Not Data3.ADOQuery1.Eof do
begin
ComboBox4.Items.Add(Data3.ADOQuery1.FieldByName('人员类别').Value);
Data3.ADOQuery1.Next;
end;
end;
procedure TForm77.EditClear;
begin
Edit1.Clear;
Edit2.Clear;
ComboBox1.ItemIndex := 0;
ComboBox2.ItemIndex := 0;
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
Edit7.Clear;
ComboBox3.Text := '';
end;
procedure TForm77.BitBtn3Click(Sender: TObject);
begin
inherited;
EditClear;
aa := False;
BitBtn2.Enabled := False;
BitBtn1.SetFocus;
DataSource1.DataSet := Nil;
DBGrid1.Visible := False;
ListBox1.Visible := False;
end;
procedure TForm77.Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key = VK_Shift then
FindnextCtrl
else if (Key = VK_ReTurn)and(Trim(Edit3.Text)<>'') then
begin
with Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 部门信息表 where 部门名称 = :a');
Parameters.ParamByName('a').Value := Trim(Edit3.Text);
Open;
end;
if Data3.ADOQuery1.RecordCount>0 then
begin
ListBox1.Visible := False;
if Data3.ADOQuery1.RecordCount>1 then
begin
DataSource1.DataSet := Data3.ADOQuery1;
DBGrid1.Visible := True;
DBGrid1.SetFocus;
end
else
Edit4.Text := Data3.ADOQuery1.FieldByName('部门编号').Value;
end
else
begin
Application.MessageBox('该部门不存在,请重新输入。','提示',64);
Edit3.Clear;
end;
end
else if Key = Vk_Next then
begin
With Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select Distinct 部门名称 from 部门信息表');
Open;
end;
if Data3.ADOQuery1.RecordCount<1 then
begin
Application.MessageBox('部门信息表为空,请向该表中添加数据。','提示',64);
Exit;
end
else
begin
ListBox1.Clear;
While Not Data3.ADOQuery1.Eof do
begin
ListBox1.Items.Add(Data3.ADOQuery1.FieldByName('部门名称').Value);
Data3.ADOQuery1.Next ;
end;
ListBox1.Visible := True;
ListBox1.SetFocus;
end;
end;
end;
procedure TForm77.ListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key = Vk_ReTurn then
begin
Edit3.Text := ListBox1.Items[ListBox1.itemIndex];
ListBox1.Visible := False;
Edit3.SetFocus;
end;
end;
procedure TForm77.DBGrid1DblClick(Sender: TObject);
begin
inherited;
Edit3.Text := Data3.ADOQuery1.FieldByName('部门名称').Value;
Edit4.Text := Data3.ADOQuery1.FieldByName('部门编号').Value;
DBGrid1.Visible := False;
end;
procedure TForm77.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key = Vk_ReTurn then
DBGrid1.OnDblClick(Sender);
end;
procedure TForm77.Edit5KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if (Trim(Edit5.Text)<>'')and(Key = Vk_SHift)and(BitBtn2.Enabled = True)then
BitBtn2.SetFocus;
end;
procedure TForm77.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
inherited;
Key := #0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -