-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorkers.frm
1354 lines (1222 loc) · 42.4 KB
/
Workers.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Workers
ClientHeight = 10890
ClientLeft = 45
ClientTop = 375
ClientWidth = 17085
OleObjectBlob = "Workers.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "Workers"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim inRead, CommentTrigger, DayTrigger As Boolean
Dim ChosenMate, ConfirmObject As Integer
Sub ObjectsRecall()
WorkersTreeHolder.Visible = False
JobsTree.Visible = True
DayList.Visible = True
DateAndWorker_Frame.Visible = True
ConfirmObject = 0
ConfirmChoice_Button.Top = 420
ConfirmChoice_Button.Left = 120
End Sub
Sub ScanWorkers()
Dim i, p, TotalCats As Integer
On Error GoTo ExceptionControl:
With Workers
.WorkersTreeHolder.Top = -500
.WorkersTree.Visible = True
.WorkersTreeHolder.Visible = True
.WorkersTree.Nodes.Clear
Sheets("Каталог").Select
TotalCats = Cells(4, 23).Value
For i = InfoOffset To CInt(InfoOffset - 1 + TotalCats)
.WorkersTree.Nodes.Add(, , CStr(Cells(i, 24)) & "z", Cells(i, 23).Value).Sorted = True
.WorkersTree.Nodes(i - InfoOffset + 1).Tag = "Cat"
Next
Sheets("Сотрудники").Select
WeHaveWorkers = Cells(1, 2).Value
For i = 3 To WeHaveWorkers + 2
For p = 1 To TotalCats
If (Cells(i, 4).Value <> 1) And (.WorkersTree.Nodes(p).Key = CStr(Cells(i, 6).Value) & "z") Then
If (SelectUpdatesOnly And Cells(i, 1).Value = 1) Or Not SelectUpdatesOnly Then
.WorkersTree.Nodes.Add(p, 4, Cells(i, 3), Cells(i, 2) & " " & Cells(i, 5)).Sorted = True
If Not AdminMode Then .WorkersTree.Nodes(.WorkersTree.Nodes.Count).Tag = Cells(i, 7)
p = TotalCats
End If
End If
Next p
Next i
p = 1
Do While p < .WorkersTree.Nodes.Count
If .WorkersTree.Nodes(p).Children = 0 And .WorkersTree.Nodes(p).Tag = "Cat" Then
.WorkersTree.Nodes.Remove (p)
p = p - 1
TotalCats = TotalCats - 1
End If
p = p + 1
Loop
.WorkersTree.Tag = TotalCats
.WorkersTreeHolder.Visible = False
End With
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/ScanWorkers()"
Exception.Show
End Sub
Sub ScanJobs()
Dim i, p, TotalCats As Integer
On Error GoTo ExceptionControl:
Sheets("Каталог").Select
With Workers
.JobsTree.Visible = True
.JobsTree.Nodes.Clear
.BonusRate_Box.Value = Cells(4, 6).Value
TotalCats = Cells(4, 19).Value
For i = InfoOffset To CInt(InfoOffset - 1 + TotalCats)
.JobsTree.Nodes.Add(, , , Cells(i, 19).Value).Sorted = True
.JobsTree.Nodes(i - InfoOffset + 1).Tag = "Cat"
Next
TotalJobs = Cells(4, 2).Value
ShowRates = Cells(4, 5).Value
For i = InfoOffset To CInt(InfoOffset - 1 + TotalJobs)
AddRate = ""
If ShowRates = 1 Then
If Cells(i, 5) = 0 Then AddRate = " (" & CStr(Cells(i, 6)) & ")" Else AddRate = " (" & CStr(Cells(i, 5)) & ")"
End If
If Not AdminMode Then
If (Cells(i, 7) = 0) And (Cells(i, 9) = 0) Then _
.JobsTree.Nodes.Add(CInt(Cells(i, 1).Value - InfoOffset + 1), 4, CStr(Cells(i, 3)) & "z", Cells(i, 2).Value & AddRate).Sorted = True
Else
If (Cells(i, 7) = 0) Then _
.JobsTree.Nodes.Add(CInt(Cells(i, 1).Value - InfoOffset + 1), 4, CStr(Cells(i, 3)) & "z", Cells(i, 2).Value & AddRate).Sorted = True
End If
Next
p = 1
Do While p < .JobsTree.Nodes.Count
If .JobsTree.Nodes(p).Children = 0 And .JobsTree.Nodes(p).Tag = "Cat" Then
.JobsTree.Nodes.Remove (p)
TotalCats = TotalCats - 1
p = p - 1
End If
p = p + 1
Loop
.JobsTree.Tag = TotalCats
End With
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/ScanJobs()"
Exception.Show
End Sub
Sub FillControlList()
On Error GoTo ExceptionControl:
Sheets(NameChooser.Value).Activate
ControlList.ListItems.Clear
For i = InfoOffset To InfoOffset + 31 * Lines - Lines Step Lines
If (Cells(i, 10).Value <> 0) Or (Cells(i, 11).Value <> 0) Or (Cells(i, 13).Value <> "") Then
Dat = Cells(i, 1).Value
Fee = Cells(i, 10).Value
Pre = Cells(i, 11).Value
Comment = ""
If Cells(i, 13).Value <> "" Then
For j = i To i + Lines - 1
If Cells(j, 13).Value <> "" Then Comment = Cells(j, 13).Value Else Exit For
Next j
End If
If Len(Dat) = 1 Then Dat = "0" & Dat
With ControlList
.ListItems.Add = Dat
.ListItems.Item(.ListItems.Count).ListSubItems.Add = Fee
.ListItems.Item(.ListItems.Count).ListSubItems.Add = Pre
.ListItems.Item(.ListItems.Count).ListSubItems.Add = Comment
If CInt(Dat) = CDay_Box.Value Then
.ListItems.Item(.ListItems.Count).ForeColor = &HFF&
For j = 1 To ControlList.ListItems.Item(.ListItems.Count).ListSubItems.Count
.ListItems.Item(.ListItems.Count).ListSubItems(j).ForeColor = &HFF&
Next j
End If
End With
End If
Next i
ControlList.Refresh
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/FillControlList()"
Exception.Show
End Sub
Sub ReadLockedInfo()
On Error GoTo ExceptionControl:
Sheets(NameChooser.Value).Select
Left_Box.Value = Cells(2, 10).Value
Income_Box.Value = Cells(4, 9).Value
Outcome_Box.Value = Cells(3, 11).Value
Tax_Box.Value = -Cells(4, 10).Value
Balance_Box.Value = Cells(1, 10).Value
Oklad_Box.Value = Cells(4, 2).Value
If Cells(3, 1).Value = "RO" Then
MakeReadOnly_Chk.Value = True
If Not AdminMode Then
Apply_Button.Enabled = False
Clear_Button.Enabled = False
Delete_Button.Enabled = False
ChooseMate_Button.Enabled = False
Select_Button.Enabled = False
End If
Else
MakeReadOnly_Chk.Value = False
If Not (AdminMode Or LMMode) Then
Apply_Button.Enabled = True
Clear_Button.Enabled = True
Delete_Button.Enabled = True
ChooseMate_Button.Enabled = True
Select_Button.Enabled = True
End If
End If
If Oklad_Box <> "" Then AboveOklad_Chk.Visible = True Else AboveOklad_Chk.Visible = False
If Balance_Box.Value >= 0 Then Balance_Label.ForeColor = &H8000& Else Balance_Label.ForeColor = &HFF&
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/ReadLockedInfo()"
Exception.Show
End Sub
Sub SetRandomMark()
On Error GoTo ExceptionControl:
Randomize
Cells(2, 1).Value = Round(10000000 * Rnd())
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/SetRandomMark()"
Exception.Show
End Sub
Sub RecordLine(ByVal Day, ByVal Job, Optional ByVal Mark As Boolean = False)
Dim Index, i, ADLen As Integer
On Error GoTo ExceptionControl:
If NameChooser.Value <> "" And CDay_Box.MatchFound Then Sheets(NameChooser.Value).Select Else Exit Sub
Index = Job + InfoOffset + Lines * (Day - 1) - 1
If Mark Then
If Cells(Index, 2).Value <> "" Then
If Cells(Index, 15).Value = 1 Then Cells(Index, 15).Value = "" Else Cells(Index, 15).Value = 1
LogAction ("MarkLine " & CStr(Index))
End If
Exit Sub
End If
If (ID.Value <> "") And DayTrigger Then
Application.Calculation = xlCalculationManual
Cells(Index - Job + 1, 10).FormulaR1C1 = "=SUM(RC[-1]:R[8]C[-1])"
Cells(Index, 9).FormulaR1C1 = "=(RC[-5]*(1-RC[-1])+RC[-3]*RC[-1])*RC[-2]"
'OldAmount = Cells(index, 4)
'OldId = Cells(index, 3)
'OldTime = Cells(index, 6)
ADLen = Len(AltDiam_Box.Value)
If ADLen > 2 And ADLen < 5 Then
Cells(Index, 2).Value = ReplaceToAlternate(JobName_Box.Value, CInt(AltDiam_Box.Value))
Cells(Index, 14).Value = AltDiam_Box.Value
Else
Cells(Index, 2).Value = JobName_Box.Value
Cells(Index, 14).Value = ""
End If
Cells(Index, 3).Value = ID.Value
Cells(Index, 5).Value = Unit.Caption
If CheckNumber(Amount_Box.Value) Then Cells(Index, 4).Value = Amount_Box.Value
If CheckNumber(Time_Box.Value) Then Cells(Index, 6).Value = Time_Box.Value
If Not AdminMode Then SetRandomMark
If Oklad_Box = "" Or AboveOklad_Chk.Value = True Then
If CheckNumber(Rate_Box.Value) Then Cells(Index, 7).Value = Rate_Box.Value
Else
Cells(Index, 7).ClearContents
End If
If Rate_Box.Tag = "Time" Then Cells(Index, 8).Value = 1 Else Cells(Index, 8).Value = 0
Cells(Index, 2).Select
If (Cells(Index, 2).Value = "") Then Selection.EntireRow.Hidden = True Else Selection.EntireRow.Hidden = False
LogAction ("RecordLine " & CStr(1 + (Index - InfoOffset) \ Lines) & "(" & CStr(Index) & ");" & _
ID.Value & ";" & Amount_Box.Value & ";" & Time_Box.Value & ";" & AltDiam_Box.Value)
'AddAmount = Amount_Box.Value
'AddTime = Time_Box.Value
'If AddAmount = "" Then AddAmount = 0
'If AddTime = "" Then AddTime = 0
'If OldId = "" Then OldId = 0
'Sheets("Каталог").Select
'If (OldId <> 0) And (OldId <> 5) Then Cells(OldId, 11) = Cells(OldId, 11) - OldAmount
'Cells(JobPosition(OldId) + 287, 6) = Cells(JobPosition(OldId) + 287, 6) - OldTime
'End If
'If ID.Value <> 5 Then Cells(ID.Value, 11) = Cells(ID.Value, 11) + AddAmount
'Cells(JobPosition(ID.Value) + 287, 6) = Cells(JobPosition(ID.Value) + 287, 6) + AddTime
'Sheets(NameChooser.Value).Select
Application.Calculation = xlCalculationAutomatic
End If
If CommentTrigger And Comment_Box.Value <> "" Then
For i = Index - Job + 1 To Index - Job + Lines
If (Cells(i, 13).Value = "") Or (i = Index - Job + Lines) Then
Cells(i, 13).Value = Comment_Box.Value
LogAction ("NewComment " & CStr(Day) & ";" & Comment_Box.Value)
Exit For
End If
Next i
CommentTrigger = False
If Not AdminMode Then SetRandomMark
End If
If AdminMode Then
If CheckNumber(PrePay_Box.Value) And (CStr(Cells(Index - Job + 1, 11).Value) <> PrePay_Box.Value) Then
Cells(Index - Job + 1, 11).Value = PrePay_Box.Value
LogAction ("SetPrePay " & CStr(Day) & ";" & PrePay_Box.Value)
End If
If CheckNumber(Left_Box.Value) And (CStr(Cells(2, 10).Value) <> Left_Box.Value) Then
Cells(2, 10).Value = Left_Box.Value
LogAction ("SetLeft " & Left_Box.Value)
End If
If CheckNumber(Oklad_Box.Value) Then Cells(4, 2).Value = Oklad_Box.Value
If MakeReadOnly_Chk.Value = True Then Cells(3, 1).Value = "RO" Else Cells(3, 1).Value = ""
End If
Cells(Index - Job + 1, 2).Select
If (Cells(Index - Job + 1, 2).Value = "") And _
(Cells(Index - Job + 1, 11).Value = "") And _
(Cells(Index - Job + 1, 13).Value = "") Then _
Selection.EntireRow.Hidden = True _
Else Selection.EntireRow.Hidden = False
If CInt(Day) > CInt(Cells(1, 1).Value) Then Cells(1, 1).Value = Day
ReadLockedInfo
FillDayList (CDay_Box.Value)
MakeShitLookGood
If LMMode Then TransferBalance NameChooser.Value, Balance_Box.Value
DayTrigger = False
FillControlList
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/RecordLine()"
Exception.Show
End Sub
Sub DeleteLine(ByVal Day, ByVal Job)
On Error GoTo ExceptionControl:
If NameChooser.Value <> "" And CDay_Box.MatchFound Then Sheets(NameChooser.Value).Select Else Exit Sub
Index = Job + InfoOffset + Lines * (Day - 1) - 1
'OldAmount = Cells(index, 4)
'OldId = Cells(index, 3)
'OldTime = Cells(index, 6)
'Sheets("Каталог").Select
'If OldId > 5 Then Cells(OldId, 11) = Cells(OldId, 11) - OldAmount
'Sheets(NameChooser.Value).Select
Application.Calculation = xlCalculationManual
Range(Cells(Index, 2), Cells(Index, 9)).ClearContents
Range(Cells(Index, 14), Cells(Index, 15)).ClearContents
If AdminMode Then Cells(Index, 3) = 4
Cells(Index, 2).Select
If (Cells(Index, 2).Value = "") And _
(Cells(Index, 11).Value = "") And _
(Cells(Index, 13).Value = "") Then Selection.EntireRow.Hidden = True
ReadLockedInfo
JobName_Box.Value = ""
ID = ""
Time_Box.Value = ""
Amount_Box.Value = ""
Rate_Box.Value = ""
Rate_Box.Tag = ""
Unit.Caption = ""
LogAction ("DeleteLine " & CStr(Index))
Application.Calculation = xlCalculationAutomatic
MakeShitLookGood
If LMMode Then TransferBalance NameChooser.Value, Balance_Box.Value
FillDayList (CDay_Box.Value)
FillControlList
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/DeleteLine()"
Exception.Show
End Sub
Sub ClearDay(ByVal Day)
Dim Index, i As Integer
On Error GoTo ExceptionControl:
If NameChooser.Value <> "" And CDay_Box.MatchFound Then Sheets(NameChooser.Value).Select Else Exit Sub
Index = InfoOffset + Lines * (Day - 1)
If CInt(Cells(1, 1)) = Day Then Cells(1, 1).ClearContents
For i = 0 To Lines - 1
If (AdminMode) And (Cells(Index + i, 3) <> "") Then Cells(Index + i, 3) = 4
'OldAmount = Cells(index + i, 4)
'OldId = Cells(index + i, 3)
'OldTime = Cells(index + i, 6)
'If OldId > 5 Then
'Sheets("Каталог").Select
'Cells(OldId, 11) = Cells(OldId, 11) - OldAmount
'Sheets(NameChooser.Value).Select
'End If
Next
Application.Calculation = xlCalculationManual
If AdminMode Then
Range(Cells(Index, 2), Cells(Index + Lines - 1, 2)).ClearContents
Range(Cells(Index, 4), Cells(Index + Lines - 1, 9)).ClearContents
Else
Range(Cells(Index, 2), Cells(Index + Lines - 1, 9)).ClearContents
End If
Range(Cells(Index, 13), Cells(Index + Lines - 1, 15)).ClearContents
Cells(Index, 11) = ""
Cells(Index, 10) = ""
Range(Cells(Index, 2), Cells(Index + Lines - 1, 2)).EntireRow.Hidden = True
LogAction ("ClearDay " & CStr(Day))
Application.Calculation = xlCalculationAutomatic
ReadLockedInfo
JobName_Box.Value = ""
ID = ""
Time_Box.Value = ""
Amount_Box.Value = ""
Rate_Box.Value = ""
Unit.Caption = ""
MakeShitLookGood
If LMMode Then TransferBalance NameChooser.Value, Balance_Box.Value
FillDayList (CDay_Box.Value)
FillControlList
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/ClearDay()"
Exception.Show
End Sub
Sub ReadLine(ByVal Day, ByVal Job)
On Error GoTo ExceptionControl:
If Day = "" Or NameChooser.Value = "" Or Not CDay_Box.MatchFound Then Exit Sub
inRead = True
Index = Job + InfoOffset + Lines * (Day - 1) - 1
Sheets(NameChooser.Value).Select
If Cells(Index, 3) > 4 Then ID.Value = Cells(Index, 3) Else ID.Value = ""
JobName_Box.Value = Cells(Index, 2).Value
Rate_Box.Value = Cells(Index, 7).Value
Rate_Box.Tag = ""
Time_Box.Value = Cells(Index, 6).Value
Unit.Caption = Cells(Index, 5).Value
Amount_Box.Value = Cells(Index, 4).Value
AltDiam_Box.Value = Cells(Index, 14).Value
If Unit.Caption = "" Then Amount_Box.Enabled = False Else Amount_Box.Enabled = True
If Oklad_Box.Value <> "" And Rate_Box.Value <> "" Then AboveOklad_Chk.Value = True
If Oklad_Box.Value <> "" And Rate_Box.Value = "" Then AboveOklad_Chk.Value = False
If Amount_Box.Enabled = False Then Time_Box.SetFocus Else Amount_Box.SetFocus
If JobName_Box.Value = "" Then JobsTree.SetFocus
inRead = False
DayTrigger = False
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/ReadLine()"
Exception.Show
End Sub
Function LastFilled(ByVal Day) As Integer
On Error GoTo ExceptionControl:
Index = InfoOffset + Lines * (Day - 1)
LastFilled = 0
For i = 1 To Lines
If Cells(Index + i - 1, 2).Value <> "" Then LastFilled = i
Next
Exit Function
ExceptionControl:
Exception.Error_Box.Value = "Workers/LastFilled()"
Exception.Show
End Function
Private Sub AltDiam_Box_Change()
If AltDiam_Box.Value <> "" Then AltDiam_Box.Value = PointFilter(AltDiam_Box.Value, False, False, 4)
DayTrigger = True
End Sub
Private Sub Bonus_Button_Click()
On Error GoTo ExceptionControl:
ObjectsRecall
inRead = True
Sheets(NameChooser.Value).Select
Index = InfoOffset + Lines * (CDay_Box.Value - 1)
JobName_Box.Value = "Доплата " & CStr(BonusRate_Box.Value) & " %"
Amount_Box.Value = 1
Unit.Caption = " "
Rate_Box.Tag = "Amt"
Rate_Box.Value = Round(Cells(Index, 10).Value * BonusRate_Box.Value / 100, 2)
Time_Box.Value = ""
ID.Value = 5
If Apply_Button.Enabled = True Then Apply_Button.SetFocus
inRead = False
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/Bonus_Button_Click()"
Exception.Show
End Sub
Private Sub BonusRate_Box_Change()
If BonusRate_Box.Value <> "" Then BonusRate_Box.Value = PointFilter(BonusRate_Box.Value, False, False, 3)
End Sub
Private Sub CollapseJobs_Button_Click()
On Error GoTo ExceptionControl:
For i = 1 To JobsTree.Nodes.Count
JobsTree.Nodes(i).Expanded = False
Next
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/CollapseJobs_Button_Click()"
Exception.Show
End Sub
Private Sub Comment_Box_Change()
If Not inRead Then CommentTrigger = True
End Sub
Private Sub Comment_Box_DropButtonClick()
ObjectsRecall
End Sub
Private Sub ConfirmChoice_Button_Click()
Select Case ConfirmObject
Case 1
WorkersTree_DblClick
Case 2
ControlList_DblClick
Case 3
DayList_DblClick
Case 4
JobsTree_DblClick
End Select
ObjectsRecall
ConfirmObject = 0
End Sub
Private Sub ControlList_Click()
ControlList.Refresh
ObjectsRecall
ConfirmObject = 2
ConfirmChoice_Button.Top = 120
ConfirmChoice_Button.Left = 570
End Sub
Private Sub DayList_Click()
DayList.Refresh
ObjectsRecall
ConfirmObject = 3
End Sub
Private Sub Delete_Button_Click()
ObjectsRecall
DeleteLine CDay_Box.Value, CJob_Box.Value
End Sub
Private Sub JobsTree_Click()
ObjectsRecall
ConfirmObject = 4
End Sub
Private Sub LastMonth_Label_Click()
ObjectsRecall
End Sub
Private Sub Div_Button_Click()
On Error GoTo ExceptionControl:
ObjectsRecall
If Amount_Box.Value <> "" And Amount_Box.Value <> 0 And CheckNumber(Amount_Box.Value) Then Amount_Box.Value = Round(Amount_Box.Value / 2, 2)
If Apply_Button.Enabled = True Then Apply_Button.SetFocus
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/Div_Button_Click()"
Exception.Show
End Sub
Private Sub Log_Button_Click()
Dim i, Stopp, Count As Integer
On Error GoTo ExceptionControl:
ObjectsRecall
If LogHolder.Visible = True Then
LogHolder.Visible = False
Else
LogHolder.Top = -500
LogHolder.Left = 6
LogHolder.Visible = True
With Log
Count = 1
.ListItems.Clear
.Sorted = False
Stopp = CInt(Cells(InfoOffset - 1, 19).Value)
If CInt(Cells(InfoOffset - 1, 21).Value) > Stopp Then Stopp = CInt(Cells(InfoOffset - 1, 21).Value)
If Stopp = 0 Then Stopp = 600
For i = InfoOffset To InfoOffset + Stopp
If Cells(i, 19).Value = "" And Cells(i, 21).Value = "" Then
Exit For
End If
If Cells(i, 19).Value <> "" Then
.ListItems.Add = Cells(i, 19).Value
.ListItems.Item(Count).ListSubItems.Add = Cells(i, 20).Value
Count = Count + 1
End If
If Cells(i, 21).Value <> "" Then
.ListItems.Add = Cells(i, 21).Value
.ListItems.Item(Count).ListSubItems.Add = Cells(i, 22).Value
Count = Count + 1
End If
Next i
.Sorted = True
LogHolder.Top = 6
End With
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/Log_Button_Click()"
Exception.Show
End If
End Sub
Private Sub Select_Button_Click()
On Error GoTo ExceptionControl:
ObjectsRecall
If DayList.ListItems.Count > 0 Then
If DayList.SelectedItem.Text = "" Or DayList.SelectedItem.Text = " " Then Exit Sub
RecordLine CDay_Box.Value, CInt(DayList.SelectedItem.Text), True
FillDayList CDay_Box.Value
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/Select_Button_Click()"
Exception.Show
End Sub
Private Sub Triv_Button_Click()
On Error GoTo ExceptionControl:
ObjectsRecall
If Amount_Box.Value <> "" And Amount_Box.Value <> 0 And CheckNumber(Amount_Box.Value) Then Amount_Box.Value = Round(Amount_Box.Value / 3, 2)
If Apply_Button.Enabled = True Then Apply_Button.SetFocus
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/Triv_Button_Click()"
Exception.Show
End Sub
Private Sub SelectUpdatesOnly_Change()
ObjectsRecall
ScanWorkers
End Sub
Private Sub ControlList_DblClick()
On Error GoTo ExceptionControl:
If ControlList.ListItems.Count > 0 Then
If ControlList.SelectedItem.Text <> "" Then CDay_Box.Value = CInt(ControlList.SelectedItem.Text)
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/ControlList_DblClick()"
Exception.Show
End Sub
Private Sub DayList_DblClick()
On Error GoTo ExceptionControl:
Records = DayList.ListItems.Count
If Records > 0 Then
If DayList.SelectedItem.Text = "" Then Exit Sub
If (DayList.SelectedItem.Text = " ") Then
If (Records - 2) < Lines Then CJob_Box.Value = Records - 1
Else
CJob_Box.Value = CInt(DayList.SelectedItem.Text)
End If
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/DayList_DblClick()"
Exception.Show
End Sub
Sub FillDayList(ByVal Day)
Dim Index, i, Records As Integer
On Error GoTo ExceptionControl:
If NameChooser.Value <> "" Then Sheets(NameChooser.Value).Select Else Exit Sub
If Day = "" Then Exit Sub
DayList.ListItems.Clear
Comment_Box.Clear
Comment_Box.Value = ""
CommentTrigger = False
Index = InfoOffset + Lines * (Day - 1)
Records = LastFilled(Day)
PrePay_Box.Value = Cells(Index, 11).Value
If (Records > 0) Or (Cells(Index, 13).Value <> "") Then
TotalTime = 0
For i = 1 To Lines
Index = i + InfoOffset + Lines * (Day - 1) - 1
If i <= Records Then
JobName = Cells(Index, 2)
Amount = Cells(Index, 4)
UnitList = Cells(Index, 5)
TimeList = Cells(Index, 6)
TotalTime = TotalTime + TimeList
RateList = Cells(Index, 7)
Subtotal = Cells(Index, 9)
With DayList
.ListItems.Add = i
.ListItems.Item(i).ListSubItems.Add = JobName
.ListItems.Item(i).ListSubItems.Add = Amount
.ListItems.Item(i).ListSubItems.Add = UnitList
.ListItems.Item(i).ListSubItems.Add = TimeList
.ListItems.Item(i).ListSubItems.Add = RateList
.ListItems.Item(i).ListSubItems.Add = Subtotal
If Cells(Index, 15) = "1" Then
.ListItems.Item(i).ForeColor = &HC000&
For j = 1 To .ListItems.Item(i).ListSubItems.Count
.ListItems.Item(i).ListSubItems(j).ForeColor = &HC000&
Next j
End If
End With
End If
If Cells(Index, 13).Value <> "" Then Comment_Box.AddItem (Cells(Index, 13).Value)
Next i
With DayList
If .ListItems.Count > 0 Then
Index = InfoOffset + Lines * (Day - 1)
If .ListItems.Count < Lines Then
.ListItems.Add = .ListItems.Count + 1
If .ListItems.Count = CJob_Box.Value Then .ListItems.Item(CInt(CJob_Box.Value)).ForeColor = &HFF&
Else
.ListItems.Add = " "
End If
.ListItems.Add = " "
.ListItems.Item(.ListItems.Count).ListSubItems.Add = ""
.ListItems.Item(.ListItems.Count).ListSubItems.Add = ""
.ListItems.Item(.ListItems.Count).ListSubItems.Add = "ВСЕГО"
.ListItems.Item(.ListItems.Count).ListSubItems.Add = TotalTime
.ListItems.Item(.ListItems.Count).ListSubItems.Add = "ИТОГО"
.ListItems.Item(.ListItems.Count).ListSubItems.Add = Cells(Index, 10).Value
.Refresh
End If
End With
If Comment_Box.ListCount > 0 Then
Comment_Box.Value = Comment_Box.List(Comment_Box.ListCount - 1)
CommentTrigger = False
End If
End If
If Records < Lines Then CJob_Box.Value = Records + 1
If Records > Lines - 1 Then CJob_Box.Value = Lines
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/FillDayList()"
Exception.Show
End Sub
Private Sub AboveOklad_Chk_Change()
DayTrigger = True
End Sub
Private Sub Amount_Box_Change()
If Amount_Box.Value <> "" Then Amount_Box.Value = PointFilter(Amount_Box.Value)
DayTrigger = True
End Sub
Private Sub ChooseWorker_Click()
On Error GoTo ExceptionControl:
ObjectsRecall
WorkersTreeHolder.Top = 6
WorkersTreeHolder.Left = 320
'For i = 1 To CInt(WorkersTree.Tag)
' If WorkersTree.Nodes(i).Tag = "Cat" Then _
' WorkersTree.Nodes(i).Expanded = False
' Next
'WorkersTree.Visible = True
DateAndWorker_Frame.Visible = False
WorkersTreeHolder.Visible = True
ConfirmObject = 1
ConfirmChoice_Button.Top = 46
ConfirmChoice_Button.Left = 270
If ChosenMate <> 0 Then
WorkersTree.Nodes(ChosenMate).Selected = True
ChosenMate = 0
End If
WorkersTree.SetFocus
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/ChooseWorker_Click()"
Exception.Show
End Sub
Private Sub ChooseMate_Button_Click()
On Error Resume Next
ObjectsRecall
WorkersTreeHolder.Top = 255
WorkersTreeHolder.Left = 290
ConfirmObject = 1
ConfirmChoice_Button.Top = 310
ConfirmChoice_Button.Left = 240
'For i = 1 To CInt(WorkersTree.Tag)
' If WorkersTree.Nodes(i).Tag = "Cat" Then _
' WorkersTree.Nodes(i).Expanded = False
' Next
'WorkersTree.Visible = True
WorkersTreeHolder.Visible = True
ChosenMate = WorkersTree.SelectedItem.Index
If ChosenMate = 0 Then ChosenMate = 1
DayList.Visible = False
WorkersTree.SetFocus
End Sub
Private Sub Frame2_Click()
ObjectsRecall
End Sub
Private Sub Frame3_Click()
ObjectsRecall
End Sub
Private Sub Frame4_Click()
ObjectsRecall
End Sub
Private Sub Frame6_Click()
ObjectsRecall
End Sub
Private Sub DateAndWorker_Frame_Click()
ObjectsRecall
End Sub
Private Sub JobName_Box_Change()
On Error GoTo ExceptionControl:
If (Left(Right(JobName_Box.Value, 4), 1) = "х") Or _
(Left(Right(JobName_Box.Value, 4), 1) = "x") Or _
(Left(Right(JobName_Box.Value, 5), 1) = "х") Or _
(Left(Right(JobName_Box.Value, 5), 1) = "x") Then
AltDiam_Box.Visible = True
AltDiam_Label.Visible = True
Else
AltDiam_Box.Visible = False
AltDiam_Box.Value = ""
AltDiam_Label.Visible = False
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/JobName_Box_Change()"
Exception.Show
End Sub
Private Sub JobsTree_DblClick()
If JobsTree.SelectedItem.Key <> "" Then
ID.Value = CutZ(JobsTree.SelectedItem.Key)
End If
End Sub
Private Sub Left_Box_Change()
If Left_Box.Value <> "" Then Left_Box.Value = PointFilter(Left_Box.Value)
End Sub
Private Sub MateChooser_Change()
If MateChooser.Value = "" Then CopyDay_Button.Enabled = False Else CopyDay_Button.Enabled = True
End Sub
Private Sub Oklad_Box_Change()
If Oklad_Box.Value <> "" Then Oklad_Box.Value = PointFilter(Oklad_Box.Value, False, False)
End Sub
Private Sub PrePay_Box_Change()
If PrePay_Box.Value <> "" Then PrePay_Box.Value = PointFilter(PrePay_Box.Value, False)
End Sub
Function isVisible(ByVal Day As Integer) As Boolean
On Error GoTo ExceptionControl:
isVisible = False
Index = InfoOffset + Lines * Day
If Cells(Index, 10) <> 0 Then
isVisible = True
Exit Function
End If
If Cells(Index, 11) > 0 Then
isVisible = True
Exit Function
End If
If Cells(Index, 13) <> "" Then
isVisible = True
Exit Function
End If
Exit Function
ExceptionControl:
Exception.Error_Box.Value = "Workers/isVisible()"
Exception.Show
End Function
Sub Mark(ByVal Day As Integer, ByVal PrevMarked As Boolean)
On Error GoTo ExceptionControl:
If PrevMarked Then Colorr = 2 Else Colorr = 15
Index = InfoOffset + Lines * Day
Range(Cells(Index, 1), Cells(Index + Lines - 1, 12)).Select
With Selection.Interior
.ColorIndex = Colorr
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/Mark()"
Exception.Show
End Sub
Sub MakeShitLookGood()
On Error GoTo ExceptionControl:
Last = Cells(1, 1).Value
PrevMarked = True
If Last = "" Then Last = MDays(CMonth)
For i = 0 To CInt(Last)
If isVisible(i) = True Then
PrevMarked = Not PrevMarked
Mark i, PrevMarked
End If
Next
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/MakeShitLookGood()"
Exception.Show
End Sub
Private Sub Print_Button_Click()
On Error Resume Next
ObjectsRecall
If NameChooser.Value <> "" Then
Count = 0
Sheets(NameChooser.Value).Select
MakeShitLookGood
If OnScreen_Chk.Value = True Then Sheets(NameChooser.Value).PrintOut
If OnScreen_Chk.Value = False Then
WorkersExit = True
Application.ScreenUpdating = True
Workers.Hide
Main.Hide
Cells(3, 1).Select
End If
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/Print_Button_Click()"
Exception.Show
End Sub
Private Sub Rate_Box_Change()
If Rate_Box.Value <> "" Then Rate_Box.Value = PointFilter(Rate_Box.Value)
DayTrigger = True
End Sub
Private Sub Time_Box_Change()
If Time_Box.Value <> "" Then Time_Box.Value = PointFilter(Time_Box.Value, False)
DayTrigger = True
End Sub
Private Sub Apply_Button_Click()
ObjectsRecall
RecordLine CDay_Box.Value, CJob_Box.Value
End Sub
Private Sub CDay_Box_Change()
On Error GoTo ExceptionControl:
If (NameChooser.Value <> "") And (Not ExtChange) And CDay_Box.MatchFound Then
ObjectsRecall
FillDayList (CDay_Box.Value)
ReadLine Workers.CDay_Box.Value, Workers.CJob_Box.Value
Label_FullDate.Caption = GetDayName(Workers.CDay_Box.Value) & ", " & Workers.CDay_Box.Value & " " & MName(CMonth, True)
Workers.Caption = Workers.RealName_Box.Value & ": " & Workers.Label_FullDate.Caption
MarkListLine ControlList, CDay_Box.Value
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Workers/CDay_Box_Change()"
Exception.Show
End Sub
Private Sub CJob_Box_Change()
ReadLine CDay_Box.Value, CJob_Box.Value
MarkListLine DayList, CJob_Box.Value
End Sub
Private Sub MarkListLine(ByRef List As ListView4, ByVal Line As Integer)
Dim i, j As Integer
On Error GoTo ExceptionControl:
With List
For i = 1 To .ListItems.Count
If .ListItems.Item(i).Text <> " " Then
OldColor = .ListItems.Item(i).ForeColor
If CInt(.ListItems.Item(i).Text) = Line Then
If OldColor = &H0& Then NewColor = &HFF& Else NewColor = &H80&
.ListItems.Item(i).ForeColor = NewColor
For j = 1 To .ListItems.Item(i).ListSubItems.Count
.ListItems.Item(i).ListSubItems(j).ForeColor = NewColor
Next j
Else
NewColor = OldColor
If OldColor = &HFF& Then
NewColor = &H0&
Else
If OldColor = &H80& Then NewColor = &HC000&
End If
If NewColor <> OldColor Then
.ListItems.Item(i).ForeColor = NewColor