|
int CObserverLaneDB::InsertTollSplitWasteBook()9 ~! v, E- j+ l3 a. {' Q1 U+ \
{# x ~$ d- t s
_ConnectionPtr pLocalConnectPtr;
2 X: w( h% W4 |! c' [ _RecordsetPtr pRstPtrTollRate;3 J' w* V& o6 C) u# K
_RecordsetPtr pRstPtrSplitWastebook;! |# f$ L ^: W' z
5 {$ k3 y7 x, x6 v- ^5 T+ |3 Y
char pcSQL[300];" I/ n1 f- T' m
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 ",
- I6 w$ ~$ H* @" R! w g_ModelEntryInfo.m_PassCard.nEntryStationID,/ y) q3 \# E* H3 w+ I) p
g_ModelEntryInfo.m_PassCard.nFlagStation1,
- M% B& {) f4 Q$ {5 z' ] g_ModelEntryInfo.m_PassCard.nFlagStation2,
+ }/ s! k9 V; Z) V' o: f. K9 y g_ModelNodeInfo.m_nStationID,4 [; I3 |9 g# `! u4 Y
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
% u' ?* U# i0 Y: y j! F$ Z& x g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase! k+ T& C* H q$ r; T4 o n7 R8 H o0 R. D
);2 X/ g" T- E+ @7 x h
* [! p8 `$ h# }/ m1 Y% Y+ w
try
4 C, X% Y0 T4 m! r' G! \ {
( M6 g+ l9 T& \: K pLocalConnectPtr.CreateInstance(__uuidof(Connection));
+ R, J/ [4 W+ H8 j pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);8 d# R/ U$ R4 x; P3 K M
! W {2 \8 m( V: L2 A0 z8 Y- ~
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
! \3 f1 N. l9 t( ~& [" V% Y pRstPtrTollRate->Open(pcSQL,
( A0 I" ?$ J1 v9 A2 R7 @+ z( X pLocalConnectPtr.GetInterfacePtr(),/ c2 b) `- o( v. z3 Q/ f7 {" B/ a
adOpenStatic,
) X' p) f9 ]. C adLockPessimistic,
! V8 j8 Q; | C# L6 }( R& _ adCmdText);
2 r; w6 Q( S3 @& @/ T pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
3 Y* p# e$ m( t pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),$ ?- k5 s" @# Q# a$ i; B# z( ]4 A
pLocalConnectPtr.GetInterfacePtr(),
8 i: Q' x$ M3 |( ` adOpenUnspecified,) K' O: n8 p9 v/ v; u
adLockPessimistic,9 \+ J9 F! N9 G. L+ a
adCmdTable);
% J, Y. C, c3 M! |" C8 O1 {" K# K6 g% X" R( w! a$ M' m/ k
pRstPtrTollRate->MoveFirst();
; f( j2 X- L0 I for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
# g5 k/ J" i; {# [) r, l& n {
! h# q$ ~& w1 u& |4 \3 o$ T% m8 H pRstPtrSplitWastebook->AddNew();: a9 o7 `3 \7 }% R8 w0 l
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
6 d4 P+ [7 `5 R) G/ s ' Y' C4 a* U4 v% C; |- I7 _
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);$ A6 @ h3 `/ F @* |% F! X' l
; d0 E" y& t2 {% G9 g
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);' q' w5 H5 k9 [' J: O) X# L8 T W
r" @6 q. y& n1 e6 w p2 I2 e
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
6 P5 Q. _0 W9 o) d/ U
) {6 k+ U& ?! z7 {, _& u COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
2 A# N. ?) X# O+ N3 @0 w7 _8 o pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;
# a: ?0 p& l( c( W4 k: m
+ p* P7 ?: e; J: _; h. t pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;
4 ^1 _( y1 A1 W* p 0 e2 ~' r$ E0 E$ x1 U$ Q8 t" f" s
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
7 z1 Z; I; W* ?$ C; {/ s9 ]
N2 K0 F+ D, f' ?6 ~( T% D0 a( F7 d pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;, J3 a0 a( x. _) q0 g
9 Q; ^) P' w$ O. Y# K6 Q5 U
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);+ e% l* W9 I1 U. K: k- W
6 E: k! a+ p6 n7 X: M
pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;$ Z- K# G9 T/ D* g' U* i: I
* ?3 L& T; s8 d$ E) H: \ float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;, Z4 T4 U7 |$ X$ g7 {6 a J
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;$ v7 I' c0 O; ]4 t# g
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
4 B3 o5 A2 J* ]& R5 N+ Q& W pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
8 W N/ y# R2 A5 n3 | ! [ l1 k8 K( _ z2 n+ [' F
pRstPtrSplitWastebook->Update();
$ J6 e; _. W: [: ]* s , g$ Z% S1 K) {: Y# s7 x0 e
m_nTableSplitTollWasteNOCount++;) d1 I6 x' q8 D
pRstPtrTollRate->MoveNext();* o) }1 `. p' O# F( b" E/ t" C
}
- ?; x; {6 x2 g) p9 F! t' O pRstPtrSplitWastebook->Close();
7 P/ x& e- F5 M4 H& w0 V pRstPtrTollRate->Close();
- r& L8 I) C" _- Q, V5 I c5 x pLocalConnectPtr->Close();
. ?& }; M. ?, v9 `1 z! g m_nStatus = DB_OK;9 o' N0 k7 ^$ r1 |/ P' F
return(m_nStatus);
; O, |$ a" R h; g }" ~' e; k0 @( _: `3 x! G
catch(_com_error e)
8 P4 e" `* l) ~$ Z, F+ B" B {
. }; y/ |: z7 I: q g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());8 ^: f2 r* l# f8 Y
g_ModelPrompt.Notify(); * Y2 y/ \- m2 l
m_nStatus = DB_ERROR;
! r0 O4 U/ W& I3 | return(m_nStatus);
: [! U( E, X+ W0 A4 j& V, I* Z. w }) W7 t1 e" G: t0 T" g- M
}! O5 N5 ?& V. i/ H5 \( L
" N5 L4 P4 P6 r1 u- m k6 Z* h# S! l( o/ m
/ J2 x+ H8 b6 A5 y
float CObserverLaneDB::GetTollRate()& n6 f1 D4 U& l' @! P
{& q+ r7 U1 n9 P, X; D
5 Y) g/ W, w. a# j& { _ConnectionPtr pLocalConnectPtr;8 ~5 P* z# L2 L: V/ f- q
_RecordsetPtr pRstPtrTollRate;
6 G: k! H8 \: I _RecordsetPtr pRstPtrOrganInfo;
& Y$ b9 _& }& u4 f# ?8 i9 F4 ]9 }3 K5 B% d m) k8 J
float fToll = -1;
# J' c; L) ] h! Z4 s7 r char pcSQL[300];' t# A: _2 y$ r# l# s" e; M
int nSplitCount = 0;
9 K6 V0 M: H* u: O' { switch(g_ModelNodeInfo.m_nNodeType)
3 z0 S( K2 F8 ?4 Q I. k# y {: q# `: M7 ~4 z; t t
case NODE_TYPE_ENTRY:8 p0 T& G4 z8 n5 v) B6 X
return(0);% r, `" D v. W
break;
" q9 w* x: b( V) ]0 w( d case NODE_TYPE_EXIT:
4 y9 P5 k$ s- \1 h' D& n case NODE_TYPE_MAIN_LANE:
8 {7 h" n! q) j* C4 S) \ switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
- g9 X+ s1 J P* w; h: v/ X {8 H4 B& E/ D; s
case VEHICLE_CASE_URGENT:
: q% N3 r" \* K' S: r" U case VEHICLE_CASE_ILLEGAL:4 Z1 z2 w$ s M" z
case VEHICLE_CASE_OFFDUTY_ILLEGAL:
8 b" L3 G( K |" T case VEHICLE_CASE_MOTORCADE:
( v8 R1 p2 d$ ~/ A3 b case VEHICLE_CASE_COMMUTATION_TICKET:, M6 q0 L' _: y( S
case VEHICLE_CASE_ETC:
: S! h2 w# c3 r$ l. l. @. l case VEHICLE_CASE_BAD_CARD:; `2 z) e, k0 e! I
case VEHICLE_CASE_NO_CARD:6 c1 _% v- E4 s3 }
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",% W9 u. G' a2 e/ ^( a6 K$ `
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,9 R. Z/ k$ b, ]. `
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
: i( d: A. \7 w1 {3 l break;6 I6 z! r- ?# Q7 M/ S
default:3 y, k1 |& D2 M, W) C
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 ",
# A9 a' U0 l( b9 {# g& \- K g_ModelEntryInfo.m_PassCard.nEntryStationID,
" \% M V; o' D& R" O' L9 b g_ModelEntryInfo.m_PassCard.nFlagStation1,
' ]$ m+ c2 P' ]" Z3 R g_ModelEntryInfo.m_PassCard.nFlagStation2,
1 O7 l: A# H/ x" W9 H/ @ g_ModelNodeInfo.m_nStationID,; ?/ g5 P* w3 I8 H- d5 n
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,! x+ N( B% J7 @9 n) Y2 L* N/ y: w
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
3 S2 ]3 i. P4 [! f \$ i break;
d1 }: _" |' c( B* x) n( D! Y% E }
. l; `' O$ V; v
: G I8 T& P# {9 Q try
0 u2 }& W! ^( X {, `+ A/ W; t4 X: S* Y# V7 {/ }4 h
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
0 H0 E' D8 S7 e, P, w pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
- G6 {& E L1 @' g; {$ k& X
$ p; J+ q: Z% v/ \/ v8 z pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
. A9 H2 E0 F! u. b: x" G pRstPtrTollRate->Open(pcSQL,6 d. f9 h! Y/ @" s
pLocalConnectPtr.GetInterfacePtr(),% v" y0 m; y) g7 D3 C4 _
adOpenStatic, K3 F. Z; i9 }/ r
adLockPessimistic,
( t" o3 n! n8 V2 a2 K adCmdText);8 }3 m0 d( B5 Q! u1 g/ r' o) l+ N
if(pRstPtrTollRate->RecordCount > 0)" A: ~& \( j! n* P+ V2 |+ t
{
3 v) H6 ] k: [. v* ]. F& d' o fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
% G( \5 i% k2 s if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )7 O) q) X+ [! n* l$ a
{
' u) G& W7 c- j; D7 S. g memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
1 n* \- ~: C" x) U pRstPtrTollRate->MoveFirst();
5 c+ R2 k0 D. {5 X5 I for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
7 B* J, O6 w4 P {/ R! E, }0 w5 p4 s; ]2 i& S: U
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
/ t' a* T0 k$ Y. r- L8 \: n6 g pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));7 G2 Z* W3 }4 Y, Z) m
pRstPtrOrganInfo->Open(pcSQL,
M9 M7 f, {6 H m! h pLocalConnectPtr.GetInterfacePtr(),+ a6 j6 `3 J# {% z* d, G
adOpenStatic,
+ G& R8 Q5 N+ k7 y adLockPessimistic,1 w' w, g4 `; A( T+ i# l3 N5 V
adCmdText);. e, @: |1 W3 j) T$ u' z
nSplitCount++;! f! b' H m* U& Y$ b. A
char pcBuf[10];
! `/ U1 g5 N' m9 { if(0 == nSplitCount%3)
9 N; `0 W, l% ]1 n {
/ v" ?9 g! L4 U6 B8 Y2 B sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
& y2 j, ?* u' u( s# j9 R }else7 ]: s/ `/ `, ~. P0 r
{
" D9 J, y* z' Y9 Q' m0 m) W% ~ sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);/ h# ?) b# t, x7 j2 X0 e
}4 h+ `7 g5 Q5 [( O' l
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
* j. n7 j- \' |% B% w9 m: x) w3 R strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
! P( X5 j" B9 G) y7 p pRstPtrOrganInfo->Close();
* y1 M8 b2 a8 [) M pRstPtrTollRate->MoveNext();6 p8 _' d) U+ v' W: _6 u
}4 G) f2 c$ q9 D/ f
} u1 N; p: U# J4 h& e, T: J
2 Q. s: p+ n9 o8 d
}else fToll = -1;
* T5 }% m1 @& ~2 d: W' ^ Y/ B) }
" { b1 A' q) w: b% J pRstPtrTollRate->Close();
" C7 u5 J, Y* [$ ` }0 c. z5 ~ pLocalConnectPtr->Close();
3 [1 z V$ J8 S) J; U m_nStatus = DB_OK;
0 |2 V/ t6 @# i1 D return(fToll);2 s0 w! o8 q8 P% I
}
/ X7 S' n0 G* j catch(_com_error e)
V! W1 P0 u; Q3 z# I' d I2 x {
2 M" ]& I5 u# g/ j- R g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
9 P- |) R# m6 x3 W6 @$ y1 c g_ModelPrompt.Notify(); J5 c) |: E$ B7 W
m_nStatus = DB_ERROR;
1 B! m+ O; ]+ P! l* }( p return(fToll);
% K' f: R7 {0 [: V; h3 l5 a% E }' ~% S w" W8 w8 e
1 |' F! I* X' @. w# g2 S* |
break;9 q5 U' `* K' d, L
case NODE_TYPE_OPEN:
9 U9 n$ t$ g0 L& u5 O; G sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",
. N$ D! }) I w+ v g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass% m9 F) W/ m5 y+ M5 n5 y8 ~
);$ [5 G! J- U+ u% K2 B9 r
try. U/ z: }, {3 H( q
{
H$ m% U/ U$ t. Z% Z+ } pLocalConnectPtr.CreateInstance(__uuidof(Connection));
( F2 ]3 t( n! X) j% @7 i pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);+ H1 J5 |3 z2 @, ]1 E. b$ b& E4 a% U
! K1 O( t$ e* d5 H' Z
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));; r& G8 @2 H4 {7 _7 E1 j& y
pRstPtrTollRate->Open(pcSQL,7 s$ t$ q, c& X* K' }
pLocalConnectPtr.GetInterfacePtr(),( b, m, s0 [' D4 `4 g9 H
adOpenStatic,
. F" N, |, }5 [ w% x1 A( S+ v5 z, Y adLockPessimistic,
_! Y% [0 R3 k" j$ ]2 O adCmdText);4 q1 o' V: K4 z
if(pRstPtrTollRate->RecordCount > 0)
0 Y. E0 y t! m. z9 ?. I {+ C3 U& ~+ r3 E* {3 f1 }( `. W6 P
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;- o8 }8 n& K# X" o5 \
}else fToll = -1;
+ u( _& i& V- R4 b: y: O5 E& O1 f
$ b+ c. ?! _9 |3 { pRstPtrTollRate->Close();
/ Z7 X9 \5 P) }! g' ` pLocalConnectPtr->Close();. l; U) J2 ^5 \ i3 o5 L
m_nStatus = DB_OK;
; U4 m$ b5 A4 J3 Y8 d# s) j return(fToll);0 H2 _6 T2 u9 w. C! w$ N$ E
}/ S) Y& g" S$ H/ s Y( B1 Y' X1 n
catch(_com_error e)
! Y. ]9 o# }/ ^ {
. U4 k/ n$ D. h0 A5 | g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());6 G1 n# x4 \' F) k
g_ModelPrompt.Notify();
' { Z7 H. F, u m_nStatus = DB_ERROR;2 P" F& p! a0 O E- Q* {9 Z
return(fToll); ) `$ J" ~" A- q$ s# j5 B
}
; i, i$ Y8 A# ~! x8 x f, W0 l break;; J# u. j) n/ ?# o
default:
Z w* v0 ~1 i$ A' g, u m_nStatus = DB_ERROR;
5 }" z' l6 ^9 d" Z break;0 n/ Q* C0 _. [2 C8 m* u
}
7 Z% ]$ h0 p( M return(fToll); * u' b) W* [: Q' H. P( Y
} |
|