|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
2 N4 o- ?3 ^2 Y; h5 {# N0 D{0 G( I4 `. L( }$ p1 X2 {
_ConnectionPtr pLocalConnectPtr;/ {2 o+ F) Y- M& j1 F, t
_RecordsetPtr pRstPtrTollRate;& w' |6 p4 w! i- Q, c2 U: E) s& {3 M
_RecordsetPtr pRstPtrSplitWastebook;
6 h- t8 V o8 ?* k# N3 c$ _: W9 k% g3 m3 S+ |# ^& @, W
char pcSQL[300];
* P/ o/ Q* `" p, Z6 {: R 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 ",+ E0 A+ E Q! T9 f; O0 ]* W
g_ModelEntryInfo.m_PassCard.nEntryStationID,# }3 u! a5 B f) O# Y9 x
g_ModelEntryInfo.m_PassCard.nFlagStation1,
( s1 W1 {& Y/ c$ f4 C# O g_ModelEntryInfo.m_PassCard.nFlagStation2,/ {( ^# ^& A7 c
g_ModelNodeInfo.m_nStationID,
/ f: Y$ R% F0 d3 P0 s4 Q f5 l2 A g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
( G" G$ @7 }* p3 c- l# u/ m g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase4 g5 |/ l8 _+ ^' q N- g
);! X, b0 V5 N" s
8 ]8 g' i" v& V& O% v% @6 L! z- j
try
( ~# M6 B9 R% B3 x+ j: { {, f; a5 g+ X C
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
" C# o! D( r6 v: p$ }3 q pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);+ ~: t; ^3 f/ }3 O
% n' R3 G! u O: a6 T. s1 t pRstPtrTollRate.CreateInstance(__uuidof(Recordset));7 y; d! P% [# B* g' X
pRstPtrTollRate->Open(pcSQL,
+ `0 r: |' \9 e4 k# {9 z/ B" P pLocalConnectPtr.GetInterfacePtr()," X' ?5 X/ B; d) ? o
adOpenStatic,
1 s$ l' ]% i6 ^& U1 K adLockPessimistic,- s1 t8 q- F6 q
adCmdText);, o C' ?7 w( h9 L
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
. O+ U Z2 L6 P D6 E/ j9 { pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),
8 H1 J6 A9 f; B( G pLocalConnectPtr.GetInterfacePtr(),% W! R4 E3 u$ n) b
adOpenUnspecified,
) o C, }6 P1 }9 }( T adLockPessimistic,
2 r9 U, T2 _2 F9 b% J3 C, g adCmdTable);
9 I6 V/ @0 s# r0 l5 ^
! D2 x% [, ^' d pRstPtrTollRate->MoveFirst();
' u q) Y( r; p; z7 V% {5 ^5 N# Q: F for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
# ^1 M; J Y; n' \ {
2 F) j- L) ~2 N. D! a* S+ y pRstPtrSplitWastebook->AddNew();+ \7 ^: n7 }+ K0 u2 }; c6 |4 s
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);0 h( i- u+ f2 V( R7 ?. D+ T
' r6 ~7 k( j' k: V3 F# A6 `) H pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);! B7 u! i8 [1 h: t8 f9 p
2 A3 ?$ P5 Z% E4 p3 {) l5 l pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);/ Z6 a" r8 V+ V1 d. l9 ]7 D/ Y
' L8 A9 h$ k/ ~' {+ T) l pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);3 s; _! F0 F8 Q
7 v8 ?# P5 _/ u: E1 k; [ COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
6 q, l Y( q+ ~. ?" T pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;. x4 \2 ~& E3 @6 W
% B/ O7 Y" N$ G1 l. S" V% @, j9 N pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;
$ D1 Q+ j6 |1 e ( [2 ~9 Y( N5 t i
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
. h) F" B! t3 o$ ~9 ^6 J6 `3 ?, z 9 b+ ~" m% V) O( X- ^- M
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;3 ~" f' V; I, p7 G. F9 O' \$ n
% T7 y; y, |0 U. ^% D' z
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);
9 b1 `3 X+ d; T1 E6 i# t; ^# W 5 c8 G$ D( C2 ?% r, z4 [
pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
, j4 ~/ P4 h$ c* o M% r
$ E% o9 X- x1 i7 N* b float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;
5 A, `( M. H R" U; A! y, H1 o float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;
2 U5 D1 j& t2 q2 K float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
" q# y& ~7 X- N' Y2 U* G2 b pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
e5 D1 k [1 K" h
! t5 L$ `3 e+ x5 u' \7 ` pRstPtrSplitWastebook->Update(); ! |9 C a6 y6 G k: C: d& m+ I. u
# ]1 L" c1 `3 v- n7 [# X! J* x
m_nTableSplitTollWasteNOCount++;
5 [! \( E# w2 N+ ]" d; A pRstPtrTollRate->MoveNext(); F/ n+ v4 s. J/ H7 O
} 4 `! R; e$ v' @0 u# V* n3 d; P* w! n
pRstPtrSplitWastebook->Close();, v' W. M# U- h* M
pRstPtrTollRate->Close();
* R4 i0 w# r+ B! M pLocalConnectPtr->Close();8 _! n6 O/ h; F, J' [# s! g
m_nStatus = DB_OK;. Q+ `6 P( z. V6 \
return(m_nStatus);
7 y( ?# o# r" Y! u- b- F }
. D9 `% d9 P1 [7 q catch(_com_error e)
* ^6 X7 u# T2 O7 R5 I {: F0 W' K0 }- I- z3 S
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());& p' a6 m. ?1 [+ O7 d2 \
g_ModelPrompt.Notify();
. S: G5 p: ^ y/ Y/ O4 }% K- T! n m_nStatus = DB_ERROR;
g+ o0 C* h2 A. s$ V$ }3 X+ F/ e return(m_nStatus); * [" D. r4 T% i4 Z6 w1 l
}! f- P5 M, G* H& C
}
N& j% x/ r+ m. U* q" C( s* Q, |' r! f9 y
0 i/ ~5 P, a/ }- @' K; U
. P. K$ r9 V% A" u% Hfloat CObserverLaneDB::GetTollRate()
1 }$ A9 J& C/ ~! R{; G: A* X" C* _- |0 ]) g8 m
' i; \, _ J. L- |% r. V
_ConnectionPtr pLocalConnectPtr;
, U; `- c/ {2 W _RecordsetPtr pRstPtrTollRate;- L8 H( S- t( [. @
_RecordsetPtr pRstPtrOrganInfo;. r- @+ p5 ~. A8 }; a- C: Q
" m' a* a6 o1 e% D0 ]8 E; ~ float fToll = -1;
8 f. y+ E2 O A; w' y6 ^ char pcSQL[300];
2 v6 U1 t0 k/ C* E. l c( O int nSplitCount = 0;
6 b, U: c9 z `/ z! @9 j switch(g_ModelNodeInfo.m_nNodeType)
) E+ `0 t3 I1 I3 o {
9 {4 x- _7 |2 ~8 K2 p9 g5 ^# r case NODE_TYPE_ENTRY:
' S p* A$ f: w6 _& k1 q# k0 H; ^ return(0);/ U4 e" F0 z/ A: o4 V
break;! |0 P+ o& \$ T1 y J
case NODE_TYPE_EXIT:
, q( S6 L- n" u1 V8 k, I, |0 D- V9 L case NODE_TYPE_MAIN_LANE:5 E5 J4 k: T- [
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
7 y5 ~( O- l* F% c8 ], v( f: }$ q% W {! W0 H% Q2 U# j
case VEHICLE_CASE_URGENT:; O1 @- g& ?+ Y# h0 v
case VEHICLE_CASE_ILLEGAL:
x5 Z0 Q; ]7 I0 [5 Q! }. {5 D case VEHICLE_CASE_OFFDUTY_ILLEGAL:1 _$ J2 s3 D3 d# q, S, e0 F n
case VEHICLE_CASE_MOTORCADE:
. }! C8 ]4 {$ @$ r' M case VEHICLE_CASE_COMMUTATION_TICKET:
% T9 ^2 I+ o, K' ? case VEHICLE_CASE_ETC:1 z' H+ [* N* P, G, w; D, y; _
case VEHICLE_CASE_BAD_CARD:' s) b) Y/ o1 k( s9 t
case VEHICLE_CASE_NO_CARD:
2 Y: c' Q# U2 i4 O1 ^' ] sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",. C4 ]! c f. p0 f2 }4 H; F- @
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
4 W. I& G* B3 g( Y# s g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);$ N) I k' d6 H8 x6 v; B& @& @$ D
break;
. U# {( a! H* p! J. Y: l i default:
) a$ A+ \1 ^0 p5 h, y e0 ` 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 ",
' L3 e. q, D+ o& u! r$ p g_ModelEntryInfo.m_PassCard.nEntryStationID,
7 W) I! E, H# J! T g_ModelEntryInfo.m_PassCard.nFlagStation1,
! T& A- s, c* k6 Y8 F, h g_ModelEntryInfo.m_PassCard.nFlagStation2,
2 F7 q0 [* R+ s6 C) I- l g_ModelNodeInfo.m_nStationID,
; I& h' M+ H0 {* n' x$ n g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
G3 k9 q4 Y3 n2 C% e3 F g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
4 V9 n/ g7 _ { break;) A5 J; K( ^7 X$ [: B" N8 {' g; x
}
( E5 x# n& X6 V: @0 X
7 p! A$ H8 f& A/ z8 s2 D try" \( k: K0 Z' n, l
{6 B2 \2 i6 b# a1 g
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
1 i: f) G, J# J' f, U/ c1 _ pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
8 v4 |) O5 P, C: P. ~ 9 s$ _$ V/ e4 g" E
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
2 s# e7 l" ~6 H) Y9 Y pRstPtrTollRate->Open(pcSQL,
* h4 n7 x6 @7 n$ v m pLocalConnectPtr.GetInterfacePtr(),* A6 [% T) C3 u/ v
adOpenStatic,6 ? t C8 a( p
adLockPessimistic,+ H" C6 o6 c! O% V3 G
adCmdText);
7 M; F1 N/ ^1 r% o if(pRstPtrTollRate->RecordCount > 0)7 n% ]6 m* K+ A. a4 [5 ~- o
{5 I/ B' G; M/ B5 O
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;# B6 o5 b+ p& W3 U0 t4 k! t' }4 Z
if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )7 f+ c* ~6 [! Z* U. p. p0 Q
{) K+ f& n- l/ @7 r% j
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));' T3 [) Y6 w9 |
pRstPtrTollRate->MoveFirst();" ?" o( k7 t6 s3 G( U
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)' Y. u6 c2 o6 E3 j: H7 t( F' ~! \
{
, ^& J& T% h: a. I4 M5 [7 ` sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
' g; f1 ]# A$ s$ t2 o# R pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));
6 `" s8 Z. T; E' x$ P/ [+ ? pRstPtrOrganInfo->Open(pcSQL,8 d* e0 l1 `* F: K5 z6 y, |9 S
pLocalConnectPtr.GetInterfacePtr(),
" g) }* T; ~ X, f' Y2 J& h; L" K# k adOpenStatic,
; y) m$ L& h, V1 m( n adLockPessimistic,
) Z) q/ e# ]! x& | adCmdText);1 ?6 n0 o+ K( p4 A
nSplitCount++; T0 j p% P/ G, j
char pcBuf[10];3 Z S/ \! a% N) W6 o5 p
if(0 == nSplitCount%3)
1 p3 g* ^# X, D$ f( T" t3 c7 U {
6 n2 i6 h9 i V- U8 t- O% Q/ `. H sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
8 n, H9 u- ]3 S }else1 G w ~3 |/ K. H1 m- Z1 o
{7 [: ^, e" k# Y% u4 z: y& j0 j
sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);" f4 J: [7 e* H5 F
}8 @3 P/ A" g4 d# p, U2 L
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
" Y' U/ l+ z. D& O3 f! O strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
2 @8 _) a) C3 `% K$ p2 l& B pRstPtrOrganInfo->Close();
+ [0 S8 ~2 ` J* u. E pRstPtrTollRate->MoveNext();- E- ]5 d7 |" ]. R! }* n
}0 y5 P5 }4 c f1 I
}# J; q* x: k3 ^6 z. u' O2 _; `
% r( c% B* _ \; e; k% a
}else fToll = -1;
/ y: W {# @: B( K9 n+ P% @6 _
: v8 ?1 p9 q1 X" k pRstPtrTollRate->Close();0 q9 K. }, F) I) d9 N6 S
pLocalConnectPtr->Close();
* e# Q( J$ T: B- s+ Z0 i8 H! v m_nStatus = DB_OK;
7 `2 _8 m$ m+ }4 y7 ^ return(fToll);
+ X3 s; M9 ^* J8 v }$ Z) l# z/ i, J2 k0 c: l
catch(_com_error e)# k Z7 I5 Q7 E0 u$ v8 B
{
5 ^$ E: Q5 [: H K g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
3 `( r5 W5 y7 ]1 N$ [& M! | g_ModelPrompt.Notify(); # H0 n! E6 {6 q" X
m_nStatus = DB_ERROR;4 i- |# Q" R, Q2 P% u1 T% B
return(fToll);
( Z! a4 J) ?; [* U }6 ]" `3 x/ S0 T+ w
% [( x- M4 M( {( t- Q$ w break;
" z; Z3 u7 K7 R$ a2 K case NODE_TYPE_OPEN:! N, U8 f% a/ m: ]0 z: i
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",* c* x( X7 _# y$ t
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass! v V+ W7 I+ w2 V
);3 k& _0 n# w6 L$ j2 n5 ^9 m) R. x+ d
try
, y$ O% `. R6 `7 @' R! Y! P. ]/ y9 w2 v {
. x5 Q4 }- ~5 O: J; a5 z pLocalConnectPtr.CreateInstance(__uuidof(Connection));
: Q7 ]( x6 ]5 ^* ?9 I8 N# j pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
2 L* f2 z# h# Y) q * k/ j$ x& p& t! y& f8 j: m) P
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));5 ?: H) f0 D' `. l9 E/ A
pRstPtrTollRate->Open(pcSQL,4 X2 \3 g; n1 c; G2 T! ?) ?
pLocalConnectPtr.GetInterfacePtr(),# q3 _/ h) ~) ^# J4 U' i+ ^3 |
adOpenStatic,4 G( G3 D6 L2 m0 P% u& H4 m
adLockPessimistic,8 J( M2 D( g- k6 g+ Q4 z) O0 I
adCmdText);
2 @. u! O% k. T5 n1 \+ O* Y if(pRstPtrTollRate->RecordCount > 0)" L0 S4 l/ { }
{, `6 |7 R4 ^3 X
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
. V& a# |4 |, }" o/ P }else fToll = -1;
% Y& b/ ?, f* q " [- B& |( y+ o
pRstPtrTollRate->Close();' {8 G5 [1 r( ?
pLocalConnectPtr->Close();
' W" [7 v, ]2 T1 ^* q m_nStatus = DB_OK;: N6 L! e8 w5 q6 ?! S9 X3 \4 B
return(fToll);, V6 m% \& m7 ?7 d
}
4 w) P1 f! E* W0 h catch(_com_error e)
1 W2 [5 e% j( ? {
8 z: v' b4 }, N# I# i g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());0 H! E3 N! Z: x5 ~) H3 X
g_ModelPrompt.Notify(); 6 `, a" x e* G9 [; I1 I8 J5 [
m_nStatus = DB_ERROR;
3 i' o1 M3 e7 I+ s o return(fToll); ; n {0 i9 I! h2 D
}
5 q$ k3 ]) o( |* u break;
) O& E5 ?. E) M7 s* a default:) j: x0 f4 n4 d9 ^- r$ B6 f
m_nStatus = DB_ERROR;
' v- d# u6 a, b+ y. a6 D break;- x! y, ^3 j* e
}
2 Z3 i/ B& A2 X return(fToll);
V5 n6 | Z" M0 L} |
|