|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
}( e9 o; V- i+ ~* ]9 ?; d1 H{1 l' P# P4 C0 [; v2 \4 ]
_ConnectionPtr pLocalConnectPtr;
& K: R" z6 _) e U2 C _RecordsetPtr pRstPtrTollRate;# u/ m. x* x" y& i+ ?8 d. j
_RecordsetPtr pRstPtrSplitWastebook;
: T9 h0 G, [- D2 R6 v9 Z3 X& ^6 X$ d8 s1 F* O& ^
char pcSQL[300];
! i" b; E4 T) S% H) u 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 ~ [3 {; g2 z, M) Z5 }
g_ModelEntryInfo.m_PassCard.nEntryStationID,
( }: Q/ t( j3 C5 Z' _9 W g_ModelEntryInfo.m_PassCard.nFlagStation1,
V! w" e9 J# o/ I6 S! o' I4 r g_ModelEntryInfo.m_PassCard.nFlagStation2,
( Q8 h3 R4 S" g# [9 u/ s, V g_ModelNodeInfo.m_nStationID,
* R1 F% j! p+ y) o! d9 `; r g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
n* X! z( R" R. a6 w% T, O g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase" K: j- f( |% t: B: ~
);2 T( x9 A" g }2 \2 d4 R' ?! j
3 Y& b+ c, s( e. ~1 c try
1 {1 u# d' X1 B5 V {2 F4 \/ m6 q4 v
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
$ A- E5 V- w: g* l L- [- [ pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);+ Y+ o0 n6 @' b, ]
8 C3 @% u; W# y z: h
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));! B% e$ R( g. l) P
pRstPtrTollRate->Open(pcSQL,5 v- x! W3 S. g4 g
pLocalConnectPtr.GetInterfacePtr(),
3 r' Y; [. \* m6 Q0 \$ E6 {2 H/ N adOpenStatic,9 t( `( T1 f- ?2 Z1 z7 k
adLockPessimistic,
9 ]- X$ E1 U1 i3 ^ adCmdText);6 E" }- x" k( a: T: l
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
; a$ N% ~3 E( H/ \$ K5 y" ? j pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),6 e2 X8 s1 x5 f% A2 }8 r
pLocalConnectPtr.GetInterfacePtr(), x/ b ~/ N3 k3 E6 o
adOpenUnspecified,
0 W% i3 S1 N4 g9 ]& X! c" K adLockPessimistic,0 x* ^2 n/ W. ]0 G. ^
adCmdTable);
: {- [$ \; C2 ]) ~# g* K8 a: y) P+ }1 r) Z
pRstPtrTollRate->MoveFirst();
# L% w5 P1 v& `2 R- s8 c2 T G for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
9 a$ Y6 p; K, T# a {& R4 I! d4 W0 Z0 f
pRstPtrSplitWastebook->AddNew();
: v- K, ^7 I7 ?# ^& ] pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
. ~6 R1 Y6 V- l. e* t8 ~, d
: p# _, ?& e( S! I pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
3 y9 y/ C. e& o' k3 m 4 ^$ [2 S2 I7 e; g! @1 t: Y& g3 @
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);/ p- m) ~5 p- z9 s# P c, K
. ]& ?4 N" n' C- B) B
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);; f- x) x j% Y5 r* O7 ?9 M' b
5 ]8 X! a% u# E6 u9 y1 x COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);. }3 P7 y, ~$ {9 e
pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;
2 r+ X' i+ l. ~5 l8 ^+ o& B" P 5 {8 y! T: X* C. \: |( h `0 |
pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;
: s, _/ G: _ t3 @* r% B! f
" l8 ^ K* c2 I5 i; y pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
4 h1 U A4 T# r* e
0 ]6 U( v& ^3 A# y& O- v* P pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
5 K3 G- T7 \& Q& |% u 4 \0 I8 V$ [/ ?5 z }' I$ V
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);* P. f! O& y, M1 u' z" t+ J5 e
a! q2 c* ^; n/ ~% n( {% Y: p7 q, G
pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;7 J! L9 J. g) d1 Q6 H8 Z. S# {
5 `/ b! T* p5 v1 D q1 { y! E
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;
5 e3 |& o! g& c! y- i float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;( [, d: @% M T6 n# @$ d
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;) u y- K" b. u0 c0 l( ^8 J3 c
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;! {1 R- ^7 ] z& n' `7 V9 f
r p* g' x& }1 a7 m$ q8 E
pRstPtrSplitWastebook->Update(); - e6 U# l! M( R9 @& q% E5 G
, i1 r$ d# j9 }! e& B' c" }! j m_nTableSplitTollWasteNOCount++;9 a/ V. k7 o9 }" f9 h5 k$ a
pRstPtrTollRate->MoveNext();
/ I6 L3 k) W+ V* F }
- g) k/ C8 _* o+ F7 b pRstPtrSplitWastebook->Close();
4 N @/ s2 J2 f" { pRstPtrTollRate->Close();
" O# ]# }3 `9 `7 }" _% F pLocalConnectPtr->Close();
5 J; a5 a- S" y/ Z; j# N$ O m_nStatus = DB_OK;
0 [1 A5 A+ D p return(m_nStatus); , V" N! `* V# `+ t; d& P
}- U5 }1 o! _" k
catch(_com_error e)
+ D q( j; C$ w; i {
: W& F; q R7 W f5 y+ F1 N2 u g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());, k0 b4 f1 O: c2 a$ c0 O! Z
g_ModelPrompt.Notify();
: d7 Q f9 n. {. i& x: F" Y& ` m_nStatus = DB_ERROR;' r9 w y: S% V L9 ~% t3 a
return(m_nStatus); c5 r" X" n# h) F
}
3 Q6 ?; s! M- H1 z4 U4 \}+ C5 ]" X2 v8 Z4 w% U! k& E+ o3 L
$ M0 ^5 O; T0 E( o9 R
/ }1 o; H( Z6 W- G2 u4 m3 Z. u1 E, |$ `7 ]3 _: A& F
float CObserverLaneDB::GetTollRate()6 } R' z. i' J% S8 r `" u7 X* w: v
{7 {: s9 l+ a( B; C& e; B ?
) \4 o( i1 L: k! }; R' u
_ConnectionPtr pLocalConnectPtr;& s' y) b5 C# f4 [2 G; s
_RecordsetPtr pRstPtrTollRate;0 ^* p1 V7 ~ V$ M! m
_RecordsetPtr pRstPtrOrganInfo;
% W8 ~. l$ B0 e; e; ^, Q5 E3 k! W, D" F/ r: x$ ^& @: e) m
float fToll = -1;
- f5 b n( q! i. @* n4 d l char pcSQL[300];/ \( M& f( e. k
int nSplitCount = 0;5 K. R [8 D% E0 p1 S% h' e
switch(g_ModelNodeInfo.m_nNodeType)
Z6 p4 Q! ]. F9 C" c {7 [5 F3 d; F: J0 K+ Q/ [( S
case NODE_TYPE_ENTRY:
- n6 l5 f2 z2 f' j% J n return(0);
( C9 q0 L( J2 b0 G- [+ `6 O break;
' p( e% \! s i9 y8 X( k& E case NODE_TYPE_EXIT:) _+ \+ X: Y5 g6 \6 U% Z
case NODE_TYPE_MAIN_LANE:
- A; j! C6 e* ^9 v switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)% E+ Y. O8 f) p2 }9 d R
{
! t, y) g3 T; _0 S/ E. x2 \ case VEHICLE_CASE_URGENT:
5 Q* G; ?$ a( o case VEHICLE_CASE_ILLEGAL:
3 ~0 M( _& n4 E0 ~ B9 a% P case VEHICLE_CASE_OFFDUTY_ILLEGAL:
! L- _6 ^3 P2 Y, {5 q3 T case VEHICLE_CASE_MOTORCADE:. I% B/ o9 \4 n& e0 S
case VEHICLE_CASE_COMMUTATION_TICKET:
& j: @8 H v4 E7 I) J case VEHICLE_CASE_ETC:" f, E* ]# O: v% G4 i
case VEHICLE_CASE_BAD_CARD:: ~' [+ @( X5 N; [
case VEHICLE_CASE_NO_CARD:9 A, F# K% }) R8 v+ x/ m# a
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
6 K+ O* q, m4 s0 D+ Y Z" M+ ] g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
' r, h* O) s2 F/ } g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
5 t; _2 G5 g& v2 |* O" J break;8 f1 d1 h6 p, y) g, L) _
default:
7 G& k" b5 x9 q& ^- 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 X9 O' ]- [1 f7 Z+ q
g_ModelEntryInfo.m_PassCard.nEntryStationID,# [9 x. K9 w# I3 q3 X0 r$ o j
g_ModelEntryInfo.m_PassCard.nFlagStation1,
z' g6 V. |! {; @% N4 Q& @2 i g_ModelEntryInfo.m_PassCard.nFlagStation2,! g& C0 B+ @* {! S
g_ModelNodeInfo.m_nStationID,, z% h: O7 E& R0 O$ H6 l( j+ W
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,% t* r; ^6 J( i
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);$ U$ r! Q$ @6 r: R" i, P5 L" r
break;2 W, {; u" z( V- H3 n
}+ I; E7 ]( ]- ^
" G m: Q$ y! d# Z0 c, l. v6 M
try
+ L+ e/ p- d. d8 a& s% B8 x+ { {* u5 C2 F% F0 V1 y& S, K
pLocalConnectPtr.CreateInstance(__uuidof(Connection));7 d. P$ s8 Q, L% q
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);) K$ g, ~! q; _, _) L& a
1 @1 T" y l3 v( R
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
t5 U% i3 J6 O( K+ E2 d/ L pRstPtrTollRate->Open(pcSQL,0 p, \* y+ W/ h2 \
pLocalConnectPtr.GetInterfacePtr(),
5 m! Z& N5 k5 S adOpenStatic,
8 [6 K/ g2 }0 p4 ] adLockPessimistic,6 U8 ` {" K! t
adCmdText);' }; C4 h# E/ E* P
if(pRstPtrTollRate->RecordCount > 0)
% @; l, L: f3 \7 W6 ` {
! H& p. c. \2 T# N, P. d% |4 I" T fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
: @) ~( Q: r6 B: \- C if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )% G* ~+ E* z/ h7 i4 h# D* E
{ N# T c, Q$ h" L: [5 |8 [3 `% v S
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
! N. h( t3 [/ w. y pRstPtrTollRate->MoveFirst();
5 q8 n( H+ j5 h0 N for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
# s; n1 Y( M% ?4 |' p5 G {
9 ~# H7 a" u2 q# w3 N: S; G [ sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
- Z3 l* o0 d0 I, Z: r" I' \, @ pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));
4 N) @5 K( ^' B* l9 E9 W pRstPtrOrganInfo->Open(pcSQL,
: E" r0 g% a1 w* Q, l7 H2 O pLocalConnectPtr.GetInterfacePtr(),
$ e3 `, W0 W4 g+ |# Z& c8 _; g adOpenStatic,( a# z( T1 C% D: t8 _
adLockPessimistic,
1 |- m. k% {9 N* U adCmdText);0 X& C- x# E& o$ U6 b8 n
nSplitCount++;
# {: }+ \& Y$ Y/ y char pcBuf[10];
+ U- i6 q. x H+ k7 t4 ]% z7 X4 [7 O if(0 == nSplitCount%3)
. Z, K+ g/ p; `; K s) K {
" R( a8 t1 w1 H: F sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
( t" m# {' C6 I$ a3 v: E }else; a( P- `! i0 }" ]" m
{# B8 ^! _( @+ S+ u' H0 Y( J$ N
sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value); y5 W. F5 U6 T7 x$ x; {$ p" t
}, U! M$ N0 h! b B8 I. X1 U. e' m
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
: L; i4 J4 i, P; f( l# S5 J strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);( w( f& J3 Z; j
pRstPtrOrganInfo->Close();
/ \/ ^: S) R3 e pRstPtrTollRate->MoveNext();
- D' I. o5 I5 K5 E( F/ X# C9 J }# z: Y( w+ n" }* u) p! }5 ?
}
: a' D( r b. M( x: W5 U. ^) b7 N * [9 [/ ^8 I. p# N8 j ~
}else fToll = -1;4 A7 |2 }( `" J' A1 f2 N* z7 A
, t. n/ d% I3 q% h3 i pRstPtrTollRate->Close();! o3 M# R* _) R
pLocalConnectPtr->Close();
* ]1 ?8 i+ {8 D" r* h& n m_nStatus = DB_OK;
% ]& X9 b9 e# ~" S. p9 L2 d8 E return(fToll);
6 v! t: `, P' a% c }
* I& p. K6 B8 e catch(_com_error e)/ b" n% C1 Y& F7 o7 V& _
{
" [) Q: ~1 L+ d2 T, r g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());1 U, U3 b: W6 ] E2 G; L6 |0 l
g_ModelPrompt.Notify();
0 u. p; j* T( t2 I8 C# g- v9 P H m_nStatus = DB_ERROR;
- H+ v e) v6 A- ^) e. q( I return(fToll);
+ s: \ f; `7 W0 } }
3 Z2 h/ u; V* E/ F9 H& [* o2 i$ y
& B1 Z1 y( e, M$ s. x. S break;
! q0 T2 {2 E2 D3 y0 B/ v* q" ^ case NODE_TYPE_OPEN:
: x: w' ^- y1 b) f, k* @6 q3 ~ sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",7 s t7 D9 X9 G
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
* B0 d5 v5 d! a& G9 p! T1 c );! Q% ?4 {* H' y4 H* m
try2 K/ [7 \2 w4 K t3 t/ v- j7 X2 o
{8 e" }+ H8 s/ ^' M' p. B# x
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
# Y. J9 `1 u+ ~' M pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);$ F2 w4 j( \" {# K- n" m" H
+ {& |8 M |& l4 K+ ? pRstPtrTollRate.CreateInstance(__uuidof(Recordset));+ d! O: S$ ?8 n# Q+ B4 i1 `7 V
pRstPtrTollRate->Open(pcSQL,
, c( z, B* D$ @) R pLocalConnectPtr.GetInterfacePtr(),
' |: C# v! ?. x6 @ adOpenStatic,
}+ ?7 ]& l4 K9 w x @ adLockPessimistic,
/ h6 z: G8 u1 j! K6 o& G% c& ^" f% o adCmdText);0 }& g& v6 A4 l, p
if(pRstPtrTollRate->RecordCount > 0)
$ r. Q% m! c; D {
1 B q, j$ ? a4 x @6 N8 x fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;7 l! K8 M+ t: O) V5 P( j, x
}else fToll = -1;9 x2 g6 N0 p% k/ |5 R5 l* r: [
& q- V% T( w. y
pRstPtrTollRate->Close();( y4 q$ Z% S' `! t
pLocalConnectPtr->Close();) J& U& @2 [6 r; l$ F+ {: J6 r
m_nStatus = DB_OK;7 N& P" g# s, v9 i0 B$ x
return(fToll);
: g0 P1 e) _. Q( @$ c z( |% A }
9 @; I w" P* m" U( v" ]& C6 Q+ j catch(_com_error e)
, t& w9 H! I$ ^, W) J/ B {" x+ o+ _9 J, \3 k5 H; U# e" E5 P6 c3 E
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
/ @5 s; m3 A$ D6 u; b8 |+ ^% V* O g_ModelPrompt.Notify(); 8 C+ m' E$ m W9 Y! j
m_nStatus = DB_ERROR;
. f8 u9 T" E" X& A. R3 r+ J1 X return(fToll); ! V; P R j+ }! \$ W5 s
}% o" V- Q3 V/ C9 e B S; a
break;
& L& f* `* p& a, `5 P! J: Y default:+ ]8 a6 G$ Z' U" d
m_nStatus = DB_ERROR;- {# |' j7 L5 ?2 u
break;0 q: ]3 A7 H' W- j
}! _5 n U J' ~
return(fToll); " }+ i, ~7 g" |2 g" Z+ \. Z# Y4 b
} |
|