-
Notifications
You must be signed in to change notification settings - Fork 0
/
calcularlpg.cs
301 lines (284 loc) · 10 KB
/
calcularlpg.cs
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
/*
File: CalcularLPG
Description: Calcular LPG
Author: GeneXus C# Generator version 10_3_2-86442
Generated on: 1/26/2015 11:14:56.5
Program type: Callable routine
Main DBMS: sqlserver
*/
using System;
using System.Collections;
using GeneXus.Utils;
using GeneXus.Resources;
using GeneXus.Application;
using GeneXus.Metadata;
using GeneXus.Cryptography;
using System.Data;
using System.Data.SqlClient;
using GeneXus.Data;
using com.genexus;
using GeneXus.Data.ADO;
using GeneXus.Data.NTier;
using GeneXus.Data.NTier.ADO;
using System.Runtime.Remoting;
using GeneXus.WebControls;
using GeneXus.Http;
using GeneXus.Procedure;
using GeneXus.XML;
using GeneXus.Search;
using GeneXus.Encryption;
using GeneXus.Http.Client;
using System.Threading;
using System.Xml.Serialization;
using System.Data.SqlTypes;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Runtime.Serialization;
namespace GeneXus.Programs {
public class calcularlpg : GXProcedure
{
public calcularlpg( )
{
context = new GxContext( );
DataStoreUtil.LoadDataStores( context);
dsDefault = context.GetDataStore("Default");
IsMain = true;
context.SetDefaultTheme("Flat");
}
public calcularlpg( IGxContext context )
{
this.context = context;
IsMain = false;
dsDefault = context.GetDataStore("Default");
}
public void release( )
{
}
public void execute( long aP0_LPGBandaM3 ,
out SdtSdtResultado aP1_SdtResultado )
{
this.AV16LPGBandaM3 = aP0_LPGBandaM3;
this.AV13SdtResultado = new SdtSdtResultado(context) ;
initialize();
executePrivate();
aP1_SdtResultado=this.AV13SdtResultado;
}
public SdtSdtResultado executeUdp( long aP0_LPGBandaM3 )
{
this.AV16LPGBandaM3 = aP0_LPGBandaM3;
this.AV13SdtResultado = new SdtSdtResultado(context) ;
initialize();
executePrivate();
aP1_SdtResultado=this.AV13SdtResultado;
return AV13SdtResultado ;
}
public void executeSubmit( long aP0_LPGBandaM3 ,
out SdtSdtResultado aP1_SdtResultado )
{
calcularlpg objcalcularlpg;
objcalcularlpg = new calcularlpg();
objcalcularlpg.AV16LPGBandaM3 = aP0_LPGBandaM3;
objcalcularlpg.AV13SdtResultado = new SdtSdtResultado(context) ;
objcalcularlpg.context.SetSubmitInitialConfig(context);
objcalcularlpg.initialize();
ThreadPool.QueueUserWorkItem( new WaitCallback( executePrivateCatch ),objcalcularlpg);
aP1_SdtResultado=this.AV13SdtResultado;
}
void executePrivateCatch( object stateInfo )
{
try
{
((calcularlpg)stateInfo).executePrivate();
}
catch ( Exception e )
{
GXUtil.SaveToEventLog( "ClienteWeb Peajes", e);
throw e ;
}
}
void executePrivate( )
{
/* GeneXus formulas */
/* Output device settings */
AV17ResultadoLPGBandaM3 = AV16LPGBandaM3;
AV15ValorACalcular = 0;
/* Using cursor P000B2 */
pr_default.execute(0);
while ( (pr_default.getStatus(0) != 101) )
{
A14LPGBandaM3 = P000B2_A14LPGBandaM3[0];
A15LPGTarifaCargados = P000B2_A15LPGTarifaCargados[0];
A13LPGID = P000B2_A13LPGID[0];
if ( AV17ResultadoLPGBandaM3 >= A14LPGBandaM3 )
{
if ( A14LPGBandaM3 != 0 )
{
AV15ValorACalcular = (decimal)(AV15ValorACalcular+(A14LPGBandaM3*A15LPGTarifaCargados));
AV17ResultadoLPGBandaM3 = (long)(AV17ResultadoLPGBandaM3-A14LPGBandaM3);
}
else
{
AV15ValorACalcular = (decimal)(AV15ValorACalcular+(AV17ResultadoLPGBandaM3*A15LPGTarifaCargados));
AV17ResultadoLPGBandaM3 = 0;
/* Exit For each command. Update data (if necessary), close cursors & exit. */
if (true) break;
}
}
else
{
AV15ValorACalcular = (decimal)(AV15ValorACalcular+(AV17ResultadoLPGBandaM3*A15LPGTarifaCargados));
AV17ResultadoLPGBandaM3 = 0;
/* Exit For each command. Update data (if necessary), close cursors & exit. */
if (true) break;
}
pr_default.readNext(0);
}
pr_default.close(0);
AV13SdtResultado.gxTpr_Sdtresultadopanamax = AV15ValorACalcular;
AV13SdtResultado.gxTpr_Sdtresultadoneopanamax = AV15ValorACalcular;
AV17ResultadoLPGBandaM3 = AV16LPGBandaM3;
AV15ValorACalcular = 0;
AV17ResultadoLPGBandaM3 = AV16LPGBandaM3;
/* Using cursor P000B3 */
pr_default.execute(1);
while ( (pr_default.getStatus(1) != 101) )
{
A14LPGBandaM3 = P000B3_A14LPGBandaM3[0];
A16LPGTarifaLastre = P000B3_A16LPGTarifaLastre[0];
A13LPGID = P000B3_A13LPGID[0];
if ( AV17ResultadoLPGBandaM3 >= A14LPGBandaM3 )
{
if ( A14LPGBandaM3 != 0 )
{
AV15ValorACalcular = (decimal)(AV15ValorACalcular+(A14LPGBandaM3*A16LPGTarifaLastre));
AV17ResultadoLPGBandaM3 = (long)(AV17ResultadoLPGBandaM3-A14LPGBandaM3);
}
else
{
AV15ValorACalcular = (decimal)(AV15ValorACalcular+(AV17ResultadoLPGBandaM3*A16LPGTarifaLastre));
AV17ResultadoLPGBandaM3 = 0;
/* Exit For each command. Update data (if necessary), close cursors & exit. */
if (true) break;
}
}
else
{
AV15ValorACalcular = (decimal)(AV15ValorACalcular+(AV17ResultadoLPGBandaM3*A16LPGTarifaLastre));
AV17ResultadoLPGBandaM3 = 0;
/* Exit For each command. Update data (if necessary), close cursors & exit. */
if (true) break;
}
pr_default.readNext(1);
}
pr_default.close(1);
AV13SdtResultado.gxTpr_Sdtresultadolastre = AV15ValorACalcular;
this.cleanup();
}
public override void cleanup( )
{
CloseOpenCursors();
if ( IsMain )
{
context.CloseConnections() ;
}
exitApplication();
}
protected void CloseOpenCursors( )
{
}
public override void initialize( )
{
scmdbuf = "";
P000B2_A14LPGBandaM3 = new long[1] ;
P000B2_A15LPGTarifaCargados = new decimal[1] ;
P000B2_A13LPGID = new short[1] ;
P000B3_A14LPGBandaM3 = new long[1] ;
P000B3_A16LPGTarifaLastre = new decimal[1] ;
P000B3_A13LPGID = new short[1] ;
pr_default = new DataStoreProvider(context, new GeneXus.Programs.calcularlpg__default(),
new Object[][] {
new Object[] {
P000B2_A14LPGBandaM3, P000B2_A15LPGTarifaCargados, P000B2_A13LPGID
}
, new Object[] {
P000B3_A14LPGBandaM3, P000B3_A16LPGTarifaLastre, P000B3_A13LPGID
}
}
);
/* GeneXus formulas. */
context.Gx_err = 0;
}
private short A13LPGID ;
private long AV16LPGBandaM3 ;
private long AV17ResultadoLPGBandaM3 ;
private long A14LPGBandaM3 ;
private decimal AV15ValorACalcular ;
private decimal A15LPGTarifaCargados ;
private decimal A16LPGTarifaLastre ;
private String scmdbuf ;
private IGxDataStore dsDefault ;
private IDataStoreProvider pr_default ;
private long[] P000B2_A14LPGBandaM3 ;
private decimal[] P000B2_A15LPGTarifaCargados ;
private short[] P000B2_A13LPGID ;
private long[] P000B3_A14LPGBandaM3 ;
private decimal[] P000B3_A16LPGTarifaLastre ;
private short[] P000B3_A13LPGID ;
private SdtSdtResultado aP1_SdtResultado ;
private SdtSdtResultado AV13SdtResultado ;
}
public class calcularlpg__default : DataStoreHelperBase, IDataStoreHelper
{
public ICursor[] getCursors( )
{
cursorDefinitions();
return new Cursor[] {
new ForEachCursor(def[0])
,new ForEachCursor(def[1])
};
}
private static CursorDef[] def;
private void cursorDefinitions( )
{
if ( def == null )
{
Object[] prmP000B2 ;
prmP000B2 = new Object[] {
} ;
Object[] prmP000B3 ;
prmP000B3 = new Object[] {
} ;
def= new CursorDef[] {
new CursorDef("P000B2", "SELECT [LPGBandaM3], [LPGTarifaCargados], [LPGID] FROM [LPG] WITH (NOLOCK) ORDER BY [LPGID] ",false, GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK, false, this,prmP000B2,100,0,false,false )
,new CursorDef("P000B3", "SELECT [LPGBandaM3], [LPGTarifaLastre], [LPGID] FROM [LPG] WITH (NOLOCK) ORDER BY [LPGID] ",false, GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK, false, this,prmP000B3,100,0,false,false )
};
}
}
public void getResults( int cursor ,
IFieldGetter rslt ,
Object[] buf )
{
switch ( cursor )
{
case 0 :
((long[]) buf[0])[0] = rslt.getLong(1) ;
((decimal[]) buf[1])[0] = rslt.getDecimal(2) ;
((short[]) buf[2])[0] = rslt.getShort(3) ;
break;
case 1 :
((long[]) buf[0])[0] = rslt.getLong(1) ;
((decimal[]) buf[1])[0] = rslt.getDecimal(2) ;
((short[]) buf[2])[0] = rslt.getShort(3) ;
break;
}
}
public void setParameters( int cursor ,
IFieldSetter stmt ,
Object[] parms )
{
switch ( cursor )
{
}
}
}
}