|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
& W' h: z! f) a. W4 U; S{6 W2 {: V1 p8 t
_ConnectionPtr pLocalConnectPtr;
( Q8 z7 N, n! n% t. W# [ _RecordsetPtr pRstPtrTollRate;( r6 r4 k* O4 s, u+ P0 r* ?
_RecordsetPtr pRstPtrSplitWastebook; W" y' Q+ P7 f' `/ H9 d
$ s. m% D; ?0 x0 [
char pcSQL[300];
7 v) k) m! y' R: ]4 F2 ] 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 ",- V2 q$ {9 |# @5 `' ?5 W+ M$ p, S
g_ModelEntryInfo.m_PassCard.nEntryStationID,5 j$ m6 X1 ^9 i7 p1 v3 N
g_ModelEntryInfo.m_PassCard.nFlagStation1,, m5 ~# h: L1 O
g_ModelEntryInfo.m_PassCard.nFlagStation2,5 e! Z9 d) x8 V# [8 b
g_ModelNodeInfo.m_nStationID,/ b" |( d a* g0 a* ]- o- k3 V
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,+ H- G0 ~3 U! p5 `- P
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase
' ~1 I5 d/ K2 [' z );
5 a! y+ c: r* W8 J: X3 w/ k' o& f% b/ H) V0 q( D
try1 O9 q; j9 c) u+ a5 H! e/ A
{
4 C8 B L( q1 y( C; Y pLocalConnectPtr.CreateInstance(__uuidof(Connection));. O- {+ Q' z: h0 H
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);* X' G1 g- n' F2 k4 K
6 n( y# N+ z) f9 d% q
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));$ Y' P: ?0 k3 h5 E1 Y2 N: m& V5 B# s) b
pRstPtrTollRate->Open(pcSQL,. U, b/ {7 e- i# q/ L
pLocalConnectPtr.GetInterfacePtr(),
2 b+ \; I- v3 X' b adOpenStatic,: d- g- D% c3 b
adLockPessimistic,- W1 o- f3 M K5 X: s5 _' _" G
adCmdText);
% M2 L6 w# a. T0 J3 ]: Q pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));- l3 Z* r" J& V) q8 ]& B- B9 D/ U! w9 w
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),
1 o* M" V$ w" ~$ q' {, m7 \0 B* [: g pLocalConnectPtr.GetInterfacePtr(),
; b5 o3 \9 j# |8 i& A; I adOpenUnspecified,6 X' b$ \8 x1 b, F* J0 O4 ?; [! |
adLockPessimistic,$ J" c) s" u2 Q5 Q7 K- P
adCmdTable);7 J V$ a* D- W8 ?0 R6 q9 |8 C
4 p @" g. P" c3 \( R% Z) f
pRstPtrTollRate->MoveFirst();
o4 y7 y7 H% N1 s for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
w0 m* u! L' i4 r( @ {# c) y$ T& S3 A& V/ b. a
pRstPtrSplitWastebook->AddNew();
% g# W; r n( [7 h4 w pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
% o1 N: X! z% n* N r
' H" W6 T7 a1 s! D/ k4 d pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
2 H( U; X' ]5 F+ J' p' r
: `7 d, l0 k x4 b6 [/ M" ~$ V pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);$ ^2 g( Z9 @+ m
, A' G. y2 D, Z# [. @% S
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);$ u% E3 p5 \0 ?4 [
9 A6 h8 `5 H, L: k COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
: Q& ]- {, v$ C- e) x1 R( P3 r pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;
: q% k6 p" u4 ], I3 ]
/ P! y0 [9 O- n$ a( V pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;+ m+ ]/ Q% [$ m$ ? K6 \# S a
$ C1 n0 E% C' { pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;; x; q4 z2 r# o) i& W
$ H5 H0 c0 s3 e }
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
* e6 z P( `) x5 U6 Z* [) e- }" q
) h {) i' u7 U1 i pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);
& U+ @5 W( e3 h/ L ?0 @
3 N* V( S8 g! N; o4 O( ?% t! p pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;" u, T/ C! T. s
8 V' v/ A! f) I' }7 v+ G float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;
0 O2 X$ i: {( r* \8 h float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;( c% I4 S6 S6 H8 v% U$ \
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
( |4 I3 k, R( u" b5 K' E3 R2 I0 [) t pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
% R/ ^% |& e0 L) Y: X3 J- V. K
& \' t: m0 b* A1 C3 f# Z pRstPtrSplitWastebook->Update(); 7 ]1 @ e6 [6 `' R8 G: O
# Y3 r/ U7 S- B e2 V {
m_nTableSplitTollWasteNOCount++;% G L/ Q6 b; f- t+ c" J
pRstPtrTollRate->MoveNext();' @: P% g. {3 C* y
}
; z: r. h% }: D+ ~) H/ |! z! ~ pRstPtrSplitWastebook->Close();, m0 n- s4 w4 W* J
pRstPtrTollRate->Close();: E. D6 S6 Z2 P! T* a1 h' S& H
pLocalConnectPtr->Close();% r9 d( Z% U8 |% D
m_nStatus = DB_OK;
6 E, O+ P! P" Q3 P% b return(m_nStatus);
% s4 c# \4 @' Z% R* L2 O% v5 x }+ U. o/ L% i( }0 F5 K+ G; E
catch(_com_error e)
0 q9 @2 {8 O- g! n- m+ R7 h Q3 I/ } {8 @1 D' R A0 V' c5 \
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());" Z4 F+ P8 W8 O6 C
g_ModelPrompt.Notify();
" V# M# R/ O+ S# E! h6 `2 ^2 K- Q m_nStatus = DB_ERROR;
7 E- |0 R/ G: Q: N0 S7 O& g- ^ return(m_nStatus); 6 x5 i: ~3 ^, S8 Z
}; j6 T! d7 y3 Z, z& c5 ?
}* l" o2 |& x# n8 w6 h! r0 O5 F
. L. K z* g+ ]7 @8 m0 `0 }/ v9 l2 {, N$ {3 a6 l
3 a2 t' C& W4 k# F8 {0 q' ^
float CObserverLaneDB::GetTollRate()
9 a# C1 w# G/ g. P: x# C{* ^& _; }; n% E. Q+ r; n
% D7 B. I1 _0 h* K _ConnectionPtr pLocalConnectPtr;
6 W0 ~# a7 _8 N _RecordsetPtr pRstPtrTollRate;5 B8 h/ \) A0 h
_RecordsetPtr pRstPtrOrganInfo;" c- O+ q; X$ Z
% H( a F9 n, O9 X K7 \! M0 ] float fToll = -1;/ d% C/ E. g, m
char pcSQL[300];
1 ?$ L s8 `; `4 v) z: k2 o1 s/ f int nSplitCount = 0;% s0 K! m2 G+ j' ^2 B
switch(g_ModelNodeInfo.m_nNodeType)
( u* y- f: x7 y1 p4 v0 n% T/ S5 ? {
3 l6 x J8 l) y* m* D. a& Q case NODE_TYPE_ENTRY:
6 m x: l7 Y8 u return(0);
& \) Z! E: f; z/ r% G- i; X break;3 Y! n4 A7 H2 d4 W
case NODE_TYPE_EXIT:
# u1 v' x: v6 D9 Y case NODE_TYPE_MAIN_LANE:
: L. z- o9 a8 ?; u( e switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)1 j$ T: d* `# G: B
{- }% q5 v- B( R1 F; q( O( w: W
case VEHICLE_CASE_URGENT:+ l% A" r) S; L( I- ^
case VEHICLE_CASE_ILLEGAL:3 U) C- }" x/ w `, H0 j$ G
case VEHICLE_CASE_OFFDUTY_ILLEGAL: l- X5 f u6 p2 z. ?! Z& ?8 o
case VEHICLE_CASE_MOTORCADE:3 W; `( G* M5 b, W; P
case VEHICLE_CASE_COMMUTATION_TICKET:
: n. S/ x, V* V3 t8 \: g+ L case VEHICLE_CASE_ETC:
, W4 h6 U, U ? ]$ _8 K* Z2 \* q( r case VEHICLE_CASE_BAD_CARD:# J3 {& {! w& |, t
case VEHICLE_CASE_NO_CARD:
" P/ s: K4 x: X; I* k+ N, H sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",6 m! E/ B& e- }5 `/ P% G
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,! {1 [+ |; I' e. i1 n) B
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
) t4 `! _7 z) `! p' | break;5 }$ K8 z1 J4 ~1 V, }! D
default:
- @3 h7 K6 L7 U) p+ e# ? 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 ",
4 u% Z9 C* m6 ? g_ModelEntryInfo.m_PassCard.nEntryStationID,4 ^+ T6 ~7 D4 A6 T' [& Z% q+ m. j
g_ModelEntryInfo.m_PassCard.nFlagStation1,
# r% T0 t; d# d+ i$ ? g_ModelEntryInfo.m_PassCard.nFlagStation2,
+ ^1 L3 F: e& ?6 w L* F/ T% m g_ModelNodeInfo.m_nStationID,
_& l. V0 C7 K l' w) Z' h g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,! t; `" H& j1 z. p- C( }
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);$ P8 |6 U* [, Z+ {7 o6 ~2 @+ n
break;
; ~! K) Q3 }7 q! p: ]. D1 y }2 p( P, i- f. T
% [7 [9 ]+ @1 L- u" s* ]
try
$ }( \$ r6 ?9 @4 Y {
' P+ G0 N C! U _1 M% @ pLocalConnectPtr.CreateInstance(__uuidof(Connection));
9 x! V: J/ F v5 u pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
& O4 `" h5 \% n # i H' i2 w/ u- N( C8 Q
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
0 ]9 l7 S) s9 r1 W pRstPtrTollRate->Open(pcSQL,1 `; t0 g& k+ t
pLocalConnectPtr.GetInterfacePtr(),
$ G1 {. t+ @/ L6 l& |# R. h# C adOpenStatic,
2 D& a% a& o3 ?$ m- d4 U \6 o adLockPessimistic,$ _4 J; R6 ]& q, k, Q. ~0 c
adCmdText);" l8 m; u0 @( E& a. Z8 h
if(pRstPtrTollRate->RecordCount > 0)" V4 P" h1 O2 W F5 S3 ^
{! I+ c9 Z7 R) a7 J
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;/ V) O: H8 j- Q& |9 }
if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
% G: U- j- H( j/ a {, S1 N ^- k( F! d; ^- i- e7 c
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));5 K0 p) l0 Q- U: i$ H
pRstPtrTollRate->MoveFirst();
' E+ F) ^% y& D1 `+ s# d0 t& W/ ] for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)* T; O. W U d
{
3 w% b6 ?8 ~0 E/ n8 P1 p% A sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);* A5 v" c. [* C
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));
- H, u V8 p# ]' M8 h! w pRstPtrOrganInfo->Open(pcSQL,- U4 A8 O8 {$ E7 L7 t$ g- R# z
pLocalConnectPtr.GetInterfacePtr(),
, E) B8 }! E* b% u" { Z adOpenStatic,; |/ |( V* Q2 T# T
adLockPessimistic,
3 x& A$ b+ B; ^7 n* s" d9 Y! _ adCmdText);% H) E; W1 J1 u0 Q, B$ f( E5 M
nSplitCount++;2 U, J/ N8 u9 E- q. x0 O
char pcBuf[10];
2 z& P' \ x" J5 \( o if(0 == nSplitCount%3)) i6 s0 _$ w: S- {0 `
{5 P; M7 ~) q4 B$ {
sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);, S7 C$ C1 u" |8 ]( ~5 M
}else
4 j9 R; F' g$ I9 e {! d9 r- } A$ w, F- {# |5 V
sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);2 g+ S& o8 q7 k# A) B, [. q# A4 @* {
}) u$ b, [/ g- f% n$ r
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);( q- l- ?& ]! ~9 o9 n
strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);; r: F8 E$ {( h4 }& M
pRstPtrOrganInfo->Close();
/ h) c. v- \( h4 k6 v8 H pRstPtrTollRate->MoveNext();
! j1 d! E2 D% ?( y* S6 w }7 x- s; l& m9 a l9 Z9 ~
}+ z& ^6 k) V3 m: q
4 n; `' q2 c' r3 Y9 b }else fToll = -1;
! H% `$ a. E" J2 I, ^7 V
: M; S5 d8 i3 \ pRstPtrTollRate->Close();8 S7 @/ D8 s) {
pLocalConnectPtr->Close();" }, k6 Q# P+ C1 O
m_nStatus = DB_OK;
3 Y) u! Z" o" r; D3 K" E/ ^6 K return(fToll);
" H$ x6 p+ i( @/ r: R5 J8 ^ }8 s# M& S- q4 G
catch(_com_error e)
: Z% u _3 a6 v* P4 _' j {0 m: ~. A" c9 n- h( d( Z3 f- m/ }
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
! q3 j* k8 O5 A: w4 R! I* v5 X; C g_ModelPrompt.Notify();
- X a( f/ q1 Y3 q) `8 R m_nStatus = DB_ERROR;
& U o7 o! Y; H" N5 I return(fToll);
1 A* D& P7 f5 W" r0 L! R }
. T, `2 B6 B+ P9 Y+ k
$ G# b3 O9 X# Z; p0 S0 N* M break;. R! v: n* P) {
case NODE_TYPE_OPEN:
, u$ r% o% Y0 v% e) o0 H8 j sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",- c+ }( q9 y/ M
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass) f' w s" P* L3 L/ m \
);
. ^. Z) K0 ~ A* A* g/ D try# S- {2 u4 S0 b1 N* v
{
) a- N8 x# d$ Q pLocalConnectPtr.CreateInstance(__uuidof(Connection));( M7 y: @* _* y5 ~
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
]9 R7 \9 a8 d8 F/ }
9 l7 D7 v4 t7 H+ o/ w `% F0 j pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
' e4 \7 x; t& b! g pRstPtrTollRate->Open(pcSQL,' T% f {& S9 Y) N! h; z
pLocalConnectPtr.GetInterfacePtr(),
A- p# w2 `' e) q' V$ G( N adOpenStatic,- D0 F% X6 T5 U+ h: j
adLockPessimistic,0 G$ p' F0 F& e3 S R: k
adCmdText);
. e* `! y) `/ K6 w if(pRstPtrTollRate->RecordCount > 0)
& n9 H& L( u: A* h' C1 x$ ]% m$ J {2 U) U5 X7 d4 O- v' a
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;7 }7 R2 {+ F* i1 Q3 v0 R& _: Z
}else fToll = -1;: ]8 U1 I, f. @0 h- J# c* t$ z
. U t2 e8 W4 ~& u- V5 y pRstPtrTollRate->Close();
$ t& \2 z# ]3 D K pLocalConnectPtr->Close();6 |3 r9 w7 ~! [ v" S0 X
m_nStatus = DB_OK;2 W$ N8 Y4 N ?, m1 L
return(fToll);. g8 g3 f# L' u* }/ G. R/ ^
}
7 a- J8 C U6 \8 r/ D% U$ M. H catch(_com_error e)6 e! p9 ? Y. F' f- x9 }
{
' N- \ e* N- T+ }- s* a. ~# `+ F g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
% Y" X( N$ g+ S; c0 s7 Z4 [ g_ModelPrompt.Notify(); o3 h; G) O& l, q
m_nStatus = DB_ERROR;) ^! F+ A Q, W" [7 F; u
return(fToll);
8 u/ M, B- a( c9 |: t* u }
% `. o' M5 s; A break;5 I2 @1 \: m- R( p6 {7 Z7 m
default:
. h! o* w: T. G& B' y: ~ m_nStatus = DB_ERROR;
. u7 d" I# H' w: }6 z; m) T break;
! y# X9 t9 f( }8 D5 p }% Q( T3 U0 G, c+ N6 E4 b2 ?
return(fToll);
% i/ y. M- Y4 P V0 L} |
|