|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
6 F1 I5 b" F3 e) U{
4 a5 Q' `& n. e _ConnectionPtr pLocalConnectPtr;9 L& P5 d. D% |, {% u
_RecordsetPtr pRstPtrTollRate;
! \, t5 L$ W. E( Q _RecordsetPtr pRstPtrSplitWastebook;3 d! e0 Y0 d f$ @" z4 }8 w7 s% o
0 w6 F6 b3 j. M2 `
char pcSQL[300];% O, h% u+ i& J; N% [. Z
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# W. s( _, x5 A* a
g_ModelEntryInfo.m_PassCard.nEntryStationID,1 K3 W: p, n" {, Y
g_ModelEntryInfo.m_PassCard.nFlagStation1,
; c/ i9 F8 d0 @3 a% m# i1 |' K g_ModelEntryInfo.m_PassCard.nFlagStation2,+ P# m( l6 p" k3 x8 R) M- @2 i
g_ModelNodeInfo.m_nStationID,6 Q( C N" A3 x+ b" {( H3 o# b
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
6 F6 A# e- {8 o$ P g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase# ]! n; [8 a1 ~8 j6 Q6 G
);
: x2 M7 \6 s- i# Y8 I8 R4 c/ J, {
try# q5 z9 t9 f0 O' e/ H; } Z
{- n: _- M; ~, Q+ J* b2 V3 }8 ^
pLocalConnectPtr.CreateInstance(__uuidof(Connection)); d# b+ D# \: ^( o* W7 S
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);) t7 O4 _$ V x7 |8 I& K5 c
! u0 Y V/ v [: Z, \+ j( R
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
2 @3 ^# q- ?1 x+ e* \ pRstPtrTollRate->Open(pcSQL,
1 ], L8 X% Z1 o) ` pLocalConnectPtr.GetInterfacePtr(),
% W3 g1 N0 J% u adOpenStatic,. q# ~; t! u9 b; U$ \/ D3 H
adLockPessimistic,
+ Y# x6 d# F3 H/ y% s0 w* R adCmdText);
8 F1 \! t- p# Z- E% v+ X' r pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
1 B6 p& l: m5 e+ h6 `5 M pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),9 }. |9 ?5 R( A1 F2 y/ {& q
pLocalConnectPtr.GetInterfacePtr(),
9 z, ]# Y0 k0 S6 q* @1 }" C/ k adOpenUnspecified,% J# g: q% _. f7 G# ^
adLockPessimistic,7 f- C# w+ Y$ H
adCmdTable);
5 J& ~' Z) N. L2 x( K' N! e8 \- u
pRstPtrTollRate->MoveFirst();1 E. a& Q) Q2 K- g! M9 t/ l3 @* |
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
}9 J9 a: [# U' j7 m {
) C; H" K: U" u* J$ r pRstPtrSplitWastebook->AddNew();
7 }- d. L% e5 d3 [2 v9 H pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);' M/ @1 d! c7 D t3 J- v; n6 z7 s0 z
0 @, }( v$ K+ u1 q# e& s5 m M
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
5 M! D3 o- b- f) A. q' U' ]% s
|5 n% ^. l" q/ g pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
# b' e1 T2 @1 C1 R , l& j q% W8 a$ M" R0 U# D @% _+ |
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
1 R. C' @' h5 ]. ]" G$ r. a$ U* o- N& @
7 Q. O1 K4 O/ S) w+ b COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
o9 A7 r4 @: C) C" ] pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;
* S' R8 b) }! y; {: X$ N: q6 b% X% | 5 M- f1 H; ?1 V$ c
pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;
/ Z8 S# P r/ r$ x + M1 |0 s9 j! p4 C) P% O
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;* |/ J! J- b! V, z6 c: L: P
' G' ? m9 l! ?" v) I0 C. e
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;( }5 ~( P! i/ w
9 L3 r& d6 G! M3 R! p7 `' s8 h pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);3 h" M4 S5 C4 [/ T2 u9 [
% t* s! ]9 s$ F* l# Y
pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
2 I6 ~! j) j1 ~ 4 x# F# z: g1 `2 u
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;5 p1 b: `% ~' ?
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;. f8 u3 O2 ^# R' e
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;
8 Z4 g/ P9 u1 c pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;9 h3 d- X+ U: ?) E( G3 ^
3 l3 s8 P. a( d' z
pRstPtrSplitWastebook->Update(); / L, g/ ^% l/ `5 ~
3 r2 J7 B9 } L' q m_nTableSplitTollWasteNOCount++;3 @: r8 y, V. N5 {( l4 O
pRstPtrTollRate->MoveNext();- I3 a/ S2 K' j1 r, N5 S
} 4 J7 J+ S3 Q# H: u
pRstPtrSplitWastebook->Close();
% I8 K% e W# l& j; ~ pRstPtrTollRate->Close();
9 q+ n8 t8 |/ r* c& @+ r pLocalConnectPtr->Close();
! W$ N0 A/ w: v. z5 r( k* u" I$ q m_nStatus = DB_OK;
9 }3 \8 L2 }9 T0 z return(m_nStatus); 4 Z( [( {7 O' Q
}# G1 L& I1 A# |# i# l
catch(_com_error e)
: z: I/ F3 L( V' ?# p5 V) H ? {. u) `- [: v( S! r, I1 `! X Q3 |
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
: ^" B0 D3 F7 k R: S g_ModelPrompt.Notify();
& q$ s( O0 W& ]$ t/ w, D m_nStatus = DB_ERROR;
" U" z1 S P, l- ~ return(m_nStatus); " ?! i3 q9 b. Z: ]* ^1 o
}0 q3 i+ y d3 x
}6 V. P) f6 I+ \6 k
7 R" [/ U q* P# z3 L& L8 q) F9 |
1 N* J# t7 w4 p1 g( i' F- Q8 J0 @7 o8 u/ O$ |/ {
float CObserverLaneDB::GetTollRate()
2 @4 i7 W. P: `8 c4 Z5 @{ @8 R+ o/ u6 {3 L
) M' Z L$ ]' b0 |' z$ }$ v( Q8 w _ConnectionPtr pLocalConnectPtr;
, I+ R4 J- Q% S' Y7 a3 i( } _RecordsetPtr pRstPtrTollRate;% E. d8 g! h5 ?' E0 ~* I7 y2 U
_RecordsetPtr pRstPtrOrganInfo;
# H9 c6 L" A7 w$ m6 c: Y2 Y- l
/ p1 N9 W, h' n8 c4 ^$ [# H! W1 P float fToll = -1;$ u' r- `; [7 p# c: o0 K
char pcSQL[300];
; f. k6 B8 }6 i4 P int nSplitCount = 0;
, R; i; s# U5 T" z9 b/ W" l/ K switch(g_ModelNodeInfo.m_nNodeType)
2 a8 Y+ N1 y! Z, Y) q {, J" ^( u! h7 @+ j: z( j, Q
case NODE_TYPE_ENTRY: C8 X" j# {) t% J; ]+ v, M* Y
return(0);
% T4 ^( @6 l0 p' }$ a* ^" S break;
( ]1 E0 D! N% H case NODE_TYPE_EXIT:
Y: f- r% ^( H' K0 Q case NODE_TYPE_MAIN_LANE:
. P6 J3 M9 f! R( s Q. N switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)/ T- @' {5 ^0 ]2 p" h
{
9 n W# M7 K7 E5 J- ^# O case VEHICLE_CASE_URGENT:* \: U: V9 \) |: P
case VEHICLE_CASE_ILLEGAL:9 l0 O2 u, C: s/ L6 C/ m) y
case VEHICLE_CASE_OFFDUTY_ILLEGAL:* ~ V1 v; A( x
case VEHICLE_CASE_MOTORCADE:
; i9 G5 n1 b3 J% P! N0 q case VEHICLE_CASE_COMMUTATION_TICKET:
3 k+ j3 ^, @' P2 q case VEHICLE_CASE_ETC:, q3 z0 i0 S/ A% e& i( q; F
case VEHICLE_CASE_BAD_CARD:( v" m% {, ?. s1 A" {2 H' d' w8 K+ g
case VEHICLE_CASE_NO_CARD:
% ^! [" O" S3 J3 I+ ?/ j4 k sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
; u* Z7 I }9 J* D* t U g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,; s2 S) T, \! q
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);0 y M9 N/ c3 h; O6 ], E ?! I
break;
1 I ?9 w! m, Q7 ?' Y/ h% v default:2 o8 ]! X4 }/ ^ D" z
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 F# o# M+ \: w( }% ? h8 I g_ModelEntryInfo.m_PassCard.nEntryStationID,' }( n4 Z6 m) w/ d" Y: m" L
g_ModelEntryInfo.m_PassCard.nFlagStation1,9 O+ V) N3 k3 B4 \2 |+ _
g_ModelEntryInfo.m_PassCard.nFlagStation2,% Q& h7 [: E% \/ a6 ~
g_ModelNodeInfo.m_nStationID,6 K! F# }3 i# [6 l' D1 |' L
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,% t$ z+ D( ~' }1 C
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
# l& ^. L: a1 p) U break;
* j- u! g. j6 S }# P! v4 N- { |' j+ g- K
3 M& h$ z9 H% l2 R3 u, X5 D* I try
# ]1 _ {0 E3 R/ a( S {' c: U( B+ J) T7 u3 j
pLocalConnectPtr.CreateInstance(__uuidof(Connection));
! [2 h1 [) y, u. [: l pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
7 t/ k0 b% T& |) H/ R % b$ o" ] J- @* p7 P% k \& Z
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
0 N9 A" p L, D1 ?9 H1 c pRstPtrTollRate->Open(pcSQL,
. J2 v1 V$ R0 g& N' M pLocalConnectPtr.GetInterfacePtr(),
' r! n# _4 y/ }8 |! W9 G- z adOpenStatic,
1 M- d4 f& k. R$ s adLockPessimistic,/ R+ }; ]7 p Q7 ~" R
adCmdText);
7 r% d3 P$ I" n/ _% X9 Y, F if(pRstPtrTollRate->RecordCount > 0)
" ?) C" z6 _+ J' c {2 Z0 R3 |& C0 m( B4 j- @
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
; J2 O5 ~% T0 P4 o" _ if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )- o4 p Z: v, B+ T
{
% Z/ T+ n6 v1 ]9 v4 D6 ^ memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
( J- m" ~8 K" z" a/ {% F6 ^7 p pRstPtrTollRate->MoveFirst();1 K+ z* |9 k; ]
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)3 m. I# W; E" }/ _5 C" f- V
{% h' j' c- g( O( A. L
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);
7 w% c6 a, H7 Z9 ` pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));5 m. o; r& e z* r- z$ Q. |
pRstPtrOrganInfo->Open(pcSQL,
( q+ H+ p2 M4 S( \# x. D pLocalConnectPtr.GetInterfacePtr(),
8 ^5 U# [; ]9 S( X adOpenStatic,
+ X, `9 o: Z( h; c& u1 L adLockPessimistic,
; z. c2 q5 ?8 ?, y; d adCmdText);3 J* K! s7 f; J! S9 n |- l
nSplitCount++;
6 E! I( U8 n2 b, V1 e u; r+ v& {! @- ? char pcBuf[10];/ e8 r9 X- }- D c6 |3 q
if(0 == nSplitCount%3)
. y8 Q. j6 S* E% C0 m0 w, o" H& { {
( j Q; G A4 x sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);0 l. S% p3 \" Y: E0 j- C) M% m
}else
# i! z+ B' d7 o o- a# A {
: @ e. [) y1 c1 c0 ~. O4 B sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
) m+ h+ u3 B- z }# |% c) p9 |! @
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
7 U m. [+ r! d/ e strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
5 D3 I. S/ j5 l' e8 e8 t, f& F pRstPtrOrganInfo->Close();
+ L4 @) w1 t) H- ^ pRstPtrTollRate->MoveNext();
& r {9 ~- m, O% Q2 ? }
( W1 l$ N: z; _, {" R, w2 r9 Z! ]4 { }
0 `# Q6 C w! b9 n0 e" A j k7 y
3 v! F% J0 u( t4 _ }else fToll = -1;: H1 t8 `3 l9 C' e* E ^2 Z6 K4 ?7 S
8 u, b2 i* S0 d% n4 O6 Z2 y) @: a2 F
pRstPtrTollRate->Close();8 _2 w' R0 E& q# k0 d2 _3 u9 _
pLocalConnectPtr->Close();4 k: {* W& k+ B d
m_nStatus = DB_OK;. o: y' I! M* r m1 l
return(fToll);# ]: \/ \; Q( A6 F# ~% n' q- {
}
q7 U: q3 ^) \5 I+ V4 P b9 b catch(_com_error e)* H+ m- `7 ]" Z5 n( j% J
{
8 b# Z5 v5 M S% \, E6 I5 u8 S g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());4 H2 t1 n' l/ w) Q( o
g_ModelPrompt.Notify(); N) k( D# a6 V( h
m_nStatus = DB_ERROR;
: h! _/ w8 Z2 P J return(fToll);
8 C w5 f; i& n }! `( S# k) l/ l D% @8 B
- ~8 M8 Z0 j0 z$ g
break;2 I' j5 k( }, [6 E" d
case NODE_TYPE_OPEN:
5 M! H" @' F0 ] sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",9 @) i2 `3 f7 g) p9 p# Z( t
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
# I# e ~' G% B a: G- V );
5 H4 j" J5 f0 p% s$ P try9 M. E. g% y0 |1 u- h8 W8 \3 _
{
6 Z/ \, h# T: H* V pLocalConnectPtr.CreateInstance(__uuidof(Connection));
3 r% j) V V$ S) M8 ^( ~( } pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
2 e# G: Z! S8 y7 d* d+ \
O$ Q! [3 E; s5 S7 R pRstPtrTollRate.CreateInstance(__uuidof(Recordset));7 `2 Q, D1 _9 j5 R$ {8 g. |+ h
pRstPtrTollRate->Open(pcSQL,
- C4 k. u P( V2 W. ?5 m3 s( U- ^ pLocalConnectPtr.GetInterfacePtr(),9 W/ [; f/ X) B& o
adOpenStatic,8 F+ u1 V+ i8 i" \; I, F" X- g% n
adLockPessimistic,
2 t Q5 z' o* O e adCmdText);
5 r m: e3 T/ W! h; x: Z if(pRstPtrTollRate->RecordCount > 0)
4 \. v( k4 i! D* s {
; M( X3 f, S2 v fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
1 @7 W5 j: M8 a. A# o% ~6 s9 T8 i }else fToll = -1;
8 R) {9 U- [ Z3 B% t- H/ ^/ e
1 \4 T0 r0 |. x pRstPtrTollRate->Close();5 `7 |* y0 w* d8 y7 R) A1 i
pLocalConnectPtr->Close();
+ A$ x) N; K+ k8 H. o m_nStatus = DB_OK; C5 U. v1 s5 _3 e* I: K/ n1 X
return(fToll);
8 k) J) K6 k+ h8 }2 w }
/ s' r( K/ l3 m( Z# w catch(_com_error e)
. u2 y! x( k3 K- U) \% v' s2 k, S {
% e$ O a8 L2 n& Q9 n g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
4 w8 B% {, f+ j& v3 g l/ } g_ModelPrompt.Notify();
( f8 b8 N& p# a4 R m_nStatus = DB_ERROR;
$ X, k; V! k; s7 g4 j+ _9 _+ T return(fToll);
i7 b/ H0 \* A1 |2 ? }
& H/ d6 C" M& v: Q3 ~. ~1 K break;' j# w+ c- P$ \8 m" m' Y4 h& v
default:$ ~* v$ G' a! M$ x( x# [
m_nStatus = DB_ERROR;
6 V( y: r" a. D$ K break;& f% T4 ^' Z) h) [9 P
}! I: k2 ^6 f' G% _; {
return(fToll); . X9 Y4 u0 I& {, d9 l
} |
|