|
|
int CObserverLaneDB::InsertTollSplitWasteBook() z+ l6 ?* Z9 I# i% K7 m
{- `; Y# Y) t+ t$ R& L% u
_ConnectionPtr pLocalConnectPtr;7 c+ Q3 P- E, h/ f" V
_RecordsetPtr pRstPtrTollRate;
* _4 e6 A% _ g4 x. t r _RecordsetPtr pRstPtrSplitWastebook;. l% u P8 j* w- F
" V$ P2 m/ R l
char pcSQL[300];
8 g# Q% y- C) o5 `! A1 s: _2 J sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Entry_Station_ID = %ld and Flag_Station1 = %ld and Flag_Station2 = %ld and Exit_Station_ID = %ld and Vehicle_Class = %ld and Vehicle_Case = %ld ",
$ S( R9 @% T( D( w4 c% I1 N g_ModelEntryInfo.m_PassCard.nEntryStationID,: h3 ^) L0 q! u
g_ModelEntryInfo.m_PassCard.nFlagStation1,
# z& L& }# K& w3 r) v6 B g_ModelEntryInfo.m_PassCard.nFlagStation2,
; S3 n5 H) o! |0 x8 g2 ^ g_ModelNodeInfo.m_nStationID,
6 z- R7 \7 O+ F G+ A g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
9 \! c1 [' `0 d3 C( E/ q! e* U g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase
0 V8 Q2 y& E* `" j9 Y; h );
! m( x) }, S/ z
6 N3 h& X/ U- M% w try
+ L% g. F# a; W; X: s {3 j8 W4 _5 F& n4 {$ ?( D
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
( B. A5 Q* e' o; _ pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);6 `- H3 V' o/ K6 c7 [# x* W6 g
8 M# i; e0 G8 m+ s+ _3 `
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
7 k9 l P6 \( O$ x! K pRstPtrTollRate->Open(pcSQL,
) O# d+ }) e( \$ q+ j% Q! a pLocalConnectPtr.GetInterfacePtr(),
/ U, U/ z+ g! p0 C adOpenStatic,
; [8 A; g- U6 x8 G" r& F0 Q; F adLockPessimistic,7 A2 r5 G4 V* @7 F/ e; T
adCmdText);
$ Q4 E) l, G2 y% x pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));7 ^% Z; G& [' N- n3 t
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),
9 l9 J/ w5 I6 M" V3 d, b2 x pLocalConnectPtr.GetInterfacePtr(),; K$ P- s& |1 x! g) ]" Y: A% |
adOpenUnspecified,
- x* c/ U4 v4 @( D+ d adLockPessimistic,
; z3 h5 { d+ I2 E% X& P9 [ adCmdTable);) h- Q; _ Z$ q' z! [, x5 H
( O* s% g/ C( {. }. {% b pRstPtrTollRate->MoveFirst();
3 w* t- P7 |" x2 h( ^. O) M for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)( D0 v$ D* D( X# e6 J6 u' H
{
, r7 K2 c2 h7 y$ r$ v5 N% r pRstPtrSplitWastebook->AddNew();
* `) y& {8 H; s7 L4 h, ^! \ pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);' s. N# O, x5 H/ n2 g
# H6 P& L4 m w
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);8 R. H4 r* D8 M; W9 X, X% u
+ x9 D! A- ^9 n0 j
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
& E+ n% k7 u- R( Y6 F
- S/ m& v4 j# m* q9 N pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);# G. M8 K* q$ T$ d& i* }
$ s/ P) P( M( A$ M
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
, Z" d" `5 p8 m! D- T- F( k- \' U pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;
/ i2 b& \7 D" d) g5 d! A
: k" d' o8 _, _% c0 C9 l" D L pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;3 w1 D, o# i2 `/ @8 M
6 {3 E+ D7 r' A5 V- S, M4 c1 b9 j/ n pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
( y5 V V E4 f- l, N, \+ O % k, U8 O l; }1 p$ C
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;8 w! j/ b5 l$ I- |
" R [8 w+ v( S7 B' \% r L( i pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);
, m# k5 k" O9 Q$ } I8 }
2 Z, P9 I; w5 b) U. h: L6 g6 h pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;1 K) D+ O8 w5 e0 Z# y
: [5 q: F1 G- s. L8 z. X float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;+ K+ {0 A- m! m% ]
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;- k! n1 Q/ p& T2 D+ T) m, T. u/ ?
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;" ?% {8 C' Q: ?/ V
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;; B; O: z: k" ^2 [9 [( {# T
$ C& x$ h8 ?/ X. D9 j- P pRstPtrSplitWastebook->Update();
- E$ k. \7 {1 r- B1 p( l- l
j) ^* N$ Q& t: @ m_nTableSplitTollWasteNOCount++;
2 Z# E8 \) H+ W: T. \3 e% J. G pRstPtrTollRate->MoveNext();
& z0 \& Q p, |2 c& Z0 q8 \ } 1 F1 j ?$ a- f X% J9 d* C
pRstPtrSplitWastebook->Close();
$ C% Y2 ?; V3 K- B% d pRstPtrTollRate->Close();, j7 `- o) f, D! o9 @
pLocalConnectPtr->Close();
0 Y0 w. O. j9 u, t m_nStatus = DB_OK;
% e6 U( A9 d0 |3 U return(m_nStatus); # m+ J; I9 I" F. p. J% N0 W
}. `/ @+ k: H+ s( O$ e* ^; y
catch(_com_error e)5 ]- ~4 r0 f1 T
{3 ?! \; I; b6 d/ l6 j1 y
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());: c: `( Z, Z6 w' y
g_ModelPrompt.Notify(); # l6 l" n. m6 x
m_nStatus = DB_ERROR;
/ X) r$ D1 b+ R4 m r3 P return(m_nStatus); ! |2 ~. s1 z9 k8 c! Y! Q1 h
}; K" p. l8 i, H3 [
}7 y$ p: x: c9 [& g% v; I8 X% E! h$ F
; f, I1 s" R# ^8 E& P+ A' T
1 T+ w4 J; P; s# U) {7 }, ?" j
# t3 Y) j5 }8 b2 E& F' u( U( ifloat CObserverLaneDB::GetTollRate()# a- d4 }! U) p' r6 N9 T3 ^$ a/ f9 g8 K
{" G1 }2 f. w% z+ ~1 y, a5 `, r
8 j/ e+ w! y8 { _ConnectionPtr pLocalConnectPtr;
* t: h% \+ T( x( I! a/ f% U7 ^ _RecordsetPtr pRstPtrTollRate;
1 M1 o% C- I' u1 |* K3 \ _RecordsetPtr pRstPtrOrganInfo; r# }* a7 b& Y( \) W$ ?
" h+ S* q' d4 n% S" N7 x0 i
float fToll = -1;
0 O. d P8 a; G8 E3 S! m% _' ?5 i char pcSQL[300];6 X2 d' I7 R3 o) }$ L# I7 q
int nSplitCount = 0;
6 a9 _" m" G: p switch(g_ModelNodeInfo.m_nNodeType)
7 w( L2 Q) o) e {
2 k; P+ c8 z& @9 n" v" T' h+ @ case NODE_TYPE_ENTRY:) C5 m! _0 w6 G# C) [( V" |
return(0);2 ]# J" z$ [& @, [2 K/ H }. B
break;
% E$ N6 {( a. ^; z2 M case NODE_TYPE_EXIT:
0 m* }6 k, q0 }. D+ d" |2 C$ ^ case NODE_TYPE_MAIN_LANE:5 P" B) a8 o" @
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
. j5 A8 ]- k0 w+ U9 t, N {
$ t6 c2 K' C* F, k* Z0 c: J case VEHICLE_CASE_URGENT:
( l- k% R9 V5 ], F6 t case VEHICLE_CASE_ILLEGAL:
# o& B# \, H9 X4 h" C9 B/ I case VEHICLE_CASE_OFFDUTY_ILLEGAL:
+ B3 s- O% G4 K' B case VEHICLE_CASE_MOTORCADE:2 p0 C) i$ r- k5 B* p3 C
case VEHICLE_CASE_COMMUTATION_TICKET:
7 g9 X/ [' [. Y% c; ?6 a case VEHICLE_CASE_ETC:
3 R! v4 t1 f1 q8 U. w7 h' }; n case VEHICLE_CASE_BAD_CARD:; A0 v$ W5 A; S5 L
case VEHICLE_CASE_NO_CARD:
+ `6 J, U. S, I* T& E. n sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
% R3 B5 \+ e1 ^1 J# A2 | g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
' a6 \; q n" B* d- P; } g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);; U3 D& j' J: j7 m* `9 ]
break;
! x7 [6 }. F, i6 I5 H$ D, l' Y default:
, S/ j9 P" X) @' E7 ] sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Entry_Station_ID = %ld and Flag_Station1 = %ld and Flag_Station2 = %ld and Exit_Station_ID = %ld and Vehicle_Class = %ld and Vehicle_Case = %ld ",
7 C$ d7 d) c+ B; z: z) z6 n g_ModelEntryInfo.m_PassCard.nEntryStationID,
% G& w8 v3 s. W6 ? g_ModelEntryInfo.m_PassCard.nFlagStation1,* }* s4 e$ L. z1 k& |
g_ModelEntryInfo.m_PassCard.nFlagStation2,
1 }9 Y4 u# E* @7 O g_ModelNodeInfo.m_nStationID,
5 M& g# `0 u' h/ r g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,5 [! Z7 d: Y$ R3 m% T
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);* J# ?) n1 T% L% w# A. A1 M/ f
break;
, s m, V8 v3 u: c }
2 u/ Q ~+ C2 D9 X
; U5 v- y7 r# @ try1 x2 j4 [9 c7 e/ a
{
' V% |& K; o8 |& @; U3 c1 ]! a pLocalConnectPtr.CreateInstance(__uuidof(Connection)); ~( }+ h- Y6 v+ d
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);: U0 C; k$ d z9 i( Z0 d6 l
! J7 p; k" c+ J
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
! Q2 V: N9 e+ `7 p pRstPtrTollRate->Open(pcSQL," J" x# K; |- M4 h. ?
pLocalConnectPtr.GetInterfacePtr(),1 k" A; H8 }8 a3 m0 y- t
adOpenStatic,( Y, w1 E+ h' y0 \: L$ Y6 ]
adLockPessimistic,5 G/ H2 X5 u' z
adCmdText);
; n! v2 }& w. A$ y% K. A9 a if(pRstPtrTollRate->RecordCount > 0)% D0 u4 }0 V8 n9 t% G
{" P0 {5 A$ ?' P% z+ @" l
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
/ r7 C' S- P' u' `4 i5 [6 v if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
/ ^4 ~; H" `7 y: Q- u$ C {
7 t: {$ q# f4 M' K' _! x memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
. \" ]/ N$ t( U9 w0 l! f; v pRstPtrTollRate->MoveFirst();
$ E M$ k! S. O6 [- a. v7 d for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)2 o& A- F$ J/ s3 ]6 x$ u1 O6 `0 F
{4 ]! ] N6 N* G8 L# Y
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
0 d" q7 u$ C/ p pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));9 ~! J7 B$ ~( ^ ?
pRstPtrOrganInfo->Open(pcSQL,
/ R& K, E$ x, `, H6 v3 t pLocalConnectPtr.GetInterfacePtr(),* u ^# ^2 h& l' k+ s# Q7 }
adOpenStatic,! f }8 P' A) I. e0 `
adLockPessimistic,
' o" r0 k \3 l9 S; a adCmdText);: q# ^' s# V* z( y
nSplitCount++;1 {" |$ n8 w) H* M* [$ w$ F
char pcBuf[10];& A1 }3 n2 _5 o( E
if(0 == nSplitCount%3)# z. b+ H2 E5 e( X4 L: _) s
{
' K8 \3 [, F3 X, X6 u& C ^ sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);% s1 _, a( q8 ^. N1 w
}else2 L' B/ ^! z% K# m6 T2 L
{
( _# [1 K8 a' e" T% F& y6 N sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
/ c+ \+ x4 X2 J/ A k. O: J3 O- O/ n }' y. j# |' b' C: G% w. @
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
, P7 H8 M* D8 X# w5 ~# S strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);# B" P% _" r6 U/ K/ e
pRstPtrOrganInfo->Close();
, y/ \: z6 Q" Q' Q! n% ?& L' J q9 J pRstPtrTollRate->MoveNext();1 i# Q# j& c8 B
}3 W- q! }# v" m2 n& Y
}
# |" W! g) F n; \8 P- G ^& j 6 D8 x! E) v0 P
}else fToll = -1;( u0 y+ ~6 R" R8 a8 B0 F# C9 R
6 M* X* V: R' \6 d$ x+ e pRstPtrTollRate->Close();; Y% G9 p" D8 N& G) S! ]" b F
pLocalConnectPtr->Close();
. k# \; ]/ _% z m_nStatus = DB_OK;2 G+ z0 q3 h+ s: h7 u2 G5 @6 |
return(fToll);0 ~, Z8 Z$ Y# g/ w
}& v! J! [+ K2 \/ e" ~5 U
catch(_com_error e)4 h- ?9 [1 Q6 D' B5 y' a8 a
{
" o4 f/ \7 Z$ v g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());6 X5 A* S3 @' y+ S+ i n8 R. K
g_ModelPrompt.Notify();
! J5 @& k& @( a' i4 X2 ^ m_nStatus = DB_ERROR;
6 W8 C, z6 T" @ return(fToll); - e+ z/ ?" x! q! J. H6 p/ K
}# M' Y! `4 f' ]2 M: R
; e5 M5 g1 R1 j6 f! _* s7 m6 k2 s' `
break;
) M: C# m+ |/ ` case NODE_TYPE_OPEN: [ E. n& s# o, Z7 T
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",
( h' f6 O4 M* G0 j+ J g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass" d- T6 b+ |9 Z4 z6 ^" i' t/ y1 Q
);' I: ]9 A$ Q& c+ a* i9 a0 i) {
try* C8 W0 M# L O( D
{6 y; ?$ B% k* N* n; [* }
pLocalConnectPtr.CreateInstance(__uuidof(Connection));5 r* w' D8 x2 ]$ _( ^
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);5 X- |9 B6 k: H3 E/ B- r7 D
W- ]/ C- D' L
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
4 o' Z0 P) q! V8 [- Y* ] pRstPtrTollRate->Open(pcSQL,
6 l0 A' g7 K* B: f) O/ ` pLocalConnectPtr.GetInterfacePtr(),
# W ~2 }0 Z$ ?; P- p. l) Y9 m4 | adOpenStatic,
c& p5 Q6 @5 K8 L* W @ adLockPessimistic,- S. S, l3 ^) f: W
adCmdText);
8 O! _ Z# a7 X3 g4 I if(pRstPtrTollRate->RecordCount > 0)% R, H1 F* M. P
{& R* T& |2 B3 @6 Z) B: O
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
! W0 |: G: L P9 ~9 V9 f/ O }else fToll = -1;- B( e. E" J( T, \( e7 n. b
$ r. w3 `& A: p( v% i \( v7 F5 U pRstPtrTollRate->Close();
7 z d8 T- C& V+ f; | pLocalConnectPtr->Close();6 j$ P q+ {9 y5 S$ ^4 M' t
m_nStatus = DB_OK;
1 O, o: i& ?+ P5 z) n& g" \ return(fToll);' q+ M; n7 d O O1 k9 ]8 m
}
: h5 a6 B' }7 T9 s, g catch(_com_error e)
+ W# V! E0 N( M {
8 N1 ^+ H& O7 N; K, R9 G: v g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
3 B4 L* l/ T5 q& Z) L g_ModelPrompt.Notify();
3 _8 X6 Z1 w7 K5 B4 u2 Z9 N0 j% E) z m_nStatus = DB_ERROR;0 e) @8 s) X3 @" d3 \! t
return(fToll);
% b% K) y$ f4 ]+ l4 N1 ?' }% B }' A1 n0 b. [, T1 T. {. L- z+ u
break;0 B/ R! d' d3 l3 q: q5 U
default: {* O* w: e9 P
m_nStatus = DB_ERROR;
5 r9 f0 L9 I2 ~0 Y- ?% \ break;' Z' p5 m W0 @) E1 Y
}
, ^$ e$ ?; ?( m3 J- \* Y return(fToll); 8 }5 Z, I, ]$ K8 F( A" g
} |
|