Смекни!
smekni.com

Кадровий облік (стр. 5 из 5)

CheckBox1. Checked: =Worker [Index]. SubsectionLeader;

end;

procedure TForm2. ClearWorker(Index: Integer);

begin

if ((Index>=WorkersCount) or(Index<0)) then Exit;

Worker [Index]. TabN: =0;

Worker [Index]. LastName: ='';

Worker [Index]. Name: ='';

Worker [Index]. Patronymic: ='';

Worker [Index]. BirthData: =Form1. GetData('');

Worker [Index]. BirthPlace: ='';

Worker [Index]. Stat: =False;

Worker [Index]. IndCode: ='';

Worker [Index]. ReceptionData: =Form1. GetData('');

Worker [Index]. Experience: =0;

Worker [Index]. Exempt: =False;

Worker [Index]. LiberationData: =Form1. GetData('');

Worker [Index]. PositionName: ='';

Worker [Index]. DepartmentName: ='';

Worker [Index]. DepartmentLeader: =False;

Worker [Index]. SubsectionName: ='';

Worker [Index]. SubsectionLeader: =False;

end;

procedure TForm2. DelWorker(Index: Integer);

var i: Integer;

A: Kadr;

begin

if ((Index>=WorkersCount) or(Index<0)) then Exit;

ClearWorker(Index);

for i: =Index to WorkersCount-2 do

Worker [i]: =Worker [i+1] ;

ClearWorker(WorkersCount-1);

DEC(WorkersCount);

SetLength(Worker,WorkersCount);

if CurWorker>=WorkersCount then

CurWorker: =WorkersCount-1;

Form1. RefreshList;

end;

procedure TForm2. Edit7KeyPress(Sender: TObject; var Key: Char);

begin

