?? 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 ;//設(shè)置保存按鈕是否可用
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 員工基礎(chǔ)信息表 ');
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 員工基礎(chǔ)信息表 where 員工編號 = :a');
Parameters.ParamByName('a').Value := Trim(Edit1.Text);
Open;
end;
if Data3.ADOQuery1.RecordCount > 0 then
begin
Application.MessageBox('該員工已經(jīng)存在。','提示',0+64);
Exit;
end;
Try
With Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Insert 員工基礎(chǔ)信息表 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);
//零表示沒有停發(fā)工資,由于是添加操作員,所以該選項不可用
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('系統(tǒng)出錯。','提示',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('銀行信息表為空,請?zhí)砑鱼y行信息。','提示',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('人員類別表為空,請?zhí)砑尤藛T類別。','提示',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('部門信息表為空,請向該表中添加數(shù)據(jù)。','提示',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.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -