|
Кадровий облік |
nd; procedure FindByExempt; var i: Integer; begini: =0; while i<=WorkersCount-1 do beginif ORD(Worker [i]. Exempt) <>Form1. ComboBox3. ItemIndex then beginForm2. DelWorker(i); DEC(i); end; INC(i); end; Form1. RefreshList; end; procedure FindByLiberationData; var i: Integer; begini: =0; while i<=WorkersCount-1 do beginif DataToInt(Worker [i]. LiberationData) <>DataToInt(Form1. GetData(Form1. ComboBox3. Text)) then beginForm2. DelWorker(i); DEC(i); end; INC(i); end; Form1. RefreshList; end; procedure FindByPositionName; var i,j: Integer; begini: =0; j: =Form1. ComboBox3. ItemIndex; if j<0 then Exit; while i<=WorkersCount-1 do beginif Worker [i]. PositionName<>Form1. ComboBox3. Items. Strings [j] then beginForm2. DelWorker(i); DEC(i); end; INC(i); end; Form1. RefreshList; end; procedure FindByDepartmentName; var i,j: Integer; begini: =0; j: =Form1. ComboBox3. ItemIndex; if j<0 then Exit; while i<=WorkersCount-1 do beginif Worker [i]. DepartmentName<>Form1. ComboBox3. Items. Strings [j] then beginForm2. DelWorker(i); DEC(i); end; INC(i); end; Form1. RefreshList; end; procedure FindBySubsectionName; var i,j: Integer; begini: =0; j: =Form1. ComboBox3. ItemIndex; if j<0 then Exit; while i<=WorkersCount-1 do beginif Worker [i]. SubsectionName<>Form1. ComboBox3. Items. Strings [j] then beginForm2. DelWorker(i); DEC(i); end; INC(i); end; Form1. RefreshList; end; procedure FindByDepartmentLeader; var i: Integer; begini: =0; while i<=WorkersCount-1 do beginif ORD(Worker [i]. DepartmentLeader) <>Form1. ComboBox3. ItemIndex then beginForm2. DelWorker(i); DEC(i); end; INC(i); end; Form1. RefreshList; end; procedure FindBySubsectionLeader; var i: Integer; begini: =0; while i<=WorkersCount-1 do beginif ORD(Worker [i]. SubsectionLeader) <>Form1. ComboBox3. ItemIndex then beginForm2. DelWorker(i); DEC(i); end; INC(i); end; Form1. RefreshList; end; procedure TForm1. Button6Click(Sender: TObject); begincase ComboBox2. ItemIndex of0: FindByTabN; 1: FindByLastName; 2: FindByName; 3: FindByPatronymic; 4: FindByBirthDay; 5: FindByBirthPlace; 6: FindByStat; 7: FindByIndCode; 8: FindByReceptionData; 9: FindByExperience; 10: FindByExempt; 11: FindByLiberationData; 12: FindByPositionName; 13: FindByDepartmentName; 14: FindBySubsectionName; 15: FindByDepartmentLeader; 16: FindBySubsectionLeader; end; end; end. unit WorkerUnit; interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, Mask, ExtCtrls; typeTForm2 = class(TForm) Button1: TButton; Button2: TButton; Label12: TLabel; CheckBox3: TCheckBox; Edit8: TEdit; Panel1: TPanel; Label9: TLabel; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label10: TLabel; Label11: TLabel; Label13: TLabel; Label14: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; ComboBox1: TComboBox; Edit6: TEdit; ComboBox2: TComboBox; CheckBox1: TCheckBox; ComboBox3: TComboBox; CheckBox2: TCheckBox; ComboBox4: TComboBox; Edit7: TEdit; Edit9: TEdit; Edit10: TEdit; Button3: TButton; function STI(S: String): Integer; procedure ClearField; procedure FormToRec(Index: Integer); procedure ClearWorker(Index: Integer); procedure DelWorker(Index: Integer); procedure Edit7KeyPress(Sender: TObject; var Key: Char); procedure FormShow(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure ComboBox2KeyPress(Sender: TObject; var Key: Char); procedure RecToForm(Index: Integer); function Verification: Boolean; procedure Button1Click(Sender: TObject); procedure CheckBox3Click(Sender: TObject); procedure Edit7Change(Sender: TObject); procedure Edit8Change(Sender: TObject); procedure Edit10Change(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure Button3Click(Sender: TObject); procedure ComboBox2DropDown(Sender: TObject); procedure ComboBox3DropDown(Sender: TObject); procedure ComboBox4DropDown(Sender: TObject); private{ Private declarations }public{ Public declarations }end; varForm2: TForm2; OK: Boolean=False; implementationuses KadrUnit, RegUnit; {$R *. dfm}function TForm2. STI(S: String): Integer; var E: Integer; begin/ / Ця функція альтернативна StrToInt, тільки при помилці результат = 0Val(S,Result,E); if E<>0 then Result: =0; end; function SUB_Data(A,B: Data): Integer; var A1,B1: Integer; beginA1: =A. Y*365+A. M*31+A. D; B1: =B. Y*365+B. M*31+B. D; Result: =Trunc((A1-B1) / 365); end; procedure TForm2. ClearField; beginEdit1. Text: =''; Edit2. Text: =''; Edit3. Text: =''; Edit4. Text: =''; Edit5. Text: =''; Edit6. Text: =''; Edit7. Text: =''; Edit8. Text: =''; Edit9. Text: =''; Edit10. Text: =''; CheckBox1. Checked: =False; CheckBox2. Checked: =False; CheckBox3. Checked: =False; ComboBox1. ItemIndex: =-1; ComboBox2. ItemIndex: =-1; ComboBox3. ItemIndex: =-1; ComboBox4. ItemIndex: =-1; end; procedure TForm2. FormToRec(Index: Integer); beginif ((Index>=WorkersCount) or(Index<0)) then Exit; Worker [Index]. TabN: =STI(Edit1. Text); Worker [Index]. LastName: =Edit3. Text; Worker [Index]. Name: =Edit4. Text; Worker [Index]. Patronymic: =Edit5. Text; Worker [Index]. BirthData: =Form1. GetData(Edit7. Text); Worker [Index]. BirthPlace: =Edit6. Text; if ComboBox1. ItemIndex>=0 thenWorker [Index]. Stat: =Boolean(ComboBox1. ItemIndex); Worker [Index]. IndCode: =Edit2. Text; Worker [Index]. ReceptionData: =Form1. GetData(Edit10. Text); Worker [Index]. Experience: =STI(Edit9. Text); Worker [Index]. Exempt: =CheckBox3. Checked; if CheckBox3. Checked thenWorker [Index]. LiberationData: =Form1. GetData(Edit8. Text); if ComboBox4. ItemIndex>=0 thenWorker [Index]. PositionName: =ComboBox4. Items. Strings [ComboBox4. ItemIndex] ; if ComboBox3. ItemIndex>=0 thenWorker [Index]. DepartmentName: =ComboBox3. Items. Strings [ComboBox3. ItemIndex] ; Worker [Index]. DepartmentLeader: =CheckBox2. Checked; if ComboBox2. ItemIndex>=0 thenWorker [Index]. SubsectionName: =ComboBox2. Items. Strings [ComboBox2. ItemIndex] ; Worker [Index]. SubsectionLeader: =CheckBox1. Checked; end; function ItemIndex(S: String; ST: TStrings): Integer; var i: Integer; beginResult: =-1; for i: =0 to ST. Count-1 doif ST. Strings [i] =S then beginResult: =i; Exit; end; end; procedure TForm2. RecToForm(Index: Integer); beginif ((Index>=WorkersCount) or(Index<0)) then Exit; Edit1. Text: =IntToStr(Worker [Index]. TabN); Edit3. Text: =Worker [Index]. LastName; Edit4. Text: =Worker [Index]. Name; Edit5. Text: =Worker [Index]. Patronymic; Edit7. Text: =Form1. DataToStr(Worker [Index]. BirthData); Edit6. Text: =Worker [Index]. BirthPlace; ComboBox1. ItemIndex: =Ord(Worker [Index]. Stat); Edit2. Text: =Worker [Index]. IndCode; Edit10. Text: =Form1. DataToStr(Worker [Index]. ReceptionData); Edit9. Text: =IntToStr(Worker [Index]. Experience); CheckBox3. Checked: =Worker [Index]. Exempt; Edit8. Enabled: =CheckBox3. Checked; if CheckBox3. Checked thenEdit8. Text: =Form1. DataToStr(Worker [Index]. LiberationData); ComboBox4. ItemIndex: =ItemIndex(Worker [Index]. PositionName,ComboBox4. Items); ComboBox3. ItemIndex: =ItemIndex(Worker [Index]. DepartmentName,ComboBox3. Items); CheckBox2. Checked: =Worker [Index]. DepartmentLeader; ComboBox2. ItemIndex: =ItemIndex(Worker [Index]. SubsectionName,ComboBox2. Items); CheckBox1. Checked: =Worker [Index]. SubsectionLeader; end; procedure TForm2. ClearWorker(Index: Integer); beginif ((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; beginif ((Index>=WorkersCount) or(Index<0)) then Exit; ClearWorker(Index); for i: =Index to WorkersCount-2 doWorker [i]: =Worker [i+1] ; ClearWorker(WorkersCount-1); DEC(WorkersCount); SetLength(Worker,WorkersCount); if CurWorker>=WorkersCount thenCurWorker: =WorkersCount-1; Form1. RefreshList; end; procedure TForm2. Edit7KeyPress(Sender: TObject; var Key: Char); beginif not (Key in ['0'. '9',#8]) then Key: =#0; end; procedure TForm2. FormShow(Sender: TObject); beginComboBox4. 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); beginif not OK thenif ADD then beginif WorkersCount>0 thenDEC(WorkersCount); if CurWorker>=WorkersCount then CurWorker: =WorkersCount-1; if WorkersCount=0 then beginForm1. StringGrid1. RowCount: =WorkersCount+2; Form1. StringGrid1. Rows [1]. Clear; end elseForm1. StringGrid1. RowCount: =WorkersCount+1; end; Form1. Enabled: =True; if WorkersCount>0 then beginForm1. Button2. Enabled: =True; if not Form1. CheckBox1. Checked thenForm1. Button3. Enabled: =True; end else beginForm1. Button2. Enabled: =False; Form1. Button3. Enabled: =False; end; end; procedure TForm2. ComboBox2KeyPress(Sender: TObject; var Key: Char); beginKey: =#0; end; function TForm2. Verification: Boolean; beginResult: =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 beginShowMessage('Введіть дату звільнення'); Edit8. SetFocus; Result: =False; Exit; end; if Edit1. Text='' then beginShowMessage('Введіть табельний номер'); Edit1. SetFocus; Result: =False; Exit; end; if Edit2. Text='' then beginShowMessage('Введіть ідентифікаційний код'); Edit2. SetFocus; Result: =False; Exit; end; if Edit3. Text='' then beginShowMessage('Введіть прізвище'); Edit3. SetFocus; Result: =False; Exit; end; if Edit4. Text='' then beginShowMessage('Введіть ім'я'); Edit4. SetFocus; Result: =False; Exit; end; if Edit5. Text='' then beginShowMessage('Введіть по Батькові'); Edit5. SetFocus; Result: =False; Exit; end; if ComboBox1. ItemIndex<0 then beginShowMessage('Виберіть стать'); ComboBox1. SetFocus; Result: =False; Exit; end; if Edit7. Text='' then beginShowMessage('Введіть дату народження'); Edit7. SetFocus; Result: =False; Exit; end; if Edit6. Text='' then beginShowMessage('Введіть місце народження'); Edit6. SetFocus; Result: =False; Exit; end; if ((ComboBox2. ItemIndex<0) and(not CheckBox3. Checked)) then beginShowMessage('Виберіть Підрозділ'); ComboBox2. SetFocus; Result: =False; Exit; end; if ((ComboBox3. ItemIndex<0) and(not CheckBox3. Checked)) then beginShowMessage('Виберіть Відділ'); ComboBox3. SetFocus; Result: =False; Exit; end; if ((ComboBox4. ItemIndex<0) and(not CheckBox3. Checked)) then beginShowMessage('Виберіть посаду'); ComboBox4. SetFocus; Result: =False; Exit; end; if Edit10. Text='' then beginShowMessage('Введіть дату прийому на роботу'); Edit10. SetFocus; Result: =False; Exit; end; end; procedure TForm2. Button1Click(Sender: TObject); var i: Integer; beginif not Verification then Exit; i: =Form1. FindInRec(CurWorker); FormToRec(CurWorker); if i>=0 thenRezerv [i]: =Worker [CurWorker] ; Form1. RecToRow(CurWorker,CurWorker+1); OK: =True; Close; end; procedure TForm2. CheckBox3Click(Sender: TObject); beginEdit8. 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); beginif Length(Edit7. Text) in [2,5] then beginEdit7. Text: =Edit7. Text+'. '; Edit7. SelStart: =Length(Edit7. Text); end; end; procedure TForm2. Edit8Change(Sender: TObject); beginif Length(Edit8. Text) in [2,5] then beginEdit8. Text: =Edit8. Text+'. '; Edit8. SelStart: =Length(Edit8. Text); end; if Length(Edit8. Text) =10 thenEdit9. Text: =IntToStr(SUB_Data(Form1. GetData(Edit8. Text),Form1. GetData(Edit10. Text))); end; procedure TForm2. Edit10Change(Sender: TObject); beginif Length(Edit10. Text) in [2,5] then beginEdit10. Text: =Edit10. Text+'. '; Edit10. SelStart: =Length(Edit10. Text); end; Button3. OnClick(Button3); end; procedure TForm2. Button2Click(Sender: TObject); beginOK: =False; Close; end; procedure TForm2. Edit1KeyPress(Sender: TObject; var Key: Char); beginif not (Key in ['0'. '9',#8]) then Key: =#0; end; procedure TForm2. Button3Click(Sender: TObject); var TIME: SystemTime; CurData: Data; beginGetLocalTime(TIME); CurData. D: =Time. wDay; CurData. M: =Time. wMonth; CurData. Y: =Time. wYear; if Length(Edit10. Text) =10 thenEdit9. Text: =IntToStr(SUB_Data(CurData,Form1. GetData(Edit10. Text))); end; procedure TForm2. ComboBox2DropDown(Sender: TObject); beginif ComboBox2. Items. Count<1 then beginForm3. Show; Form3. Edit3. SetFocus; end; end; procedure TForm2. ComboBox3DropDown(Sender: TObject); beginif ComboBox3. Items. Count<1 then beginForm3. Show; Form3. Edit2. SetFocus; end; end; procedure TForm2. ComboBox4DropDown(Sender: TObject); beginif ComboBox4. Items. Count<1 then beginForm3. Show; Form3. Edit1. SetFocus; end; end; end. unit RegUnit; interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls; typeTForm3 = 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; varForm3: TForm3; implementationuses KadrUnit, WorkerUnit; {$R *. dfm}procedure TForm3. Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var i: Integer; A: Boolean; beginif Key=27 then Close; if Key=13 then beginA: =True; for i: =0 to ListBox1. Items. Count-1 doif Edit1. Text=ListBox1. Items. Strings [i] then beginA: =False; Break; end; if A thenListBox1. Items. Add(Edit1. Text); Edit1. Clear; end; end; procedure TForm3. Edit2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var i: Integer; A: Boolean; beginif Key=27 then Close; if Key=13 then beginA: =True; for i: =0 to ListBox2. Items. Count-1 doif Edit2. Text=ListBox2. Items. Strings [i] then beginA: =False; Break; end; if A thenListBox2. Items. Add(Edit2. Text); Edit2. Clear; end; end; procedure TForm3. Edit3KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var i: Integer; A: Boolean; beginif Key=27 then Close; if Key=13 then beginA: =True; for i: =0 to ListBox3. Items. Count-1 doif Edit3. Text=ListBox3. Items. Strings [i] then beginA: =False; Break; end; if A thenListBox3. Items. Add(Edit3. Text); Edit3. Clear; end; end; procedure TForm3. FormShow(Sender: TObject); beginForm1. Enabled: =False; Form2. Enabled: =False; end; procedure TForm3. FormClose(Sender: TObject; var Action: TCloseAction); beginForm2. 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); beginif ListBox1. ItemIndex>=0 thenif Key=46 then ListBox1. Items. Delete(ListBox1. ItemIndex); if Key=27 then Close; end; procedure TForm3. ListBox2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); beginif ListBox2. ItemIndex>=0 thenif Key=46 then ListBox2. Items. Delete(ListBox2. ItemIndex); if Key=27 then Close; end; procedure TForm3. ListBox3KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); beginif ListBox3. ItemIndex>=0 thenif Key=46 then ListBox3. Items. Delete(ListBox3. ItemIndex); if Key=27 then Close; end; procedure TForm3. ListBox1Click(Sender: TObject); var i: Integer; begini: =ListBox1. ItemIndex; if i<0 then Exit; if ListBox1. Items. Strings [i] <>'' thenEdit1. Text: =ListBox1. Items. Strings [i] ; end; procedure TForm3. ListBox2Click(Sender: TObject); var i: Integer; begini: =ListBox2. ItemIndex; if i<0 then Exit; if ListBox2. Items. Strings [i] <>'' thenEdit2. Text: =ListBox2. Items. Strings [i] ; end; procedure TForm3. ListBox3Click(Sender: TObject); var i: Integer; begini: =ListBox3. ItemIndex; if i<0 then Exit; if ListBox3. Items. Strings [i] <>'' thenEdit3. Text: =ListBox3. Items. Strings [i] ; end; end.
Страницы: 1, 2, 3, 4
|
|
|
© 2003-2013
Рефераты бесплатно, курсовые, рефераты биология, большая бибилиотека рефератов, дипломы, научные работы, рефераты право, рефераты, рефераты скачать, рефераты литература, курсовые работы, реферат, доклады, рефераты медицина, рефераты на тему, сочинения, реферат бесплатно, рефераты авиация, рефераты психология, рефераты математика, рефераты кулинария, рефераты логистика, рефераты анатомия, рефераты маркетинг, рефераты релиния, рефераты социология, рефераты менеджемент. |
|
|