-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCostes.prg
More file actions
167 lines (107 loc) · 3.97 KB
/
Copy pathCostes.prg
File metadata and controls
167 lines (107 loc) · 3.97 KB
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
#include "FiveWin.Ch"
#include "Factu.ch"
#include "MesDbf.ch"
//----------------------------------------------------------------------------//
CLASS TCosMaq FROM TMant
DATA cMru INIT "gc_industrial_robot_money_16"
DATA cBitmap INIT clrTopProduccion
METHOD OpenFiles( lExclusive )
METHOD CloseFiles()
METHOD DefineFiles()
METHOD Resource( nMode )
Method lPreSave( oGet, nMode )
END CLASS
//----------------------------------------------------------------------------//
METHOD OpenFiles( lExclusive, cPath )
local lOpen := .t.
local oError
local oBlock := ErrorBlock( {| oError | ApoloBreak( oError ) } )
DEFAULT lExclusive := .f.
BEGIN SEQUENCE
if Empty( ::oDbf )
::oDbf := ::DefineFiles( cPath )
end if
::oDbf:Activate( .f., !( lExclusive ) )
RECOVER USING oError
lOpen := .f.
::CloseFiles()
msgStop( ErrorMessage( oError ), "Imposible abrir todas las bases de datos" )
END SEQUENCE
ErrorBlock( oBlock )
RETURN ( lOpen )
//----------------------------------------------------------------------------//
METHOD CloseFiles()
if !Empty( ::oDbf )
::oDbf:end()
end if
::oDbf := nil
RETURN .t.
//----------------------------------------------------------------------------//
METHOD DefineFiles( cPath, cDriver )
local oDbf
DEFAULT cPath := ::cPath
DEFAULT cDriver := cDriver()
DEFINE TABLE oDbf FILE "Costes.Dbf" CLASS "Costes" ALIAS "Costes" PATH ( cPath ) VIA ( cDriver ) COMMENT "Costes de maquinaria"
FIELD NAME "cCodCos" TYPE "C" LEN 12 DEC 0 COMMENT "Código" COLSIZE 100 OF oDbf
FIELD NAME "cDesCos" TYPE "C" LEN 35 DEC 0 COMMENT "Nombre" COLSIZE 400 OF oDbf
FIELD NAME "nImpCos" TYPE "N" LEN 16 DEC 6 COMMENT "Importe" COLSIZE 100 PICTURE cPouDiv() ALIGN RIGHT OF oDbf
INDEX TO "Costes.Cdx" TAG "cCodCos" ON "cCodCos" COMMENT "Código" NODELETED OF oDbf
INDEX TO "Costes.Cdx" TAG "cDesCos" ON "cDesCos" COMMENT "Nombre" NODELETED OF oDbf
END DATABASE oDbf
RETURN ( oDbf )
//----------------------------------------------------------------------------//
METHOD Resource( nMode )
local oDlg
local oGet
DEFINE DIALOG oDlg RESOURCE "CostesMaquina" TITLE LblTitle( nMode ) + "costes de maquinaria"
REDEFINE GET oGet VAR ::oDbf:cCodCos;
ID 110 ;
WHEN ( nMode == APPD_MODE ) ;
VALID NotValid( oGet, ::oDbf:cAlias ) ;
PICTURE "@!" ;
OF oDlg
REDEFINE GET ::oDbf:cDesCos;
ID 120 ;
WHEN ( nMode != ZOOM_MODE ) ;
OF oDlg
REDEFINE GET ::oDbf:nImpCos;
ID 130 ;
PICTURE ( cPouDiv() ) ;
WHEN ( nMode != ZOOM_MODE ) ;
OF oDlg
REDEFINE BUTTON ;
ID IDOK ;
OF oDlg ;
WHEN ( nMode != ZOOM_MODE ) ;
ACTION ( if( ::lPreSave( oGet, nMode ), oDlg:end( IDOK ), ) )
REDEFINE BUTTON ;
ID IDCANCEL ;
OF oDlg ;
CANCEL ;
ACTION ( oDlg:end() )
if nMode != ZOOM_MODE
oDlg:AddFastKey( VK_F5, {|| if( ::lPreSave( oGet, nMode ), oDlg:end( IDOK ), ) } )
end if
oDlg:bStart := { || oGet:SetFocus() }
ACTIVATE DIALOG oDlg CENTER
RETURN ( oDlg:nResult == IDOK )
//---------------------------------------------------------------------------//
METHOD lPreSave( oGet, nMode )
if nMode == APPD_MODE .or. nMode == DUPL_MODE
if Empty( ::oDbf:cCodCos )
MsgStop( "Código del coste no puede estar vacío" )
oGet:SetFocus()
Return .f.
end if
if ::oDbf:SeekInOrd( ::oDbf:cCodCos, "CCODCOS" )
msgStop( "Código existente" )
oGet:SetFocus()
return .f.
end if
end if
if Empty( ::oDbf:cDesCos )
MsgStop( "La descripción del coste no puede estar vacía." )
Return .f.
end if
Return .t.
//---------------------------------------------------------------------------//