Code
1
unit VehiclePonderation;
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
interface
4![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
uses
6
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7
SingleMoudle, Db, ADODB, PrnDbgeh, Wwdatsrc, ActnList, ImgList, Grids,
8
DBGridEh, ExtCtrls, StdCtrls, wwSpeedButton, wwDBNavigator, wwclearpanel,
9
ComCtrls, ToolWin, Mask, DBCtrls, MemTableEh, DataDriverEh, GridsEh,
10
wwdbdatetimepicker, Buttons, wwdblook, OoMisc, AdPort, Spin, Menus,
11
FR_Class, FR_DSet, FR_DBSet;
12![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
type
14
TVehiclePonderationFrm = class(TSingleMoudleFrm)
15
wwModuleQryId: TIntegerField;
16
wwModuleQryVehicleNo: TStringField;
17
wwModuleQryWeight0: TFloatField;
18
wwModuleQryWeight1: TFloatField;
19
wwModuleQryWeight2: TFloatField;
20
wwModuleQryWeight3: TFloatField;
21
wwModuleQryRemark: TStringField;
22
ICVehicleInOutQry: TADOQuery;
23
ICVehicleInOutQryId: TIntegerField;
24
ICVehicleInOutQryWork_No: TIntegerField;
25
DataSource1: TDataSource;
26
Panel3: TPanel;
27
Panel5: TPanel;
28
DBGridEh3: TDBGridEh;
29
Label1: TLabel;
30
DBEdit1: TDBEdit;
31
Label2: TLabel;
32
DBEdit2: TDBEdit;
33
Label3: TLabel;
34
DBEdit3: TDBEdit;
35
Label4: TLabel;
36
DBEdit4: TDBEdit;
37
Label5: TLabel;
38
DBEdit5: TDBEdit;
39
Label6: TLabel;
40
DBEdit6: TDBEdit;
41
wwModuleQryPonderation_No: TIntegerField;
42
ICVehicleInOutQryVehicleNo: TStringField;
43
Label8: TLabel;
44
DBEdit8: TDBEdit;
45
wwModuleQryOccur_Date: TDateTimeField;
46
Label15: TLabel;
47
wwDBDateTimePicker1: TwwDBDateTimePicker;
48
DBEdit7: TDBEdit;
49
Label7: TLabel;
50
SpeedButton1: TSpeedButton;
51
SpeedButton2: TSpeedButton;
52
Panel1: TPanel;
53
Label9: TLabel;
54
Label10: TLabel;
55
dtStart: TDateTimePicker;
56
dtEnd: TDateTimePicker;
57
Button1: TButton;
58
Button6: TButton;
59
Button2: TButton;
60
CheckBox1: TCheckBox;
61
ComPort1: TApdComPort;
62
Panel2: TPanel;
63
wwModuleQryShipper_Id: TIntegerField;
64
wwModuleQryMateriel_Name: TStringField;
65
wwModuleQryOccur_Date1: TDateTimeField;
66
wwModuleQryAmount: TFloatField;
67
Label12: TLabel;
68
CustomerInfoLK1: TwwDBLookupCombo;
69
Label13: TLabel;
70
SpinEdit1: TSpinEdit;
71
wwModuleQryIC_No: TStringField;
72
Label14: TLabel;
73
DBEdit10: TDBEdit;
74
frDBDataSet1: TfrDBDataSet;
75
frReport1: TfrReport;
76
PopupMenu1: TPopupMenu;
77
N4r5te1: TMenuItem;
78
ertre1: TMenuItem;
79
wwModuleQryPonderation_Type: TStringField;
80
wwModuleQryKa_No: TStringField;
81
Label11: TLabel;
82
DBEdit9: TDBEdit;
83
Label16: TLabel;
84
DBEdit11: TDBEdit;
85
Label17: TLabel;
86
wwDBDateTimePicker2: TwwDBDateTimePicker;
87
Label18: TLabel;
88
DBComboBox1: TDBComboBox;
89
wwModuleQryUserID: TStringField;
90
wwModuleQryInput_Date: TDateTimeField;
91
Label19: TLabel;
92
DBEdit12: TDBEdit;
93
Label20: TLabel;
94
DBEdit13: TDBEdit;
95
wwModuleQryshipper_name: TStringField;
96
Label21: TLabel;
97
DBEdit14: TDBEdit;
98
Button3: TButton;
99
wwModuleQrykong_weight: TFloatField;
100
wwModuleQryzong_weight: TFloatField;
101
Timer1: TTimer;
102
wwModuleQryhandleperson_name: TStringField;
103
wwModuleQryWork_No: TStringField;
104
wwModuleQryweight4: TFloatField;
105
N1: TMenuItem;
106
frReport2: TfrReport;
107
wwModuleDetQryId: TIntegerField;
108
wwModuleDetQryMaster_Id: TIntegerField;
109
wwModuleDetQryAmount: TFloatField;
110
wwModuleDetQryWeight: TFloatField;
111
wwModuleDetQryUserID: TStringField;
112
wwModuleDetQryInput_Date: TDateTimeField;
113
wwModuleDetQryRemark: TStringField;
114
N2: TMenuItem;
115
frReport3: TfrReport;
116
procedure DBGridEh3DblClick(Sender: TObject);
117
procedure wwModuleQryAfterInsert(DataSet: TDataSet);
118
procedure wwModuleQryBeforePost(DataSet: TDataSet);
119
procedure Button1Click(Sender: TObject);
120
procedure FormCreate(Sender: TObject);
121
procedure CheckBox1Click(Sender: TObject);
122
procedure SpeedButton1Click(Sender: TObject);
123
procedure SpeedButton2Click(Sender: TObject);
124
procedure Button2Click(Sender: TObject);
125
procedure ComPort1Trigger(CP: TObject; Msg, TriggerHandle, Data: Word);
126
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
127
procedure tbPrintClick(Sender: TObject);
128
procedure ertre1Click(Sender: TObject);
129
procedure Button3Click(Sender: TObject);
130
procedure wwModuleQryCalcFields(DataSet: TDataSet);
131
procedure Timer1Timer(Sender: TObject);
132
procedure FormActivate(Sender: TObject);
133
procedure N1Click(Sender: TObject);
134
procedure Button6Click(Sender: TObject);
135
procedure Panel1Click(Sender: TObject);
136
procedure N2Click(Sender: TObject);
137
private
138
CodeArr:array[0..82] of String;
139
WeighS: String;
140
counti: integer;
141
IC_No:Integer;
142
RefreshCount: integer;
143
function Gethex(data: Char): String;
144
function GetVehicleNo: String;
145
{ Private declarations }
146
public
147
procedure GetVehiclePonderation(Weight: Double);
148
{ Public declarations }
149
end;
150![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
151
var
152
VehiclePonderationFrm: TVehiclePonderationFrm;
153
procedure ExecVehiclePonderation;
154![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
155
implementation
156![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
157
uses CommonData, ICCommon, CommonFunction, Ponderation;
158
//97.5
159
{$R *.DFM}
160![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
161
procedure ExecVehiclePonderation;
162
begin
163
VehiclePonderationFrm := TVehiclePonderationFrm.Create(nil);
164
try
165
VehiclePonderationFrm.ShowModal;
166
finally
167
VehiclePonderationFrm.Free;
168
end;
169![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
170
end;
171![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
172
procedure TVehiclePonderationFrm.DBGridEh3DblClick(Sender: TObject);
173
begin
174
inherited;
175
Button6Click(nil);
176![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
177
end;
178![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
179
procedure TVehiclePonderationFrm.wwModuleQryAfterInsert(DataSet: TDataSet);
180
begin
181
inherited;
182
end;
183![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
184
procedure TVehiclePonderationFrm.wwModuleQryBeforePost(DataSet: TDataSet);
185
begin
186
end;
187![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
188
procedure TVehiclePonderationFrm.Button1Click(Sender: TObject);
189
begin
190
inherited;
191
end;
192![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
193
procedure TVehiclePonderationFrm.FormCreate(Sender: TObject);
194
begin
195
inherited;
196
RefreshCount := 0;
197
CodeArr[0] := '0';
198
CodeArr[1] := '1';
199
CodeArr[2] := '2';
200
CodeArr[3] := '3';
201
CodeArr[4] := '4';
202
CodeArr[5] := '5';
203
CodeArr[6] := '6';
204
CodeArr[7] := '7';
205
CodeArr[8] := '8';
206
CodeArr[9] := '9';
207
CodeArr[10] := 'A';
208
CodeArr[11] := 'B';
209
CodeArr[12] := 'C';
210
CodeArr[13] := 'D';
211
CodeArr[14] := 'E';
212
CodeArr[15] := 'F';
213
CodeArr[16] := 'G';
214
CodeArr[17] := 'H';
215
CodeArr[18] := 'I';
216
CodeArr[19] := 'J';
217
CodeArr[20] := 'K';
218
CodeArr[21] := 'L';
219
CodeArr[22] := 'M';
220
CodeArr[23] := 'N';
221
CodeArr[24] := 'O';
222
CodeArr[25] := 'P';
223
CodeArr[26] := 'Q';
224
CodeArr[27] := 'R';
225
CodeArr[28] := 'S';
226
CodeArr[29] := 'T';
227
CodeArr[30] := 'U';
228
CodeArr[31] := 'V';
229
CodeArr[32] := 'W';
230
CodeArr[33] := 'X';
231
CodeArr[34] := 'Y';
232
CodeArr[35] := 'Z';
233
CodeArr[36] := ':';
234
CodeArr[37] := '*';
235
CodeArr[38] := '';
236
CodeArr[39] := '';
237![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
238
CodeArr[51] := '京';
239
CodeArr[52] := '津';
240
CodeArr[53] := '沪';
241
CodeArr[54] := '渝';
242
CodeArr[55] := '粤';
243
CodeArr[56] := '闽';
244
CodeArr[57] := '桂';
245
CodeArr[58] := '湘';
246
CodeArr[59] := '黑';
247
CodeArr[60] := '辽';
248
CodeArr[61] := '蒙';
249
CodeArr[62] := '新';
250
CodeArr[63] := '宁';
251
CodeArr[64] := '青';
252
CodeArr[65] := '甘';
253
CodeArr[66] := '藏';
254
CodeArr[67] := '晋';
255
CodeArr[68] := '冀';
256
CodeArr[69] := '鲁';
257
CodeArr[70] := '豫';
258
CodeArr[71] := '贵';
259
CodeArr[72] := '云';
260
CodeArr[73] := '赣';
261
CodeArr[74] := '鄂';
262
CodeArr[75] := '苏';
263
CodeArr[76] := '皖';
264
CodeArr[77] := '琼';
265
CodeArr[78] := '川';
266
CodeArr[79] := '吉';
267
CodeArr[80] := '浙';
268
CodeArr[81] := '陕';
269
CodeArr[82] := '特';
270![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
271
dtStart.Date := dtEnd.Date;
272
273
end;
274![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
275
procedure TVehiclePonderationFrm.SpeedButton1Click(Sender: TObject);
276
begin
277
inherited;
278
end;
279![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
280
procedure TVehiclePonderationFrm.SpeedButton2Click(Sender: TObject);
281
begin
282
inherited;
283
end;
284![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
285
procedure TVehiclePonderationFrm.Button2Click(Sender: TObject);
286
var tagtype, Work_No:Integer;
287
snr:Longword;
288
Vehicle_No: String;
289
data:array[0..15] of Char;
290
begin
291![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
292
if Sender <> nil then
293
begin
294
IcShow(RFConfig($c6,$0e));
295
IcShow(RFRequest(1,tagtype));
296
IcShow(RFAnticoll(0,snr));
297
IC_No := snr;
298
IcShow(RFReadA(snr,56,@data,#$FF#$FF#$FF#$FF#$FF#$FF));
299
try
300
Vehicle_No := CodeArr[StrToInt(Gethex(data[0]))] +
301
CodeArr[StrToInt(Gethex(data[1]))] +
302
CodeArr[StrToInt(Gethex(data[2]))] +
303
CodeArr[StrToInt(Gethex(data[3]))] +
304
CodeArr[StrToInt(Gethex(data[4]))] +
305
CodeArr[StrToInt(Gethex(data[5]))] +
306
CodeArr[StrToInt(Gethex(data[6]))];
307
except
308
end;
309
// DM.ExeSql(Format('select top 1 Work_No, Vehicle_No from NanChuWuLiu_IC_Vehicle_InOut where IC_No = ''%s'' order by Work_No Desc', [IntToStr(snr)]));
310
// Work_No := DM.Dual1Qry.FieldByName('Work_No').Value;
311
// Work_No := snr;
312
// Vehicle_No := DM.Dual1Qry.FieldByName('Vehicle_No').asString;
313
end;
314![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
315
tbInsertClick(nil);
316
wwModuleQryVehicleNo.Value := Vehicle_No;
317
wwModuleQryIC_No.Value := IntToStr(IC_No);
318
end;
319![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
320
function TVehiclePonderationFrm.Gethex(data: Char): String;
321
begin
322
Result := Format('%d',[StrtoInt('$'+inttohex(byte(data),2))]);
323![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
324
end;
325![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
326
function TVehiclePonderationFrm.GetVehicleNo: String;
327
var snr:Longword;
328
data:array[0..15] of Char;
329
buf1:array[0..1] of byte;
330
i: integer;
331
S: String;
332
begin
333
IcShow(RFReadA(snr,56,@data,#$FF#$FF#$FF#$FF#$FF#$FF));
334
// Edit1.Text:=inttohex(byte(data[0]),2);
335
// Edit1.Text:=Format('%d',[StrtoInt('$'+Edit1.Text)]);
336
try
337
Result := CodeArr[StrToInt(Gethex(data[0]))] +
338
CodeArr[StrToInt(Gethex(data[1]))] +
339
CodeArr[StrToInt(Gethex(data[2]))] +
340
CodeArr[StrToInt(Gethex(data[3]))] +
341
CodeArr[StrToInt(Gethex(data[4]))] +
342
CodeArr[StrToInt(Gethex(data[5]))] +
343
CodeArr[StrToInt(Gethex(data[6]))];
344
except
345
end;
346
end;
347![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
348
procedure TVehiclePonderationFrm.FormCloseQuery(Sender: TObject;
349
var CanClose: Boolean);
350
begin
351
inherited;
352
SaveINI('Start', 'DibangCom', IntToStr(SpinEdit1.Value));
353![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
354
end;
355![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
356
procedure TVehiclePonderationFrm.tbPrintClick(Sender: TObject);
357
begin
358
//inherited;
359
// frReport1.LoadFromFile(WorkDir + '称重单.frf');
360
// frReport1.ShowReport;
361
if LoadINI('Start', 'Ponderation') <> '1' then
362
begin
363
frReport2.PrepareReport;
364
frReport2.PrintPreparedReport('', 1, True, frAll);
365
end
366
else
367
begin
368
frReport1.PrepareReport;
369
frReport1.PrintPreparedReport('', 1, True, frAll);
370
end;
371![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
372
// frReport1.PrintPreparedReportDlg;
373![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
374
end;
375![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
376
procedure TVehiclePonderationFrm.ertre1Click(Sender: TObject);
377
begin
378
inherited;
379
frReport1.LoadFromFile(WorkDir + '称重单.frf');
380
frReport1.DesignReport;
381![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
382
end;
383![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
384
procedure TVehiclePonderationFrm.Button3Click(Sender: TObject);
385
var F: Double;
386
begin
387
inherited;
388![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
389
end;
390![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
391
procedure TVehiclePonderationFrm.wwModuleQryCalcFields(DataSet: TDataSet);
392
begin
393
inherited;
394
end;
395![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
396
procedure TVehiclePonderationFrm.Timer1Timer(Sender: TObject);
397
var tagtype, Work_No:Integer;
398
snr:Longword;
399
Vehicle_No: String;
400
data:array[0..15] of Char;
401
Weight1: double;
402
Id: integer;
403
begin
404![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
405
if PonderationFrm <> nil then
406
exit;
407
inc(RefreshCount);
408
if (RefreshCount > 30) and (wwModuleQry.State in [dsBrowse]) then
409
begin
410
RefreshCount := 0;
411
Id := wwModuleQryId.Value;
412
Button1Click(nil);
413
wwModuleQry.Locate('Id', Id, []);
414
end;
415![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
416
if RFConfig($c6,$0e) < 0 then
417
begin
418
snr := 0;
419
IC_No := 0;
420
exit;
421
end;
422![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
423
if RFRequest(1,tagtype) < 0 then
424
begin
425
snr := 0;
426
IC_No := 0;
427
exit;
428
end;
429
if RFAnticoll(0,snr) < 0 then
430
begin
431
IC_No := 0;
432
snr := 0;
433
exit;
434
end;
435![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
436
// showinfo(inttostr(snr));
437![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
438
if snr = 0 then
439
exit;
440
if IC_No = snr then
441
exit;
442
IC_No := snr;
443
IcShow(RFReadA(snr,56,@data,#$FF#$FF#$FF#$FF#$FF#$FF));
444
try
445
Vehicle_No := CodeArr[StrToInt(Gethex(data[0]))] +
446
CodeArr[StrToInt(Gethex(data[1]))] +
447
CodeArr[StrToInt(Gethex(data[2]))] +
448
CodeArr[StrToInt(Gethex(data[3]))] +
449
CodeArr[StrToInt(Gethex(data[4]))] +
450
CodeArr[StrToInt(Gethex(data[5]))] +
451
CodeArr[StrToInt(Gethex(data[6]))];
452
except
453
exit;
454
end;
455
end;
456![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
457
procedure TVehiclePonderationFrm.FormActivate(Sender: TObject);
458
begin
459
// inherited;
460
Timer1.Enabled := True;
461
end;
462![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
463
procedure TVehiclePonderationFrm.N1Click(Sender: TObject);
464
begin
465
inherited;
466
frReport1.ShowReport;
467![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
468
end;
469![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
470
procedure TVehiclePonderationFrm.Button6Click(Sender: TObject);
471
begin
472
inherited;
473
DM.DB.Close;
474
DM.DB.Open;
475
end;
476![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
477
procedure TVehiclePonderationFrm.GetVehiclePonderation(Weight: Double);
478
var Amount: integer;
479
begin
480![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
481
end;
482![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
483
procedure TVehiclePonderationFrm.Panel1Click(Sender: TObject);
484
begin
485
inherited;
486
// ExecPonderation(wwModuleQryId.Value);
487![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
488
end;
489![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
490
procedure TVehiclePonderationFrm.N2Click(Sender: TObject);
491
begin
492
inherited;
493
// frReport3.PrepareReport;
494
// frReport3.PrintPreparedReport('', 1, True, frAll);
495
frReport3.ShowReport;
496
end;
497![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
498
end.
转载于:https://www.cnblogs.com/zhongkeruanjian/archive/2009/09/10/1563883.html