|
int CObserverLaneDB::InsertTollSplitWasteBook()) J9 v2 m6 m' q: m- J/ V; I, ~! o9 k
{
& {, _, i8 C9 ^* ^3 E& m _ConnectionPtr pLocalConnectPtr;. u" m8 K( U: F: U
_RecordsetPtr pRstPtrTollRate;2 y" _2 P( h# ~
_RecordsetPtr pRstPtrSplitWastebook;# v. F8 N, D1 S( N" A
$ O* g$ s% q; g. B
char pcSQL[300];
1 v1 A0 U$ O7 I9 B/ \- [6 t( 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 ",! `2 b" c1 A1 A" }
g_ModelEntryInfo.m_PassCard.nEntryStationID,
* b2 }4 |8 s$ ]3 r& ?8 g2 J/ M g_ModelEntryInfo.m_PassCard.nFlagStation1,
- E& K/ A, g8 f w. u g_ModelEntryInfo.m_PassCard.nFlagStation2,
6 A9 Y& s, _7 O! J7 B g_ModelNodeInfo.m_nStationID,
. q8 Q1 L- g) C! Y5 K7 H g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,$ E+ b- s6 L5 y
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase* \9 {! ~0 M3 O; M5 e( [- f
);
3 L* x9 L' f/ [! Y: z: }" ]1 S6 c* ?
try
' M/ S* [( P" I* k1 ^ k/ M' [) o {2 a+ E2 i3 _7 Q$ j4 X0 @% }
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
+ X9 U# z) v1 Q! A f2 h7 i# F F pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
% I; s) s) y. N" }9 n2 W& ] , R5 q1 Q+ b4 X. p, D
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
+ {- z, { ]2 U pRstPtrTollRate->Open(pcSQL,5 ^! P! c6 ~2 G2 R0 E2 {9 D
pLocalConnectPtr.GetInterfacePtr(),+ ~8 g& ?6 P, a6 G0 c8 h/ _
adOpenStatic,
0 r. q2 @: t7 E& j adLockPessimistic,! K: z7 [ b6 s' Z4 C
adCmdText);/ y& L; v- U* E% R; B1 S
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));. X+ S' f$ {# P; K: m- F5 K
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),, y) j" f* Z- h) X- |" C
pLocalConnectPtr.GetInterfacePtr(),' |- I- f/ p. J p
adOpenUnspecified,
4 U# H( F7 j8 B2 ]$ j adLockPessimistic,
7 O3 n6 V2 b/ {# A" [" { adCmdTable);
, b7 @9 r1 F1 f1 x- S# V0 _' Y
& P: C0 }: n6 ?/ B4 q' a pRstPtrTollRate->MoveFirst();" U. y& P8 t/ _' l3 @! Z
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
' M$ \7 p0 m) E" b% H1 G# ~ {
F, W! x& z% q+ ~" l pRstPtrSplitWastebook->AddNew();! Q7 s- u0 K" f* w6 |2 Q' I
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
, m! I/ I7 V* E, e5 u * G" T: ~- l, T9 G! t
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
# R; ~7 B8 a7 N- O5 O% g
- x/ Z' n0 t1 e- F; K2 k- P" a pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
) R4 A# {$ ?# e0 W. K8 g : G* g1 m1 H+ @7 T
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
; J; a9 I! \, H" d9 \5 U7 D- N6 X % i2 z2 G+ P( ]8 ?% K. c/ B& a
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
: ?* f8 i7 p7 n1 d3 e1 O pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;: a% I R- @6 T0 ^: K( w5 c! \; \3 \
' D* M+ G9 B9 a9 x6 ^3 V pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;- ? e, g- O" P4 L& S
( G% h& a; @, `$ n
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;' J/ m9 f8 A y/ C4 t! @3 B
3 \& a2 \ `' V; ^ ]* @
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;; H i5 U" O! b0 ]" J
2 m M. h. @2 ~2 s' M1 f pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);. U- u1 h" f6 ^7 f
4 a D2 R7 J9 M' I8 x pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;9 B5 x+ W) u. O, l* D2 z
+ _4 ~+ V9 P; j$ P
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;% L' M, J, Z L# h* m
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;
6 _" Y! R" \; C3 I7 E float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
& |* l7 T1 Y* L( I pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;+ N, ]1 [7 A" |" U# S6 m
' o; o3 N/ z( }+ [# _$ Y
pRstPtrSplitWastebook->Update();
; P& E) F7 N0 H
+ X7 m0 D# x2 n* X8 _, k5 ~ m_nTableSplitTollWasteNOCount++;* ~6 `% d- I- o ?) p5 @
pRstPtrTollRate->MoveNext();/ y- ~" [) w6 [5 [
} 8 c. x5 ~7 \6 ?' X/ p1 G
pRstPtrSplitWastebook->Close();
/ _' c! ]7 x1 v pRstPtrTollRate->Close();
9 B* B# c* e& W7 o3 W4 Y$ R pLocalConnectPtr->Close();, V5 Y+ O s' S+ n2 r9 U0 Z
m_nStatus = DB_OK;
' n2 d0 } `! w* c$ l return(m_nStatus); 0 M# N, V, a; J U. F9 H
}# q8 H6 C, C* { X
catch(_com_error e)) Q3 J6 ]: Y, r' _! c% i! c
{& w- B- W0 u c8 |/ ` N3 B6 C
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());/ f( Q+ i# w7 i( d: b/ z* V
g_ModelPrompt.Notify();
# g; ?# W9 Y! o m_nStatus = DB_ERROR;! O; _, t: U: V" A
return(m_nStatus);
" f# X4 N* ~7 s( M# F k }
' Q) b. u$ w1 m0 |1 n" A) s6 s}
6 g/ |$ ~, A$ O' ^9 r
l) i/ R6 n. e( u2 r: N5 v) I. g/ w# Z( U; M A
4 \, b3 l' R6 y2 X# D( t+ jfloat CObserverLaneDB::GetTollRate()- @. J# T: _2 J7 l( H7 k
{
3 q4 F( Q8 ~: S- n# g/ C; S; C. X0 j: e* I( k
_ConnectionPtr pLocalConnectPtr;
$ l8 @% r' p/ I: \; t2 i _RecordsetPtr pRstPtrTollRate;9 @: n8 D0 E6 e, O
_RecordsetPtr pRstPtrOrganInfo;
& f' z' e: J' e
' d% x4 J3 _% o" F9 y float fToll = -1;# v9 Y9 j: [1 u2 _6 H
char pcSQL[300];
4 z# l: ~8 L- ?& e& j6 J, { int nSplitCount = 0;1 e' q0 ?* d' C" a5 o
switch(g_ModelNodeInfo.m_nNodeType)
8 O. {: s5 B( B" Q6 c B {: a1 j/ b1 J1 w! @
case NODE_TYPE_ENTRY:
( O$ ]2 o3 s4 `. U- I3 O7 @( p return(0);
9 t3 A# x/ c. K/ `0 b/ ^ break;+ T9 B$ R) b& l
case NODE_TYPE_EXIT:
, e6 g) {3 q. }4 I/ o- i; X case NODE_TYPE_MAIN_LANE:. n. C' a: u* R6 W
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)& R r. i! N2 }& S- @
{
1 e: m, c. \/ d) O' ?/ q7 j case VEHICLE_CASE_URGENT:
. g# F4 x, ]# _0 O ^, { v. M1 @ case VEHICLE_CASE_ILLEGAL:
$ H5 i' X, j* x u) L8 ~/ C" M# y case VEHICLE_CASE_OFFDUTY_ILLEGAL:
8 j! R# n8 L' @ case VEHICLE_CASE_MOTORCADE:& K- E' Z/ m u# f
case VEHICLE_CASE_COMMUTATION_TICKET:6 _$ G( ^( V8 G% N. W( y2 V
case VEHICLE_CASE_ETC:, g. h7 z2 h" {0 r
case VEHICLE_CASE_BAD_CARD:
2 W; Y) }& [ }, v- X, T: R0 b case VEHICLE_CASE_NO_CARD:6 I. B$ P0 |2 p
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",# p; `) J9 l. [6 H6 P
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,( [! S. @, l9 l# k
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
# q7 n1 |+ ~& y8 N @( b break;
1 x0 C' |# k% |$ m2 P3 a D* z2 A default:
7 F3 f) o+ C' 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 ",4 x3 C4 \9 I& A! T" V: m) t
g_ModelEntryInfo.m_PassCard.nEntryStationID,
( l5 h% F% q9 n3 |5 A" E9 U g_ModelEntryInfo.m_PassCard.nFlagStation1,3 I# W n8 j6 h# U3 i) L
g_ModelEntryInfo.m_PassCard.nFlagStation2,9 P* E/ O6 i3 Y" n, ^8 S, u
g_ModelNodeInfo.m_nStationID,
+ D& k2 H4 O; E g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,; m+ D1 j( x* X* e9 A, H+ E
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
# r7 J3 T1 d4 _, G4 x break;: f" E/ a; p* F6 N/ h1 e; q* D
}$ i5 u2 W& S& r8 S
4 k, s( Q5 C: b2 J+ ~8 i; u2 W try! ]) |8 P" w0 N# C: D. k( n, w. I
{
. C+ x7 A& w* H; R3 l/ T6 d pLocalConnectPtr.CreateInstance(__uuidof(Connection));* U# j1 Q {: Q- _; V5 |
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
! l6 h5 S; t$ r. d3 M1 O! u
$ v4 h/ E* T4 _7 j, y pRstPtrTollRate.CreateInstance(__uuidof(Recordset));5 y5 k/ [$ Y/ ]9 z4 U9 Y0 M( x1 A
pRstPtrTollRate->Open(pcSQL,& y, P2 t2 d2 H: n- }
pLocalConnectPtr.GetInterfacePtr(),
6 D! h Q: C. D, j adOpenStatic,, S- Z) C7 M" q. `
adLockPessimistic,
2 c6 f" }& [2 e, e. C adCmdText);+ d8 T, N$ i3 S' K8 a" b8 r' n
if(pRstPtrTollRate->RecordCount > 0)
' f- J, E1 X) h; [ {
Z5 U) C( w) ?$ ? fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
, a5 H* i# x m' D! c( T! H" M if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
3 X# f+ q" v w$ | { F+ p- a; ]8 l
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));/ H& ?0 \: z" L7 o5 \
pRstPtrTollRate->MoveFirst();
5 g) |: ]4 t+ Q for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)) h4 l9 C* h: G" t4 Y/ o2 E
{3 f$ t+ b+ K& m
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);; x$ G0 U8 ?4 M
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));
~/ k5 t+ C( N+ x/ A pRstPtrOrganInfo->Open(pcSQL,
* N8 T+ k% e9 n' e d: u, R8 A pLocalConnectPtr.GetInterfacePtr(),
$ [$ F7 c4 l9 e( } adOpenStatic,
( f6 g8 F) q3 W, C/ h* m adLockPessimistic,
6 E$ J2 z8 \1 M1 N( T adCmdText);
; a% A; x6 _; S, R, q8 n* a nSplitCount++;
5 d& k9 U% x7 T! L7 h# E char pcBuf[10];: Y) W. u( j1 P$ s
if(0 == nSplitCount%3)
3 l! Q3 a6 o. ~0 b {
, q9 F+ |: j* E# z sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);$ L0 N! u$ I; s9 Q- k9 n: V
}else" p3 G9 q) s; O8 y: W7 f7 W% K
{
, g1 ]5 m9 B- Q; t8 b) B sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
5 _* D) }$ w; d, D2 M: b }
0 `1 {/ K! U, I. r& U* t strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);& Q) y9 U( S `& n- ]& M
strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
c4 L1 n3 U1 H9 f$ G. A pRstPtrOrganInfo->Close();
& V" I2 n6 W) i pRstPtrTollRate->MoveNext();% r Y7 U3 J& E! x& ?+ _3 `
}9 u$ N2 |) w$ ]; N m
}) l( f0 I- I) t
& |/ `, t k; m2 |' Q }else fToll = -1;1 m' }! T7 L9 q) B' G% Q) [
) Q% x9 S# t$ ]; n0 o pRstPtrTollRate->Close();
" F& E+ ~ T; e, K4 D- b pLocalConnectPtr->Close();. P* ^0 t( G0 [ n6 M: ^; u6 d
m_nStatus = DB_OK;8 Z. J9 I2 p9 u1 u) T; n" V: U
return(fToll);+ G4 |' z& ~$ A% R
}
5 x' }% R) N& D/ ^3 Z catch(_com_error e)0 t3 u6 O: S& a
{
# N; p$ H! r+ V4 {4 l: q g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
) |& b) H5 _# T% }" P* v g_ModelPrompt.Notify();
\( }* a* q3 W* t( |# n; o m_nStatus = DB_ERROR;
' y1 q/ R' K* @! F+ P return(fToll);
" _4 U! B" y9 b1 k% U/ n }. B6 Q" Q) D! y Q$ |/ o+ P
' `1 ?$ D7 S8 U4 G4 q
break;
: h5 L3 [1 Z% M6 n2 u% x, j* J case NODE_TYPE_OPEN:
9 o0 e* A: {" f/ E sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",
( k7 ?& a* {5 g. h$ b g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass' {& I3 v* j. R9 x* o
);
z8 v; `9 r7 L' ~9 L. G try. U$ x5 f+ u M; B4 ^4 t
{
: B! I0 _$ d0 _( R6 l pLocalConnectPtr.CreateInstance(__uuidof(Connection));& ]8 u3 q5 C! K7 B& o- `' r
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);! R7 `4 I: v+ T, X; A+ q
) |2 Q6 B+ P! Q) s% o+ } pRstPtrTollRate.CreateInstance(__uuidof(Recordset));/ z! y+ j9 v2 v+ z" E
pRstPtrTollRate->Open(pcSQL,& T1 g1 F9 u: M3 c! ^
pLocalConnectPtr.GetInterfacePtr(),
5 f% k5 X7 e4 x+ ]- ? adOpenStatic,
* b% H8 @( z8 L6 E" {+ K: l* z adLockPessimistic,
: ~' u/ V% t( r1 J; @3 N3 o- u adCmdText);0 _( e+ o' u; h8 g% o, G8 f
if(pRstPtrTollRate->RecordCount > 0). l3 V" P5 N" H$ Y$ D0 r4 o) x# B
{
. ^# G1 P( d5 [6 ]- N2 X fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;# w+ g7 u, ?: k; c
}else fToll = -1;
e% x0 V; t0 C8 j! s " z( ~/ k3 x# S
pRstPtrTollRate->Close();
0 X. M3 X9 ^% d) {) w pLocalConnectPtr->Close();
8 U8 w2 T, p7 R, ^* e9 @1 B' T: f" t; Y m_nStatus = DB_OK;9 z% E g- i/ D9 p! `4 R' Q
return(fToll);; |- f( M! W( |% B. ]
}# v% m7 W4 v& A$ f# ?
catch(_com_error e) Y k) y: {& |7 o, x. l9 s' {
{* i2 d, P% F- d# E/ A% N9 X+ w
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());6 _+ a4 I% w9 C7 ?
g_ModelPrompt.Notify(); 2 J# c. c, X. ]/ ^* w- W& U
m_nStatus = DB_ERROR;0 ^8 P- ?$ `: z: W+ m @ N+ g. p
return(fToll); 9 n* f+ p- {: \; {
} \/ X; k0 b( R4 s z! D7 {3 I. p5 ~
break;
8 D+ w4 S* W) i, U5 x default:% Y R" c& i) Y
m_nStatus = DB_ERROR;
% I5 d9 {/ Z; _ break;
( u) _- N2 i) [/ O. c3 p; E6 u3 k }
% y( o0 O6 J; m. y7 N8 s1 \' W, u return(fToll);
1 [/ t. f2 u! r8 F6 b( e} |
|