|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
4 C: ^6 L* g, d* V/ |8 Q2 I" C{
: T' O% ?8 F4 R+ p2 c2 p; } B _ConnectionPtr pLocalConnectPtr;& K0 t; p1 f2 w( l) i+ X
_RecordsetPtr pRstPtrTollRate;% Q4 z0 C# j4 F% O( Y5 Z2 |
_RecordsetPtr pRstPtrSplitWastebook;
9 M7 U9 f% m( `7 p& t
: m! C$ t9 G$ O+ V* i# j9 S4 D char pcSQL[300];9 j9 G0 r! u0 l3 e) O$ _
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. G i j8 s g_ModelEntryInfo.m_PassCard.nEntryStationID,
/ \: V* z/ J- `5 Y g_ModelEntryInfo.m_PassCard.nFlagStation1,; W. p7 w* M- G3 Q0 b( v
g_ModelEntryInfo.m_PassCard.nFlagStation2," a G! z' e c
g_ModelNodeInfo.m_nStationID,
; o$ G1 }+ |) M8 O$ f g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
6 m7 U4 s! D; u' r: [5 x g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase
" \ C) \* J" r. ? );
$ @6 a5 q9 N0 ^: t- U2 A/ A2 ]; i& G) ^# q3 p, \& J
try
4 f9 ~9 I. g. a S {: N! `! U& F* C! X' H6 a
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
7 w$ A- c0 t8 W% `! K2 Z9 p) J2 ^ p pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);. D% l. E5 a: i2 c9 d
; v M4 J! }3 n pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
- M* y0 k& x" D% s7 T# f$ B) {8 \ pRstPtrTollRate->Open(pcSQL,
' n9 r9 q$ H" ?/ u' U. p9 g d2 | pLocalConnectPtr.GetInterfacePtr(),
# e1 b3 H1 K* N1 J adOpenStatic,* m1 y3 e4 D6 }9 X
adLockPessimistic,
9 D& ]; _) [6 q. @. ^: b1 Z$ L adCmdText);5 J8 f, l' S L( ?
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
- h) k6 j6 I6 A1 B; \ pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT")," P* z* E' u. {" v- _0 [
pLocalConnectPtr.GetInterfacePtr(),$ m6 J, l# j8 r0 |8 M: b
adOpenUnspecified,
- D7 L0 g+ `: D adLockPessimistic,4 e7 D: s1 K2 T0 w- K; u# Q
adCmdTable);! e( s& V) X# ?2 ]4 q1 V; L: M8 ~9 f
$ W! n; S T# o5 W% l, c" }# s
pRstPtrTollRate->MoveFirst();
% ^% |4 |( p3 I5 J1 [( X( a for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
' z8 W5 V: ^. W7 e" g5 `- I M5 u9 X {
# T P ^% ?. c! x; u% ] pRstPtrSplitWastebook->AddNew();
\) a6 D' y/ R* s" J3 u0 {( R pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
: F# `' k3 t! f; G0 A) s" D : P% ?9 o# m& _7 S3 s
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);7 v" S, v4 q. }: g% j {
' c. u; J# y1 _0 h" e% w
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);2 _# [7 b1 w! V$ ~
& }7 p( S8 z: I2 G1 g8 [4 a pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
* f- T% Q% k# b3 L2 c
6 |) ~ q. ]* q9 T COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);$ u0 a- a, g; J
pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;( e7 S" z6 N( H7 W$ J
5 ]; d3 H i# {" ]) p* D pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;
5 ?+ ?! l+ s8 }+ L
0 z5 B! B) s* Y' C! S E3 a pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
! I1 J7 L; W# E/ I " @: J7 F- K* b3 i
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;. T: y' `6 k$ L5 e$ A
. q( m( L$ G! R C8 a- o/ d
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);+ `9 s' s" c* ~& E
, o* T( ~6 o- ? pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;0 W8 w9 `: D) i/ e% Z0 w
2 _8 [- L: d! @" A7 |7 x+ [" @( C float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;
# h* [4 K1 G Z5 t5 V. } float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;# k( I2 D! t( J7 F# Y
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
* |( |% ?+ y: i& f: V! _9 O- C pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
& i6 K9 o; {( g" X$ H8 ?
& V, c9 }) K% S$ d9 x pRstPtrSplitWastebook->Update();
+ `, m7 b5 b6 j. j1 c) `: d5 i r+ G
$ G7 B4 \6 z( o+ w m_nTableSplitTollWasteNOCount++;; _% z7 [6 y0 Q, _) H/ v5 T2 [
pRstPtrTollRate->MoveNext();
/ k8 v! P: ]. m* f4 L }
' o/ W: |; Z# n! p p pRstPtrSplitWastebook->Close(); R4 J" K! _7 {
pRstPtrTollRate->Close();# ~( P2 F* N' R. W: H- J
pLocalConnectPtr->Close();
: S) I: k ?) A4 E7 U! j% S+ p* r m_nStatus = DB_OK;
, O9 |1 w! o# u3 i- K return(m_nStatus); 5 H- j& }% o2 w. c) ^ B0 ]# J
}
/ i1 J+ c9 D' n catch(_com_error e). I- [1 v6 M! W S0 @2 |
{$ `, Z$ j$ }0 O$ `3 N7 P! q( c
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
" P3 @$ n8 [* R q7 w g_ModelPrompt.Notify();
* |- h; M K; Y m_nStatus = DB_ERROR;+ L; X4 X- b- B+ \
return(m_nStatus); % U3 W- E5 _! O! H# C) j
}7 B' T0 G* T3 S: N
}9 ~3 H) w0 A4 Z( |2 p
' w. ?1 P0 r8 ?4 v' \1 O% Q3 _5 x+ }5 s+ h
a4 c& W$ f. s# Lfloat CObserverLaneDB::GetTollRate()
, n4 e8 D3 R" m3 J. d! _. |{; U: D) b: t' D4 o& L. B z5 N1 v- O
+ d2 D9 }5 G: r$ P! ?0 u
_ConnectionPtr pLocalConnectPtr;" M/ }# s& G5 K2 F# ^
_RecordsetPtr pRstPtrTollRate;
( o6 r1 C, B( |6 p/ x _RecordsetPtr pRstPtrOrganInfo;
$ ~1 c7 U% w* {3 k4 G. p
* K4 \) |+ r+ h( J% ~* h float fToll = -1;! Q& i, T; U; T4 f+ X) `+ \
char pcSQL[300];# x! r# u, E4 J
int nSplitCount = 0;
) E( ?% w, b5 \$ |. T5 F- m switch(g_ModelNodeInfo.m_nNodeType)
6 J( o1 g* [) m( o/ B% x {% o, `2 ?' p7 r o
case NODE_TYPE_ENTRY:
6 Z7 V Q4 v3 a* K/ H return(0);4 S' E& L6 _, P$ a! F3 F( K
break;
/ ] e% `& N) e! i case NODE_TYPE_EXIT:. F9 ?2 D( u; A' M. x7 c) g* r
case NODE_TYPE_MAIN_LANE: W! b: g5 b- O) P
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
8 T- H0 Y! G2 _2 m. J. } {; X3 E+ x9 m0 e* f0 X
case VEHICLE_CASE_URGENT:/ ~3 U6 N6 [; ^* p
case VEHICLE_CASE_ILLEGAL:
7 e- f B/ S4 c, N- d8 Q case VEHICLE_CASE_OFFDUTY_ILLEGAL:4 X' h! X) @: ~
case VEHICLE_CASE_MOTORCADE: [1 H; u3 ^9 S/ K* Q8 j. T
case VEHICLE_CASE_COMMUTATION_TICKET: }7 h3 k- ^- | W+ w# o0 {
case VEHICLE_CASE_ETC:3 E! m% m7 R8 V& j9 j. b
case VEHICLE_CASE_BAD_CARD:4 p' G2 U O) Y$ O4 S: F& [
case VEHICLE_CASE_NO_CARD:; Q- H( I) z! w% B
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
, `# k n; I, O" K; X) ]; ^ g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,4 V0 N" @( |! S
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
7 b) ~+ J6 ?; W break;
3 d# k7 S2 S* \4 Y9 _ default:" V: \- L' G% b- k9 K) J
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 ",& _/ i4 T, d! q; O
g_ModelEntryInfo.m_PassCard.nEntryStationID,
7 ?2 u! ]) y5 {6 Q1 S5 k5 ^ g_ModelEntryInfo.m_PassCard.nFlagStation1,
4 f* J" x( n' S1 N g_ModelEntryInfo.m_PassCard.nFlagStation2,5 _+ h% Y2 E# {! W% o6 `
g_ModelNodeInfo.m_nStationID,
. P% ^4 F4 E+ O' Q# @ g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
# f# X) q6 e+ u2 H; d* \ g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);, ^# }/ T! t1 _6 G; }; Y
break;/ F4 ]6 G0 v8 e; Y2 m' T
}0 A" J! q+ X) N9 U6 z5 L& q2 s6 q% U
$ k7 B8 O) i: I- ]; x7 @! \+ \+ } try
: m8 `9 O) ]: h {# N2 p- L* \3 d8 H
pLocalConnectPtr.CreateInstance(__uuidof(Connection));! X7 B p t. I4 T. a$ V1 D; U
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
: w/ Y! ?0 P9 Z
0 C0 W; I6 \& K pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
/ }0 a5 }' |2 }: Z' `$ Y pRstPtrTollRate->Open(pcSQL,7 A3 z% g, v* l% @* q$ P) \* m9 n
pLocalConnectPtr.GetInterfacePtr(),
2 a) P* Z, n4 Y. E6 `" [4 a adOpenStatic,! x+ U L$ u( T5 U$ ~
adLockPessimistic,
+ }2 o% h% Y7 I3 A6 T adCmdText);7 M; Y( _( O% C& h2 g/ a
if(pRstPtrTollRate->RecordCount > 0)
8 ?- k5 W3 y4 n4 Y/ A {
( m7 E( v& Y/ m' y6 c& i! n# Q8 J fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
0 u! G' F8 S& r0 S0 ]1 @; C |7 c if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
9 Y: N+ Y! Z4 G4 ~ {
4 f$ I( ~7 _5 s8 B. v0 u( e2 H memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));( R3 Z l, Q" f- n
pRstPtrTollRate->MoveFirst();0 }! N$ l9 h& }$ o
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
: Q L0 g1 {1 W! W$ ? {( ^- ?: @0 }9 B/ T7 w) e. O
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);; k% b# i4 O; _1 l
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));
! G0 r: x: j: X e# D- ~6 v) Q, L* K pRstPtrOrganInfo->Open(pcSQL,
0 R6 Y7 U$ X: }& L! c; z/ C7 ^ pLocalConnectPtr.GetInterfacePtr(),3 S5 ~2 ^+ `, i4 a
adOpenStatic,
( t7 \/ s6 A/ `1 t4 C% B* Q2 U adLockPessimistic,- j7 v* o0 e/ U, k; H
adCmdText);: B7 [* w' A4 o1 F; i. y0 q
nSplitCount++;
1 F- N' E5 W6 I" [; d char pcBuf[10];3 \/ m1 l7 @5 V. C" ]( f
if(0 == nSplitCount%3)
5 z$ f+ C2 C% b" U4 ?6 a5 T3 g {
) y% Z9 x2 [! H# k- N8 K sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);. o- c6 ^7 h2 l, b$ G
}else( F- l$ c! [/ ~
{# ?0 Z: e" O9 }! c: }
sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);% c, X8 R7 d* y7 k; j( s: P
}
: C' b; l+ x, s strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);# Q0 x) l1 C) {6 t/ H
strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
& w0 g8 X6 d; ~) I4 n. }$ p pRstPtrOrganInfo->Close();
5 `+ Q9 c; M" p4 _6 j pRstPtrTollRate->MoveNext();
7 A/ k4 r- p" \$ Z5 | }
2 R: e7 C9 p# Z/ r# [7 Q }8 h, L, F" ^, }! L1 O7 K# {
7 P" ^. F0 T) }% R' s8 L; I) V% B' M }else fToll = -1;& [6 U. m* s( \+ {7 D
4 \ p* T- X8 O7 }& m
pRstPtrTollRate->Close();
: s3 c4 v J z3 d! | pLocalConnectPtr->Close();' G3 v! q# b' _3 B( l; ^4 i
m_nStatus = DB_OK;2 N3 a n, b/ B( S8 d5 x. H3 T
return(fToll);# b1 R) X j, i* W
}
1 k' V: o# Y0 h* h8 Y0 w catch(_com_error e)
7 z2 b1 q" e! ]. T& i+ A. d {1 x# W0 S, e2 G
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
Q; l: K. S* E+ E/ f g_ModelPrompt.Notify(); * \9 K" O0 x( _# |' d) `9 d7 J
m_nStatus = DB_ERROR;2 g& Q& \: h, r/ y5 C0 Y
return(fToll);
' b/ x1 X) M$ Z) B# s7 V% [! @ }
' }) ?( [& P X - I1 U: H% {# H
break;" G2 {5 R2 }3 ~) u% G
case NODE_TYPE_OPEN:
: f9 c1 z Y2 Z) k W sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",) U; `: e) E) k' A) n! p( H" Y4 ~, o
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass! y/ ?! a6 G3 |. z3 A* q
);: K, C i* X" Z0 f3 t" b
try
) J& l& a, m/ d3 O, ^' I {
1 j% I/ X z, w6 { pLocalConnectPtr.CreateInstance(__uuidof(Connection));
) M1 t8 u3 M/ y* p$ a pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
& f7 K# o7 f+ B2 {+ k1 a
* T% s* S/ D, i4 x! ~4 |6 x/ e5 l pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
& W* p ~! A' d pRstPtrTollRate->Open(pcSQL,
; s- F' H4 H Y pLocalConnectPtr.GetInterfacePtr(),
# O3 u, p; f+ B# W' u- L- n3 U/ M adOpenStatic,
0 T2 _( i1 h8 [7 D adLockPessimistic,
" h1 \+ I. `0 V$ v# E adCmdText);
- [9 n8 X) i8 \& Y; N, }+ |) h( J if(pRstPtrTollRate->RecordCount > 0)6 X" q! T- A3 d8 x1 B8 w2 T6 e+ n
{
, l( }2 h( L- ^8 L5 d fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value; A: p# Y0 r$ i M9 G7 s/ }# v
}else fToll = -1;
% U! t% @" i; u& a$ T0 _; h
3 `) P6 H! U0 a' s% I" C pRstPtrTollRate->Close();
/ _& _6 t1 h- b1 H+ T s, c# p4 w pLocalConnectPtr->Close();
6 |. ^$ }1 V' G/ Y' ^ m_nStatus = DB_OK;
% W% u% M4 k4 v# P: i7 Z n return(fToll);; f% j& F! U) z* D2 a2 R9 n$ ^
}$ m4 d' q A# |7 Z) y9 P6 k8 `
catch(_com_error e)' L: h; x2 H/ x% L5 k$ ?
{/ ~6 m o$ m. w) z
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
* S: s3 A5 }' o. u8 Q9 P g_ModelPrompt.Notify();
- L' K! A7 z5 ^% M/ o9 d, u& j m_nStatus = DB_ERROR;( g; V1 F0 j ]5 t) M; o& p
return(fToll); * H7 M. k; r3 x- ~
}
5 q8 B" G7 M; H) ]" P6 {2 U break;
3 N6 M b1 g# w( Y7 I default:
0 d% M" Q' _ ?8 n3 }+ C m_nStatus = DB_ERROR;
8 x/ L* J& R/ u break;% O& S0 x; Z/ B: m1 s& b8 X
}
& h8 O8 w' K9 t4 z# e. d return(fToll); 9 t3 Y8 C/ M# T$ k2 ^) H1 A
} |
|