|
|
int CObserverLaneDB::InsertTollSplitWasteBook()% q6 V$ G8 Q h, y8 `
{/ X% M4 Q$ H& T) ^! _' P
_ConnectionPtr pLocalConnectPtr;! Y! J4 a1 d+ @) e' N
_RecordsetPtr pRstPtrTollRate;9 q; ?4 E( o+ A1 e4 M
_RecordsetPtr pRstPtrSplitWastebook;) r% K* X6 }$ T! r& h: E
+ S8 r& q3 h8 a2 h: T2 @
char pcSQL[300];& f. F% s# V3 Q$ P" K/ 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 ",* ~+ T1 m0 G3 O9 p+ C, R
g_ModelEntryInfo.m_PassCard.nEntryStationID,8 Q0 s. Z0 m e h0 g9 A
g_ModelEntryInfo.m_PassCard.nFlagStation1,
V0 e3 P( k M g_ModelEntryInfo.m_PassCard.nFlagStation2,
' k' @5 F- f p# v g_ModelNodeInfo.m_nStationID,
- l# p3 K8 H+ {# F g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
* |& G, U5 F/ f/ P9 F2 q g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase+ t7 o; ~4 e9 s
);
2 Q) f" w6 }9 x3 ?4 U, v3 k; X" M) Z
) N, ^# z2 Q0 Q7 p8 g1 I; p try
; K; k( b% a3 t, m+ v: x {" Q5 B: f5 E, Z, B- p( x, \* u
pLocalConnectPtr.CreateInstance(__uuidof(Connection));% V0 O$ ]1 { m
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);- G9 |+ P% u/ e1 e+ Y
) M) y' d! `/ a" t$ w
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
! M2 x& \6 w( @7 x& n pRstPtrTollRate->Open(pcSQL,) @; @2 @' B% t. x9 C
pLocalConnectPtr.GetInterfacePtr(),- M4 ^, W2 `* G# L
adOpenStatic,& O, t0 J [+ t. i2 T$ {4 P+ {4 Q0 @; T
adLockPessimistic,: Z( W4 Z. D9 g) k) u1 V
adCmdText);. P8 v7 U/ @& S
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));' `4 r/ _9 @& H* ?5 @
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),3 [; ^. }/ L; e' L$ s# q w
pLocalConnectPtr.GetInterfacePtr(),# E& B/ c0 V1 v3 k# g, Q
adOpenUnspecified,1 R. Y9 S/ [" r, X0 O- f6 E' ]
adLockPessimistic, T/ D" {# N% E8 r6 [
adCmdTable);
. L/ P! z% H6 @5 V( D G: K: w9 t, \ E( q) p! j6 K
pRstPtrTollRate->MoveFirst();
/ l* K& A8 x4 M1 V: M) G4 F: Q for(int i = 0;i<pRstPtrTollRate->RecordCount;i++). B# x3 X) k' r# c: z
{
8 G$ ]1 T/ K$ l7 G. u( C6 J* { pRstPtrSplitWastebook->AddNew();
4 ^; r& F9 ^! W9 ~7 n& J# g pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
4 x' n) p0 X9 _$ i$ u @/ u ! B* p5 V, G w' Q
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
; g: i2 G3 d c * i& ^- C7 ?8 Y+ d9 b( @
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
( y0 Z# D! d$ E; d0 u! i) a- S
; G( @6 ?3 @9 M2 N4 N pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);6 Z( J- R' k- {# z: H2 V
/ s E% G; @3 I/ A: U% c, u
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
, `) e5 w! x' N) o/ E4 i" x2 w pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;% Q3 Q; N! Y/ }8 R9 ]; K
5 v% ^( b* I( l! {+ G4 \* ] pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;
) [. n+ C4 l/ J# y2 k $ l# b: M0 ^4 C; T
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;! @5 Y/ N( S8 \/ [; }) K. e4 z" G
6 c$ h) y# V$ U- k
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
" C( J# B: a# D 6 K5 D' g/ T3 s) J' z. q) I
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);/ E. L. V- {0 d' G' w
6 z9 h% G# t; g2 W pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
8 S4 n# h; g" E( c' G
0 Z0 L, i( ?2 ~2 r' ^2 C6 ^0 d% ~ float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;; `& u4 K# G; |
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;$ g/ P; ^8 Q# Q2 i8 H: F7 w
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;& V9 F9 J. ]& \* G
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
5 I0 P% A7 v. r) Y* u' f ; Z- Z8 O y8 \% H. R, e1 C, d+ J
pRstPtrSplitWastebook->Update();
; L) g9 P2 S$ h) s8 U
: I2 Q2 H. c3 v/ {: b* V m_nTableSplitTollWasteNOCount++;
- d& }5 W$ A7 z5 C( X B5 k$ z; c. a pRstPtrTollRate->MoveNext();+ i' v' b4 v* F$ L
}
* c1 I$ g" o/ C% ^7 k& [$ t! d pRstPtrSplitWastebook->Close();% H6 f- s; J3 p0 ~+ n, T E
pRstPtrTollRate->Close();# B. @! k4 i' [+ u3 S7 Z$ L
pLocalConnectPtr->Close();
6 A9 h9 _+ n5 {$ \4 X& r+ K+ |8 Y5 J m_nStatus = DB_OK;
2 ~+ K- ?4 }1 t( Y1 e return(m_nStatus);
6 o8 C, Q5 V: H; R- F }
% l7 s3 H, _: }& [( ^ catch(_com_error e)5 n, v8 U) G z9 M
{; a) k8 A8 c7 P) b
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());2 V4 y' v" p- p5 r. f$ J) }
g_ModelPrompt.Notify();
# J+ x3 ]* u% l) H; L. ~ m_nStatus = DB_ERROR;, x. M' R- k5 C1 E7 @
return(m_nStatus);
: r+ p% @3 T9 [" b, Z- K+ ^, k } E: v# b. x" G1 k; F8 A; v; a, F
}! a8 y6 b* q* k3 f1 ^) g
d7 ~; n+ W5 S- R, Y* f& e* c- \3 o a8 b) ^
[; j' E0 f0 I
float CObserverLaneDB::GetTollRate()
% P" t. f! I" c{/ C' o" ^3 |: g$ D/ I7 Y
8 p" v1 V) V* h5 i2 [7 H _ConnectionPtr pLocalConnectPtr;) A& E% G) M- J7 B
_RecordsetPtr pRstPtrTollRate;
r; A* Z2 P1 P4 Z# N7 \ _RecordsetPtr pRstPtrOrganInfo;/ N- @* |& P8 g7 k( X
7 ?9 J4 V& \2 k
float fToll = -1;+ r3 i( i5 x0 i( B/ ~* `
char pcSQL[300];! H+ p* ?. X6 K0 z4 `0 m- q
int nSplitCount = 0;& P" j) m# X" [; J
switch(g_ModelNodeInfo.m_nNodeType)
% h; w, H% X- l; ?1 \ {8 V- o+ ^- s( p
case NODE_TYPE_ENTRY:
- ?4 B+ |0 Z# C3 U3 f return(0);/ j4 L/ \3 P( R
break;
( k# M5 i( a& Y case NODE_TYPE_EXIT:
% A- _7 `1 u9 E4 _; @( L4 R case NODE_TYPE_MAIN_LANE:- z. {* Z9 J& \" J# b7 [& Z: |
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
) U- a# H5 Q$ Q$ t; s {6 a/ s/ i. D9 s' m+ r; n
case VEHICLE_CASE_URGENT:
, T1 j( @. j4 ?8 ?6 B) o' z case VEHICLE_CASE_ILLEGAL:
8 I& i( u9 j& w; @. j case VEHICLE_CASE_OFFDUTY_ILLEGAL:& H& i; U2 [1 K7 y$ ~. f
case VEHICLE_CASE_MOTORCADE:
% h( m) w8 ~" n7 e+ \. g; H case VEHICLE_CASE_COMMUTATION_TICKET:
- @. U" D$ D& w case VEHICLE_CASE_ETC:) w7 x M+ j- ^8 n3 L" U0 \2 {
case VEHICLE_CASE_BAD_CARD:, L" H5 R/ `5 Y6 L2 v- p5 V
case VEHICLE_CASE_NO_CARD:
+ `0 u. x, A* d9 ^; [5 O sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
7 N* `7 S( g& `$ { g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
5 B& Z4 t7 l* J' c: w9 W/ j g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);! v7 s5 d. g! `5 b& ]
break;
9 }3 f: O# s3 a- L default:
! @) m/ C+ `1 ?+ @; l- l 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 a1 ~0 i7 g; \ g_ModelEntryInfo.m_PassCard.nEntryStationID,
Q: _% J# q$ o( b! R4 b4 J g_ModelEntryInfo.m_PassCard.nFlagStation1," Z9 ^! m$ x; g
g_ModelEntryInfo.m_PassCard.nFlagStation2,
* @6 m7 _: O# o$ v4 h5 @2 }7 g2 i g_ModelNodeInfo.m_nStationID,* e, o5 p/ P" m& {' _% W
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,6 a. P0 e S" p3 w. {
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
( S0 r4 u$ \. }0 N7 N break;2 J" U+ I$ m* o V1 Z. W( v' Q
}
0 O* |: z) H. ]- V3 \( C ! _0 @2 k" _4 }7 _7 h& x
try
. `3 p1 ?% ]! T2 r0 ~0 e/ q {
7 l2 i6 I9 `. l3 i5 S pLocalConnectPtr.CreateInstance(__uuidof(Connection));6 k/ i8 ~- T! _$ T
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
4 v, g3 |: u2 O- Q1 e6 X' e+ I. m* v
: y r G H7 u9 x/ Y, Q- h pRstPtrTollRate.CreateInstance(__uuidof(Recordset));2 c3 V3 j5 ^! G4 v% K, x
pRstPtrTollRate->Open(pcSQL,
/ k# a0 Y: Y% e9 Y+ r: t/ N2 Q pLocalConnectPtr.GetInterfacePtr(),2 c, f: `9 K) \2 z( g
adOpenStatic,2 S/ @$ ?/ ]9 J
adLockPessimistic,8 Y3 e' n1 U# \! R3 [" q0 T
adCmdText);; a5 p1 {# _9 Y
if(pRstPtrTollRate->RecordCount > 0)
5 }, N$ p$ R5 V4 k {& j6 |0 T- k! l% j7 u8 p. Z
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
' _. v; O. q! W if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )' i0 _/ Y! O, }" F5 t W0 V
{1 C; n0 Q- U! ]2 l, e
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
$ E- [* A; n* t2 L7 @2 v pRstPtrTollRate->MoveFirst();
" L& b$ o! @1 |; l( _7 K" q% u for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
& M1 L3 j- }( u J3 K {7 z5 D. C" b& Y+ p! T0 ^- m
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);" n, P3 m: X% ?2 S& u7 {
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset)); w% h3 f9 q9 I
pRstPtrOrganInfo->Open(pcSQL,
& I1 d" f9 h( n# m pLocalConnectPtr.GetInterfacePtr(),8 w* ?7 E, S! P- d3 Q& y& V; {
adOpenStatic,
' P0 C' O X3 n adLockPessimistic,, |/ x0 i. W$ X/ Z9 x" ?
adCmdText);2 E2 S0 W7 _/ I' I/ s! A u
nSplitCount++;
* T F/ m8 c9 i5 @7 H char pcBuf[10];
! S) W2 r s6 d$ X% q if(0 == nSplitCount%3)* y# d. T+ L. n; ?; ^ |
{
# ]# P: _6 S' a) S sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);5 E u( {' h& a
}else+ b B8 \! A" a$ [ h
{
! K$ r1 s7 l: G5 C, ~3 J5 Y8 ?9 D sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);2 L$ Y" @' t, c% ]& k1 l
}
1 ^. m) n2 A2 { S strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
4 z3 h* h3 H. F" j% c strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
# W3 u5 D& t0 |8 Y pRstPtrOrganInfo->Close();1 [5 Z1 `! u/ U o' ?/ d" @: t2 l% ]
pRstPtrTollRate->MoveNext();9 W8 A% v. C& [
}
% g; E/ ^( p( u0 O. c+ K2 ]3 n }! W' |! v9 X+ ]0 ?" {6 u/ H) q# o' Y' N
# v* s2 l+ u* c, a: h( a8 e) S }else fToll = -1;
8 U( u+ O q e! t' }$ s 1 q$ X& {$ O6 e s3 i- V
pRstPtrTollRate->Close();
! j, E; ]% p; C7 | pLocalConnectPtr->Close();
. ]9 M2 | C3 s1 x m_nStatus = DB_OK; \. [' H, o7 m0 } n( }0 r: M
return(fToll);2 ?7 s5 Q! A2 x# Y+ o8 j
}4 {+ \9 X, u; T
catch(_com_error e)
+ u& U! |& u `) s6 v. B( [ {- U3 a7 r4 b! B' f2 t
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());$ y$ H& l! i1 q* C8 W. D: ^
g_ModelPrompt.Notify();
4 e0 _5 c f! Q9 [7 ~ m_nStatus = DB_ERROR;. E" @9 k9 v- l! z; k
return(fToll); , Y) g) k+ P! n7 x* a
}- {# h/ n* x7 G8 r
, ?6 u8 J8 |; y& a: \7 B break;) U: e/ F: e @5 }( P' ?; }
case NODE_TYPE_OPEN:
% h- f" l/ j; k, U; L sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",4 p+ {) J, T( T ~$ Y: v
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
+ `( C0 T/ d( w+ j- x4 d0 F+ C y );
; y l$ ~2 i1 u! O' @, g try# p, o- }9 c& O" n
{
# N- \# S! M. o' Q8 t3 B. T- o pLocalConnectPtr.CreateInstance(__uuidof(Connection));# A0 D+ h1 b& e1 g3 P
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
: G. S5 P% Q5 Y
" N$ J& B0 ^1 N' v$ ^! \ pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
8 L) e3 [' M& O% n, D& M pRstPtrTollRate->Open(pcSQL,
: W _! K) l) O) g+ d9 y* g* o pLocalConnectPtr.GetInterfacePtr(),7 S1 C, }% D e/ D
adOpenStatic,
2 Y" G* l3 g/ W6 V9 O6 \/ V adLockPessimistic,$ `- K& N8 M: K4 F" }+ t
adCmdText);
2 F9 E5 Z9 G& Q7 y if(pRstPtrTollRate->RecordCount > 0)
$ `5 G) G3 M) p+ {; l: Q {1 ?/ \+ @: q8 j
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
# N- u, F' q. g4 b! p! j }else fToll = -1;
5 Z L% q/ H& @/ _, |4 z
6 M7 c4 ^- ^) M1 v$ l) i pRstPtrTollRate->Close();1 _3 O9 C& [4 Q# u9 l7 ?& S* k( G
pLocalConnectPtr->Close();, `2 H" H9 _4 x5 ?
m_nStatus = DB_OK;9 {8 X- J0 l1 d3 ?3 x* p
return(fToll);
1 e* G, h' M" @( W/ Q; ?9 A- j }3 Q% \1 f/ m# z7 g' X9 C
catch(_com_error e): R4 @+ g$ I# o& J) }, _3 x) O
{+ J6 R7 @9 z1 Y: _7 p2 o) v
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());: R1 V u. Q) Z: J3 {1 `/ y5 V# f: o
g_ModelPrompt.Notify();
: o% F7 Q: W4 a; P; [0 T5 e m_nStatus = DB_ERROR;4 y% P5 D7 t6 N* ?
return(fToll); ) E. R$ F" \3 R( A
}
! h- p, t1 W+ P* W/ G break;
/ W$ `$ u7 K, m! B8 a% P( F default:
. P! T T: S `; Y1 v7 m, K L m_nStatus = DB_ERROR;5 N. S. v7 C" @
break;2 s. C5 F" ~# d! f: u
}# C5 f% S$ M0 d9 M# O9 i3 M! o$ |
return(fToll);
' z t8 Z$ { k} |
|