|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
& D3 U+ ]3 W! b{
$ c! H) G7 B* z q; O) R8 M6 n; p( @ _ConnectionPtr pLocalConnectPtr;
' I9 o" o# w1 h/ } _RecordsetPtr pRstPtrTollRate;
9 Z3 F/ t' E1 [, [7 w _RecordsetPtr pRstPtrSplitWastebook;" b e4 H: |% l" O4 t N
/ F. j) Z; u7 l4 t* W
char pcSQL[300];6 K5 @3 t+ 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 ",5 A& T( A* G5 @6 O- A
g_ModelEntryInfo.m_PassCard.nEntryStationID,- C* g' ?4 d3 Y! g* N
g_ModelEntryInfo.m_PassCard.nFlagStation1,
6 J" f) m, u" V* v- z g_ModelEntryInfo.m_PassCard.nFlagStation2,
6 C( I; r' v4 S2 k g_ModelNodeInfo.m_nStationID,
e& F) h& I: ~+ r" B g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
1 L8 @: `/ q; x' p3 d g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase* R0 s2 Z/ p5 q4 p
);! |, W+ N. ^# e
4 r0 I4 M& N; u& M. X try
9 K* i0 H+ F* Q/ ^, s1 V& C# E+ L. k/ l6 f {
3 v# ^' ?# Q2 a ? R" a, J, V2 O pLocalConnectPtr.CreateInstance(__uuidof(Connection));
1 z- B& @: ^1 d! J pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
* p e! Z$ O [1 M c
9 }, t8 G% u% ~& A' t& g1 O pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
8 q# I& e4 C! `- ~6 ] pRstPtrTollRate->Open(pcSQL,
1 E7 @6 ?: o/ _# {: L6 R pLocalConnectPtr.GetInterfacePtr(),$ }, _ X7 |# A6 _$ S
adOpenStatic,
, |- k0 K; h& {0 F2 m' ^( E adLockPessimistic,. ~5 m6 }+ Z: R
adCmdText);, [/ {7 \) o% [' I
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
m& B0 J4 D* O! p- K pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),
5 J4 v7 \0 C" Y( e/ g- C/ J' n, p' v pLocalConnectPtr.GetInterfacePtr(),
5 Q* ?: n" T+ v7 B* z# C adOpenUnspecified,
2 H* k3 q4 Z3 s3 j; [* N3 k' B) L8 t adLockPessimistic,
& I- O3 w; a7 Z5 b: m2 v$ v& d adCmdTable);5 R) }* Z6 O' K' h
! d J3 z g8 A5 x8 k
pRstPtrTollRate->MoveFirst();
* Q5 y+ L% s% D% V5 `& E for(int i = 0;i<pRstPtrTollRate->RecordCount;i++), U7 A& H1 W6 m
{5 J! J; P6 _. v7 H" g9 Q- V, m' a
pRstPtrSplitWastebook->AddNew();) c1 U% B, d2 x L0 g ?0 Q4 O
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
7 Y, ^6 I4 N+ q% j3 g8 v
1 Y3 x: {! L6 {+ X8 ]: X pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);: X2 T3 W" a" a6 O. H6 U
: B& ~. ^3 M- r5 H' B% P0 U: L pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
" N4 t8 d/ ^& W: f
- D+ n8 I* n; W* z1 U pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
( ], d$ [ s: P" g" B
9 Y0 J J* n0 R$ N COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
# g- e; Q, P& X' i pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;1 [2 A2 A3 `2 D9 d7 A- _6 N
& R& Y4 f4 K* N5 \ pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;$ p' Q$ A7 y' ^. {1 y Z! a7 ?
- l8 O1 [4 b; [6 ^& B3 @; | pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
4 [6 O: e' Z! w/ C
2 n" Z& @! W2 H O }& a pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
" t. R1 ]: n0 N
/ T0 I7 `- B/ t* X; t+ g7 g pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);. o0 B9 H% d8 |- R% W' c
3 Y# x% D( {+ t5 S pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
# \6 W) r. r' u$ F' o7 U " D& a$ s) q2 g) h7 e
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;
+ e5 G2 @0 U0 @8 M- [ float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;: r6 \; p' b ` B
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
. a3 S5 d! g- O. x; I- s" E7 _. K pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
1 R3 Z" R- c) \ & q$ _7 D; i$ G% l
pRstPtrSplitWastebook->Update();
: Y; H% e5 |2 k; T! A* e ) y8 H( s2 l8 Z6 e
m_nTableSplitTollWasteNOCount++;3 F- v( C3 {- ], U4 d5 A; D( y
pRstPtrTollRate->MoveNext();. k& Y( _5 ]: e. [9 p
} * ^8 {0 A3 i4 r0 Y
pRstPtrSplitWastebook->Close();
* C( F, |7 g7 r' Q# y2 X pRstPtrTollRate->Close();
/ K# E* M @, H; z- s, O$ u+ Z5 J pLocalConnectPtr->Close();0 O9 a# ~* f. U. O, Z# p3 A' k
m_nStatus = DB_OK;
- t" n, k' L) Y6 {3 o return(m_nStatus);
0 z' y; W: v( L: ^# b4 Z }! s( n( q0 a8 i2 m, K4 F) O
catch(_com_error e)
$ d" O) _# | u' b& ^2 O- X8 v {6 o& W4 _# E# f: i' Y0 { f
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());6 |1 K/ G' z l4 M* ]5 t
g_ModelPrompt.Notify();
# O' G1 f4 G1 ^& G' G6 f m_nStatus = DB_ERROR;
& r# U4 j" z. {8 u# s return(m_nStatus); 3 C @" K+ R ? r0 {3 w' i5 M
}" T( o; X6 n5 q2 E5 B; D( O4 R
}
4 w, G6 A. I" Z, r" F/ e3 u5 k/ v) ]/ v
" y$ p: v* W+ `4 q
! u0 ]+ s0 ^6 [+ ^/ mfloat CObserverLaneDB::GetTollRate()
; X$ M* [7 c( i, m0 I7 S{+ o }3 V! o6 c; o: _
: w# X. c) p! v+ n' l3 Q& _; g _ConnectionPtr pLocalConnectPtr;; r5 R+ N( @$ g
_RecordsetPtr pRstPtrTollRate;
& d( R1 O9 A p- O; { _RecordsetPtr pRstPtrOrganInfo;7 g9 I F: u3 {; |
& K! V5 N" `# Q' {$ L float fToll = -1;% Q& F; P7 }4 V* m$ i6 `
char pcSQL[300];! J h4 w- R! Q% H
int nSplitCount = 0;$ _1 S+ H* {' o* m1 ?
switch(g_ModelNodeInfo.m_nNodeType)
, [- @8 P/ H/ M0 X O P& F7 q {0 ^8 V# Y7 o8 {% [* \( T
case NODE_TYPE_ENTRY:3 ?/ [ Y! R' g7 c
return(0);
k- i6 z8 @- O break;
6 C e5 u- s* E case NODE_TYPE_EXIT:
8 ?2 @& s, O ]7 F2 W$ w: b2 q: g; Y case NODE_TYPE_MAIN_LANE:" w$ o( r* Z4 L3 K- O- K
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase); b! i8 Y4 P* }9 p
{; x9 Z. W; ?) B7 a9 [ h3 G
case VEHICLE_CASE_URGENT:% ^! }* G8 b: k1 p! ]5 \! v4 }
case VEHICLE_CASE_ILLEGAL:/ _( a4 b7 K# Q. {7 E }! C
case VEHICLE_CASE_OFFDUTY_ILLEGAL:
8 Y1 e% d* `- H% u, E; T case VEHICLE_CASE_MOTORCADE:+ C( K, B: g' r& `# Z5 ^
case VEHICLE_CASE_COMMUTATION_TICKET:. B" y- s) |; o5 i: v7 B n4 [
case VEHICLE_CASE_ETC:5 k$ C, C5 z8 K. z$ x% t( W% _. P/ Y. ~
case VEHICLE_CASE_BAD_CARD:$ x4 t* z8 q9 I9 f. t1 L, A
case VEHICLE_CASE_NO_CARD:
% f: U2 S" O$ k2 m1 O9 p& Y sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
5 F- X+ f0 n! h- j' n/ w3 U g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
) B5 a, x& Y2 O! [3 T+ m% ?0 i g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
# z! ~' |# \* A9 N, z7 g break;
- }2 m0 u( a. O m: H3 Z default:
8 @, W/ D0 w1 O: T 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 ",
9 H& ~' [, g+ @ g_ModelEntryInfo.m_PassCard.nEntryStationID,) N1 B5 F$ Y/ }2 {" r* T& T# c
g_ModelEntryInfo.m_PassCard.nFlagStation1,8 M8 j( h2 |/ m
g_ModelEntryInfo.m_PassCard.nFlagStation2,9 ]+ ?6 a" X5 D: D
g_ModelNodeInfo.m_nStationID,
- k% X) z4 ]7 g g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
1 B. y$ P# m) D+ _ g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
1 z$ l5 ^. B! c A k1 g break;
. }0 U" F" U% a+ {" b- ~0 j; X# g }) z$ G9 n7 v. V4 a6 }: x- F: b8 }# k2 p
& G! n6 e! E- o8 n. e" W+ a
try" T2 ?8 M4 ]! g* J0 i% V
{( c. G$ a }0 |1 ~& }8 G
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
) p/ q' w% D1 R1 K/ i& O pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);# D- r5 w/ ?$ _9 y+ ?- ]- u8 S" y
9 J5 {- k. v; G. t
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
5 e; [5 k: v4 K pRstPtrTollRate->Open(pcSQL,
$ R- `1 t; T% }+ E& F0 ` pLocalConnectPtr.GetInterfacePtr(),# |$ I" e+ Q5 K& W) \
adOpenStatic,
% M2 R3 O5 k8 W5 @. i; J, o adLockPessimistic,; P: U. C* T% |- g- [2 X
adCmdText);0 U+ C( g$ P5 M) R6 b
if(pRstPtrTollRate->RecordCount > 0)
! \3 s# X% Y& S; F! g, c$ f {4 D6 q) Q5 @5 Y. v: B. t, M
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;) P2 L) N/ l. z. E
if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
3 x5 }: B5 W% [$ ?/ E {
: q% Z: r5 j$ x memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));! l7 E5 y1 e1 h h
pRstPtrTollRate->MoveFirst();
0 D$ A; \: k1 y8 p% a! C4 u0 N for(int i = 0;i<pRstPtrTollRate->RecordCount;i++): @/ ]8 n4 D/ z+ ^9 y8 P- }
{
6 ^" m- p5 ^( O. v1 _7 H" n sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
( b; i: o& k e) T! {5 D pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));+ j1 d/ U- {& u- ?' }' |8 ~/ Y
pRstPtrOrganInfo->Open(pcSQL,
+ c& n ~3 q, X, X4 c pLocalConnectPtr.GetInterfacePtr(),
5 X3 t$ H3 h9 X; P" s- K adOpenStatic,6 K& K r5 ]4 L" D$ T5 j& P
adLockPessimistic,
( m2 p2 A: ]% G adCmdText); c9 D5 k* u/ \6 K& T" V* p' u
nSplitCount++;
5 a& C' Q. v$ @) ?% O2 J. w2 B char pcBuf[10];- }2 B+ h7 o4 [$ n; |
if(0 == nSplitCount%3)
2 n2 `6 _( _7 _ F% }' X* S {* m" L; U7 l* P7 }
sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
3 K. a+ Z4 ]; z w. J }else- `2 e1 w: E# D y' |5 k5 x
{
4 C) k8 Z& n' F' i sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);5 n3 s$ U' T, x; c7 G _& @
}# d+ r4 t5 Q3 Y7 J% E
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);6 t7 x7 m4 C! G
strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
: o* C0 D7 F8 I, G3 n/ j pRstPtrOrganInfo->Close();$ K- k3 {8 N h+ k7 v
pRstPtrTollRate->MoveNext();5 J( a6 {, d4 ^, K( K
}- o- D2 K" v; ]) J0 f/ @
}1 ?& L" U h7 h; s2 I% G7 R
# S l n$ U0 x- J5 t$ v& N6 T) l; D
}else fToll = -1;
4 S Q" C; B* B6 W* y* V+ g
; U/ z, a) W: {2 H, s: Z5 o- P pRstPtrTollRate->Close();
) T) n7 F; u$ p pLocalConnectPtr->Close();
7 b) ], C( S2 ?8 X m_nStatus = DB_OK;
/ N$ ~$ c# P$ e: j return(fToll);# k" K% B& l. H- e& `
}
* e" I" c+ M' v9 `1 y; W, X catch(_com_error e); `- Q4 {0 L4 q3 Z- C
{
( \' ~* O9 I2 Q3 U6 d$ F9 _% L g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());) u: z: _% @' [6 C8 h
g_ModelPrompt.Notify();
) k) A3 r1 F$ ~$ Q* w- z5 v m_nStatus = DB_ERROR;: e- E% _8 w) E. a0 l: |+ W9 C) ~+ O
return(fToll);
1 W* D5 w1 B2 T- X7 M# S1 U& U }
( E1 C" I6 W7 H7 }# j! Q3 l1 [2 q- F & t! B/ x: t+ o7 R9 g& k& a: }
break;
2 r$ D: N7 L( E# r case NODE_TYPE_OPEN:, ]0 v' a' j2 t6 H9 O0 [
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",4 B+ ^; _: t9 c6 v. H- M2 `
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
% E: x, W6 @3 ~9 E );
$ i" t+ N; T* Q0 j8 Z# ^$ c+ p; D/ D try5 n& |- K) u! E% I7 D+ M
{
6 q; h! l, E( [6 @# u pLocalConnectPtr.CreateInstance(__uuidof(Connection));
! f( M5 L4 \! T1 h: M+ D m pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);9 ^7 n) h2 w8 v- e
0 u8 T" R$ `( E( \7 n
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));1 i- J% @7 W% q0 j# T' f
pRstPtrTollRate->Open(pcSQL,
8 I1 C9 W! A; o* ^, c; W/ u# G pLocalConnectPtr.GetInterfacePtr(),0 V, _7 E! S9 R
adOpenStatic,
d+ i% F) d& _ ?- Y adLockPessimistic,
2 I- U% i) l% {2 N adCmdText);
% }8 b. |1 v# a6 p2 u4 P if(pRstPtrTollRate->RecordCount > 0)
% z8 Z$ v# C( K \: F {
0 E6 i( H. x+ z fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
: w; g _/ Z7 a A }else fToll = -1;
& J* O2 x& S6 l$ C. {+ f ! r! e- q, d" V
pRstPtrTollRate->Close();
! v, p% X5 L( J5 H7 L& g pLocalConnectPtr->Close();% C; l: _& g9 q2 B, U1 l& ]3 a! \
m_nStatus = DB_OK;! Y$ l) q# ?* y% B& \2 U
return(fToll);) {: x0 j6 l: w7 G
}
- Z2 M" v0 S0 B7 B catch(_com_error e). Q0 Z' M C, I
{
: b1 [# U8 b! W/ A g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
5 y; x% m4 q+ {8 H8 K g_ModelPrompt.Notify();
$ {# O1 J& F7 A& H. v% t) C m_nStatus = DB_ERROR;* G) K: c2 i, k/ T& `3 l0 a% J- r
return(fToll);
; \. O( m" s# l }
. n. d! E; ?# t1 h) ?: O break;
) H" d4 G0 o- @$ O, R default:+ O' c5 r$ H$ ?" e
m_nStatus = DB_ERROR;) O+ |- a8 h5 L I
break;- g) Q/ v' J2 e# L; O. d* z
}4 w8 ^! I( Z9 C
return(fToll); 8 Q( f+ }! l: g( F5 @
} |
|