|
|
int CObserverLaneDB::InsertTollSplitWasteBook()- @. B3 O5 v$ i
{& \$ m! b, |" g( H) ^
_ConnectionPtr pLocalConnectPtr;- b: y5 r) n9 h) R! L9 n
_RecordsetPtr pRstPtrTollRate;
5 v8 i/ {# V) B( Y _RecordsetPtr pRstPtrSplitWastebook;
: K( x0 m! }; F( Z* t
! ]* B) @# l2 n0 m5 E char pcSQL[300];$ l6 u( _" Z6 d8 o9 E( 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 ",
4 C9 a, Y2 ]5 P% w g_ModelEntryInfo.m_PassCard.nEntryStationID,
7 x$ n( A* Z4 A g_ModelEntryInfo.m_PassCard.nFlagStation1,. r1 U! C, v/ T; X: z O
g_ModelEntryInfo.m_PassCard.nFlagStation2,
- B. `& z' E- K6 p1 b, j) ^ g_ModelNodeInfo.m_nStationID,; h U0 O+ Y# g; r
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
8 K& A& L$ ^' o* V g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase
# f4 m" l" J9 z! {( y1 K' B; _5 I4 A );
+ p9 v1 G, a c- Q, \/ k" q4 c9 G+ w+ K5 i$ h$ F
try
: H' L( k% W. A! e {
1 d2 A1 F8 [" K) g pLocalConnectPtr.CreateInstance(__uuidof(Connection));4 o; m' `& N' g, K! Z7 F
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);! P& L0 E! A* b4 X
* I% J" w' o; |, e
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));9 h9 q0 q; N8 {$ P1 p c! a
pRstPtrTollRate->Open(pcSQL,( K, h; x' h( P; h
pLocalConnectPtr.GetInterfacePtr(),
9 S# R) |! o3 Y. t# _ adOpenStatic,
0 B2 ]/ A* Z6 v% C adLockPessimistic,
3 q& j) v7 N8 y: u adCmdText);5 T( \3 p L" G
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
# s4 \! c$ e: A8 y6 {) F pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),
4 @5 A! ]' v* R! v3 p pLocalConnectPtr.GetInterfacePtr(),7 B3 b! @. \1 F, {! S& K
adOpenUnspecified,
8 C7 z$ V+ ^# v1 ] B. v0 A adLockPessimistic,( n) I* W s: |2 s; a- F# H
adCmdTable);1 u# s/ g- g$ l$ ]: E
$ } F5 v- v( i' B
pRstPtrTollRate->MoveFirst();
. m( i; E! G8 a+ L& D for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)' R& z9 ^( S7 A) ?3 W
{
7 a) @& F, I8 { pRstPtrSplitWastebook->AddNew();7 ?; R$ K2 W; D
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID); ^5 H' k/ P2 i! n2 {) w
" `3 y* G6 J2 X1 d" m pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID); g% h9 a+ P. g/ i1 W
% R; S# T2 D8 r7 U# S$ `0 P; \7 d
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
: v9 _. u, p9 X4 ?" {% W # \) X( Z: R- N$ T$ `6 h
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
3 a* n0 U3 M: D, O$ }7 h8 Y, n4 K z5 u; k- g% X% i! l
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
4 k1 G# S; x9 \$ K) ] pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;
1 e9 M: Y7 s7 o8 I7 M; l$ I , G I# O; g* [! l
pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;5 k+ p6 R, E7 A* j0 m
8 y5 x+ x5 M3 ^ U2 j1 v pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
( |# }% R3 T: g& H2 u
1 W; e% e; w* y' X/ R0 o, Q pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
6 j) g' s. Z: p' Q' N
% N% n% a4 I9 ^( b- w! v) @ pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);
: j8 f5 v; n6 N3 {
% [/ L1 {9 \" x4 o7 e pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
; a. t9 Q- x; g8 W" y
& S- Q5 S4 @0 k @5 U" t float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;; x, O( C m1 s0 m
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;
$ ^" S$ d0 q- K% B2 ]! e- W H& z float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;+ N' V# O3 Z/ i1 P9 d9 e- z
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;$ | G F6 m* |. B7 p
, ]- M0 D% r6 F8 l j1 j& ^ pRstPtrSplitWastebook->Update(); ) C+ X# F. @6 ]2 w
, M6 b& h* z. P/ Y2 W
m_nTableSplitTollWasteNOCount++;
' x6 E# c- K3 p ^6 U3 b: O- C pRstPtrTollRate->MoveNext();
. R; Q2 q! X7 A, F2 V) m }
M+ ~' |8 l) P* T8 w pRstPtrSplitWastebook->Close();
% S$ }3 S7 f+ B+ S' Q( y5 T pRstPtrTollRate->Close();
; r+ H0 x$ e9 [6 @0 y! F pLocalConnectPtr->Close();8 }7 r8 Z. I9 |! W' Y/ H
m_nStatus = DB_OK;
) c4 k, k! x( } return(m_nStatus);
# `- p7 H) p" W" Y3 _. {: W }0 x$ B, p: a' b0 M# m H" g
catch(_com_error e)
3 S0 M* L# y) R) ^7 u {
) | k1 p1 e. k! G g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());( ^. V9 ?, `( l: U
g_ModelPrompt.Notify(); 3 m' _: e% d* P7 {$ ]
m_nStatus = DB_ERROR;
' \9 V& [5 w9 p( R3 E# A return(m_nStatus); : ~, I* [9 f2 }) x; N
}1 u( | w" s; l. S. I f
}
3 j; F# v# a1 A
0 B/ ~7 Q; a+ ?
2 _5 w" w& V3 N2 g% W, l6 V
o, b, A1 j; H3 j7 T! n8 b5 jfloat CObserverLaneDB::GetTollRate()
?- M7 b0 S* q' ~" U{- ]6 w3 y& m5 K* ?: O; \6 t
% d* }/ q* G8 G2 b& f _ConnectionPtr pLocalConnectPtr;
5 B- P* g# C7 H& A+ K _RecordsetPtr pRstPtrTollRate;
; u# V' N% V T _RecordsetPtr pRstPtrOrganInfo;
4 |6 G2 z1 d; {6 B! @ T. A3 ~; B
3 a `3 g! V& S: C: d float fToll = -1;
& c" v! p9 ~ o; V/ K char pcSQL[300];( W# ~, ~& c9 R- B* P- H
int nSplitCount = 0;
, g( v: [& {& l( W# g* c switch(g_ModelNodeInfo.m_nNodeType)
' v7 P, ?: }% ?- g5 I4 H {
: i* a$ @ D/ x6 ]; l case NODE_TYPE_ENTRY:6 f2 p7 [' V Q' h' V, b
return(0);- r4 g; [- |! M
break;
0 L! X9 W9 b5 S# G- s- U" g& U case NODE_TYPE_EXIT:
* k2 T. E. O0 q: p k case NODE_TYPE_MAIN_LANE:
1 |/ P3 f0 G% z2 g, D' h: w8 K switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
% q& t/ m$ x$ U1 D1 { {
L7 I$ x3 B9 X8 j/ f case VEHICLE_CASE_URGENT:# ]( e" s% ~# n2 ]1 \/ _+ E) m7 `
case VEHICLE_CASE_ILLEGAL:
5 f: p' V' g2 S9 j ?- q6 ^ case VEHICLE_CASE_OFFDUTY_ILLEGAL:
; W. u$ U" } J8 I: a4 A case VEHICLE_CASE_MOTORCADE:+ E$ c* \- Y& @+ w( `3 k g
case VEHICLE_CASE_COMMUTATION_TICKET:
/ w" e- ?% V" v; j6 b& k case VEHICLE_CASE_ETC:
$ K8 v3 K T' m; d5 o! i1 X3 m case VEHICLE_CASE_BAD_CARD:
6 s) `/ B) ]. K2 T case VEHICLE_CASE_NO_CARD:
; Q4 h; N+ @3 d+ X0 O5 N6 q sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",3 P" p* F3 v7 Z( w5 \0 U
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
9 Z- u9 [' V+ k6 K H# W g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);, u Z8 ~9 K- ~7 x6 }: V
break;: g& u+ d2 w% ~! x. c& [1 p% N
default:3 |( g: v% M/ d
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 ",6 I5 x r4 o* m# q. O) w- U* z2 ?
g_ModelEntryInfo.m_PassCard.nEntryStationID,: T' I0 x4 B0 [) j! k
g_ModelEntryInfo.m_PassCard.nFlagStation1,
) @& d( N! x" k; k- ]! D6 s g_ModelEntryInfo.m_PassCard.nFlagStation2,+ d1 O6 }5 o1 r3 l) c8 o
g_ModelNodeInfo.m_nStationID,
( |; }2 N4 [! i# I j! l7 Y g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass, Z# x: r) q& e3 ]3 y* V
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
% d- C; f! Y2 a3 Z break;
$ s8 T4 d4 _( u9 W' O) ~5 S }
+ S U( S/ U- k P9 o6 }/ x) P- s 5 M6 g8 b. ]$ e" a- g
try
* x5 J' g) E& f+ f5 C, e {
" J5 }7 D; h3 |/ J; v8 A& [ pLocalConnectPtr.CreateInstance(__uuidof(Connection));
# N4 n* v! _/ H! u9 D$ y pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);2 l' }7 J- _" i5 _- j2 D" n
! _# z8 E7 |) j% N, h" ] pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
% e+ P. [5 ~( O" r* a: f- j. D' \ pRstPtrTollRate->Open(pcSQL, N7 o4 n1 _) \5 E, Q- S
pLocalConnectPtr.GetInterfacePtr(),
: {1 ]3 T5 |' P: G# G8 L: o adOpenStatic,
) d. m+ p" b. C4 \* T7 { adLockPessimistic,
, L; ]$ }9 o+ s* C( d adCmdText);( n8 t3 g) Q" C$ u) S; J
if(pRstPtrTollRate->RecordCount > 0)
) j7 f- k6 \) V {
. w3 Y8 P# ?5 f5 h fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
2 g8 l$ Q6 I9 U* E. x1 w if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
+ u$ Y( O6 I2 X6 ^) R, ?1 H: e" \ {
' Y$ {/ T+ C. ?! l memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
2 s* J5 z! |! _9 K7 A& I) R pRstPtrTollRate->MoveFirst();
2 m3 C* `8 r% _0 p( ]( n for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)' S o( | r, }+ j" j, i! K
{
, F+ o" i' x/ K0 \4 v+ d4 t5 K sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
; j Q8 Z; s! Z3 }0 i# Y5 o) M" ] pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));/ C$ P, [5 Z2 i' _; B+ t5 K
pRstPtrOrganInfo->Open(pcSQL,
# v; S' O' l- \9 R pLocalConnectPtr.GetInterfacePtr(),# S1 A' y" \9 x. {. O* }$ r" o$ q. k, b; S( s
adOpenStatic,
- }) L/ ^, v! _+ c; L, A. n* m adLockPessimistic,& \% \, O% {, [, u; D; }
adCmdText);
! L1 `* Z2 |8 G$ q" M: s$ t nSplitCount++;
5 F2 f- ?3 C. ]/ _+ y ^ char pcBuf[10];
4 W5 x" y9 F5 P! b/ A6 @ if(0 == nSplitCount%3)' D; O6 M" h7 O& v' l- p
{
6 N2 [- f& E4 b0 g& t' L sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
' A3 N: D% J: U( p+ b }else
! y, N3 [2 V; b" M) ^7 c {
4 F( T- C( }4 X1 r- V/ H sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);# `7 p. U Y8 L# ^ x9 o
}
& p, h2 p, a6 Z; n( X strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);( l. N$ Y7 } w( F
strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
4 q/ Y/ v4 u0 @7 |( v pRstPtrOrganInfo->Close();
9 h! Z& H- Q! k# h pRstPtrTollRate->MoveNext();
5 l" z" \+ j" R4 L }/ y& i& x5 E5 q! O) L8 U7 n5 v" g
}
7 @ l- G2 M7 E" g4 ` & V$ o$ `8 G2 U( ]% y
}else fToll = -1;
4 k. V$ Z' k4 P 2 W7 J# g, ^2 `9 d
pRstPtrTollRate->Close();
: ^% m3 I6 v0 A( w pLocalConnectPtr->Close();8 X* @" _5 t m; Y- G- D
m_nStatus = DB_OK;
0 q$ `0 U' t; w- x9 l; e0 w! X7 c return(fToll);
1 H& q3 ^' D* y; L5 w }' I: p/ I V8 {7 w2 Z, B, L9 G
catch(_com_error e)! x( {- A1 C) G. F* G. Q3 b; C, d
{
0 W5 d! q I- Y9 r, U" I g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
6 {# s* b' j& _6 y. Q g_ModelPrompt.Notify(); 8 _" ?1 M( R k2 }8 N& [& `
m_nStatus = DB_ERROR;
7 L9 m' Z3 A2 G* w$ @ { return(fToll); 3 v4 e) q! h! g' m
}9 U. e7 o( G( @7 [. m
. b& \2 V' s. A0 z. `0 a
break;
( O9 ^# P/ Y2 r' o case NODE_TYPE_OPEN:' K+ n3 d4 l+ q3 V/ _
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",3 v: c4 G9 {5 B3 w
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
. h2 J8 D4 q# P1 S );
' M5 Y; l; W( _5 _+ z6 l# q try
1 A" f/ x+ b8 u1 E: x2 { {
/ A0 L. i' S9 w" ]- L- m/ N/ A pLocalConnectPtr.CreateInstance(__uuidof(Connection));' n$ u7 Y( p1 x7 N' \2 n# i
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
2 ? E, W |6 D0 b5 \2 |, ?" w - o' k, G1 d. S+ t7 p2 ]
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
- O& S( |0 z$ v pRstPtrTollRate->Open(pcSQL,+ Z+ W7 J* u5 ^9 @0 A( Z
pLocalConnectPtr.GetInterfacePtr(),0 E7 L7 Q1 \1 X* h' y- p
adOpenStatic,
" Y% P- Q$ A# e4 m9 T2 | adLockPessimistic,+ d1 `+ k% J% d9 h; X' K2 q
adCmdText);7 I& \' _9 j2 e9 i f+ {/ E
if(pRstPtrTollRate->RecordCount > 0)- E! L1 a# L9 K0 l: X5 q
{
( Y) w9 \4 A, G% W+ \ fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
% Z: H: a! j0 ~4 A- H }else fToll = -1;
8 v5 Q* r9 e; U+ ^& y" |
! R, D; L' v3 ?9 p/ ~, m( S. J1 V pRstPtrTollRate->Close();) D- g! X' m" |1 X
pLocalConnectPtr->Close();
8 Y: I/ g) a. @! Y m_nStatus = DB_OK;
0 k1 m9 a* F: M, n. }# D. M return(fToll);
2 r c+ h v6 B' F8 [% ~% e }
% a6 ~5 F! m1 W2 | U catch(_com_error e)( ^9 F4 {( X- Z6 w( L% t' c1 O
{9 M+ j; p0 u: k2 u, I' L( ?+ R I
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
4 u' X; @9 K f" r8 V2 G1 }' x g_ModelPrompt.Notify(); & m& E d4 O. w& F8 M
m_nStatus = DB_ERROR;
4 O( d- L/ w) x! q# k return(fToll); 9 e5 K; `+ o" D, W; W% I" a
}5 p/ l9 Z# v3 ~
break;$ _3 A& C, t m' c
default:7 l1 `6 B9 s5 G, n5 h
m_nStatus = DB_ERROR;
; \% a3 Q" Y7 C! n% ~ break;
7 S+ L( Z3 I# {- [. g2 \ }( }+ u6 f1 R+ G0 O
return(fToll); & E2 S* q& w/ Q1 K% I0 A. H# C
} |
|