|
|
int CObserverLaneDB::InsertTollSplitWasteBook()+ k- E# }( o; [" e! E$ n
{
4 x7 ?' q# k6 f7 G0 [ _ConnectionPtr pLocalConnectPtr;) H. q) I2 s- y4 W% `% M. {
_RecordsetPtr pRstPtrTollRate;: \6 e C/ i' ~3 Z4 s! `
_RecordsetPtr pRstPtrSplitWastebook;4 c. K b; v/ a/ Y# G
. L1 z4 f2 m( g$ c
char pcSQL[300];
Z+ R( a/ w% X8 d( d# q 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 ",' K2 J' Y# ^9 Y( `/ f6 }
g_ModelEntryInfo.m_PassCard.nEntryStationID,
9 _9 E$ M& B9 e g_ModelEntryInfo.m_PassCard.nFlagStation1,
; q- @9 }+ S d0 i1 s g_ModelEntryInfo.m_PassCard.nFlagStation2,
# ^- {5 u) A, a g_ModelNodeInfo.m_nStationID,3 }0 c9 `# ?8 ?/ I
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,; W! t$ U5 v* f1 w
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase
8 k: k, c+ V5 B0 B7 G );8 T4 `3 e! Y; e5 n
$ M& J r) {" V4 [: ^, ~$ p
try
0 u& o4 K; K2 z, B7 o$ U {
! c8 |$ p9 p4 ^$ z pLocalConnectPtr.CreateInstance(__uuidof(Connection));( c8 d+ c& T7 C2 L
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);& o+ {& O- d; Q: y4 [4 t8 V
, K& y7 p; N1 Q, M) @9 g pRstPtrTollRate.CreateInstance(__uuidof(Recordset));8 x1 x/ x" z; a* p9 t: g
pRstPtrTollRate->Open(pcSQL,
+ Z% i# g8 o8 B7 K; P3 f pLocalConnectPtr.GetInterfacePtr(),! h" A M- c: r) n2 F
adOpenStatic,5 E0 \0 K, y9 K$ v/ E/ d1 V8 g0 X
adLockPessimistic,
$ \/ h+ x* A: P! P' h h J5 w' w adCmdText);- i6 w. X0 Q3 H! o/ h+ u9 Y
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
' ]8 |4 W; E+ x, a" B5 ~. [ pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),. J" f/ ]: q! V: ]- V
pLocalConnectPtr.GetInterfacePtr(),
% R: U+ ^( M2 r( L4 I8 t$ L adOpenUnspecified,
, t" ]4 z2 n* h1 a, z adLockPessimistic,2 I+ Q& I0 l- R. G M; C
adCmdTable);9 T9 f) y6 ~4 ~4 L. H9 p) F
: n% W: @) z8 f. J; [8 X0 f& r
pRstPtrTollRate->MoveFirst();- X- m, o5 v$ a
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)" h/ V2 K% u: }/ \
{6 _& c8 r6 ^) N( ]- l) c
pRstPtrSplitWastebook->AddNew();
( C/ x. H; R. l* Q6 i7 n pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
6 O' z, O6 \9 \) m
& i; p- Y9 Q) U% \8 k pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);, g6 a4 c# J$ p; ` i+ A% w$ V( V
+ Z( h) C T6 B1 [
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
5 D* L5 W* F) A$ _1 b+ B
5 H% J9 S; w% ^6 F, X pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
$ [; E' T6 ]& O/ ~
" b2 s7 d2 u& L/ T k9 W COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
' @+ H( N: ^. p4 H; y! Q" Q* } pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;
4 b: Z, z! x" {( U6 i, d% J6 i: X : L5 G \( `; ~
pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;5 J- C* v! [7 ^1 V* _
2 M' t& [1 V) c2 U; L- @
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
9 t P+ s2 T2 d. g+ L* I! M& q 0 H3 c, Y5 v6 u! |# X! I- h
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
- f2 p. R' T: ~ u 2 _7 {1 Z3 K$ C9 U$ C* m/ X! W
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);9 C5 Q7 m! ]! [: b
+ z8 W) n& e" h7 ]: ?, R7 S/ p, W$ W0 R pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;1 O6 V: ?: g7 _/ v! O/ F+ |: t
/ b2 T4 H4 n6 W$ K$ T; j& \3 A
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;' T: T- V$ ]0 J: l# @
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;7 L1 ?0 l- w6 Z8 J& {* @; l
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;; a% n# H0 v0 g7 P0 r7 e6 D
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;5 H. _) B! u" J9 \. P, ^) C
: g$ A7 \6 I- s2 r% v$ n& C pRstPtrSplitWastebook->Update();
4 O0 v; e( }# l2 i: X
}0 w9 d! G! a m_nTableSplitTollWasteNOCount++;+ T3 m0 ^# J7 l% J/ j
pRstPtrTollRate->MoveNext();
: \& u R, N' p) H. _* [& I7 n }
& R. N2 e! F) v+ b pRstPtrSplitWastebook->Close();
! ?/ Z5 r9 N4 g: \- k' O) I& G pRstPtrTollRate->Close();' \( Z9 C/ E) T2 |, b
pLocalConnectPtr->Close();
% g; _9 d- P1 V9 {) ~ m_nStatus = DB_OK;4 @2 J& D: J x. ^- \. c$ q# C
return(m_nStatus);
P, B) a% y& Y4 A8 a/ [ }" a7 M8 N& D$ b6 F% _* }0 g
catch(_com_error e)
: E' n O3 h: Y {8 R" l* } r- E% I' S7 E3 L
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());( [6 K X3 X& l$ e L3 l
g_ModelPrompt.Notify(); 9 Z1 h; o- [2 s: J
m_nStatus = DB_ERROR;
4 A& h8 c3 h3 @/ a1 \# ^ | return(m_nStatus); 0 V0 S b2 J3 }* Q0 R
}
3 `# z' G' J5 A) S9 |( p% P0 w}
2 ^, Y0 Y8 F! {7 u6 T, i/ y/ h
( Y5 v$ j- P( a) z' W% X) Q* z6 \( H6 \2 G+ B/ s
# P9 @4 S- m; Q9 m8 Rfloat CObserverLaneDB::GetTollRate()/ E6 ]5 u G1 L6 Q1 g
{
8 ?% k. ?# K1 n$ [; T9 f8 h% ^ e% t
_ConnectionPtr pLocalConnectPtr;7 m- f* t5 Y: |1 G
_RecordsetPtr pRstPtrTollRate;
# i2 p' T/ V8 T9 ?& m _RecordsetPtr pRstPtrOrganInfo;$ s+ v8 L- Z) s
% y+ s1 m$ @% Z, J9 J9 _
float fToll = -1;5 l4 ^. D4 a6 C
char pcSQL[300];' J( U( q/ L9 C) q2 Y; V
int nSplitCount = 0;
4 l) C7 ]3 N% y3 q: e( B switch(g_ModelNodeInfo.m_nNodeType)" t3 H+ C2 C% {( \
{
- g& b& f: T- T, d) b case NODE_TYPE_ENTRY:9 _6 ]+ G9 G% X6 r
return(0);0 d! ]* w6 ~& _: L7 r& n
break;
9 l, ~7 V% }4 D1 z% x4 p8 Q case NODE_TYPE_EXIT:7 m( i4 G9 [2 t9 h. R
case NODE_TYPE_MAIN_LANE:
: e$ `$ ?. o. w- K) d switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
- n) u- y+ T. I3 V/ i0 f8 K {5 S6 [( w: s/ p9 p+ g1 C/ o
case VEHICLE_CASE_URGENT:
1 z, N( K. Q- a8 |% f5 Q+ I3 ^ case VEHICLE_CASE_ILLEGAL:4 c) [8 N& P' L# U% I, w8 G2 H' o
case VEHICLE_CASE_OFFDUTY_ILLEGAL:
1 g6 d [$ ^- s5 o case VEHICLE_CASE_MOTORCADE:
5 S0 ^0 _+ _+ w6 H5 y case VEHICLE_CASE_COMMUTATION_TICKET:
2 e; j1 ~! |7 B5 |: O case VEHICLE_CASE_ETC:0 f) u- B/ M" t) Y' u7 ~5 @. h/ d) h
case VEHICLE_CASE_BAD_CARD:% X$ o$ I/ L: k+ M2 }* Z/ M
case VEHICLE_CASE_NO_CARD:0 X+ v$ W3 @) P# G$ k
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
. B9 C' `* X( y4 M- I8 ? g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
8 x) F- W, T2 E3 S+ M* f g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
. v$ r$ E9 x3 n2 t9 ? ?/ u break;, f) b1 }9 B# b8 ?9 q" [
default:
$ r5 S) |4 C0 S6 X+ j% \4 ]$ c$ U 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 ",2 `8 g" H; p0 ` z1 a& [- M- R
g_ModelEntryInfo.m_PassCard.nEntryStationID,
, x5 i+ I, O/ r# Y" t! |. H1 k* y g_ModelEntryInfo.m_PassCard.nFlagStation1,
) I0 a0 T) h0 X- ^9 x8 f* C g_ModelEntryInfo.m_PassCard.nFlagStation2,3 ^0 Z: C: x3 K, s+ B+ d* e3 q
g_ModelNodeInfo.m_nStationID,
, w( W8 g+ C/ M: @/ h g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,4 Q9 k* B. y" ?8 l! ]" d; J8 G
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);% G% }! ~) ~$ r& ^0 n( a9 `( L+ l" E
break;
2 G& d; f1 Z8 D }2 h, Y7 _) G* Z& `: q8 Z# ?/ J
/ ]* E5 E& }8 l5 a' _) u. u try
- m. e4 [# ?- e8 }) w {: v. b3 h# [7 ?+ ^: | T+ U
pLocalConnectPtr.CreateInstance(__uuidof(Connection));% h$ S/ H# p" t2 K
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
/ Q; u5 _8 i; s2 l: k$ e& r , k+ y8 _3 w: b& H% W
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));# m. V/ G0 h% `+ x- o% c G5 k; j
pRstPtrTollRate->Open(pcSQL," f$ ^% {5 ]- R0 U( g1 o
pLocalConnectPtr.GetInterfacePtr(),
6 ?" s6 Q9 @7 C2 N" q adOpenStatic,' Y! | ~; ]& g2 i
adLockPessimistic,
! @1 s$ M& f1 e: y adCmdText);, x/ Y+ c) ^& J
if(pRstPtrTollRate->RecordCount > 0)
, s5 E9 a% j& F4 C {' M3 h, I" z; H3 {2 p) n. q* N
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;3 e( [. l7 I3 M3 K
if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
' J# m" t7 T) M' I. Z {/ n1 Q+ Q& {( k' r
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));9 P5 a* _% E. A) M" O1 C$ c
pRstPtrTollRate->MoveFirst();* s- |8 j) m$ Q; @
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
3 L5 n, ?' ]& f8 ]; |: l {( X2 Z+ }: c% U/ g
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);7 I# B- G+ ?$ a* z) X
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));. W, V t) k U4 y4 z# A# r/ x
pRstPtrOrganInfo->Open(pcSQL,
/ b9 W/ n I( B$ o' _1 | pLocalConnectPtr.GetInterfacePtr(),
0 d' G6 H T, H' n% K3 R! s adOpenStatic,
, m4 U/ x5 ^% { adLockPessimistic,9 [2 B/ l8 i! f; c0 H2 ~) W* \
adCmdText);
0 @2 S# ^4 \( E- L: R; _ d nSplitCount++;3 |2 |% K: ]+ R) K
char pcBuf[10];
; g6 P( |! [+ Q' A) m( x( l if(0 == nSplitCount%3)
6 W% V8 {+ x& h; \ {
% p( f2 n- i+ M& X- ~ sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);/ C: c8 z" n! X- c, W) \+ m: d
}else) U9 v) A! \$ K( m2 r- [
{
: u1 F3 W7 b6 z0 T, l; d/ W sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
/ D: @4 r$ K/ f }& G# v2 h! i- T$ Y" `% N& m
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
9 }7 v5 ]. T8 P+ u$ f U/ W4 D strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
; K+ l' K _, Y' I/ T/ k6 G2 ? pRstPtrOrganInfo->Close();
& |9 h* {" A8 T! l pRstPtrTollRate->MoveNext();5 D9 V/ b& }" @+ ?
}
$ ?1 G( J8 l7 w2 f/ B Z% ^* } }0 l9 \) m9 d: X
; Q3 d1 |6 E; B' k# i
}else fToll = -1;( l- U' J6 Q s5 o1 V! L. n
6 Q, J1 w0 u) t! C# v pRstPtrTollRate->Close();
( F5 t3 d3 ] Y! Q- A pLocalConnectPtr->Close();
) n u: t M, a7 ~ m_nStatus = DB_OK;
7 s- Y( V# X$ P# x return(fToll);
- V* z. @- Z- Y1 h }
& \ J: Y% v+ A# o8 L( g6 x catch(_com_error e)# c! x: @- e: b( Q
{
u2 z8 t9 V3 i g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description()); A+ l7 v% b) i7 P/ R
g_ModelPrompt.Notify(); . B! h7 D5 b5 f# H2 D
m_nStatus = DB_ERROR;2 P! i9 ^2 z* f- U' E
return(fToll); : m: V6 W1 `1 w, o9 K
}+ x5 i: X3 x* \+ ~5 @. L
. S! G6 w/ X/ Y$ Q
break;
' }! d* C; H1 C q case NODE_TYPE_OPEN:
. N- K( X7 Y5 r* m! K: ^9 R sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",
3 E5 p Y$ K# c2 G2 P g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass$ J: p) N- u, i- k v
);
/ q% k3 R9 w$ i1 j4 l: G7 j- o try W6 {' K. K/ z0 Z9 n2 a \
{, o& Z# ?: ~9 q7 u5 D& O! v
pLocalConnectPtr.CreateInstance(__uuidof(Connection));% o% v+ O2 j( w& K
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
. G& z7 q: @- Y8 Q h
% v1 s2 h0 j9 C$ z# `0 O" u$ M) K; z. t pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
z4 w i( n- u2 j pRstPtrTollRate->Open(pcSQL,
: B" Y! l* S& w pLocalConnectPtr.GetInterfacePtr(),2 j& F& V$ s8 }: ~8 \7 m
adOpenStatic,1 s2 P5 V- W8 G6 g' ?0 r
adLockPessimistic,
0 Z+ K6 t6 C$ H/ ?5 q adCmdText);
! F4 H! H4 d5 Q" `' f' J2 P if(pRstPtrTollRate->RecordCount > 0)
) X0 `0 \0 K& w1 g {5 k8 X3 w( @1 k- H4 s: B
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
8 u9 z, L6 c/ A }else fToll = -1;
& e8 a0 G8 `$ C1 |! Y' E
( M. K/ }3 J% g n8 V; [" G pRstPtrTollRate->Close();( r/ k6 H% C& S
pLocalConnectPtr->Close();
% E4 I3 ]1 h0 r! g8 C9 V m_nStatus = DB_OK;' d3 L9 ^- G8 T6 ^) L- {1 q
return(fToll);- a+ L: l" j% q' N4 {# e
}2 b( Q( C+ i' s- V1 K$ a
catch(_com_error e)5 V" N: X0 m, m5 m( P5 ^( d
{
) Y: X1 o- n: T) @. h* S+ w: V0 t. Y g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
+ ^& x/ C" C O" u' n g_ModelPrompt.Notify();
' Q' A2 L& Q: M. I3 ?# | m_nStatus = DB_ERROR;
# S8 g4 V) t" N$ c( l return(fToll); 8 V# Q0 N9 ?. D1 d0 N
}
: Z& I3 _# v8 b& f break;
) \& N# K; ^) X& O4 Q default:
& C- ?5 _' ^! @ m_nStatus = DB_ERROR;% N* p) k2 e8 L$ S, L/ n: q
break;0 J1 p* U, v+ D7 \4 }9 ^/ N! m
}
7 W4 U: v+ u7 j& z( k( q. `' t return(fToll); ' i# F% I9 O$ }* _
} |
|