|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
' D8 v @- U- |; I D& }' M{
4 a+ M: s4 y1 w- f* A# f3 T+ b _ConnectionPtr pLocalConnectPtr;5 ?8 F* ]0 q q) D
_RecordsetPtr pRstPtrTollRate;9 L M, q' i8 o) Z- e
_RecordsetPtr pRstPtrSplitWastebook;6 c0 r$ ?9 }2 f1 [( j
% N, T/ g3 Z0 @8 J' A' T( R- J: k- D char pcSQL[300];
7 K& l l6 z7 @/ b/ P+ n 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 ", O# J4 N, ^! {
g_ModelEntryInfo.m_PassCard.nEntryStationID,4 x& S: A9 ]; j
g_ModelEntryInfo.m_PassCard.nFlagStation1,
& k6 r$ q# E* [2 u g_ModelEntryInfo.m_PassCard.nFlagStation2, W3 W- g# ^5 |4 H+ X5 j) X
g_ModelNodeInfo.m_nStationID,
2 t9 q5 o! c1 O( F9 g, C g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
" O3 W$ J& \6 O5 P& B7 Q g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase
: k; y, A) V8 l/ f* L0 @7 o6 H$ A: B' C );' [) F+ P+ F0 `0 o# n- g7 [' k% p6 Y
9 J1 ~" J3 o. d3 Q& i, f, q. [) i
try
$ R: T6 z6 v, ^ {
8 [ P7 O% D7 Q7 t: O `3 B( j pLocalConnectPtr.CreateInstance(__uuidof(Connection));: c) V* c3 s g& R( Q
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
/ v8 [' m% U9 @: v) C. o
* T. E3 w" @3 {. ]- Q" } pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
! J. V* p' i A( P3 {% d3 j pRstPtrTollRate->Open(pcSQL,
7 h+ Y8 k7 L& G7 E- b$ d/ l/ \ pLocalConnectPtr.GetInterfacePtr(),
5 ?# A) n5 t5 {3 C adOpenStatic,
; }1 L8 b5 l9 L, k* V" ^4 a adLockPessimistic,
. A3 m q4 I. t0 y% Z adCmdText);2 G# k& a3 q* ?$ C2 M2 }7 Y' T
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));, {) U& W$ @0 w @) m; c
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),
% h8 ^" U+ W* ^2 n8 F3 m pLocalConnectPtr.GetInterfacePtr(), M! g- D" G, r/ V
adOpenUnspecified,
$ K! _: E) P* |; d! G adLockPessimistic,* K. ^8 G0 y5 r0 z4 P7 |6 _
adCmdTable);
, s7 U: L! W8 E
+ {* _5 K8 Q( Q# v pRstPtrTollRate->MoveFirst();
% P9 n* m a3 J1 z for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)4 F; Q) E! k* p. `: j4 t3 }7 Y
{1 O# l" g9 _6 ]
pRstPtrSplitWastebook->AddNew();7 V- h7 L2 H; T: g
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
# h3 ~1 h) w+ d& e% z
( Z# `: h: l1 P- M c# U pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
! o/ X4 D8 ?& ~3 ]) y5 Z- E0 D , `: c1 B: T( W$ R
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);, d2 {: p% \$ W$ X
. J6 E' i% b: B H7 M0 ?' H pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
& ^$ N& D9 c4 ^! F4 u7 h6 H ( e/ b2 j% j8 x+ D+ u
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
- o4 e- C, b/ p! h1 i pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;# w+ m- H4 A1 H- B/ A
6 J( v5 I( `/ t4 n, \8 g. Q0 m
pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;
( y- _! P. t+ e$ s 3 M3 k2 F/ n& }7 d; {. V I
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
( i. y: ?6 c6 k- l$ \ 9 y: I8 j- O9 T/ d6 ^
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
7 {% ^% N' B/ M# c/ h4 X- r # d2 o+ A, ]# K
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);. T! ]( E# A$ v! A' z/ @ U( E
* [* m T) | R
pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
c) P7 h- t @" }7 | ' ^, z) Q* B: b, W/ i$ J
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;
l6 d3 r: O9 [1 l; S float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;. V8 b& \" ]9 b& V. I9 q
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
2 ]) S o( ?* O: T# y pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;) F1 a: Z: L0 C/ W- m, N! H+ G
) U# a. [2 k0 j4 e/ {+ s g
pRstPtrSplitWastebook->Update();
% S2 A$ q/ B; L: B6 e' J# h+ N: ^
/ Q+ G) Y _ `8 v% ~ w m_nTableSplitTollWasteNOCount++;& ]% \) V% u9 x* o8 \4 b5 S! G
pRstPtrTollRate->MoveNext();
- `5 [9 A/ }) z8 s } 5 z$ S- ?0 `2 O: p
pRstPtrSplitWastebook->Close();
2 M" f- O' q/ N8 ] pRstPtrTollRate->Close();
7 h4 j7 n- m9 t4 a( Z" D pLocalConnectPtr->Close();3 e! G& X7 `5 S/ r" e9 l* _; f- @
m_nStatus = DB_OK;
$ H1 j" Q8 z. \; y+ y/ X return(m_nStatus); + n! I7 d/ L8 e% y3 q
}
& w. W& l( ~ {: v9 ^8 l0 K* l; N catch(_com_error e)& e( s/ D7 g" x
{
) g3 h6 F5 m2 n5 Q. r( `# n r g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());# M: |& M z5 q! w1 ^7 t
g_ModelPrompt.Notify(); - p& S2 S/ N1 ^5 K4 U
m_nStatus = DB_ERROR;$ K4 m# ~: v: U. v# G4 D% T+ F3 O1 n
return(m_nStatus); + _. K7 c! V2 @8 p8 \
}
0 `- K3 ~2 |& J7 s' {: W2 C& |}' ^2 O! H7 P& n! @5 [
* b( R% K+ D) g- l* u- a
$ _5 }+ E3 l6 g! p
g9 v. V- j8 t8 ~+ A4 Ufloat CObserverLaneDB::GetTollRate()
( f# ]) z7 n! V& c( v{' q9 h; @# t" p
0 r" A& ^1 H4 D9 W9 N4 ~0 p4 ~& {/ z7 W
_ConnectionPtr pLocalConnectPtr;
' _+ v, J+ a5 K _RecordsetPtr pRstPtrTollRate;
0 N3 b% @ h! k' G _RecordsetPtr pRstPtrOrganInfo;
6 z8 d7 g; x% c" ^2 r
. r% x$ ?6 h- m0 C* ~& R float fToll = -1;4 _" t9 h8 ~) r# m! Z& D x+ S
char pcSQL[300];
* o% g' U0 k5 a7 C. _/ m int nSplitCount = 0;
) V6 X3 U9 Y: b5 n p switch(g_ModelNodeInfo.m_nNodeType) l. H5 Y9 T1 {0 j' q
{. n: P) M7 |+ C6 D' u4 }$ G& W
case NODE_TYPE_ENTRY:
0 |. {+ Q' X/ ~ N u" l5 k/ g return(0);& g1 l6 w; h4 n- e1 T
break;2 t# m ~) G* D: h/ g" u, v
case NODE_TYPE_EXIT:
! J& _1 z/ X2 i6 {0 G% U3 } case NODE_TYPE_MAIN_LANE:5 Q" y# u5 k, z8 q
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
2 L0 M+ I2 |, {$ Q, i" x" F {; X2 {% V2 W) z% @3 q& ~9 l6 S4 u/ c
case VEHICLE_CASE_URGENT:
0 b7 ?0 X5 Q9 o5 v9 ]$ C) ~# v1 b* Q case VEHICLE_CASE_ILLEGAL:
3 t( h, [ Y0 f4 m case VEHICLE_CASE_OFFDUTY_ILLEGAL:
9 m) o, k9 X+ l- Z9 i% V; ] case VEHICLE_CASE_MOTORCADE:
% \& t- q; _- S- h4 M$ x3 H5 x case VEHICLE_CASE_COMMUTATION_TICKET:4 S, m, c# [4 i
case VEHICLE_CASE_ETC:
. q$ u. `8 |, k7 j& n0 p case VEHICLE_CASE_BAD_CARD:
( g1 |: K9 ], [+ F/ _5 M% Q& j. | case VEHICLE_CASE_NO_CARD:& ?3 T& k& [" v
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
* K- U" w7 d1 H. t0 K g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
3 k+ ~7 \: U* k/ Z* T7 R g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);0 |5 a3 ~; o% O
break;
6 M/ n1 ^/ `0 B7 }" u default:3 [5 A( a2 Z2 i% k5 y
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 p" k8 s" O0 }! j( P- T g_ModelEntryInfo.m_PassCard.nEntryStationID,
( U# ]1 a; E) Q3 b7 ~ g_ModelEntryInfo.m_PassCard.nFlagStation1,1 n1 }' Y1 J) I1 E9 ?
g_ModelEntryInfo.m_PassCard.nFlagStation2,
, I' |! H" n! c( c2 f# s: r$ N g_ModelNodeInfo.m_nStationID,
$ a* Z4 x0 m# v8 W# v0 z g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,) ]8 T2 {( e) G$ ~
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
% U/ F& [" r) z# S0 q! w; h* w; _ break;
9 v% M3 X: a8 K! E }7 a( t; G- ]" j9 f% ^
; i& r, z4 y, D3 l
try
9 L+ ]/ o6 \1 H4 X$ \9 | {( u5 H/ A; x, C& V: \9 v/ w
pLocalConnectPtr.CreateInstance(__uuidof(Connection)); g; k' l% L8 Q7 X! m; s# ]% `
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);9 g) p% t+ g, U$ ?
2 X5 S3 R: x Z. r8 q. r: S pRstPtrTollRate.CreateInstance(__uuidof(Recordset));5 _3 \. K$ V- r, y" @* F% v
pRstPtrTollRate->Open(pcSQL,
0 V# g( d' f" v7 c: E1 @/ R8 ` pLocalConnectPtr.GetInterfacePtr(),
& V2 d, A- {8 \4 g7 h adOpenStatic,9 N. Z- s4 } |( k' h/ p
adLockPessimistic,; `4 G- N# z/ P
adCmdText);
8 L1 @. w1 e& Y0 q' ]1 g+ J if(pRstPtrTollRate->RecordCount > 0)$ {: L9 ?; G* d a, I* }
{0 L% |, [" c ^0 B7 v7 D b3 b, T
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
0 }! h" C2 n4 ^' G+ J- K# B$ `$ G if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )9 o. Y1 {+ j" w
{
! x: ?5 l7 {& R* t memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
9 ?& V$ t g/ f4 C$ _ pRstPtrTollRate->MoveFirst();% { u+ c1 t' {% m* D# [+ Z
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
) u7 v2 R) z* W, _ {
7 H5 j, Y/ B) V( ~1 U1 \ sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
9 I) `2 e- l7 I! o( A pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));7 J3 c- n$ ~- `
pRstPtrOrganInfo->Open(pcSQL,
. g& d/ b0 W# v pLocalConnectPtr.GetInterfacePtr(),
: E0 L7 ~. b$ f2 V7 N8 F' r) U/ l adOpenStatic,
4 w' [, A9 M- V/ ] adLockPessimistic,5 K) Z# D# s* C* @6 |: L
adCmdText);
8 k: V6 ]# o) A! c! L nSplitCount++;9 I& w7 Z0 r3 D' q; Q
char pcBuf[10];4 C8 J8 [9 `9 L
if(0 == nSplitCount%3)* G$ @+ m& X* Z- J* T0 @% P
{
1 X7 Z/ i; z, n, E sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
* i( p+ n2 b8 M, G }else0 I6 }4 R9 x5 H, ]5 t
{& H: {# O6 i* O9 n% g' y
sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);+ t* U8 x8 C1 X' U T
}( d' w0 }2 r; k7 b7 n0 ?
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
! h+ [9 V9 H5 q: R4 `& u strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
6 D) v5 E3 C5 @2 x pRstPtrOrganInfo->Close();
/ Y6 I! g8 T/ t5 e0 M pRstPtrTollRate->MoveNext();
7 [' l1 c7 ?, L }
5 g( O& P1 W& p, A, E3 ]3 V% x }2 W0 p- h+ F! _/ ]
: `4 N1 ~) e g q ? }else fToll = -1; |/ X/ ?/ n! Z: V; a" R
' W4 I4 q- x9 w$ T& i
pRstPtrTollRate->Close();, r0 j! k: o- Z4 t" C
pLocalConnectPtr->Close();
/ _8 a+ ?# |5 j- P m_nStatus = DB_OK;2 I5 ]: q" k0 r7 a0 z
return(fToll);
! H( B8 R( q3 n" s& H. l: e1 P }
7 i8 V" R; H6 M. L) i catch(_com_error e). ~" z+ n& s2 j6 i X: [% r7 f
{
8 g8 v1 w- v! E1 m8 H/ q g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());, n9 X b' {) P5 t% b8 q/ n. f, y
g_ModelPrompt.Notify();
9 C2 g0 D( ^( n+ H$ Q1 t5 U% v- o m_nStatus = DB_ERROR;" Z2 y |: X# T* \
return(fToll); , p: W ~" H- N4 a6 U
}
- J( V4 y9 R5 W- k; N4 _- z
( |6 x. R/ i! _9 V8 f break;
: i. W) \1 Y# t6 F' W* T) w+ b case NODE_TYPE_OPEN:4 j) k1 q! d9 F) v0 l
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",
1 H ^& A! F- Z g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
- u- I0 j! I+ x' o( S6 ]. `' A& q );
2 F- Y S$ Z3 `! \4 U try! O8 |0 g5 a8 t1 Q* S) C! F, r
{
9 q2 D: }. Q# Z9 ]) Z& s" s. G pLocalConnectPtr.CreateInstance(__uuidof(Connection));6 p* d7 j, l, |) Q: G% s! Z. X
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);- X$ W6 E; l" d7 H% [& C
% s3 e# _3 I/ {! i* q% U k
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));% l. R: G9 p/ K/ e9 z' U9 i
pRstPtrTollRate->Open(pcSQL,
w8 Y( u3 r; v pLocalConnectPtr.GetInterfacePtr(),( u7 u _5 O( S6 b9 t/ D
adOpenStatic,
/ z! u5 M" e/ c: O adLockPessimistic,
# M. W' O5 S# Z, B; K adCmdText);; Y% l& i! k r4 D% L" X! V
if(pRstPtrTollRate->RecordCount > 0)
G. h4 X4 h( @$ i W1 `+ l3 n5 | {
$ l# \+ x/ T) c% {0 p4 t: r: a fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;/ [( R+ ^2 T6 ?2 W# V
}else fToll = -1;
4 A7 G# M9 T; ^# V4 A" [5 x: W& S 2 d( T: o6 ]) j
pRstPtrTollRate->Close();; d/ [6 O$ k% k+ q6 {; q# ?* \2 x! ^8 E
pLocalConnectPtr->Close();
" ^! A$ ?* M5 f0 ^4 \9 a% `# x m_nStatus = DB_OK;
: t# d; Y$ ^2 M: I" l8 s return(fToll);, n* m. D* O3 N8 W* K% P
}0 s0 c9 P9 \# d" p
catch(_com_error e)
' E- t0 v# k" g2 A; e |7 ?6 W5 U {
" S4 q7 H& Y- g) u g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
8 S3 p1 E0 K, C$ q: a5 r" U g_ModelPrompt.Notify(); - Z7 W v: L( U- _# F
m_nStatus = DB_ERROR;8 V: c: g. n$ G+ [
return(fToll);
2 E* V5 p# S9 J! a* X# E( N2 }# Z) E# T }: g: M( ~2 x4 m: u5 u) u7 F
break;" ]2 K: Z" q# y+ u- `% F
default:
4 Q% \+ o: n- Y7 f& B m_nStatus = DB_ERROR;* n6 ~" U# h: L" z: d" O
break;$ }) h5 S2 p' {( g4 W6 t
}# o8 W- p& q5 p* i+ e0 d
return(fToll);
q' _; r1 n$ a0 _} |
|