-
Notifications
You must be signed in to change notification settings - Fork 0
/
ENERGY.PRG
364 lines (351 loc) · 14.3 KB
/
ENERGY.PRG
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
FUNCTION Energy
Local Dbf:={}
Private MonthIn:=Month_Menu("¤«ï ¢ë¡®à ¬¥áïæ ¯à¨¥¬ í¥à£¨¨")
IF MonthIn==0
Return NIL
ENDIF
IF .not.File(Schet_Share+"NameIn.Dbf")
AADD(DBF,{"Number","N",3,0})
AADD(DBF,{"Name","C",30,0})
DbCreate(Schet_Share+"NameIn.Dbf",DBF)
DeleteFile(Schet_Share+"NameIn.Ntx")
ENDIF
IF .not.File(Schet_Share+"CountIn.Dbf")
Dbf:={}
AADD(DBF,{"Number","N",3, 0})
AADD(DBF,{"Name","C", 10,0})
AADD(DBF,{"Znak","N", 1,0})
AADD(DBF,{"Koeff","N", 5, 0})
AADD(DBF,{"Pok1","N", 10, 2})
AADD(DBF,{"Pok2","N", 10, 2})
AADD(DBF,{"Pok3","N", 10, 2})
AADD(DBF,{"Pok4","N", 10, 2})
AADD(DBF,{"Pok5","N", 10, 2})
AADD(DBF,{"Pok6","N", 10, 2})
AADD(DBF,{"Pok7","N", 10, 2})
AADD(DBF,{"Pok8","N", 10, 2})
AADD(DBF,{"Pok9","N", 10, 2})
AADD(DBF,{"Pok10","N", 10, 2})
AADD(DBF,{"Pok11","N", 10, 2})
AADD(DBF,{"Pok12","N", 10, 2})
AADD(DBF,{"Reaktivn", "L", 1, 0})
DbCreate(Schet_Share+"CountIn.Dbf",DBF)
DeleteFile(Schet_Share+"CountIn.Ntx")
ENDIF
Close All
IF .not.File(Schet_Share+"NameIn.Ntx")
make_ind('0',schet_share+'NameIn.Dbf',schet_share+'NameIn.ntx','Number',,,.t.,.f.)
ENDIF
IF .not.File(Schet_Share+"CountIn.Ntx")
make_ind('0',schet_share+'CountIn.Dbf',schet_share+'CountIn.ntx','Number',,,.t.,.f.)
ENDIF
Close All
LoadGos()
/*
Select 40
IF NetUse(Schet_Share+"NameIn.Dbf")
Set Index To (Schet_Share+"NameIn.Ntx")
Select 41
IF NetUse(Schet_Share+"CountIn.Dbf")
Set Index To (Schet_Share+"CountIn.Ntx")
ELSE
Close All
Return NIL
ENDIF
ELSE
Close All
Return NIL
ENDIF
*/
InEnergy()
Commit
Close All
Return NIL
*******************************
STATIC Function InEnergy
PRIVATE recbuf,ordbuf,buff,colorbuf,nm1,nm2,nm3,nm4,t1,l1,b1,r1,inp
recbuf=recno()
ordbuf=indexord()
buff=win_save(1,0,maxrow(),maxcol())
colorbuf=setcolor()
if urov<1
if (.not. file(Schet_Share+"NameIn.Dbf")) .or. (.not. file(Schet_Share+"NameIn.Ntx"))
sign(2)
set color to (colorbuf)
win_rest(buff)
return NIL
else
select 40
if empty(fieldname(1))
wosst=.T.
al_box({" § ¤ ëå ¥ ®¯à¥¤¥«¥ "})
return NIL
endif
endif
endif
devout("")
set color to n/w
@ 6, 0 clear to maxrow()-1,maxcol()
set color to n/w
@ 6, 14 say ' ˆ … Œ ‹ … Š ’ Ž … ƒ ˆ ˆ ‡ € '+MYUpper(Mesqc(MonthIn))
declare zgl[3]
declare fil[3]
nm1=loarr('zgl','N ¯/¯',' ¨¬¥®¢ ¨¥',"ਬ¥ç ¨¥")
nm2=loarr('fil','Number','Name',"Text")
inp='1000000000'
go top
t1=7
l1=1
b1=maxrow()-1
r1=maxcol()
*********
fsbrowse(7,1,23,78,'fil','zgl',inp,urov,kl)
devout("")
set color to (colorbuf)
set order to ordbuf
go recbuf
win_rest(buff)
return NIL
*********************************
*******************************
Function CountEnergy()
LOCAL MonthName:="Pok",PrevMonthName
LOCAL recbuf,ordbuf,buff,colorbuf,nm1,nm2,nm3,nm4,t1,l1,b1,r1,inp,Sel:=Select()
recbuf=recno()
ordbuf=indexord()
buff=win_save(1,0,maxrow(),maxcol())
colorbuf=setcolor()
if urov<1
if (.not. file(Schet_Share+"CountIn.Dbf")) .or. (.not. file(Schet_Share+"CountIn.Ntx"))
sign(2)
set color to (colorbuf)
win_rest(buff)
return NIL
else
select 41
if empty(fieldname(1))
wosst=.T.
al_box({" § ¤ ëå ¥ ®¯à¥¤¥«¥ "})
return NIL
endif
endif
endif
devout("")
set color to n/w
@ 6, 0 clear to maxrow()-1,maxcol()
set color to n/w
@ 6, 14 say ' “ç¥â ¯à¨¥¬ í«¥ªâà®í¥à£¨¨ ¯® '+Alltrim(NameIn->Name)+" § "+Mesqc(MonthIn)
declare zgl[6]
declare fil[6]
PrevMonthName:=MonthName+Alltrim(Str(IF(MonthIn-1>0,MonthIn-1,12)))
MonthName:=MonthName+Alltrim(Str(MonthIn))
nm1=loarr('zgl','N áç¥â稪 ',"‡ ç.","Š®íä.",Mesqc(MonthIn),Mesqc(if(MonthIn-1>0,MonthIn-1,12)),"ਬ¥ç ¨¥")
nm2=loarr('fil','Name',"Znak",'Koeff',MonthName,PrevMonthName,"Text")
inp='00000'
Set Filter To Number==NameIn->Number
go top
t1=7
l1=1
b1=maxrow()-1
r1=maxcol()
*********
fsbrowse(7,1,23,78,'fil','zgl',inp,urov,kl)
Set Filter To
go top
devout("")
Select(Sel)
set color to (colorbuf)
set order to ordbuf
go recbuf
win_rest(buff)
return NIL
*********************************
function EnergyMenu()
LOCAL old_col1:=setcolor(),screen:=win_save(6,28,24,79),fi:='',wid:=1,widsav:=1
LOCAL temptime:={},timecreate:={},spisok,pos:=1
local first:=.T.
spisok:={" ”®à¬¨à®¢ ¨¥ áç¥â ",;
" ãá⮣à äª ",;
" ‘¬¥ à ¡®ç¥£® ¬¥áïæ ",;
" à®á¬®âà ®âç¥â ",;
"ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ",;
" ¥ç âì ®âç¥â "}
do while pos>0
if file(Ddir+'otchet.gkv')
is_choice:={.t.,.t.,.t.,.t.,.F.,.t.}
else
is_choice:={.t.,.t.,.t.,.t.,.F.,.F.}
endif
choice=vert_menu(spisok,"‚ è¥ ¤¥©á⢨¥",is_choice,12,28,pos,'n/w,n/g,,,r/w',.F.)
pos=choice
wid=choice
widsav:=wid
if wid<8.and.wid>0
pos=choice
else
pos=len(spisok)
endif
do case
case wid=1
PrintEnergy()
case wid=2
PrintBlankEnergy()
case wid=3
Month_In:=Month_Menu("¤«ï ¢ë¡®à ¬¥áïæ ¯à¨¥¬ í¥à£¨¨")
IF Month_In!=0
MonthIn:=Month_In
Al_Box({"Œ¥áïæ ¨§¬¥¥ "+Mesqc(MonthIn)})
ELSE
Al_Box({"Œ¥áïæ ¥ ¨§¬¥¥"})
ENDIF
case wid=4
TxtView(DDir+ReportFile)
case wid=len(spisok)
do print_fi
otherwise
exit
endcase
wid=if(file(Ddir+'otchet.gkv'),Len(Spisok),widsav)
enddo
M->prev_rec=-1
win_rest(screen)
set color to n/w
@ 6, 14 say ' ˆ … Œ ‹ … Š ’ Ž … ƒ ˆ ˆ ‡ € '+MYUpper(Mesqc(MonthIn))
setcolor(old_col1)
return NIL
Function PrintEnergy()
LOCAL Desc:=Fcreate(DDir+ReportFile),Win:=Win_Save(),Rec:=Recno(),Kol_Kl:=0
Local CrLf:=Chr(13)+Chr(10),Act:=0,React:=0,LenString
SELECT 41; GO Top
Obrabot("”®à¬¨à®¢ ¨¥ áç¥â ")
PredPok:="CountIn->Pok"+Alltrim(Str(IF(MonthIn>2,MonthIn-1,12)))
TekPok:= "CountIn->Pok"+Alltrim(Str(MonthIn))
FWrite(Desc,"Ú"+Replicate("Ä",Len(Str(NameIn->Number)))+"Â"+Replicate("Ä",Len(CountIn->Name))+"Â"+Replicate("Ä",Len(Str(CountIn->Znak)))+"Â"+Replicate("Ä",Len(Str(&PredPok)))+"Â"+;
Replicate("Ä",Len(Str(&TekPok)))+"Â"+Replicate("Ä",Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"Â"+;
Replicate("Ä",Len(Str(CountIn->Koeff)))+"Â"+Replicate("Ä",Len(Str(CountIn->Koeff*CalculateEnergy(&TekPok,&PredPok))))+"¿"+CrLf)
FWrite(Desc,"³"+Center("N",Len(Str(NameIn->Number))," ",.t.)+"³"+Center(" ¨¬¥.",Len(CountIn->Name)," ",.t.)+"³"+Replicate("f",Len(Str(CountIn->Znak)))+"³"+Center("।.¯®ª",Len(Str(&PredPok))," ",.t.)+"³"+;
Center("’¥ª.¯®ª",Len(Str(&TekPok))," ",.t.)+"³"+Center(" §®áâì",Len(Str(CalculateEnergy(&TekPok,&PredPok)))," ",.t.)+"³"+;
Center("Š®íä.",Len(Str(CountIn->Koeff))," ",.T.)+"³"+Center(" á室",Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok)))," ",.t.)+"³"+CrLf)
FWrite(Desc,"Ã"+Replicate("Ä",Len(Str(NameIn->Number)))+"Å"+Replicate("Ä",Len(CountIn->Name))+"Å"+Replicate("Ä",Len(Str(CountIn->Znak)))+"Å"+Replicate("Ä",Len(Str(&PredPok)))+"Å"+;
Replicate("Ä",Len(Str(&TekPok)))+"Å"+Replicate("Ä",Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"Å"+;
Replicate("Ä",Len(Str(CountIn->Koeff)))+"Å"+Replicate("Ä",Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok))))+"´"+CrLf)
LenString:=Len("Ã"+Replicate("Ä",Len(Str(NameIn->Number)))+"Å"+Replicate("Ä",Len(CountIn->Name))+"Å"+Replicate("Ä",Len(Str(CountIn->Znak)))+"Å"+Replicate("Ä",Len(Str(&PredPok)))+"Å"+;
Replicate("Ä",Len(Str(&TekPok)))+"Å"+Replicate("Ä",Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"Å"+;
Replicate("Ä",Len(Str(CountIn->Koeff)))+"Å"+Replicate("Ä",Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok))))+"´"+CrLf)-2
Select 40; Go Top
Do While .not.Eof()
kol_kl=kol_kl+39/Reccount()
colorwin(12,21,12,21+kol_kl,'n/n')
FWrite(Desc,"³"+Str(Number)+"³"+Name+Space(LenString-1-Len("³"+Str(Number)+"³"+Name))+"³"+CrLf)
Select 41
Seek NameIn->Number
IF Found()
Do While Number==NameIn->Number
PredPok:="Pok"+Alltrim(Str(IF(MonthIn>1,MonthIn-1,12)))
TekPok:="Pok"+Alltrim(Str(MonthIn))
IF Val(Name)!=0
IF .not.Empty(Koeff*CalculateEnergy(&TekPok,&PredPok))
FWrite(Desc,"³"+Space(Len(Str(NameIn->Number)))+"³"+Name+"³"+Str(Znak)+"³"+Str(&PredPok)+"³"+;
Str(&TekPok)+"³"+Str(CalculateEnergy(&TekPok,&PredPok))+"³"+;
Str(Koeff)+"³"+Str(Koeff*CalculateEnergy(&TekPok,&PredPok))+"³"+CrLf)
If Reaktivn
React:=React+Koeff*CalculateEnergy(&TekPok,&PredPok)
Else
Act:=Act+Koeff*CalculateEnergy(&TekPok,&PredPok)
Endif
ENDIF
ELSE
IF .not.Empty(Koeff*&TekPok)
FWrite(Desc,"³"+Space(Len(Str(NameIn->Number)))+"³"+Name+"³"+Str(Znak)+"³"+Space(Len(Str(&PredPok)))+"³"+;
Str(&TekPok)+"³ "+Str(&TekPok)+"³"+;
Str(Koeff)+"³"+Str(Koeff*&TekPok)+"³"+CrLf)
If Reaktivn
React:=React+Koeff*&TekPok
Else
Act:=Act+Koeff*&TekPok
Endif
ENDIF
ENDIF
Skip
EndDo
EndIF
Select 40
Skip
EndDo
SELECT 41; GO Top
FWrite(Desc,"À"+Replicate("Ä",Len(Str(NameIn->Number)))+"Á"+Replicate("Ä",Len(CountIn->Name))+"Á"+Replicate("Ä",Len(Str(CountIn->Znak)))+"Á"+Replicate("Ä",Len(Str(&PredPok)))+"Á"+;
Replicate("Ä",Len(Str(&TekPok)))+"Á"+Replicate("Ä",Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"Á"+;
Replicate("Ä",Len(Str(CountIn->Koeff)))+"Á"+Replicate("Ä",Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok))))+"Ù"+CrLf)
Fwrite(Desc,"€ªâ¨¢ ï í¥à£¨ï "+Str(Act)+CrLf)
Fwrite(Desc,"¥ ªâ¨¢ ï í¥à£¨ï "+Str(React)+CrLf)
Fclose(Desc)
Select 40
Go Rec
Win_Rest(Win)
Return NIL
Function CalculateEnergy(Pres,Last)
Local Energy:=0,MaxNumber:=Val("1"+CharRepl("1234567890",Alltrim(Str(Last)),"0"))
IF Pres>=Last
Energy:=Pres-Last
ELSE
Energy:=MaxNumber-Last+Pres
ENDIF
Return Energy
Function PrintBlankEnergy()
LOCAL Desc:=Fcreate(DDir+ReportFile),Win:=Win_Save(),Rec:=Recno(),Kol_Kl:=0
Local CrLf:=Chr(13)+Chr(10),Act:=0,React:=0,LenString
SELECT 41; GO Top
Obrabot("”®à¬¨à®¢ ¨¥ ¯ãá⮣à 䪨")
PredPok:="CountIn->Pok"+Alltrim(Str(IF(MonthIn>2,MonthIn-1,12)))
TekPok:= "CountIn->Pok"+Alltrim(Str(MonthIn))
FWrite(Desc,"Ú"+Replicate("Ä",Len(Str(NameIn->Number)))+"Â"+Replicate("Ä",Len(CountIn->Name))+"Â"+Replicate("Ä",Len(Str(CountIn->Znak)))+"Â"+Replicate("Ä",Len(Str(&PredPok)))+"Â"+;
Replicate("Ä",Len(Str(&TekPok)))+"Â"+Replicate("Ä",Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"Â"+;
Replicate("Ä",Len(Str(CountIn->Koeff)))+"Â"+Replicate("Ä",Len(Str(CountIn->Koeff*CalculateEnergy(&TekPok,&PredPok))))+"¿"+CrLf)
FWrite(Desc,"³"+Center("N",Len(Str(NameIn->Number))," ",.t.)+"³"+Center(" ¨¬¥.",Len(CountIn->Name)," ",.t.)+"³"+Replicate("f",Len(Str(CountIn->Znak)))+"³"+Center("।.¯®ª",Len(Str(&PredPok))," ",.t.)+"³"+;
Center("’¥ª.¯®ª",Len(Str(&TekPok))," ",.t.)+"³"+Center(" §®áâì",Len(Str(CalculateEnergy(&TekPok,&PredPok)))," ",.t.)+"³"+;
Center("Š®íä.",Len(Str(CountIn->Koeff))," ",.T.)+"³"+Center(" á室",Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok)))," ",.t.)+"³"+CrLf)
FWrite(Desc,"Ã"+Replicate("Ä",Len(Str(NameIn->Number)))+"Å"+Replicate("Ä",Len(CountIn->Name))+"Å"+Replicate("Ä",Len(Str(CountIn->Znak)))+"Å"+Replicate("Ä",Len(Str(&PredPok)))+"Å"+;
Replicate("Ä",Len(Str(&TekPok)))+"Å"+Replicate("Ä",Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"Å"+;
Replicate("Ä",Len(Str(CountIn->Koeff)))+"Å"+Replicate("Ä",Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok))))+"´"+CrLf)
LenString:=Len("Ã"+Replicate("Ä",Len(Str(NameIn->Number)))+"Å"+Replicate("Ä",Len(CountIn->Name))+"Å"+Replicate("Ä",Len(Str(CountIn->Znak)))+"Å"+Replicate("Ä",Len(Str(&PredPok)))+"Å"+;
Replicate("Ä",Len(Str(&TekPok)))+"Å"+Replicate("Ä",Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"Å"+;
Replicate("Ä",Len(Str(CountIn->Koeff)))+"Å"+Replicate("Ä",Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok))))+"´"+CrLf)-2
Select 40; Go Top
Do While .not.Eof()
kol_kl=kol_kl+39/Reccount()
colorwin(12,21,12,21+kol_kl,'n/n')
FWrite(Desc,"³"+Str(Number)+"³"+Name+Space(LenString-1-Len("³"+Str(Number)+"³"+Name))+"³"+CrLf)
Select 41
Seek NameIn->Number
IF Found()
Do While Number==NameIn->Number
PredPok:="Pok"+Alltrim(Str(IF(MonthIn>2,MonthIn-1,12)))
TekPok:="Pok"+Alltrim(Str(MonthIn))
IF .not.Empty(Koeff*CalculateEnergy(&TekPok,&PredPok))
IF Val(Name)!=0
FWrite(Desc,"³"+Space(Len(Str(NameIn->Number)))+"³"+Name+"³"+Str(Znak)+"³"+Str(&TekPok)+"³"+;
Space(Len(Str(&TekPok)))+"³"+Space(Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"³"+;
Str(Koeff)+"³"+Space(Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok))))+"³"+CrLf)
ELSE
FWrite(Desc,"³"+Space(Len(Str(NameIn->Number)))+"³"+Name+"³"+Str(Znak)+"³"+Space(Len(Str(&PredPok)))+"³"+;
Space(Len(Str(&TekPok)))+"³ "+Space(Len(Str(&TekPok)))+"³"+;
Str(Koeff)+"³"+Space(Len(Str(Koeff*&TekPok)))+"³"+CrLf)
ENDIF
ENDIF
Skip
EndDo
EndIF
Select 40
Skip
EndDo
SELECT 41; GO Top
FWrite(Desc,"À"+Replicate("Ä",Len(Str(NameIn->Number)))+"Á"+Replicate("Ä",Len(CountIn->Name))+"Á"+Replicate("Ä",Len(Str(CountIn->Znak)))+"Á"+Replicate("Ä",Len(Str(&PredPok)))+"Á"+;
Replicate("Ä",Len(Str(&TekPok)))+"Á"+Replicate("Ä",Len(Str(CalculateEnergy(&TekPok,&PredPok))))+"Á"+;
Replicate("Ä",Len(Str(CountIn->Koeff)))+"Á"+Replicate("Ä",Len(Str(Koeff*CalculateEnergy(&TekPok,&PredPok))))+"Ù"+CrLf)
Fwrite(Desc,"€ªâ¨¢ ï í¥à£¨ï "+CrLf)
Fwrite(Desc,"¥ ªâ¨¢ ï í¥à£¨ï "+CrLf)
Fclose(Desc)
Select 40
Go Rec
Win_Rest(Win)
Return NIL