|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
) _- }5 l( [8 e; f" Z{2 j, U+ v$ ?) H: ~3 p1 @
_ConnectionPtr pLocalConnectPtr;9 @4 J) ~5 |- l* a2 \2 e9 [( F
_RecordsetPtr pRstPtrTollRate;9 J, b0 j9 `; k3 H
_RecordsetPtr pRstPtrSplitWastebook;7 @. ^8 F* k0 G
, s8 j& a4 I3 E) ]2 j8 V
char pcSQL[300];
. o! |0 R% P# q' ?" n1 i. ~% v 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 ",8 \8 Q( v# |- h' f$ c* w
g_ModelEntryInfo.m_PassCard.nEntryStationID," q- t$ r4 Q m. U6 R
g_ModelEntryInfo.m_PassCard.nFlagStation1,; m4 M7 P1 J5 F% o
g_ModelEntryInfo.m_PassCard.nFlagStation2,
% L! w, L* C$ Y( i g_ModelNodeInfo.m_nStationID,$ ~# a$ V) L6 l) z
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
; Z/ G% S. L6 o. E g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase7 m1 {8 u9 T% `* l
);
8 r4 o8 r' J1 B+ P3 r) d1 ^& j& F1 e. \* `
try
, K' G# q( t; y$ n4 s) ]3 } {
% @' ^8 a, k c& ~. W pLocalConnectPtr.CreateInstance(__uuidof(Connection));
( Z4 k. Z/ W4 ]; s; n3 _3 c pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
$ F5 t6 [/ p3 T! |! } ) C: t5 Y7 X* [1 u! L
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));. t6 M [2 g# ~8 }! [# p
pRstPtrTollRate->Open(pcSQL," ]$ H4 T% o' a4 b% ]% i8 r' C) J" x S
pLocalConnectPtr.GetInterfacePtr(),
, d: f j' a3 n adOpenStatic,4 ?7 i7 \; L; ~
adLockPessimistic, q. o6 N# o0 O& n7 O
adCmdText);
9 ?' T7 V' ~6 ?' k) R' Q5 n pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));6 r5 A- z, c3 G: S: @1 S
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),! _; d" t. L! }) r, N, H* h
pLocalConnectPtr.GetInterfacePtr(),
$ p; G. L! E/ q5 C( C adOpenUnspecified,
: U) G, I& ]. H8 O adLockPessimistic,
' o) b0 r3 m! g# i# M adCmdTable);( l+ _ w) x& X7 M. ` s' t, i& u
% [& |+ J+ U5 L pRstPtrTollRate->MoveFirst();
. F, M: A G( {. k: l for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)4 [: {7 {1 w! J4 ]( M7 B, m) j
{" j4 U3 ^9 \8 c# \- R( R% Q) h; b
pRstPtrSplitWastebook->AddNew();
4 d$ i, p' R5 a/ k: } pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
- _; H1 e/ w; R: N2 Z* g! H# C3 h
4 d% ?4 R# e1 P) E5 q pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);7 @! U5 ^; K8 |( X
/ T5 N. V3 Q1 o2 F pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);; M6 f" Z e( q8 ^9 ~7 u
7 F5 [. V; `- p9 F3 u& A
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);0 U9 X$ D: N% O4 q
' X+ }8 I% H8 f- b2 D COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
. D% y% f( U7 H8 K, @5 Z pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;2 K5 x, [9 `; Y) I, w% J# r
h4 B/ l9 E. f$ \$ U; n" h' H pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;% {* M3 q9 c; f1 o2 h) x9 V
( r4 J& i! w: p7 r B& o
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;/ S- ?2 S U( {. Y Z; M* O( B
$ M7 t) t1 F0 U* B; s8 J) R4 V% P! P pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
6 x/ x% h! A) W5 @0 ~2 Z& V
8 P3 _# b8 F6 h2 D; y/ w G, m A pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);! K+ y- M& b- v9 [
- a1 z+ q e3 S2 k' a$ `
pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;9 u6 N/ @) U( a3 i5 O
; {. g( [8 }; e( F/ f) s float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;
! L1 p+ W1 T7 x. H( g5 J l5 Z) u" i float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;1 Z. b+ i# u" S) t& E3 F% ]9 s
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
3 Q. H0 f8 q' E' n, w- s, @ pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
% [: r `5 e1 a0 t; ?; i5 v
4 ?5 a; ^5 C M6 H$ c pRstPtrSplitWastebook->Update(); * \7 { h3 y5 T
% h) z# Y a+ b% \; K m_nTableSplitTollWasteNOCount++;& N7 U# H* X/ C }, ]
pRstPtrTollRate->MoveNext();2 o, ^- ]# u8 ~; j X
}
/ m0 _! J/ S0 i, P0 z pRstPtrSplitWastebook->Close();
V/ i8 _, G* q2 e- s; B' C pRstPtrTollRate->Close();
7 ]( v! M3 s I% ~9 @ pLocalConnectPtr->Close();8 Y6 T) g0 {: R, z! }; v) ?
m_nStatus = DB_OK;
. ?6 N2 s2 V% c, F* @( ^ return(m_nStatus); 0 t$ ~' A) h' q5 ?4 K4 J; C
}( b- X* y1 y* _" |2 |
catch(_com_error e)
& c1 ~1 R) V7 l2 Z) q# p9 R {! t4 s2 k# ?$ z& @3 x
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
2 u7 o) K, e, g& T. R$ s" y g_ModelPrompt.Notify(); 7 ^3 Z3 W* C9 y" m
m_nStatus = DB_ERROR;+ I% _4 m: x7 R2 E
return(m_nStatus); 4 g' ]0 B7 e/ u# o
}
; B& @' T7 V9 c$ B( f( V& N}
8 I) g8 T+ T4 v
' }% T! B$ o# d" X% `, o6 o/ t
( e8 [; F, h: N0 \8 c& q/ i# C5 J* g: ]7 g# J
float CObserverLaneDB::GetTollRate()1 P' G1 q- u% I/ `7 u5 y
{/ N0 O# v8 L* X( ~& H$ L7 T8 c1 Z
" x& `; n- w/ y5 X- o: h
_ConnectionPtr pLocalConnectPtr;
& R! }* t% H! H3 p; |4 q0 j _RecordsetPtr pRstPtrTollRate;9 c, k0 k4 g, B4 |5 C2 z" Z
_RecordsetPtr pRstPtrOrganInfo;7 g* y$ u& c. V7 S# y
) {/ @( Q. i& w7 V; K A
float fToll = -1;
6 o. E! b5 _3 Q: p5 i char pcSQL[300];
4 j1 {; g }7 J int nSplitCount = 0;( H5 t' c7 S5 y
switch(g_ModelNodeInfo.m_nNodeType)
+ y1 A* X; F7 w {
$ d) Q4 t. R; v3 v) c+ r case NODE_TYPE_ENTRY:
8 _6 l# _0 H# Y h \' T$ c, a* B return(0);$ F2 W9 X4 W4 S7 r! @. ~. n9 t
break;' C+ l& f! a) T
case NODE_TYPE_EXIT:
! t& |1 J. S0 H- B case NODE_TYPE_MAIN_LANE:. B, V" n3 T8 s# a g+ _
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)7 I3 b2 n9 u6 z+ k: S
{6 ~- d" O' \2 W" i" P) o
case VEHICLE_CASE_URGENT:- j- B; f2 Q5 e! H$ E- g
case VEHICLE_CASE_ILLEGAL:2 h+ B) k B! d; a/ R9 |5 E! w
case VEHICLE_CASE_OFFDUTY_ILLEGAL:; Y3 i( l/ b. o, y% _
case VEHICLE_CASE_MOTORCADE:
. [6 N5 k8 I7 r) ^ case VEHICLE_CASE_COMMUTATION_TICKET:
* k d I. ?2 j7 k9 G case VEHICLE_CASE_ETC:
5 }0 B/ q* a7 W& M. _ case VEHICLE_CASE_BAD_CARD:
7 i3 C; n5 a0 D5 a; E# ]' @ case VEHICLE_CASE_NO_CARD:
; C1 p- P3 J9 m3 H$ N/ E sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
6 U7 C( D6 D# v4 F* v* G6 K g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
$ R, A+ v8 q" Y8 o# a g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);9 c W* c: z8 g6 W1 g8 ^0 D, t
break;
# D% J! W3 o# }0 c2 q$ U default:
1 Z/ {" U K6 P8 c4 C7 J6 y 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 ",+ A1 y, R( G/ t2 F: _
g_ModelEntryInfo.m_PassCard.nEntryStationID,
& i3 j/ s( ]8 n+ I+ T g_ModelEntryInfo.m_PassCard.nFlagStation1,
. n+ M6 A* ?0 w; S1 A6 u' ` g_ModelEntryInfo.m_PassCard.nFlagStation2,3 |6 Y8 S2 K- U$ G: l, x4 ?" ~+ h% Y
g_ModelNodeInfo.m_nStationID,
- O9 J3 `- G- Z g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
9 F- y9 b: i& `* R6 M9 |) ~ g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
% h" T- U: b1 N2 o% m# v, O break;
' O$ R) Q6 D4 q% v8 A& { }
5 Q& a4 Q, `2 w' ?
7 ?7 c. m( O0 o6 j try, p3 n; `( W8 p; y& O
{, X$ q! G w+ v# S" y
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
x ^# H0 S' h/ b pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
! u* ^1 o/ u4 U" D5 P F7 I$ v
+ e9 ~! t8 S) B8 s, z! [" Y8 D pRstPtrTollRate.CreateInstance(__uuidof(Recordset));8 i3 N: X2 n( J, ?) r# R7 v
pRstPtrTollRate->Open(pcSQL,
# J j/ B7 m% q: y% e5 Q9 [ pLocalConnectPtr.GetInterfacePtr(),4 o* \+ x. x8 d
adOpenStatic,
- [! q, _% R- o8 S- } adLockPessimistic,
Q& n: p4 \4 X adCmdText);+ ^0 {' O$ Y3 T k% ~
if(pRstPtrTollRate->RecordCount > 0)
9 d9 J* y; i% F, W" N2 C {& v0 U$ g, G# i" K5 |, ]% t
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;1 s) n( r5 H) k/ k9 P" L( C: r: s
if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )1 Q$ P7 N( k4 h" L+ |# t
{8 f' N- k& d2 _3 Z% h2 X0 ?2 ~
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
. ^$ N8 F3 P, ], z( j$ H6 J8 o pRstPtrTollRate->MoveFirst();% Q, D- @1 _ x4 `5 C, {4 Q
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
2 K) v0 u% Z+ L# p& J- r {
9 E$ S& k/ m4 D$ i sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
1 A, U7 f- L# R$ h# @5 H pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));' c$ \ A+ a; d+ U+ B& V8 ^+ j1 B+ F
pRstPtrOrganInfo->Open(pcSQL,: H3 R* a( N. ]1 K
pLocalConnectPtr.GetInterfacePtr(),
; R: G/ |: W7 ~/ G% ` adOpenStatic,
3 T1 f3 d7 |9 o# q4 G' y adLockPessimistic,
6 H# _6 w) M$ z, @4 Q adCmdText);6 ]/ E9 \) c# e) D4 {+ M
nSplitCount++;
0 ^# }+ R- `8 H3 ?& U char pcBuf[10];) a$ [ T5 h1 `2 K% Q4 Z v
if(0 == nSplitCount%3)
/ y* R3 ~, {: l! M' n8 N- K { ?7 M/ z _0 V: ?7 W2 w
sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
$ M7 W) Q) s7 y% v }else
; C7 h5 M& ^) g: [) p4 s {
% B& b) u' y: k& R sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);4 X' J8 a! W4 s# F7 `$ V; Q3 I" E( I
}
3 G6 D7 j, I Y s$ d strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);) O6 s9 ^ d& f- t$ K+ m) e4 K
strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
* ?9 j! [# a4 E pRstPtrOrganInfo->Close();
! |) V( w3 H' G: `0 {3 o pRstPtrTollRate->MoveNext();
9 X6 x: j& \4 i! Q }7 H" i8 V, _: z; ?- k' n3 p( w
}# c/ }' g7 Q9 y
9 O2 s) `: F+ g8 N0 T! ?' j
}else fToll = -1;+ j ~3 ] H; @$ q% F4 T, W
, l# H6 E6 X8 G; Q/ A1 P pRstPtrTollRate->Close();
- c6 F1 `# J7 L* f* K' p pLocalConnectPtr->Close();7 D- `4 Q& P. u& D. ^
m_nStatus = DB_OK;! w) f2 K& E/ `3 D4 L
return(fToll);$ i1 V' B9 Y9 }, z k$ u
}
/ M) j1 @: s1 a- N' N- I1 A% F catch(_com_error e)
0 D' S' @2 P- r$ z$ i5 P {
! x) d* s( C: |2 D9 D g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
! \2 w& O5 k& ]' z! ? g_ModelPrompt.Notify();
9 j/ `) ?) z; i& O- {7 T m_nStatus = DB_ERROR;8 C+ Y1 W! ^5 x* [7 A
return(fToll); : I8 @0 d/ P! f
}3 C' A2 t* t/ X- S5 L
% W+ d* y0 j6 Z$ q9 r J break;
& H. x! D& a( f: c3 R case NODE_TYPE_OPEN:
8 G% s" z! E/ Y6 U0 B! H sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",9 w+ a/ o5 N/ }; K2 @
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
! F' n/ `$ q# k" O );. c1 N) ]5 D. ]) D9 f: ~8 Q
try5 g3 [, Y' e W% }
{
H! ~+ [: k3 |/ w# R pLocalConnectPtr.CreateInstance(__uuidof(Connection));1 x1 k! [3 c3 J
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);5 A3 J* I, _4 A$ h: p4 T
, l' p6 V* q; |" `$ f. c+ R b pRstPtrTollRate.CreateInstance(__uuidof(Recordset));; |8 f. h7 M* A
pRstPtrTollRate->Open(pcSQL,5 }6 W2 \. p1 m
pLocalConnectPtr.GetInterfacePtr(),2 T" Q, R0 |5 s f8 w) W' w
adOpenStatic,
' e- j3 X- T% W4 _* l! | adLockPessimistic,: U2 V# ^ _: e7 L+ s/ Q
adCmdText);+ `* c) g* v3 H
if(pRstPtrTollRate->RecordCount > 0)
; d) _0 R* }, ]- D {
8 H' I! U) L* n3 N3 R K fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;& f ~, y/ t0 h. v) h
}else fToll = -1;1 l1 n" J% H4 m' `- y5 c
0 a* U7 ~# j1 ?8 L2 ?! f pRstPtrTollRate->Close();2 C# Z( H3 \/ u. d5 L' n2 ]' R
pLocalConnectPtr->Close();
$ W) T& C( v+ U B% [1 y6 } m_nStatus = DB_OK;+ `$ N _- ~9 K! }8 K# g
return(fToll);; A+ F; R# q) M2 `/ z5 g9 R
}& {. K8 X9 W+ y( ^
catch(_com_error e)+ l- r) O& |# G$ W. h7 ~ X- }
{
' Q3 V% Z/ M1 t8 `3 F3 A, o g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
5 m0 I" X9 R+ _$ m" v g_ModelPrompt.Notify();
) @0 y; X- P( a5 K: H m_nStatus = DB_ERROR;2 t2 N5 l+ B# J2 E3 m8 Z* Y& x
return(fToll);
/ n" D# m) T" P( T9 ? }
3 c) @; ^2 w7 n& ] break;6 V/ m8 n" H R2 ]1 B+ W
default:/ N7 C7 w: j4 J0 {. \$ P
m_nStatus = DB_ERROR;2 ?: S$ J/ |: Q) M: T+ X
break;
, p4 q8 f, V* g7 i }
* a1 \+ U& t# S' Z return(fToll);
8 j# p) V% t8 z/ D1 Y" z0 n% K( N} |
|