-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.frm
440 lines (376 loc) · 12.7 KB
/
Main.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
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Main
ClientHeight = 11025
ClientLeft = 6045
ClientTop = 6330
ClientWidth = 15270
OleObjectBlob = "Main.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "Main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Leftt, Income, Outcome, Balance, LastName, Namess As String
Function SetCaption(Fil, Side)
''Protect
If Side = 1 Then
End If
''unprotect
If Side = -1 Then
End If
End Function
Private Sub Block_Button_Click()
BlockIt.Show
End Sub
Private Sub GenerateNextMonth_Click()
On Error GoTo ExceptionControl:
If DateTime.Month(DateTime.Date) <> NMonth Then
b = MsgBox(NextMonth & " ещё не наступил (или уже прошёл :-D)", vbOKOnly, "Внимание")
Exit Sub
End If
Query.NoButton.SetFocus
Query.Msg_label.Caption = "После перехода на новый месяц будет невозможно " & SwitchToLastMonth.Caption & ". Продолжаем?"
Query.Show
If Query.OK.Value = True Then
ProcessFile WorkersBase, "SaveClose"
ArcMonth = CMonth - 1
ArcYear = CYear
If ArcMonth = 0 Then
ArcMonth = 12
ArcYear = CYear - 1
End If
ArcName = Path + "Archive\Valid\" & MNameEng(ArcMonth) & "_" & ArcYear
ArcFiles = Path + "lWorkers.xls"
RunCommand (Archiver & " a " & ArcKey & " " & ArcName & " " & ArcFiles)
Destination = Path & "lWorkers.xls"
Source = Path & WorkersBase
FileCopy Source, Destination
Workbooks.Open FileName:=Path + WorkersBase
Windows(WorkersBase).Activate
Sheets("Каталог").Select
CYear = Cells(1, 3).Value
CMonth = Cells(2, 3).Value
Cells(2, 3).Value = Cells(2, 3).Value + 1
If CMonth = 12 Then
Cells(2, 3).Value = 1
Cells(1, 3).Value = Cells(1, 3).Value + 1
End If
CYear = Cells(1, 3).Value
CMonth = Cells(2, 3).Value
Cells(2, 2).Value = MName(CMonth)
Cells(1, 6).Value = Cells(2, 6).Value
Cells(2, 6).Value = ""
For i = FirstWorkersSheet To ActiveWorkbook.Sheets.Count
Sheets(i).Select
Cells(2, 10).Value = Cells(1, 10).Value
Cells(1, 1).ClearContents
Range("b6:k284").ClearContents
Range(Columns(13), Columns(22)).ClearContents
Range(Rows(6), Rows(284)).EntireRow.Hidden = True
Next
ReportExit = True
MainInit
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Form/GenerateNextMonth_Click()"
Exception.Show
End Sub
Sub DropSensitiveData()
On Error GoTo ExceptionControl:
Sheets("АвансовыйОтчёт").Select
Range(Rows(7), Rows(1000)).ClearContents
Sheets("Производство").Select
Range(Rows(7), Rows(1000)).ClearContents
Sheets("Отчёт").Select
Range(Rows(7), Rows(1000)).ClearContents
Sheets("Каталог").Select
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Form/DropSensitiveData()"
Exception.Show
End Sub
Sub DoneForNow(ByVal CloseBase As Boolean)
On Error GoTo ExceptionControl:
If AdminMode Then
Windows(WorkersBase).Activate
DropSensitiveData
ProcessFile WorkersBase, "SaveClose"
PushBase = "push.xls"
Destination = Path & PushBase
Source = Path & WorkersBase
FileCopy Source, Destination
ArcName = Path & "push.7z"
Kill (ArcName)
ArcFiles = Path & PushBase & " " & Path & "index-c.xls"
RunCommand (Archiver & " a " & ExchangeKey & " " & ArcName & " " & ArcFiles)
RunCommand (Archiver & " rn " & ExchangeKey & " " & ArcName & " index-c.xls index.xls")
Kill (Path & PushBase)
If CloseBase Then
ArcName = Path + "Archive\LastState.7z"
ArcFiles = Path + "*Workers.xls"
RunCommand (Archiver & " a " & ArcKey & " " & ArcName & " " & ArcFiles)
RunCommand "ftp -v -s:" & Path & "ftp_server_send_all " & FtpStorageName, False
Else
RunCommand "ftp -v -s:" & Path & "ftp_server_send " & FtpStorageName, False
End If
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Form/DoneForNow()"
Exception.Show
End Sub
Private Sub Reports_Button_Click()
With Reports
.CDay_Box.Clear
For i = 1 To MDays(CMonth)
.CDay_Box.AddItem (i)
Next
.CDay_Box.Value = 1
.Mark_Chooser.Clear
.Mark_Chooser.AddItem ("Все")
.Mark_Chooser.AddItem ("Выделенные")
.Mark_Chooser.AddItem ("Без выделения")
.Mark_Chooser.Value = "Без выделения"
.Show
End With
End Sub
Private Sub RunTC_Button_Click()
BlockIt.Pass = PinAdmin
BlockIt.PassOK = False
BlockIt.AdminOverrides = False
BlockIt.SupervisorOverrides = False
BlockIt.Password_Box.SetFocus
BlockIt.Show
If BlockIt.PassOK Then a = Shell("c:\Program Files\WINCMD\totalcmd.exe", vbMaximizedFocus)
End Sub
Private Sub SaveAndClose_Click()
On Error GoTo ExceptionControl:
DoneForNow (True)
Windows("Index.xls").Close (SaveChanges = xlDoNotSaveChanges)
Main.Hide
Application.Quit
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Form/SaveAndClose_Click()"
Exception.Show
End Sub
Private Sub SaveState_Click()
DoneForNow (False)
MainInit
End Sub
Private Sub SwitchToLastMonth_Click()
On Error Resume Next
If LMMode Then
LastWorkersDay = 0
If AdminMode Then
Windows(WorkersBase).Activate
DropSensitiveData
ProcessFile "lWorkers.xls", "SaveClose"
ArcName = Path & "lm.7z"
ArcFiles = Path & "lWorkers.xls"
RunCommand (Archiver & " a " & ExchangeKey & " " & ArcName & " " & ArcFiles)
Else
Windows(WorkersBase).Activate
ActiveWorkbook.Close SaveChanges:=False
Kill (Path & WorkersBase)
End If
Else
LastWorkersDay = 31
If Not AdminMode Then
ArcFiles = "lWorkers.xls"
ArcName = Path & "lm.7z"
RunCommand ("ftp -v -s:" & Path & "ftp_client_get_lm " & FtpStorageName)
RunCommand (Archiver & " e -y " & ExchangeKey & " " & ArcName & " -o" & Path & " " & ArcFiles)
Kill (ArcName)
End If
Workbooks.Open FileName:=Path & "lWorkers.xls"
End If
ReportExit = True
MainInit
End Sub
Private Sub InitWorkers()
On Error GoTo ExceptionControl:
Main.Top = 0
Main.Left = 0
Windows(WorkersBase).Activate
With Workers
ExtChange = True
.CDay_Box.Clear
For i = 1 To MDays(CMonth)
.CDay_Box.AddItem (i)
Next
If LastWorkersDay <> 0 Then
.CDay_Box.Value = LastWorkersDay
Else
.CDay_Box.Value = DateTime.Day(DateTime.Date)
End If
If .CDay_Box.Value > MDays(CMonth) Then .CDay_Box.Value = MDays(CMonth)
ExtChange = False
.Label_FullDate.Caption = GetDayName(.CDay_Box.Value) & ", " & .CDay_Box.Value & " " & MName(CMonth, True)
.IncomeLabel.Caption = "Заработано за " & MName(CMonth)
.OutComeLabel.Caption = "Выдано за " & MName(CMonth)
.LeftLabel.Caption = "Остаток за " & MName(LMonth)
.ScanWorkers
.ScanJobs
If LMMode Then
.LastMonth_Label.Visible = True
.MakeReadOnly_Chk.Visible = False
Else
.LastMonth_Label.Visible = False
.MakeReadOnly_Chk.Visible = True
End If
End With
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Form/InitWorkers()"
Exception.Show
End Sub
Private Sub Workers_Button_Click()
On Error GoTo ExceptionControl:
MainReInit
If AdminMode Then
ArcFiles = "pull.xls"
RunCommand ("ftp -v -s:" & Path & "ftp_server_get " & FtpStorageName)
ArcName = Path + "pull.7z"
RunCommand (Archiver & " e -y " & ExchangeKey & " " & ArcName & " -o" & Path & " " & ArcFiles)
PullOnServer
InitWorkers
With Workers
.WorkersTreeHolder.Visible = True
.RealName_Box.Value = ""
.NameChooser.Value = ""
.RealName_Box.Value = .WorkersTree.Nodes(CInt(.WorkersTree.Tag) + 1).Text
.NameChooser.Value = .WorkersTree.Nodes(CInt(.WorkersTree.Tag) + 1).Key
.WorkersTree.Nodes(CInt(.WorkersTree.Tag) + 1).Selected = True
.WorkersTreeHolder.Visible = False
.Show
End With
Else
If Not LMMode Then
Windows(WorkersBase).Activate
Sheets("Каталог").Select
ReferenceTokens = Cells(2, 6).Value
ArcFiles = "push.xls index.xls"
ArcName = Path & "push.7z"
RunCommand ("ftp -v -s:" & Path & "ftp_client_get " & FtpStorageName)
RunCommand (Archiver & " e -y " & ExchangeKey & " " & ArcName & " -o" & Path & " " & ArcFiles)
PushBase = "push.xls"
Destination = Path & "tWorkers.xls"
Source = Path & PushBase
If Not IsOpened("push.xls") Then Workbooks.Open FileName:=Path + PushBase
Windows(PushBase).Activate
Sheets("Каталог").Select
If (Cells(1, 6).Value = ReferenceTokens) Or (Cells(2, 6).Value = ReferenceTokens) Then
ActiveWorkbook.Close SaveChanges:=False
Windows(WorkersBase).Activate
ActiveWorkbook.Close SaveChanges:=False
FileCopy Source, Destination
MainReInit
Else
ActiveWorkbook.Close
Windows(WorkersBase).Activate
End If
End If
InitWorkers
With Workers
.MakeReadOnly_Chk.Visible = False
If LMMode Then
.Apply_Button.Enabled = False
.Clear_Button.Enabled = False
.Delete_Button.Enabled = False
.ChooseMate_Button.Enabled = False
.Select_Button.Enabled = False
End If
.Show
End With
End If
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Form/Workers_Button_Click()"
Exception.Show
End Sub
Private Sub Setup_Button_Click()
On Error GoTo ExceptionControl:
With Setup
.ScanWorkers (WorkersBase)
.ScanWCats
.ScanJobs
.ScanOrgs
.ScanJCats
.ScanOCats
.NameChooser.Value = .WorkersTree.Nodes(CInt(.WorkersTree.Tag) + 1).Key
.jID.Value = CutZ(.JobsTree.Nodes(CInt(.JobsTree.Tag) + 1).Key)
.oID.Value = CutZ(.OrgsTree.Nodes(CInt(.OrgsTree.Tag) + 1).Key)
.cCatChooser.Value = .cCatChooser.List(1)
.jCatChooser.Value = .jCatChooser.List(1)
.oCatChooser.Value = .oCatChooser.List(1)
.Show
End With
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Form/Setup_Button_Click()"
Exception.Show
End Sub
Private Sub Chamber_Button_Click()
On Error GoTo ExceptionControl:
FiltersReady = 0
With Orders
.CDay_Box.Clear
.Day_Filter.Clear
.Day_Filter.AddItem ("Все")
For i = 1 To MDays(CMonth)
.CDay_Box.AddItem (i)
.Day_Filter.AddItem (i)
Next
.CDay_Box.Value = DateTime.Day(DateTime.Date)
.Day_Filter.Value = "Все"
.Dol_Chooser.Clear
.Dol_Chooser.AddItem ("Все")
.Dol_Chooser.AddItem ("Долги")
.Dol_Chooser.Value = "Долги"
.Opl_Chooser.Clear
.Opl_Chooser.AddItem ("Все")
.Opl_Chooser.AddItem ("нал")
.Opl_Chooser.AddItem ("б/н")
.Opl_Chooser.Value = "б/н"
.Opl_Chooser_w.Clear
.Opl_Chooser_w.AddItem ("нал")
.Opl_Chooser_w.AddItem ("б/н")
.Opl_Chooser_w.Value = "б/н"
.RoundType.Clear
.RoundType.AddItem ("в большую сторону")
.RoundType.AddItem ("в меньшую сторону")
.RoundType.Value = "в большую сторону"
.Label_FullDate.Caption = GetDayName(.CDay_Box.Value) & ", " & .CDay_Box.Value & " " & MName(CMonth, True)
.ScanOrgs (WorkersBase)
.ScanJobs
.ScanOCats
FiltersReady = 1
.Region_Filter.Value = "Все"
.OrgName_Box.Value = .OrgsTree.Nodes(CInt(.OrgsTree.Tag) + 1).Text
.oID.Value = CutZ(.OrgsTree.Nodes(CInt(.OrgsTree.Tag) + 1).Key)
.OrgsTreeHolder.Visible = True
.OrgsTree.Nodes(CInt(Orders.OrgsTree.Tag) + 1).Selected = True
.oCat.Value = CutZ(Orders.OrgsTree.SelectedItem.Parent.Key)
.OrgsTreeHolder.Visible = False
'If LastPerson <> "" Then Workers.NameChooser.Value = LastPerson Else _
' Workers.NameChooser.Value = Workers.NameChooser.List(0)
.Show
End With
Exit Sub
ExceptionControl:
Exception.Error_Box.Value = "Form/Chamber_Button_Click()"
Exception.Show
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
BlockIt.Pass = PinAdmin
BlockIt.AdminOverrides = False
BlockIt.SupervisorOverrides = False
BlockIt.PassOK = False
BlockIt.Password_Box.SetFocus
BlockIt.Show
If BlockIt.PassOK = False And CloseMode = 0 Then Cancel = 1
End Sub