|
|
int CObserverLaneDB::InsertTollSplitWasteBook() g0 k! H. L* v; w/ j/ g$ v' f& V
{
# Q4 i" u2 m, j, |; @; S; o! O _ConnectionPtr pLocalConnectPtr;
( T6 N8 x! e- Q; `) E: B _RecordsetPtr pRstPtrTollRate;. v* m% y4 p g. ]
_RecordsetPtr pRstPtrSplitWastebook;* c% g4 H) g9 @7 r
' L n2 O/ W, z char pcSQL[300];
3 a Z) u6 G+ x1 T# X* 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 ",
% F/ \/ y8 t; s2 G# b4 q g_ModelEntryInfo.m_PassCard.nEntryStationID,: ]; C* [ ]4 T) t4 f1 D
g_ModelEntryInfo.m_PassCard.nFlagStation1,
) {3 s8 V# H2 L; e g_ModelEntryInfo.m_PassCard.nFlagStation2,
/ n" P' H$ _+ ^0 }7 v# [ g_ModelNodeInfo.m_nStationID,0 E6 q* |/ D" Z! z& v
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
6 P6 _3 O; G9 O! `, {6 _4 [ g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase; A( D8 ]% A( `2 [) w
);
; @6 D2 Y8 Y |& f5 d' A6 d9 F8 _5 p3 X8 Z) z2 P$ s
try
3 J( l) ]& Z) k9 T/ O {
) E' S' X, H, u# l0 K pLocalConnectPtr.CreateInstance(__uuidof(Connection));
7 j" x# Q5 @! E' U2 ] pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
& C9 @6 {4 N3 o0 }* @ 0 C" U- a- ?! e! ~ O
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
2 c" ?6 e5 s& B' n: f pRstPtrTollRate->Open(pcSQL,& y, ^+ {! Y* l" T, b* _0 O
pLocalConnectPtr.GetInterfacePtr(),
8 Y; O9 n8 ]+ k: G1 m adOpenStatic,+ U8 m/ p. u& T0 Q( t! m9 | `
adLockPessimistic,
# _6 C( k) I; I1 ~! K0 K& m adCmdText);# s$ U, n! C/ t; Y5 Y) c* |
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));7 ]& S) s9 C) d8 Z2 F
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),, W& W' R1 v/ L6 G) D7 s9 y4 l
pLocalConnectPtr.GetInterfacePtr(),
2 `) J. m4 L2 ^6 C9 e! f9 f) m* ~ adOpenUnspecified,
8 z$ k% e3 z: S: L' p( i& E adLockPessimistic," e6 [% E# x& y
adCmdTable);
0 U. _4 `" X" [* j
0 Q# J3 Z1 r' Z% w$ j' u; S6 ^ pRstPtrTollRate->MoveFirst();( P$ T1 ~# x3 r# J
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
- @* v8 H4 p4 E' y {
# a' a& K7 f5 a# K& ~3 M/ b pRstPtrSplitWastebook->AddNew();
6 W3 @, x3 o5 k$ E# r" x, |) _ ~ pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
7 d4 O( K! R3 O( C 1 {3 L) [$ ?6 e
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID); a: O I+ w$ t* Z4 V8 i4 s% q
% o( y; o" }7 a* a7 D pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
& f& E0 `4 P4 u# k& G* M3 [; d
* y4 Z8 y9 F6 V pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);* D7 V+ |0 b+ i' e0 B' f
# B7 [1 ^4 D/ y3 t+ z- f9 D- @
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);- ^- G2 \5 b: i# H7 W
pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;6 C% |6 C/ ^8 F) A; `0 r
3 k6 ^! Z1 p" d
pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;
/ m: E# H; M+ Q, e/ i( e0 M7 o
# E; F D0 C% k4 i: r+ c( X5 z pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;6 Q- p; ?( s( |/ }
2 z/ G; z& m; u5 d- M+ p pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
1 y6 e8 ^) Q; X9 P, y7 }) t " z, T1 n: I* _. h3 u
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);
% X& Z/ d9 S& w- t3 }7 s % S3 s/ j/ P5 F! r* S1 x! |
pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
! J( Q' o1 @/ j! @( ]1 i/ r# D 8 g1 m" K5 S0 k) [* j
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;/ {* L0 e2 Q( @2 s
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;/ c& g, k O2 W1 U3 t0 f v2 u
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
4 D0 |0 \, o, i6 r/ |" u7 ^/ Z pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
% v8 H8 N/ S6 \2 N3 I7 r- s
% \8 r2 T x6 P( a& L9 Q$ o! U3 a pRstPtrSplitWastebook->Update(); 7 f% q# a$ i+ |8 C4 G$ M
0 |' ?! i1 j2 B0 Y: ^8 k2 `: l m_nTableSplitTollWasteNOCount++;
4 Y; Y) q9 m7 l pRstPtrTollRate->MoveNext();
# D! m0 |; ^9 f& z l } + j0 _) q$ |; M( F* K3 Y
pRstPtrSplitWastebook->Close();4 ~% N, M) A* [7 u% T( U
pRstPtrTollRate->Close();1 C: y% S; l5 T
pLocalConnectPtr->Close();2 c6 ^: `" n3 s) W/ v
m_nStatus = DB_OK;2 D O9 r& w* R' p# a( ~1 b. e
return(m_nStatus); , {; k$ s) r3 e* q; Z* f
}( X$ {! `2 s6 w6 p7 w8 x) U
catch(_com_error e)
# u0 j6 z0 H0 B* } {. a% ?# B* L5 `5 Y, h7 J! d. W
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
$ ]; t& }$ P8 i7 L8 d0 z g_ModelPrompt.Notify();
7 v( J$ t8 K( d& I& } m_nStatus = DB_ERROR;1 u' a/ _1 D/ p/ u
return(m_nStatus);
: e# _, V# R C* _' ]" |! G }
1 z5 M: e3 r" v3 P- x- }}7 g5 O8 ^# j* s' W% `! Z
5 x- y0 \2 F& d* G, b
. v! p5 P3 C& n _, ?" W2 h! W. B0 u
+ j/ p m# { \1 ~" D }float CObserverLaneDB::GetTollRate()
* [4 M9 L$ |5 L5 z6 X; U) c, M{, C; D G4 _0 B+ V6 {$ i
2 l& \" B0 X" u# _$ I% N _ConnectionPtr pLocalConnectPtr;1 O, G1 X' B2 [: ^
_RecordsetPtr pRstPtrTollRate;
" ~ v# }! z9 _: Q$ m4 D: e( F _RecordsetPtr pRstPtrOrganInfo;5 s3 ~, K. j) t+ h1 l
9 R \+ g9 ]5 ^ a! S. ~
float fToll = -1;" D5 Z0 T( a1 o7 W/ n! E
char pcSQL[300];! z7 E( F6 y: p9 Q
int nSplitCount = 0;
' \; o' X! K% |. Y6 o# W* M switch(g_ModelNodeInfo.m_nNodeType)
' A) }0 I2 c1 L" h {
9 W/ X; K) O& w" a) H: H case NODE_TYPE_ENTRY:' P& s1 @( i& X) o8 k
return(0);7 S) k% T# w$ q$ r$ N' K+ g
break;' p: K8 D7 {2 ]
case NODE_TYPE_EXIT:
, w2 {6 ?$ c4 L" n$ ^" K. F) O8 z case NODE_TYPE_MAIN_LANE:9 b X" B$ J4 q( o( V1 ~8 P2 w% Z# e
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)+ n/ _3 o& H$ a3 o' X( ` p' V+ B
{. d0 u9 _- I" |
case VEHICLE_CASE_URGENT:. n0 d( B6 v& S& k2 P
case VEHICLE_CASE_ILLEGAL:7 x7 r. ]0 {- y. X" O$ A: y
case VEHICLE_CASE_OFFDUTY_ILLEGAL:7 u' t* w# F: e2 O8 I
case VEHICLE_CASE_MOTORCADE:: i7 p3 G3 W' ]8 ^9 o) r
case VEHICLE_CASE_COMMUTATION_TICKET:
6 y& N- Q' w3 ~+ p" Y8 S case VEHICLE_CASE_ETC:) v! Q/ i1 l) ^. i. f5 u4 E6 j! G
case VEHICLE_CASE_BAD_CARD:/ z2 Z/ B8 F' _$ e4 I) T8 `
case VEHICLE_CASE_NO_CARD:
7 u D# U2 \' W8 Y: ]- m sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
# |) J; [9 A" {: \& U" k) w g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
* ^, u/ b& S- i; m g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
7 i4 r) m% J0 K* R2 _0 S) G break;
J) l, l. f$ x( \1 `1 u default:5 {$ _( l! e. M; @3 X) [( P
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 ",+ `' Z; {8 c) t! f( R" b
g_ModelEntryInfo.m_PassCard.nEntryStationID,8 ^+ L( o9 c: l4 y: I( [2 a3 Q
g_ModelEntryInfo.m_PassCard.nFlagStation1,3 d/ {% C2 q. X; U
g_ModelEntryInfo.m_PassCard.nFlagStation2,. w$ }7 [( ^! w: S" t4 M
g_ModelNodeInfo.m_nStationID,
7 \3 F% D! V+ A$ S# E2 j g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
5 x i+ V e6 ?7 }! C g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
3 j \+ y1 Q! `+ m M8 g: X break;) z& o! j/ Z- ?0 p: a& ]
}
$ P# ?" B4 A8 m6 e' @$ _
: K5 ^% w2 g( G H) x try
3 E9 s! S" {9 d$ | {
0 ^( _2 y8 q& h8 i- q. Q+ R pLocalConnectPtr.CreateInstance(__uuidof(Connection));
8 H5 @% z/ \2 \/ Z. J4 {6 v pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);1 t# y1 z, [2 [$ H
0 x5 ~, P! `! {9 ` pRstPtrTollRate.CreateInstance(__uuidof(Recordset));( ^! ]) T$ V# U4 J7 F4 |5 _
pRstPtrTollRate->Open(pcSQL,
) @' @: X- k7 F& A5 w$ e! s3 Q pLocalConnectPtr.GetInterfacePtr(),
$ E, Z1 u7 Y" l- d3 T2 b: v& W adOpenStatic,
8 j9 o4 U; T' O% y adLockPessimistic,0 V* T. v8 ?/ I6 t
adCmdText);
$ e3 s( k/ i# K5 a# S; x if(pRstPtrTollRate->RecordCount > 0)% T( t' v5 Q) K
{
- M0 `. m$ @, [3 ?! z& U% y fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
# H- F# ^( N) N2 O8 Y$ n if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 ). l7 g b9 Y1 b& R
{& a1 f' J5 M4 J w0 q
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
* A4 k5 X5 s7 e: w& S! K6 h$ a pRstPtrTollRate->MoveFirst();
/ K4 X% |4 O7 Z* @/ c) d for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
1 C4 a% Z$ g" K# w5 b: Y5 ^ {4 k4 X& t( A U. [6 r
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);1 i% o1 c3 ]# Z& b' b
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));
) k( l4 T) e. g& P) Y( y% T pRstPtrOrganInfo->Open(pcSQL,
" d) F, a) Q* a+ g pLocalConnectPtr.GetInterfacePtr(),
* |1 f! I( T9 L q5 U1 B adOpenStatic,
9 {$ u& \+ s) f0 E9 D9 _0 s% ]$ o adLockPessimistic," y: C2 E' T, M/ N, K( m
adCmdText);
2 q8 Y2 W$ o& J* p" n" A. A8 Z nSplitCount++;
, E4 j. g- y ?. g& G: K char pcBuf[10];6 y" {& M; ^; y- H; I
if(0 == nSplitCount%3)2 q% b# H% q8 h* V$ v
{
* _- [; }: d; S1 s sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
, J: x& a) z5 n1 D/ G }else4 y/ X/ i/ U% i
{
4 d& E5 O/ ?4 L( c, W sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
+ w4 i* u$ i& f }
0 ~- y* `6 o- i strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
' w. C& f; H8 [2 a strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf); B: I+ B: K8 t0 r3 u
pRstPtrOrganInfo->Close();& P7 v+ N$ H2 J, U" u' j: w4 h
pRstPtrTollRate->MoveNext();4 }; E7 g `0 B G# F+ X5 ?% e& F+ G
}+ f. _/ |0 k0 e2 g/ O1 Y: U @) f! U
}
q$ w/ _* p$ J# S1 ^! ^ ! C$ m2 ^6 u% x# A
}else fToll = -1;0 d. w' S: r: N6 }
/ D7 v6 B6 Z5 M. g
pRstPtrTollRate->Close();7 V$ r m0 ?6 f1 }0 x: X
pLocalConnectPtr->Close();
# z" S4 f% D+ M, R3 N5 \, f$ u; _ m_nStatus = DB_OK;
8 G6 q; k# y! _4 i; D+ U return(fToll);
; D' o6 Q2 P" Q" C2 ^4 E }/ s }1 L5 v g' b2 G, s5 _7 G
catch(_com_error e)7 m6 S5 @# c& \- D) {. I6 m! ]& Y
{$ I3 B( B+ |5 U4 t
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
3 w2 _2 p8 q5 X, I# |% i" | g_ModelPrompt.Notify();
5 X# Z" b3 Y+ q& ^% g v0 H$ b m_nStatus = DB_ERROR;# k# |! \ P3 t5 t, Q
return(fToll);
' d8 H; u/ h% E }: n" y- @0 _1 W2 c$ ]' q( J: Z
2 g2 O' }8 _, S. b' F break; A! n3 d9 X/ z2 u
case NODE_TYPE_OPEN:, i g$ J$ s/ o" C/ w. @
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld"," Z! I) G& q, b! h; Q
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass. T( W B( ^5 d- V& F% U' }# o
);
0 G t( v: k- H0 Y/ T% N try: a# Z" I, B' M* X' A t
{0 d, N% p0 r6 c
pLocalConnectPtr.CreateInstance(__uuidof(Connection));2 v$ ]# z# n0 Y( N
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);" ?! }# R( z2 B- _0 L+ I
! g$ D( l* y- E$ _+ M) [3 m0 j
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
/ Q k% a/ |; n5 s pRstPtrTollRate->Open(pcSQL,) c. w( ^8 {( s; B
pLocalConnectPtr.GetInterfacePtr(),
( |6 @5 w7 v& ^5 ^8 E) V, l/ w2 q" U adOpenStatic,* Z0 o" E# X! K( T: N! e
adLockPessimistic,- s) T* o0 P9 ?- {; {' C
adCmdText);% z/ Q6 P {8 F3 J# s: B
if(pRstPtrTollRate->RecordCount > 0)1 C. S3 T5 b% I0 I4 h5 e. R
{
+ }2 h* ^0 j1 i, J# n7 f fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
. {3 w) @6 ?; \4 Q( l" R }else fToll = -1;
- R- N6 X) W* h% X6 o
% }$ \ a4 z% ~. Z pRstPtrTollRate->Close();
; O, {- l5 e1 `$ z pLocalConnectPtr->Close();
+ j& |4 y: ^) ~7 }- L+ y) Z' c m_nStatus = DB_OK;
7 g1 p3 }* ^# ^; | s return(fToll);
3 E9 a: D, W* b1 [# T+ Q7 i% G3 N }
7 U9 \2 C x( M3 x+ R% Y catch(_com_error e)
/ m4 s9 y6 a: m' p; a! @8 P {
1 s" ~' H0 |( `/ G( W g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());$ @+ s+ L, a7 H1 c
g_ModelPrompt.Notify(); ) W4 C- y- q" i8 s1 z* i9 J+ P
m_nStatus = DB_ERROR;3 H y- f( x9 S7 K: p( c% S
return(fToll);
# U) Q: A8 _6 l! q6 N! x }
6 k- C0 ]3 Y+ y break;3 e$ c! F n7 _3 p" v$ k
default:2 i: p; v9 \9 t; G
m_nStatus = DB_ERROR;6 l9 z) Q, G; x- a/ w
break;
$ r/ X0 y5 P9 i0 E& k8 W }
1 l% Z3 ^1 f3 B1 @0 E) F1 l return(fToll); $ f4 P5 [8 e1 N4 }+ z+ T
} |
|