|
|
int CObserverLaneDB::InsertTollSplitWasteBook()/ Q/ Z8 R I! F# z! L. B1 R0 h: E
{
9 P7 X* e+ w) a+ I$ R- R _ConnectionPtr pLocalConnectPtr;" m- U8 i$ e2 f" u1 q& E/ V
_RecordsetPtr pRstPtrTollRate;4 E$ U+ [( w, q2 v6 w9 @+ f
_RecordsetPtr pRstPtrSplitWastebook;) U9 w$ |( s2 N* g
: ^6 @9 ?' g3 \2 J char pcSQL[300];/ [ ?3 r+ r& n" V: [. p7 E' v0 v
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 ",/ v; [) p6 D/ b0 x
g_ModelEntryInfo.m_PassCard.nEntryStationID,
5 J' z: ~9 `! N( [- J& a1 N g_ModelEntryInfo.m_PassCard.nFlagStation1,
# D2 j4 k2 }) ^3 a! S- y1 Q0 n g_ModelEntryInfo.m_PassCard.nFlagStation2,
9 c9 H% _# ~/ V+ e- O ]/ t g_ModelNodeInfo.m_nStationID,
! M) q+ ^$ B' _6 n7 \4 m" o2 ?' N: t g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
) w- u7 j. [0 O% d% l g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase3 g( M2 p5 R( c" G" S
);
# w4 l9 H0 b, b
* N) Q3 X- {6 B ?3 w. w* c$ D& ` try9 ~; [1 r& L7 b/ ]
{) |$ f; {$ ?; T
pLocalConnectPtr.CreateInstance(__uuidof(Connection));. ?: [* w7 ~' W D' I: Q
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
" z" N% C( O. X( H% ?& e3 m) }& x # _& H0 c b- `' r) t: \
pRstPtrTollRate.CreateInstance(__uuidof(Recordset)); ]" q# K. L2 l
pRstPtrTollRate->Open(pcSQL,
, J1 H/ \5 T; L2 |. C+ Z pLocalConnectPtr.GetInterfacePtr(),* m$ p, m8 y u5 k6 P! m* a$ R" w
adOpenStatic,8 N6 d, y L! U- M! }- d( o
adLockPessimistic,4 c8 Q U( w/ n ], J6 }5 j
adCmdText);
3 Q8 X! U% [, ~& n7 Q2 V( I4 O pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));2 B% [ F Q8 A" k
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),5 x7 p& t6 u6 }4 d: W
pLocalConnectPtr.GetInterfacePtr(),
# f: T7 \5 y! o6 I' p adOpenUnspecified,
4 ^$ o. h# Y% M, E+ p adLockPessimistic,1 R2 s3 u& _+ a, I* t0 A9 _
adCmdTable);
* y# a8 e5 K$ ]. E# @
, V, \( T* m$ R! m3 L# ^, C, d& a pRstPtrTollRate->MoveFirst();9 c% `5 u- ^( G1 z: O
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)4 [8 k5 o/ G' d+ g4 z" _5 F) v; D
{* T) v7 I* l m e8 K4 S- ]
pRstPtrSplitWastebook->AddNew();/ H* s' S- Q6 e- J7 K0 J! e
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);# n! k, \ p9 p$ |
7 C, D' c H. A: X, f% q
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
1 V1 Z/ m) F, q9 h4 f' y
: T0 G: y, d% k% I4 Q- t$ X! t9 ` pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
( @7 ]/ }) @, L* l. Z* A
1 H& S( B- B! [ pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
# g" E' k+ Q" Z3 S! x" u. W
6 j. |( q5 ?9 `+ Q% K8 l) C. M. I COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);& H+ C) P- m1 @5 d
pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;& v2 X8 }0 h* N2 A
) u$ A- W# P* [# B; A9 p6 M5 [
pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;9 ]- Y, \: ?4 _8 p1 Y9 a& t
9 B7 Y; e( J$ j0 ~
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
* y7 Z) [+ Z. f3 J9 F/ m# r 6 e. o$ z. }1 ~! i+ ~6 P
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value; ^+ y! [0 C/ E/ j' f! ^
" |3 \$ L& b: B7 _4 ^3 ?3 _7 Y pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);6 G! D# ~: w9 ]
; D8 d" k. l3 u& Z- ?, ?) m
pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;- Z! I) o$ Z$ M- V7 W
7 ~( b2 m% g W0 W7 {, Z# `. q float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;. Q3 `" W2 q+ f; c
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;2 H+ ^ W8 Z0 d% o$ C. y& ?
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;- j9 s7 Y- p0 t0 q$ W+ u `
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
! q" ^7 ?, j) S
" X* g& b! I O: o M pRstPtrSplitWastebook->Update();
0 N5 `3 L/ Z) i( P& E
# s9 I) W% `* P, a3 N& T0 i m_nTableSplitTollWasteNOCount++;
% t6 o% L5 B3 S4 U% i/ M3 t6 l pRstPtrTollRate->MoveNext();) }- Y! g5 b' d9 D/ ]7 ^/ E7 t& u6 K
} 2 S" r4 c: l) ~" [! ]1 Y7 {4 l5 Y" d. ^
pRstPtrSplitWastebook->Close();
# `: ]" W9 T+ Q4 }4 ^5 @ pRstPtrTollRate->Close();
9 ^' ~$ ?( Q: i P- e pLocalConnectPtr->Close();4 [; e. Q! x9 F5 z' ?
m_nStatus = DB_OK;
2 K$ y7 Z( X+ T1 n, D return(m_nStatus);
0 Y; a. i+ P1 W; j }/ E; `4 X; @: X/ W
catch(_com_error e)0 n; V" B/ v; ?5 j; }0 H- z
{6 [: y9 d. _# o- G) J1 [4 x& l4 ]
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());! p. C- ~4 ~$ w: @7 Q; v$ `! q
g_ModelPrompt.Notify(); 1 g0 C: E5 n5 K: h8 S/ E. \0 _
m_nStatus = DB_ERROR;; s. V8 b: M6 j( d4 s& F
return(m_nStatus); , U% e4 Q, Y0 A" Z( d3 E
}- f" V! D9 ]& k2 E" _' q
}6 d# g- w; n t6 G `
7 ~- X/ Q& K+ Z, x- w
% w+ \8 k- Q( q9 h4 j% G, [# ^
5 y1 G+ Z: r& I" y* @7 pfloat CObserverLaneDB::GetTollRate()! o. ?. r* @/ J* K1 y4 c
{
) Z$ s- H ?9 T" G4 `
" c3 }8 A2 j/ m5 b9 x5 `3 M _ConnectionPtr pLocalConnectPtr;$ C; Z3 [& J+ J& B3 A( h
_RecordsetPtr pRstPtrTollRate;
) ^) b4 @; l+ y5 l( V _RecordsetPtr pRstPtrOrganInfo;+ @- D" W6 _ y6 p7 g! e
2 W; x% Y+ |% l# m/ v8 v+ S, H float fToll = -1;6 d. U) m2 e' R
char pcSQL[300];
! q4 n; v% }& Y$ w- i6 ~ int nSplitCount = 0;
8 F- R5 W) O3 T) X( \ switch(g_ModelNodeInfo.m_nNodeType)
$ W2 q, E4 M& _* F2 x" f3 [$ | {
6 s, v7 q0 h o; ]0 } case NODE_TYPE_ENTRY:
& U+ P0 w/ j& K, X. E- R, n- s# f" q return(0);
; m" J, |* O; M) ? break;& t9 K3 r4 e+ Y2 @3 [
case NODE_TYPE_EXIT:; |% j% b4 @1 z) D! k3 }8 F
case NODE_TYPE_MAIN_LANE:! M* L+ j# s) L% O* E
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)1 @4 S" h" k, ~3 K" K* A& j; J/ @6 s
{$ V$ {5 b1 Y1 A% o! L
case VEHICLE_CASE_URGENT:
4 }6 \1 `' J4 u+ Q case VEHICLE_CASE_ILLEGAL:
) L1 L7 t, C+ I! U0 `% M& ]) f8 i* p case VEHICLE_CASE_OFFDUTY_ILLEGAL:4 O$ C! w! O: l3 X7 g$ T0 B
case VEHICLE_CASE_MOTORCADE:
4 K L& b0 G4 x0 j case VEHICLE_CASE_COMMUTATION_TICKET:
! M. b$ _6 G9 E8 t( ]; z case VEHICLE_CASE_ETC:& r( a7 t* `1 j: \/ j2 {& O! m
case VEHICLE_CASE_BAD_CARD:7 u$ Z! ~: K: Z
case VEHICLE_CASE_NO_CARD:7 t" x" O$ G9 l4 P
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ", Q$ N2 ~3 U2 \5 M; u
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,+ H8 l( ^9 C! I' _- b1 P
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
, B) W- g$ n$ d7 W0 p% P break;
6 T' t# _5 }9 P8 F4 ` default:
3 L3 X$ W# z0 A: ~5 H1 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 ",
( {6 e, \2 t+ h) H g_ModelEntryInfo.m_PassCard.nEntryStationID,. t/ N9 s" r/ O8 ~: q8 H( c
g_ModelEntryInfo.m_PassCard.nFlagStation1,
7 c) A9 t5 \& Q' @. s7 u g_ModelEntryInfo.m_PassCard.nFlagStation2,
; ~0 E; N% d- z3 Q7 B g_ModelNodeInfo.m_nStationID,, }1 Q. ?" E9 w
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
8 D9 h+ q4 u2 t g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
$ {: f) J7 { T; z) {! Q break;$ @1 W) e# e! U
}
- E1 d" m8 k* ^! p& m: b9 ]& w4 M* \ 9 n$ {, M5 l' Q. a: [! t
try
9 t2 F, s3 W" H K$ Z& }; F! L {
3 i8 O$ X% H6 T y% X pLocalConnectPtr.CreateInstance(__uuidof(Connection));
( x" ?9 [/ A1 r pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
; g, W/ O; M0 Z' m& E6 l F $ Z$ n S9 `" \& P& B
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));# G4 T, R9 }" m' X0 L8 y
pRstPtrTollRate->Open(pcSQL,
' a7 X+ u. N' Y8 U- Y9 H pLocalConnectPtr.GetInterfacePtr(),
: u5 `# D: p7 e2 o# \ ~ adOpenStatic,. F8 C) l; D Z% i9 ?
adLockPessimistic,
$ L1 K+ f. e6 y( K adCmdText);
! o- |: Y6 \3 }: u- H if(pRstPtrTollRate->RecordCount > 0)
/ U2 a A p* A6 x {
; i) n9 L3 e8 ^$ m fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;! i* w2 q( I, [9 O, [( F
if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
* ^3 F. M1 V* ^1 j: k* A! `. U {
j( s8 q$ u' A& L0 _( v1 q memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
- v1 Z- S2 b4 l( H4 P pRstPtrTollRate->MoveFirst();! r: [8 W" z3 y b Y5 V2 ~( x
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
% O8 _; S+ p- d# b {
% }6 B5 L4 c: o; ~ sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);5 _! H6 n6 @# a" s% L$ {. u% q. j
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));/ _: V4 g/ E. B$ j* a* N# m' n
pRstPtrOrganInfo->Open(pcSQL,: ~; Z& y! k; I5 U0 o0 R" j
pLocalConnectPtr.GetInterfacePtr(),. f7 g7 F/ m. V x
adOpenStatic,
O' v$ _" t# U @ adLockPessimistic,
1 G1 U3 l Z5 J/ k5 T+ o adCmdText);! y$ X% j# ]/ `( j
nSplitCount++;; J9 b, C+ T. ?) Y0 ?$ {6 r; J! ^* J* _* U
char pcBuf[10];
+ I& f$ O7 w* {- s if(0 == nSplitCount%3)
8 G( Z7 Z% h9 h) Y! @" g {" i( j4 H' z% T
sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);, y; [7 D- k: p1 r1 i! Q
}else' }) L5 ?3 k7 I) d+ d
{
a5 e2 E$ |0 O' a) @* y sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);9 K+ T! M/ k2 E7 B' ]
}
8 i" s. q; ?! s! k strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
1 g9 w% I: R4 h4 }( e strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);" V9 j3 O* e) p$ Y
pRstPtrOrganInfo->Close();4 e. b! v+ b2 O1 i
pRstPtrTollRate->MoveNext();8 ^" g$ g/ X$ {" c8 L' q
} b! e% P9 R, L1 ~) n( A9 c- {1 ?
}4 J: @9 n2 J$ b
# r* v# p4 D: t }else fToll = -1;
/ ?2 a& v/ R' }$ Y" y4 v
- L5 [1 t7 M2 d# A5 T6 O& F pRstPtrTollRate->Close();0 p! ^) u' c" B: R' k4 G
pLocalConnectPtr->Close();
0 ]7 H p: W) b4 w, o5 P m_nStatus = DB_OK;
: w7 Z+ X `4 C8 w4 N return(fToll);) U2 C7 l7 y# C/ ~3 r; Q
}4 U1 o* X# W0 T4 d+ k
catch(_com_error e)! b0 h3 X" v. n/ r# L" j
{
# t$ `6 K( m& h2 b& N g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
- r5 `; _' n; ? g_ModelPrompt.Notify();
0 V' ` j8 S' `& }: R+ v m_nStatus = DB_ERROR;
7 o* M, }* [0 q& ` return(fToll); 9 V! ^- t3 M y
}
& y8 v* ^7 T; G; T& p& Z
: x- m( P, @/ V$ N4 v break;8 o' G. f6 ~8 I$ W6 |1 _5 | D# x
case NODE_TYPE_OPEN:4 e+ ?( P3 ^8 j' p. O4 O- f+ c& B
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",( ]- V( v& O7 U. R [+ L5 X9 ~
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass# o' ]' P2 B. \
);2 g1 o2 M* ?" Y# r" Z
try
& C f3 i8 S J6 T/ I% J# r {$ V, v! h V. q/ n) u
pLocalConnectPtr.CreateInstance(__uuidof(Connection));, E4 S2 s% x: c* A+ }& \+ C4 B/ U
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
: l! n/ I2 w' ?: @- L) Z& e 4 y: B1 x) g: W5 N
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
7 H6 k: d* Q: `2 F' A/ B1 Z, @& i pRstPtrTollRate->Open(pcSQL,
0 ?1 E+ `( ^; V pLocalConnectPtr.GetInterfacePtr(),
. N8 h, F' f+ u( M2 \1 [ adOpenStatic,/ U2 ~6 A" e% t$ s% ^/ S7 [
adLockPessimistic,. q4 h1 D) X" {
adCmdText);# u" l, d8 |7 L C
if(pRstPtrTollRate->RecordCount > 0)1 D. ? G F$ @* e& p" P7 q
{
& {8 n. G6 K3 P fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;+ @3 w# d3 u& C5 [( C( f* [7 i
}else fToll = -1;
8 M% v% E. h( s. w+ X [' W1 J! j& A ; }9 Q9 z% y$ n; F ~% O0 e
pRstPtrTollRate->Close();
6 N( a6 \4 i* q% V" w& j pLocalConnectPtr->Close();
* D. z$ o) Q% R7 i( G9 c% ~ m_nStatus = DB_OK;
$ s2 [9 p* v: e return(fToll);0 W: b- H) ]: C1 X+ y
}
3 K) J0 f$ v+ { catch(_com_error e)
5 N0 X! F8 ], P2 k8 ]% k {
) X W1 s- J# @1 R% ?8 | g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());1 ?9 J; v6 D. m/ r( U0 i
g_ModelPrompt.Notify(); 0 a( ?4 N: ]" @0 t8 w! c! h
m_nStatus = DB_ERROR;
4 r/ U6 _1 M# ?4 K# c return(fToll);
) p/ C1 B1 \6 W q }
; `1 D, G1 g, M: x: J. j. k break;: g8 R5 s0 E% Z1 h1 h% w3 M
default:
2 b1 g6 k5 s. ^' E m_nStatus = DB_ERROR;8 Q1 Y1 Y' D! Z
break;
* A# [2 I; C9 r; C! {( C }% ] B# Y2 p1 R8 x+ n; z, {. ^
return(fToll); ' ~. l' D: k+ v5 E3 q! n
} |
|