if not (Key in ['0'. '9',#8]) then Key: =#0;

end;

procedure TForm2. FormShow(Sender: TObject);

begin

ComboBox4. Items: =Form3. ListBox1. Items;

ComboBox3. Items: =Form3. ListBox2. Items;

ComboBox2. Items: =Form3. ListBox3. Items;

Form1. Enabled: =False;

OK: =False;

end;

procedure TForm2. FormClose(Sender: TObject; var Action: TCloseAction);

begin

if not OK then

if ADD then begin

if WorkersCount>0 then

DEC(WorkersCount);

if CurWorker>=WorkersCount then CurWorker: =WorkersCount-1;

if WorkersCount=0 then begin

Form1. StringGrid1. RowCount: =WorkersCount+2;

Form1. StringGrid1. Rows [1]. Clear;

end else

Form1. StringGrid1. RowCount: =WorkersCount+1;

end;

Form1. Enabled: =True;

if WorkersCount>0 then begin

Form1. Button2. Enabled: =True;

if not Form1. CheckBox1. Checked then

Form1. Button3. Enabled: =True;

end else begin

Form1. Button2. Enabled: =False;

Form1. Button3. Enabled: =False;

end;

end;

procedure TForm2. ComboBox2KeyPress(Sender: TObject; var Key: Char);

begin

Key: =#0;

end;

function TForm2. Verification: Boolean;

begin

Result: =True;

ComboBox2. ItemIndex: =ItemIndex(ComboBox2. Text,ComboBox2. Items);

ComboBox3. ItemIndex: =ItemIndex(ComboBox3. Text,ComboBox3. Items);

ComboBox4. ItemIndex: =ItemIndex(ComboBox4. Text,ComboBox4. Items);

if ((Edit8. Text='') and(CheckBox3. Checked)) then begin

ShowMessage('Введіть дату звільнення'); Edit8. SetFocus;

Result: =False; Exit;

end;

if Edit1. Text='' then begin

ShowMessage('Введіть табельний номер'); Edit1. SetFocus;

Result: =False; Exit;

end;

if Edit2. Text='' then begin

ShowMessage('Введіть ідентифікаційний код'); Edit2. SetFocus;

Result: =False; Exit;

end;

if Edit3. Text='' then begin

ShowMessage('Введіть прізвище'); Edit3. SetFocus;

Result: =False; Exit;

end;

if Edit4. Text='' then begin

ShowMessage('Введіть ім’я'); Edit4. SetFocus;

Result: =False; Exit;

end;

if Edit5. Text='' then begin

ShowMessage('Введіть по Батькові'); Edit5. SetFocus;

Result: =False; Exit;

end;

if ComboBox1. ItemIndex<0 then begin

ShowMessage('Виберіть стать'); ComboBox1. SetFocus;

Result: =False; Exit;

end;

if Edit7. Text='' then begin

ShowMessage('Введіть дату народження'); Edit7. SetFocus;

Result: =False; Exit;

end;

if Edit6. Text='' then begin

ShowMessage('Введіть місце народження'); Edit6. SetFocus;

Result: =False; Exit;

end;

if ((ComboBox2. ItemIndex<0) and(not CheckBox3. Checked)) then begin

ShowMessage('Виберіть Підрозділ'); ComboBox2. SetFocus;

Result: =False; Exit;

end;

if ((ComboBox3. ItemIndex<0) and(not CheckBox3. Checked)) then begin

ShowMessage('Виберіть Відділ'); ComboBox3. SetFocus;

Result: =False; Exit;

end;

if ((ComboBox4. ItemIndex<0) and(not CheckBox3. Checked)) then begin

ShowMessage('Виберіть посаду'); ComboBox4. SetFocus;

Result: =False; Exit;

end;

if Edit10. Text='' then begin

ShowMessage('Введіть дату прийому на роботу'); Edit10. SetFocus;

Result: =False; Exit;

end;

end;

procedure TForm2. Button1Click(Sender: TObject);

var i: Integer;

begin

if not Verification then Exit;

i: =Form1. FindInRec(CurWorker);

FormToRec(CurWorker);

if i>=0 then

Rezerv [i]: =Worker [CurWorker] ;

Form1. RecToRow(CurWorker,CurWorker+1);

OK: =True;

Close;

end;

procedure TForm2. CheckBox3Click(Sender: TObject);

begin

Edit8. Enabled: =CheckBox3. Checked;

ComboBox2. Enabled: =not CheckBox3. Checked;

ComboBox3. Enabled: =not CheckBox3. Checked;

ComboBox4. Enabled: =not CheckBox3. Checked;

CheckBox1. Enabled: =not CheckBox3. Checked;

CheckBox2. Enabled: =not CheckBox3. Checked;

Button3. Enabled: =not CheckBox3. Checked;

if CheckBox3. Checked then Edit8. SetFocus;

end;

procedure TForm2. Edit7Change(Sender: TObject);

begin

if Length(Edit7. Text) in [2,5] then begin

Edit7. Text: =Edit7. Text+'. ';

Edit7. SelStart: =Length(Edit7. Text);

end;

end;

procedure TForm2. Edit8Change(Sender: TObject);

begin

if Length(Edit8. Text) in [2,5] then begin

Edit8. Text: =Edit8. Text+'. ';

Edit8. SelStart: =Length(Edit8. Text);

end;

if Length(Edit8. Text) =10 then

Edit9. Text: =IntToStr(SUB_Data(Form1. GetData(Edit8. Text),Form1. GetData(Edit10. Text)));

end;

procedure TForm2. Edit10Change(Sender: TObject);

begin

if Length(Edit10. Text) in [2,5] then begin

Edit10. Text: =Edit10. Text+'. ';

Edit10. SelStart: =Length(Edit10. Text);

end;

Button3. OnClick(Button3);

end;

procedure TForm2. Button2Click(Sender: TObject);

begin

OK: =False;

Close;

end;

procedure TForm2. Edit1KeyPress(Sender: TObject; var Key: Char);

begin

if not (Key in ['0'. '9',#8]) then Key: =#0;

end;

procedure TForm2. Button3Click(Sender: TObject);

var TIME: SystemTime;

CurData: Data;

begin

GetLocalTime(TIME);

CurData. D: =Time. wDay;

CurData. M: =Time. wMonth;

CurData. Y: =Time. wYear;

if Length(Edit10. Text) =10 then

Edit9. Text: =IntToStr(SUB_Data(CurData,Form1. GetData(Edit10. Text)));

end;

procedure TForm2. ComboBox2DropDown(Sender: TObject);

begin

if ComboBox2. Items. Count<1 then begin

Form3. Show;

Form3. Edit3. SetFocus;

end;

end;

procedure TForm2. ComboBox3DropDown(Sender: TObject);

begin

if ComboBox3. Items. Count<1 then begin

Form3. Show;

Form3. Edit2. SetFocus;

end;

end;

procedure TForm2. ComboBox4DropDown(Sender: TObject);

begin

if ComboBox4. Items. Count<1 then begin

Form3. Show;

Form3. Edit1. SetFocus;

end;

end;

end.

unit RegUnit;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

type

TForm3 = class(TForm)

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

ListBox1: TListBox;

ListBox2: TListBox;

ListBox3: TListBox;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

procedure Edit1KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure Edit2KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure Edit3KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure FormShow(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure ListBox1KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure ListBox2KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure ListBox3KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure ListBox1Click(Sender: TObject);

procedure ListBox2Click(Sender: TObject);

procedure ListBox3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form3: TForm3;

implementation

uses KadrUnit, WorkerUnit;

{$R *. dfm}

procedure TForm3. Edit1KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

var i: Integer;

A: Boolean;

begin

if Key=27 then Close;

if Key=13 then begin

A: =True;

for i: =0 to ListBox1. Items. Count-1 do

if Edit1. Text=ListBox1. Items. Strings [i] then begin

A: =False;

Break;

end;

if A then

ListBox1. Items. Add(Edit1. Text);

Edit1. Clear;

end;

end;

procedure TForm3. Edit2KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

var i: Integer;

A: Boolean;

begin

if Key=27 then Close;

if Key=13 then begin

A: =True;

for i: =0 to ListBox2. Items. Count-1 do

if Edit2. Text=ListBox2. Items. Strings [i] then begin

A: =False;

Break;

end;

if A then

ListBox2. Items. Add(Edit2. Text);

Edit2. Clear;

end;

end;

procedure TForm3. Edit3KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

var i: Integer;

A: Boolean;

begin

if Key=27 then Close;

if Key=13 then begin

A: =True;

for i: =0 to ListBox3. Items. Count-1 do

if Edit3. Text=ListBox3. Items. Strings [i] then begin

A: =False;

Break;

end;

if A then

ListBox3. Items. Add(Edit3. Text);

Edit3. Clear;

end;

end;

procedure TForm3. FormShow(Sender: TObject);

begin

Form1. Enabled: =False;

Form2. Enabled: =False;

end;

procedure TForm3. FormClose(Sender: TObject; var Action: TCloseAction);

begin

Form2. ComboBox2. Items: =ListBox3. Items;

Form2. ComboBox3. Items: =ListBox2. Items;

Form2. ComboBox4. Items: =ListBox1. Items;

Form1. Enabled: =True;

Form2. Enabled: =True;

end;

procedure TForm3. ListBox1KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if ListBox1. ItemIndex>=0 then

if Key=46 then ListBox1. Items. Delete(ListBox1. ItemIndex);

if Key=27 then Close;

end;

procedure TForm3. ListBox2KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if ListBox2. ItemIndex>=0 then

if Key=46 then ListBox2. Items. Delete(ListBox2. ItemIndex);

if Key=27 then Close;

end;

procedure TForm3. ListBox3KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if ListBox3. ItemIndex>=0 then

if Key=46 then ListBox3. Items. Delete(ListBox3. ItemIndex);

if Key=27 then Close;

end;

procedure TForm3. ListBox1Click(Sender: TObject);

var i: Integer;

begin

i: =ListBox1. ItemIndex;

if i<0 then Exit;

if ListBox1. Items. Strings [i] <>'' then

Edit1. Text: =ListBox1. Items. Strings [i] ;

end;

procedure TForm3. ListBox2Click(Sender: TObject);

var i: Integer;

begin

i: =ListBox2. ItemIndex;

if i<0 then Exit;

if ListBox2. Items. Strings [i] <>'' then

Edit2. Text: =ListBox2. Items. Strings [i] ;

end;

procedure TForm3. ListBox3Click(Sender: TObject);

var i: Integer;

begin

i: =ListBox3. ItemIndex;

if i<0 then Exit;

if ListBox3. Items. Strings [i] <>'' then

Edit3. Text: =ListBox3. Items. Strings [i] ;

end;

end.