|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
/ ?# J& {" t$ F* w3 B8 D- w{
9 e7 \8 C9 }* G7 w, @2 G _ConnectionPtr pLocalConnectPtr;( m F4 |- J5 s! ~! q6 i8 d
_RecordsetPtr pRstPtrTollRate;
8 K0 Q7 }: @" R& x5 d _RecordsetPtr pRstPtrSplitWastebook;7 }/ W9 V9 @* ^- l4 r+ \
" N* W: n, s- ]; c! x0 r char pcSQL[300];
9 H! L+ Y) O2 b9 Y! g. I/ b* l1 g 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 ",* y J0 X4 W' @) f* o
g_ModelEntryInfo.m_PassCard.nEntryStationID,
. q- w. i) m0 V! c g_ModelEntryInfo.m_PassCard.nFlagStation1,
( j' u! @. j3 b2 G/ P g_ModelEntryInfo.m_PassCard.nFlagStation2,
1 q% h9 n! E+ Y) { g_ModelNodeInfo.m_nStationID," b# A# N/ {" X# G7 s; O# z
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,8 P" o0 O k, U5 G/ H
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase
. O# G2 | z w );
) c+ H4 s* r' e3 j! W1 R- [5 G: i4 @% \
try
' a! a9 d) T9 Q! E6 {7 i {
" D, G' b% R( {0 M. X pLocalConnectPtr.CreateInstance(__uuidof(Connection));
- y- w% p1 m+ c8 R pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
B* V4 u+ C4 U- K
# G4 g# i- E" l8 F. i1 F- @- e pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
0 A1 h2 L; ^4 b, K) T5 x; F$ p pRstPtrTollRate->Open(pcSQL, k. C7 N& f9 K7 U
pLocalConnectPtr.GetInterfacePtr(),
( l. B0 w; @7 w4 ?( `7 q adOpenStatic,
6 `7 O. w1 g1 U& ]! J7 j adLockPessimistic,& B. R6 X8 Y' J5 n3 i. X
adCmdText);9 b# W7 |9 b1 P& F9 i/ a" ^9 L5 V
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));$ ^" ^0 f7 }( z; J7 M# @
pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),6 J, ~+ j& E( n2 o$ X5 y. U
pLocalConnectPtr.GetInterfacePtr(),2 x: {+ i( d r* }- t8 H5 q
adOpenUnspecified,+ ~: |% i. y* m& a3 m' L0 {
adLockPessimistic,
' B. f g/ t; I9 S3 k2 Q) R, P" m& A adCmdTable);; ^. F6 p3 \) S& G3 Y
! G! N5 M$ \6 g8 p: c pRstPtrTollRate->MoveFirst();& J, v# o1 C u/ R( ^6 }" l
for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)+ P$ ~" n0 B; h
{
9 L; i& P. {2 I6 R; B pRstPtrSplitWastebook->AddNew();: R1 i4 s3 g8 S; {0 o2 N
pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
4 L( h2 T* [1 {% J' O2 ?! j 9 ]8 K8 K# s: N; r
pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
$ G8 h4 ~* L- ]6 @$ ]) R" E, X
9 J. p; k; X' c pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);# b% m' P+ B9 k6 T
$ T4 _$ h. n% Q3 D# x2 ? pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);3 R% p7 S2 p% _( p* \7 Z
+ q% X, X" ]# }# D( N
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);
( y2 g8 R* T. \" k4 b pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;! t( H$ B6 C" D' J7 |( |' F
, |1 H; Q$ G5 ]) O6 { pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;8 V- n& \% t" u7 j. ^! S& j: g
- Y9 s+ ]' V# d! p) S! G; g
pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
2 D8 a0 p7 a7 y1 h- x& q7 _ * A5 V) x4 T. H; \, U
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
& U8 ~: C2 S+ `; _% s
" z# }! @) A9 c! P* ]4 { pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);6 r+ Q- X6 s4 g- _
1 n0 h; Y* z! l3 q$ k pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
( `; a. X7 |1 k1 R% q ) _. s' ~8 x8 _+ G8 \7 t
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;1 C# u3 c ]. n9 w
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;$ u1 t- C8 U4 K0 R# ~( t ]* @
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;, Y' u; `5 b( p6 P" N* t* X& J
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;
5 E6 o! O) d8 `2 D: J
: i! z! V* Z* [; ^ pRstPtrSplitWastebook->Update();
0 M. |# {+ |" ]/ n
, Z* P4 \' U8 p) o m_nTableSplitTollWasteNOCount++;
! o) i& \7 v, Y( f) E- X pRstPtrTollRate->MoveNext();& M: i/ d& `. ~% Q0 N
}
9 i1 a6 a. v" @: Y# d pRstPtrSplitWastebook->Close();
1 `2 R5 B$ z' ~* |' j! x% P& w pRstPtrTollRate->Close();5 w7 V$ |: e" L4 b% W) f5 m, L
pLocalConnectPtr->Close();( y. s: k; r! C( X, T" F8 F" v) @
m_nStatus = DB_OK;
0 M) P6 d) I. [- R: I S return(m_nStatus);
% a1 X9 G/ x- E7 N. ~" G& \ }
s3 `* z( j6 [2 ^8 \/ J& |9 ?# \ catch(_com_error e)3 _* O+ L: C0 u( ]8 a6 z
{5 f9 n N9 b! {8 t7 Q# B, k
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());% l& w; L& i+ R; F! A& _* ?8 p, I& S
g_ModelPrompt.Notify();
5 g# p" C! @& e m_nStatus = DB_ERROR;5 M+ C( M0 Z) n& ~4 m! l" V+ s: g
return(m_nStatus);
: \, T7 n) S, N8 x& m3 I0 C% [ }
( g% ?4 z1 p' R2 [1 q}
$ s* d$ o2 H8 \- X7 r4 X
+ a+ g2 D3 F' F+ ]& Z2 i1 B
9 v6 y/ U7 G1 i/ _# T. e ^2 _: z: O: I$ |2 O9 H, b& ^9 _% [9 X
float CObserverLaneDB::GetTollRate()
- h2 Z, W6 L* M! |$ w' w9 H7 u{. {# q/ X6 T' t# I/ e
" G5 p2 r$ X; ]& z. F, \" [1 D
_ConnectionPtr pLocalConnectPtr;' z9 J- B! X5 c0 r
_RecordsetPtr pRstPtrTollRate;! @2 D; J: @4 h" _7 V/ z
_RecordsetPtr pRstPtrOrganInfo;
& G$ t t' D! o! d
: @! O; N. g$ @# I B# _- o- F6 J float fToll = -1;
$ R$ u, @- i& c7 a char pcSQL[300];
7 ~3 E6 T1 S( q1 h+ ]3 O! M; d int nSplitCount = 0;
+ R0 c8 b }& [- D switch(g_ModelNodeInfo.m_nNodeType)2 q, o( s! r6 ^8 ?, q
{
X8 R/ ^8 _5 G; a+ m1 k! A3 x) K case NODE_TYPE_ENTRY: K& @1 ]9 k% ~0 F$ q, A& C; J0 X
return(0);2 o! q7 l2 R+ ^# |
break;) f6 K3 q% e& O, J- N, y
case NODE_TYPE_EXIT:1 ~9 V8 x! B$ G
case NODE_TYPE_MAIN_LANE:( }" Y" N' M" {8 K6 b; ^3 t1 i4 w0 A
switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
+ P+ Q+ Y$ c p$ o. O, L" h; \" o% x {4 ~4 D) t) D; B9 ~/ y
case VEHICLE_CASE_URGENT:
% K1 L- ~4 V r1 C5 M$ O case VEHICLE_CASE_ILLEGAL:
. l" S3 Z+ C& q& c2 v* j case VEHICLE_CASE_OFFDUTY_ILLEGAL:
; w+ M, b3 U# ^4 a" Q8 R case VEHICLE_CASE_MOTORCADE:+ T' k0 Z' }# g0 P9 Z
case VEHICLE_CASE_COMMUTATION_TICKET:
0 R) m5 A8 o2 J# d5 E case VEHICLE_CASE_ETC:
, n; L$ x6 r5 K6 ~ case VEHICLE_CASE_BAD_CARD:0 k6 @# r2 V: T3 [: C8 g5 j$ `# |
case VEHICLE_CASE_NO_CARD:- _5 A) v V3 _1 n% h
sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
0 ?/ D H% H, e$ F+ b g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,' M/ C4 z* z( b; c4 b
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
5 U+ t' u# h7 B) N5 l! i break;
0 L6 Z' _. H* ` default:, g* V: g. N5 \) 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 ",
( s& p' ?( Z: {2 {9 U g_ModelEntryInfo.m_PassCard.nEntryStationID,- A3 i! W$ ~! v5 _% R
g_ModelEntryInfo.m_PassCard.nFlagStation1,
, t/ J$ U, \2 x0 ` g_ModelEntryInfo.m_PassCard.nFlagStation2,- p& G8 u& p* @' Y' e( `7 [" v0 A
g_ModelNodeInfo.m_nStationID,- ?* C1 h0 f N
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
- o* G' N: U* A7 o4 z7 r g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);0 N' ~3 i$ y& M: ?' g/ y
break;
2 K- i- G8 ~' P$ U }$ F$ `! j: R9 |5 n- n/ ^
! E v8 K9 d6 ]& s; S try+ d3 g; ]6 b1 y# a' f8 R# ]$ O
{
$ Y1 J/ p& N' G8 C1 S) I pLocalConnectPtr.CreateInstance(__uuidof(Connection));. q6 t8 C' [# J
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
9 W! {1 U+ f: V2 b3 g 2 n" \# x3 F/ ~" k3 h, G
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));/ K3 H# M9 T2 W, \7 \5 w [) v
pRstPtrTollRate->Open(pcSQL,
8 O1 L9 r2 i7 ?% R' F pLocalConnectPtr.GetInterfacePtr(),
5 G9 R' {0 ?8 f) y. ?( [9 h adOpenStatic,
_0 [ U* V& C+ v3 a adLockPessimistic,
- S/ s& t% a7 O: d/ \0 O1 E adCmdText);
, r9 `; V7 R% v6 W if(pRstPtrTollRate->RecordCount > 0)
1 Q: R: b( \7 a {
% @! p6 [3 _: s7 Y2 M6 \3 i fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
9 v) ~2 d% ?) |% S$ k if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
; |; N5 w4 G# p5 i) W9 K& _ {
# U4 R" r' U; [/ K/ R memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));$ y( c! \1 X- [- p( ?8 B# F
pRstPtrTollRate->MoveFirst();
3 D% z! I! K P2 N/ G for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
# }4 f+ Q0 y/ N! E! n {2 O( E. m# f. u p; }) e1 Q# c- g
sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);7 L l+ R8 ^' k5 l0 [
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));
7 @. k' `/ l2 `9 s pRstPtrOrganInfo->Open(pcSQL,
9 b2 k h/ D+ C9 x pLocalConnectPtr.GetInterfacePtr(),3 Q- E, {; @5 @8 G& {) _1 u
adOpenStatic,
0 N( |4 j# P0 B, k5 F0 G3 D( t adLockPessimistic,
0 p. n6 W+ t; D7 r Z adCmdText);+ z$ g T: { ?; @# o- T
nSplitCount++;
J$ K* _, X0 l# S char pcBuf[10];. {$ r$ x8 H* b' i" }
if(0 == nSplitCount%3)
9 \, }( p% l2 d$ o/ b2 h {
/ W" b0 D' F$ y% a# C+ i+ n6 e3 \ sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
[& X Q2 z; g: C4 l: R" H }else' ?" f1 ^ \. R: N8 i. z9 P
{
7 J' N" N3 C& J7 A+ B, g9 L sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);# Q! ]6 C1 s4 c) u0 c3 H- j$ y
}
. p/ q4 a! D* \ | strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);) I2 ?# W3 z2 F' F8 _1 q8 z6 k
strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);
# k2 i0 F, o' t8 N5 }- t o B* e# K pRstPtrOrganInfo->Close();
- g* m( @% h- C1 }/ P8 ~ K0 R" o pRstPtrTollRate->MoveNext();0 `$ e6 w% ]. {
}# {* C8 }3 k5 V. R% B; i6 q
}
9 v2 n* v+ E4 @ ; }, `# ^0 u0 k6 C! l: h
}else fToll = -1;
1 Q1 z" y' B2 s! k L7 ` 2 S+ y$ D% ?& c, \: v
pRstPtrTollRate->Close();
1 ^( d5 q6 |, L# d pLocalConnectPtr->Close();( L8 Y# [" j: S& r2 q' y' C
m_nStatus = DB_OK;
- W6 ~* b& @/ u j return(fToll);
2 R3 H; `5 ~5 g8 ` }
R r1 M+ W# O; I6 v) h( s catch(_com_error e)0 m; ]2 j- Z- Z' R$ d' i/ I
{
5 B2 J! v- p/ {4 s3 ` g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
+ r& {" K0 N* r3 r J4 k2 k0 { g_ModelPrompt.Notify(); ' n* G8 E6 R/ i
m_nStatus = DB_ERROR;
4 Q- o R, M4 K9 q return(fToll);
6 a! `# g" R+ g& p. I }% B+ o) ~" f) `" S3 ^6 X1 B9 M: |; ~
' Y6 T6 w) i0 Z# _; t break;' v; r* c! Z( ^
case NODE_TYPE_OPEN:
& p8 _, G( [5 W7 U sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",
( q3 v- D; x+ B; C3 }! G! C g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass
& E9 c- @6 s& c );
) H4 A7 o V* O, R& R- z try
2 h4 M1 m9 |0 y! D {
& ?* h% |/ s( a8 S! K; n- Q pLocalConnectPtr.CreateInstance(__uuidof(Connection));& U8 [ N/ S( U! h. p( ~
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);( v/ _/ g7 K( W
5 q! k, j6 F5 q4 w- `" R pRstPtrTollRate.CreateInstance(__uuidof(Recordset)); M7 p2 c1 m& b" ^( v2 {) ^' _
pRstPtrTollRate->Open(pcSQL,
4 J! z3 F4 r# j( }7 p$ X pLocalConnectPtr.GetInterfacePtr(),
) a6 g4 K8 y; T% X% U! \ adOpenStatic,
7 `9 k* v2 i6 G4 S adLockPessimistic," f9 j4 V4 f) V% _/ \, l$ _
adCmdText);
) p; W' p+ [% O. ^1 Q' B$ v if(pRstPtrTollRate->RecordCount > 0)6 a% A6 `6 ^5 I) m9 z2 n
{. `. ]: l9 D, g
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;( Q- e; J0 t Y' |9 @3 S3 j
}else fToll = -1;
$ ] F3 y$ A# w, l# s4 F A) O3 i . p% ?3 B2 L. y: U+ U
pRstPtrTollRate->Close();
4 v# {2 |: c6 X0 c& Q pLocalConnectPtr->Close();3 @3 T; N8 M1 f& j N9 n
m_nStatus = DB_OK;8 k3 q- x) Q* ]( A- H
return(fToll);' V8 g( h. o0 N" \6 c- O3 J1 }1 Y9 d
}
5 ^4 C K g# C8 A catch(_com_error e) f9 k% N! |1 Y, P8 Z
{
3 P/ j1 m1 t1 P. F0 _" }3 B8 q! j+ x! ~ g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());9 q4 y/ w6 c7 [$ d/ v5 \! r
g_ModelPrompt.Notify(); $ n) O0 v% \8 x, s% ?2 N) u; G
m_nStatus = DB_ERROR;
& A6 r/ }/ G9 V1 [# Q. x return(fToll);
3 O5 `/ }5 L8 Q! z4 [) g }9 g& [# z3 L' Y7 R: X
break;
$ U# ~& s1 u; @/ c2 h3 L default:. Y2 L w3 C- J, q
m_nStatus = DB_ERROR;
+ Q( g" g# Y2 [, A1 m- ? break;
& w) Z3 _! M3 y2 m( J- f }
4 _0 o1 ^0 c( ^5 M4 F; j return(fToll); # v7 G. J1 @" _( E
} |
|