|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
, C6 l! q2 T' ]0 t& q$ |# a{3 j4 Q. p: Y/ [* q; V8 ?! e$ d& X& U
_ConnectionPtr pLocalConnectPtr;8 E. F: h _6 w7 R7 J: M. i
_RecordsetPtr pRstPtrTollRate;8 ]( R/ Y6 U: f, S, w5 q
_RecordsetPtr pRstPtrSplitWastebook;- P' \$ Z. z! {+ r* j3 E9 }! E9 t
5 \8 {1 a6 @4 x' l$ `4 c) v* }
char pcSQL[300];6 W- {/ q) U0 G
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 ",
1 y8 x* j9 E' {; d8 m g_ModelEntryInfo.m_PassCard.nEntryStationID,' o) R p- j) K: i$ o u) a
g_ModelEntryInfo.m_PassCard.nFlagStation1,
8 L; }/ _6 e; O) ^ g_ModelEntryInfo.m_PassCard.nFlagStation2,5 P+ \4 F5 i i" W
g_ModelNodeInfo.m_nStationID,
+ G x5 \8 k/ i0 _: P g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
- ~& _2 ^0 m# C9 H/ r g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase4 H/ `/ P7 @5 ?) e
);2 j6 G- a. _+ K: U0 `7 b: u! g
& s# n3 u/ d0 X! s9 P; L; `
try
9 j, e1 b( b4 A' e% G/ ?. Y- X# B2 v {
8 E8 K3 B7 P6 {' u$ Q pLocalConnectPtr.CreateInstance(__uuidof(Connection));
" j5 U) j8 n: k: Z pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
, O- g n6 l$ | 0 }/ K g+ G3 t! Q" V* R+ \. |. i" ^
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
+ y0 a8 ~: F% g# }; U. y0 ? pRstPtrTollRate->Open(pcSQL,
" f# w& D0 h1 m/ h1 L8 M" s pLocalConnectPtr.GetInterfacePtr(),
' @: X) a1 w2 a/ s- ` adOpenStatic,
( ^& N; ]7 v) M: E" r. V! Z. C3 ` adLockPessimistic,
7 y& L8 L1 Z9 s3 n4 m& C adCmdText);
/ Q) b1 Z& x; t0 i0 \. t% U pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
/ E' K/ L: L3 K/ Q* O, y1 E6 ? pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),8 `+ S3 n' u5 ~1 T
pLocalConnectPtr.GetInterfacePtr(),' u; b3 J! G/ H% F9 A
adOpenUnspecified,
+ t0 v Q& a; U* \& q" v adLockPessimistic,
& e0 t. V7 Q7 f3 k adCmdTable);
- r) O7 S) |5 d% \9 X' Q8 `( x4 i2 t
pRstPtrTollRate->MoveFirst();9 q* y% R1 ]) A4 r( T0 V9 X& e
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
* J( ^3 E0 Q8 a; Q' H5 s) \ {
# }) f' s5 h7 h' h! C' W- g0 B pRstPtrSplitWastebook->AddNew();. I$ w5 O \* Z/ z! f$ j0 O* h* R
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
P+ b! |1 ^* M; t ( H6 J# \7 W" S; Q& Y( \& O6 p
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);' p8 E+ L F0 W) v4 r
* L' }6 h+ p* B) }4 ?) W1 U! n- F
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
: v" q( O0 X @5 N x+ C6 B+ [, b+ k0 Y0 k
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);! i& f- n2 m- Y% i6 `
& n9 ~# k$ M/ @; ~; B
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);$ c: B8 O; I( f# C( O& H8 p w7 F1 e
pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;6 |) ~+ Y! I T
3 `& o4 `4 v+ C: l5 j* p Q pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;2 J4 x ~) F$ A7 K
$ ?0 a' H) K" ~3 |. D: a
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
) m4 ]& {# x2 c! B+ l
; J2 j% a* _5 Z( i5 y) ^ I3 g1 s pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
) O j6 o. c* T. f : Q/ ~( S0 @0 K4 {; g3 S ]
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);
7 E& Z2 m# [% T! S0 |
4 U9 g& r1 S. _: _" p pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;8 m2 H/ y- O$ r' J
$ H7 Q' S4 N: f2 G
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;7 I9 f& @ @4 v% i
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;" [" ~( k6 i- R: I5 a
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;; O" r4 p: |6 W ]6 t
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;2 G( C2 Y4 f6 r4 [7 x- }# ?% |
5 V* _8 n, U7 r! v0 n- F
pRstPtrSplitWastebook->Update(); ; f8 A2 Q5 t! \% m
I( f4 O( m3 K) y9 o5 j
m_nTableSplitTollWasteNOCount++;2 o) B1 p1 _ G% o7 d5 O
pRstPtrTollRate->MoveNext();9 x7 h2 q- Y- R1 K, p4 i$ j
} 7 C. v3 m* r& Z& ~$ W
pRstPtrSplitWastebook->Close();
+ I3 @+ x! G& t0 r3 K' e+ ] pRstPtrTollRate->Close(); k n: Y. w. S
pLocalConnectPtr->Close();* \, `; s4 `: t2 k5 B; V; y, _
m_nStatus = DB_OK;
, ^# }9 D3 ]; x+ ~+ j return(m_nStatus);
# l6 ]; T0 m# \' _: S/ T8 O6 l }
5 P1 R6 Y* ?/ D3 n D+ q catch(_com_error e)5 q+ L% A4 s* w1 y, Q
{$ c& F6 t w( d7 ^
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
' u1 M3 t4 w1 b- V- W r7 N+ H g_ModelPrompt.Notify();
0 J, {) J1 Y% Z m_nStatus = DB_ERROR;
9 v' P! ]( c6 `; a/ A/ a/ j return(m_nStatus);
f1 o( q; x* W" A" ^5 l- M1 B } G; L" w9 i l; H# \9 ]6 C/ ~
}5 a- }8 Z5 }# r8 Y! U$ G4 ~
# O1 x5 M8 w0 z! A: V R* k; [
; q! G. ?0 a/ }, R. R. a" G* v [+ s: C7 I6 ^' D
float CObserverLaneDB::GetTollRate() l0 s6 w/ s5 J) l: B( E, v* ^
{$ N5 a) S; q# U4 R' e0 a* [ g
, _4 [4 s8 b' `2 o* r/ s _ConnectionPtr pLocalConnectPtr;2 W# ?* T2 L+ j; R7 {( K6 E# i: \
_RecordsetPtr pRstPtrTollRate;
( h3 z. n+ |! t* r' Q) ^ _RecordsetPtr pRstPtrOrganInfo;
5 R. F# c7 [+ ~1 g2 ]+ z- Y3 G" u) `. a9 t% g% H3 h' O
float fToll = -1;* x. p% Q- x" ]
char pcSQL[300];. G) T8 U$ E8 }/ I0 [# L2 z
int nSplitCount = 0;
( W5 w) v8 B! u+ u! o, b switch(g_ModelNodeInfo.m_nNodeType)
6 I8 m( r0 ^1 k! U- _ {
! i3 \8 d# B* b4 x case NODE_TYPE_ENTRY:
4 Y; l+ d% w7 L return(0);1 s# e8 f- M( K1 f; J
break;. g1 c9 u- N) ]: p0 S2 ~
case NODE_TYPE_EXIT:9 @7 A5 P9 K! l/ g
case NODE_TYPE_MAIN_LANE:8 p }3 s5 H. [+ e3 }
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
. B* n7 H% T1 `9 L, \! x$ t8 s {0 v* {) J" i2 G
case VEHICLE_CASE_URGENT:7 q+ ]5 d# _$ Y3 {, E0 o% Y
case VEHICLE_CASE_ILLEGAL:
$ x! E& S! @" G* l) D+ x4 W case VEHICLE_CASE_OFFDUTY_ILLEGAL:& \% d- B3 z8 L( Y2 Z9 I9 X% H# Q
case VEHICLE_CASE_MOTORCADE:
2 D. W' k, F# G3 O case VEHICLE_CASE_COMMUTATION_TICKET:
) n+ Q0 f6 f) x ]% @/ j) m case VEHICLE_CASE_ETC:
1 g! m: ^' X% q4 G case VEHICLE_CASE_BAD_CARD:
8 n6 M2 B. h2 |1 a case VEHICLE_CASE_NO_CARD:! [+ T( Q, [; L9 N5 J
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",1 J9 l4 j/ D& q
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
1 W3 E$ {( A/ ?2 h* A6 m g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
" C3 b' A4 M5 P# H3 B5 r9 u, J break;
# C- u9 y- ^6 |8 ^# C8 | default:# `! c% q: v6 L: f) A, O( [ S
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 ",
Z1 M t( r1 b9 a& B6 u g_ModelEntryInfo.m_PassCard.nEntryStationID,7 q' x, K }/ V4 B! ?4 F4 h1 _
g_ModelEntryInfo.m_PassCard.nFlagStation1,% L& ^7 K# J$ W' U3 y" W
g_ModelEntryInfo.m_PassCard.nFlagStation2,
! \. ?- `6 m# A; d% _( b+ c- ~( e g_ModelNodeInfo.m_nStationID,
4 J T, r. X+ E* i4 s. S g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,/ F" L9 c4 r' ^8 p+ w: `
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);4 c+ L4 f4 f4 d
break; F( b( F& E0 `5 f0 q( g
}+ h: Q. }# y1 L) h/ M. m
5 F3 D& |* D/ g) I, Q
try: }/ H/ D8 L1 \0 Y' H4 r' _
{
* u) s; t. A$ D! [, q pLocalConnectPtr.CreateInstance(__uuidof(Connection));
# v3 }+ s& H- M% V pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);0 [+ `& Z/ \: V2 q* w3 F$ o# D4 C3 h
- o" g0 c; v% z' w0 F; [) {. r! B pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
% [) x4 R' e- R* E$ X pRstPtrTollRate->Open(pcSQL,
C6 M+ |$ f* R. A8 [! S( u pLocalConnectPtr.GetInterfacePtr(),5 I4 |) A' x. `1 B
adOpenStatic,: _7 {; n9 ]4 q* {/ ^
adLockPessimistic," e+ u0 ~ X, y6 H* v- R
adCmdText);, L. d* x6 W/ Q8 L6 }
if(pRstPtrTollRate->RecordCount > 0) Q' |* r& d2 ^- ]
{" v3 i5 X7 C( z8 {! A
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
$ ]3 N' L/ W4 e if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
( u$ N; @1 X' M, p' o {: r# r' l$ A6 i& P
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
" t; c/ i) r' a: } pRstPtrTollRate->MoveFirst();
. T9 a5 D" h' }$ { o. w4 f" v: m1 S for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)& A o. Z8 D) d; s
{
# J& {' }/ Q) C- |7 ? sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);. H3 \0 s9 K$ T: V" G/ m8 {
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));. E3 k8 W+ W1 j" f7 D
pRstPtrOrganInfo->Open(pcSQL,
7 R4 M+ p7 Q! ^. g' ^# D2 z pLocalConnectPtr.GetInterfacePtr(),
7 p5 t4 S# P+ @5 N( ?0 D1 V adOpenStatic,
A+ x) Q0 P6 p4 @ adLockPessimistic,
- k- Z1 o) w6 \ adCmdText);
& G) k+ k+ s9 X: H; K0 g: j# I7 n nSplitCount++;
# N' r6 g3 _# K! o2 V1 M char pcBuf[10];
8 N5 Q, e' }+ A) j4 r if(0 == nSplitCount%3)7 g/ i0 i* ?3 U4 s
{
% H1 n' R" G2 Q1 |( Q sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
2 @1 C% F$ t6 s }else
$ @' t& p& v! ^* ]$ {( ^# D {
' L0 n3 y N, X+ E( i7 N sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
1 u% {! |1 p( c }& F% z* I2 f( i1 s$ l/ q
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);2 S3 U0 X2 H Z- q/ }6 |) h% ^
strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
5 D* z% L/ H% I6 r( u# F pRstPtrOrganInfo->Close();
; t- p# R* h* v pRstPtrTollRate->MoveNext();- u R! f) b& z, a9 H3 O$ j
}: P/ Z# R7 I1 \/ T6 a- v
}+ r7 T0 T; d. \
& G, F' E- [2 F7 g; @- P' U6 N6 [ }else fToll = -1;, u, D. E4 L# x, N9 `
5 G* e$ ]4 Q; W& e% y
pRstPtrTollRate->Close();1 m" Y, x. S$ s. u
pLocalConnectPtr->Close();
' o' Y$ a4 P( `/ B5 Z2 v m_nStatus = DB_OK;3 ]7 L4 x7 j% s3 [
return(fToll);! p& f8 P1 M1 ~/ }/ Q% g! Q( \6 C( V
}
- u3 K$ L+ _! |3 Q- }1 Y0 N. ? catch(_com_error e)
3 E: }3 q1 O! @+ U( G7 l0 V {
+ a! w8 ]' H. f2 V) A- s g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());: u- O6 J: F' F
g_ModelPrompt.Notify();
+ o+ e8 a+ b9 ]+ y( }* C m_nStatus = DB_ERROR;) _+ g/ Y I+ B% B- \
return(fToll); 0 X1 { l, _) i5 X
}
- D$ G) H2 C- F# z) e/ j
; e- E0 F( z, _5 D break;2 u2 z: e& _2 G6 [3 b5 G, C7 u" L
case NODE_TYPE_OPEN:
$ t: J! Q% K+ H* _3 J+ g( r sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",
3 F3 T( S. N+ N5 f4 n* ?! M7 W$ ` g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
( Z |& ~) _- K$ G- ^6 z );3 d0 C; {8 m7 W$ d
try3 O# s# W# B2 L, Q1 o
{
! F/ |% T& f$ v% R1 x pLocalConnectPtr.CreateInstance(__uuidof(Connection));
( o p3 k1 c3 j7 E pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
# w5 r: d4 E: J3 `; V; Q5 o
/ p- s$ n/ ~! n$ E pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
% z! g. I _7 I4 D5 _6 V pRstPtrTollRate->Open(pcSQL,
& k/ | q; I+ i' F) h) L pLocalConnectPtr.GetInterfacePtr(),
( @$ J' c9 Y* s) [ k7 @7 c adOpenStatic,3 y, d2 r' a0 J* \6 }7 _
adLockPessimistic," U: r( x& [5 G( R* t# v
adCmdText);1 t! f& x6 b, Y- i' H9 M
if(pRstPtrTollRate->RecordCount > 0). F. u& _. I/ u l/ K
{& d. \3 H, Z9 C% y' o
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
* h0 n: C& H' ?! v }else fToll = -1;2 k5 x1 E! W& p
; x1 d) c; E( M. t0 o
pRstPtrTollRate->Close();( P# U: `* T* o# G* K/ z2 q8 R
pLocalConnectPtr->Close();
- ]0 y2 d; W9 A) w2 C' ^3 A m_nStatus = DB_OK;& A. f' d8 X& l( C
return(fToll);
$ s% B: [2 Q. u( ] }9 R: P/ t# g! l& @& {# [
catch(_com_error e)# D% K, Z+ A% L5 F0 n: P6 c
{. ~* R2 p. I# ~
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
5 M) S4 O% q1 j0 y$ m g_ModelPrompt.Notify();
9 C% r A) B" {8 k* \( g5 x j m_nStatus = DB_ERROR;
/ u1 ?& l. i; [ return(fToll); 0 z: } P1 ^: N, g, @
}
2 U9 F+ x. |: d break;
7 q0 [, R2 `- E7 T- `- I. O' X: o; T% j$ _ default:
m+ n2 [+ @1 N6 I. j( y8 ] m_nStatus = DB_ERROR;
/ g! [+ u+ _3 p# ~: A break;
" {% E" U1 b Z3 y# ^ }* i) A$ K! C7 q; ?
return(fToll); # x4 {# T+ g! F* ]
} |
|