|
|
int CObserverLaneDB::InsertTollSplitWasteBook()
- U; r% }2 k Z7 {: L" }8 f{
- L8 U$ t3 H1 Z% @ _ConnectionPtr pLocalConnectPtr;
9 J2 o+ d1 E9 \. E* l, E- n _RecordsetPtr pRstPtrTollRate;$ A4 S' X9 U/ J
_RecordsetPtr pRstPtrSplitWastebook;
+ I5 ~" I3 y! W9 k- H" J. I$ Y
* b) {+ g# A7 e7 ?# P: A char pcSQL[300];. ?' n0 Q$ U1 X# K. k( p
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 ",: M/ p7 ?: ?6 A2 Q3 ^
g_ModelEntryInfo.m_PassCard.nEntryStationID,% i! ]; o- F( @3 w% V
g_ModelEntryInfo.m_PassCard.nFlagStation1,) j; O) Y5 S/ M) m6 x) \
g_ModelEntryInfo.m_PassCard.nFlagStation2,7 m" B2 b8 X. T3 T* E
g_ModelNodeInfo.m_nStationID,
1 O( G! Z5 J3 u! k* z* d7 Z g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,
( i; \8 d3 T- [: m g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase
1 ~: r+ z& _0 u );! U4 w2 A+ d3 T, ]# Q6 Q0 V1 C2 a
& g" U6 T! \ h4 j9 h3 e6 t try
" Y8 n2 N2 Z* Y1 d, N {
) \0 Y& H; y$ H8 x( S pLocalConnectPtr.CreateInstance(__uuidof(Connection));, L$ _) v6 Z) F5 k1 T4 x$ a
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
g( N2 y1 \, ]# W/ i* m% d 8 p$ G$ Z: a& J; L ^
pRstPtrTollRate.CreateInstance(__uuidof(Recordset));; X" u- A* o5 F) Q7 `
pRstPtrTollRate->Open(pcSQL,
/ I" I4 R J+ w7 t pLocalConnectPtr.GetInterfacePtr(),
( t% S) U$ A( D) o+ c' C6 m adOpenStatic,
. ~! n) r) B% u0 v! `/ [- p adLockPessimistic,( j4 j6 b1 p8 f; w+ S) [. N
adCmdText);+ v* H0 ~. S0 o5 b; E+ y+ f6 Y
pRstPtrSplitWastebook.CreateInstance(__uuidof(Recordset));
+ G, m# W) Q- V7 l( u& s; A7 _5 ` pRstPtrSplitWastebook->Open(_variant_t("TBL_SPLIT_WASTEBOOK_CURRENT"),
/ e3 x5 M$ V k$ b pLocalConnectPtr.GetInterfacePtr(),
* |% {/ h8 {9 E' L# t3 E adOpenUnspecified,8 D! A o- G2 L5 k" C
adLockPessimistic,
4 T- D2 J0 G/ K5 w adCmdTable);. p3 a" E- V* a- K2 S7 N1 |
+ u! d* R8 t7 b; B pRstPtrTollRate->MoveFirst();
- j" e9 ]6 G& Q" V for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)! I* Y6 c" d) L, C
{
# y/ o& b% @6 F$ f6 U$ \ pRstPtrSplitWastebook->AddNew();
4 y9 w n$ X& l pRstPtrSplitWastebook->Fields->Item["NET_ID"]->Value= _variant_t((long)g_ModelNodeInfo.m_nNetID);
9 H ?/ `) e# e* p, z6 L: |
" B% k6 L0 ?+ a pRstPtrSplitWastebook->Fields->Item["STATION_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nStationID);
! L4 L- B) \5 l5 M 9 s$ [) T% f5 x+ q% K \9 [
pRstPtrSplitWastebook->Fields->Item["NODE_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nNodeID);
' f+ K: K3 B8 p ) s& W$ n" i g
pRstPtrSplitWastebook->Fields->Item["WASTE_NO"]->Value=_variant_t((long)m_nTableTollWasteNO);
0 J6 p0 G6 S' U9 o % I5 U U5 G' S) Q8 L" E0 {2 v
COleDateTime CreationTime((time_t)g_ModelTollInfo.m_TollWasteBook.m_nCreationTime);% V/ ]) q G2 v- } b
pRstPtrSplitWastebook->Fields->Item["SPLIT_TIME"]->Value=(DATE)CreationTime;2 W6 ^% D' n$ a+ ^* @8 R
7 K6 W$ Z: V( b% l4 W pRstPtrSplitWastebook->Fields->Item["WORK_DATE"]->Value=(DATE)g_ModelOperatorInfo.m_oletmWorkDate;( [! R- T+ o/ m* w
& @6 m! o7 N$ N5 t6 X* Y, O: T pRstPtrSplitWastebook->Fields->Item["SPLIT_NUMBER"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_NUMBER"]->Value;
1 l) L- \2 S5 i8 U + f5 i* k& w J' k3 Y
pRstPtrSplitWastebook->Fields->Item["SPLIT_SEQUENCE"]->Value=pRstPtrTollRate->Fields->Item["SPLIT_SEQUENCE"]->Value;
& [# D; k! y- _% [5 T0 `5 S- ^+ z# q + O! O5 U" \0 M/ R
pRstPtrSplitWastebook->Fields->Item["OUT_OWNER_ID"]->Value=_variant_t((long)g_ModelNodeInfo.m_nOwnerID);
4 y# m6 j/ c; v+ ]2 [3 U7 p' r
5 W" x# p0 Q( q' ~* } pRstPtrSplitWastebook->Fields->Item["OWNER_ID"]->Value=pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value;
, t- Y& q- b2 Q $ F* Q0 e9 z% Z
float fTollReceivable = g_ModelTollInfo.m_TollWasteBook.m_fTollReceivable;7 ^0 p- l) f7 a% l2 x* S
float fOwnerToll = pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value;4 A7 I' P# I7 m+ k/ Q6 E
float fTollMoney = pRstPtrTollRate->Fields->Item["Toll_Money"]->Value;5 k6 S# b0 K& S S9 H$ a
pRstPtrSplitWastebook->Fields->Item["OWNER_TOLL"]->Value= fTollReceivable * fOwnerToll / fTollMoney;" u1 F2 ?1 h- j/ R {% ^
, Y% C M4 P- V# d- f! o* l- y pRstPtrSplitWastebook->Update(); / C7 i O1 `0 J6 |8 Z0 C1 z
; q( u. |- j/ _6 A4 N) a m_nTableSplitTollWasteNOCount++;/ K: a6 g7 {$ `$ o! Z6 k) N
pRstPtrTollRate->MoveNext();
' |4 O( p# H5 c% p/ q( W }
2 |3 n. A7 E0 i+ m: {8 x* o pRstPtrSplitWastebook->Close();. W6 o# Q n7 W' [2 i$ ]3 V' Q
pRstPtrTollRate->Close();; W, U- v5 I5 j6 O' x: }* `
pLocalConnectPtr->Close();
y- w- n4 }: f2 f, x1 Y m_nStatus = DB_OK;
o! n6 m1 i5 m: m' P return(m_nStatus); # ~1 \. t+ I2 W3 r6 J/ a
}' r' Q2 O; T$ x/ w) M2 M7 k
catch(_com_error e)/ C( U9 D; Q I
{
8 ^, z) }! d- \# M! G6 O% ` g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());
3 f) m( x1 F/ T$ G$ h( G0 @: o g_ModelPrompt.Notify(); X' q# ~) w }7 W4 @+ \" h* C! J
m_nStatus = DB_ERROR;
/ ^( ~& [/ r- O7 E2 F return(m_nStatus); . |1 u) W/ }) v5 O( e C
}
, G3 E. j4 y. E. y: f2 l1 M}3 I6 L6 ?% m! P, Y1 t5 f" l; ?
5 s/ @" ?/ Y/ |( b$ F
% I- p7 e6 R, g4 W5 f y7 i5 f: o7 t5 V5 M% X9 N
float CObserverLaneDB::GetTollRate(). V9 h/ b$ D a% a8 |3 |$ R
{
5 _: Z+ r: m) L( P: Y9 F* C: t3 N# Q- z5 z& C0 a% w7 L f5 ?7 u& _
_ConnectionPtr pLocalConnectPtr;1 {9 h e4 e4 t9 @4 L
_RecordsetPtr pRstPtrTollRate;
) ]" [' i$ y( f1 t* |; Y _RecordsetPtr pRstPtrOrganInfo;& P o$ J7 K _& ~8 a. B
: M* K" a' w4 Q6 Q1 K float fToll = -1;& d# x! E1 [& _: c3 N' d
char pcSQL[300];7 E2 Z8 a% Q4 v" o5 @( R
int nSplitCount = 0;1 t/ J( G, c2 `& U I, X) D" E
switch(g_ModelNodeInfo.m_nNodeType)" O* c& T/ F) _0 U+ |- u/ f/ E8 X6 t# ]
{2 l7 k8 j. w3 y! f/ ?! n7 M
case NODE_TYPE_ENTRY:
( B) I7 z+ F6 ^- q return(0);4 \: r4 A+ I% e( X
break;
# j7 q; {7 e& |1 m8 W case NODE_TYPE_EXIT:
% {. F: Z3 m6 u# v8 _5 A9 V, r' T+ K case NODE_TYPE_MAIN_LANE:
) N& M$ f- m- b% ]- l& B, { switch(g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase)
5 Z; O) v- t# B1 J4 i9 E {
- f% i6 d: ?6 y9 Q4 F case VEHICLE_CASE_URGENT:/ L6 C. P: q( c5 S) a7 t, _$ G
case VEHICLE_CASE_ILLEGAL:
2 c$ s& [0 ? ]& y case VEHICLE_CASE_OFFDUTY_ILLEGAL:
3 I$ l2 X& Z5 @1 Z/ b v case VEHICLE_CASE_MOTORCADE:% { k0 N# J: [9 q
case VEHICLE_CASE_COMMUTATION_TICKET:2 E; r( m, P5 q5 L& s
case VEHICLE_CASE_ETC:/ m: K/ S+ M$ o8 O0 t9 [1 v9 ~. t
case VEHICLE_CASE_BAD_CARD:
) ^: F* b: V4 A8 [! G9 J' J case VEHICLE_CASE_NO_CARD:
8 Q" ]) E' d) Y. }+ V% R sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld and Vehicle_Case = %ld ",
0 }1 l' D. ^% y g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,! X& j2 G# \# V8 l" G
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);1 e; N2 q5 h. \) E$ H
break;8 h$ E, C0 z" x7 c& Q, G, `
default:2 E3 w; r- H: X+ }: Q& Y% p1 G1 f
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 ",
5 T# i' j3 _0 J! a g_ModelEntryInfo.m_PassCard.nEntryStationID,6 j6 Z- x& F# o
g_ModelEntryInfo.m_PassCard.nFlagStation1,
& \) `& B7 o; L& l ~7 ~, e8 C g_ModelEntryInfo.m_PassCard.nFlagStation2,
% _( y8 [( _" p9 r0 ~1 i3 s5 P g_ModelNodeInfo.m_nStationID,1 |0 Y& V) O N
g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass,# d5 R: S8 W0 v* `% u
g_ModelTollInfo.m_TollWasteBook.m_nVehicleCase);
3 {9 e2 U+ C. A$ v break;
. |) X# ^5 S$ C( Y }8 S" e4 @' D1 v. y- k. B1 g
9 X) k+ ~: C; s2 b( ^1 G& G# x6 o try
% e( Y6 L5 D" j- f {5 z: W' {7 N& S6 z- F" c
pLocalConnectPtr.CreateInstance(__uuidof(Connection));/ d! F# J) d) D% j
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);
6 _/ H2 h% H, Q M+ U
U* D. S$ }0 q% x% R7 Z; j i pRstPtrTollRate.CreateInstance(__uuidof(Recordset));
! @( B: @" Z2 }# i9 f7 h$ g$ { pRstPtrTollRate->Open(pcSQL,, t7 W' K) V4 F' x
pLocalConnectPtr.GetInterfacePtr(),
- ^3 t/ B1 F6 y3 @' i! M adOpenStatic,
; N: c' @- H) a! q7 l3 r adLockPessimistic,6 g8 |' J0 P0 p
adCmdText);
# Z% j" G S3 w0 v: p if(pRstPtrTollRate->RecordCount > 0)
! K0 g# [- ~! v; b. M+ B {
3 \! ~& L: d+ \7 G5 i" ` fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;
) F6 p1 Q j! A( R( M' @' B if(pRstPtrTollRate->RecordCount > 1 && pRstPtrTollRate->RecordCount < 5 )
/ L1 m$ n7 |: D' G- A* V {; m4 g& C: x. j8 k% W1 Y
memset(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,0,sizeof(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo));
4 t' L7 g* c& t, Z pRstPtrTollRate->MoveFirst();
" V3 B5 b+ r% B, q/ L: U for(int i = 0;i<pRstPtrTollRate->RecordCount;i++)
0 k4 ?- p0 ]: M1 G5 x, ^( @ {
; T5 n' D2 {; } sprintf(pcSQL,"Select * from TBL_ORGANINFO where MAINOWNER_ID = %ld",(long)pRstPtrTollRate->Fields->Item["OWNER_ID"]->Value);( @7 K. `/ V2 Z8 ]. n. t6 ^3 c/ b3 g% `
pRstPtrOrganInfo.CreateInstance(__uuidof(Recordset));
0 t a; B% w0 X/ q7 b pRstPtrOrganInfo->Open(pcSQL,) X. k" m. m# G
pLocalConnectPtr.GetInterfacePtr(),
1 O! X# o; C V) G" |: \; c' e adOpenStatic,
6 i* }; Z* }' J adLockPessimistic,
: I6 Z7 d3 z( {3 m" v# L! I& P; x# B8 h adCmdText);
' x+ p, ~. w4 o& ?4 t& H7 c nSplitCount++;; E+ F8 R6 B8 e* H
char pcBuf[10];
( q; {0 k: q# J0 j$ e7 | if(0 == nSplitCount%3)
( G/ n$ O! z/ g7 l' P. z4 I+ @ { t: a# f8 J# m
sprintf(pcBuf," : %.2f \n",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);3 U! V: v! y* p
}else
' _+ p) f: a5 p% W* J# l! A {& O, O4 }8 l6 Q2 B0 w
sprintf(pcBuf," : %.2f ",(float)pRstPtrTollRate->Fields->Item["OWNER_TOLL"]->Value);
7 O* l& C+ l" x }, z/ V2 h$ T3 _, P$ Y1 e6 U) O0 z
strncat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,(LPCSTR)(_bstr_t)(pRstPtrOrganInfo->Fields->Item["ORGAN_NAME"]->Value),4);
$ z m4 [- o( P4 O strcat(g_ModelDeviceInfo.m_Printer.m_pcSplitInfo,pcBuf);1 o$ g9 n) M. E
pRstPtrOrganInfo->Close();
! [/ i1 K# S; z$ Z pRstPtrTollRate->MoveNext();
2 d! V2 F3 E* F1 S" o$ N }4 p! J! P/ R( k
}
) w+ J6 A; g: X$ Y
# k! k5 m; r) ^. R0 q. S: Z }else fToll = -1; g/ H. {6 Z" N8 Y
0 B0 j" a7 r+ N) c
pRstPtrTollRate->Close();
/ i2 r( D$ t. K9 Q; O) @ H6 p" l pLocalConnectPtr->Close();
) \$ K# _$ P( Z" P- g; d m_nStatus = DB_OK;! |5 Z. }/ R! B$ G9 b6 {
return(fToll);3 I x- E+ Z6 _9 V9 }# v# t
}
0 j0 I; J. J8 C# A! M8 |2 T, ~9 I catch(_com_error e)
$ w' Q2 I8 n' K8 J6 d, [. } {
3 E8 {- ]5 M# Z' X+ E' | c g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());7 C- x4 q! V, K3 h. `: [
g_ModelPrompt.Notify(); 1 }5 Q7 E6 [* o I0 E
m_nStatus = DB_ERROR;
. _2 U( i0 h( {; G return(fToll);
! P. b0 T6 m4 ] }
* H. x9 f0 I3 ]8 M
1 A, h; w0 G( @; g break;% e- o# r; {9 j7 c2 |) x* _
case NODE_TYPE_OPEN:
" ?; M2 f4 c/ R0 d4 n) Z sprintf(pcSQL,"Select * from TBL_TOLL_RATE where Vehicle_Class = %ld",
1 _, ]: S1 k" R: O( | g_ModelTollInfo.m_TollWasteBook.m_nVehicleClass* \) R% b: x& j5 \ `
);
. F+ I9 D& j5 m6 g try
6 |! o8 u+ v9 K" { {- i8 q9 i2 Z$ b3 V5 }
pLocalConnectPtr.CreateInstance(__uuidof(Connection)); L) e8 N9 ^' H4 W$ u; X" l; e" |
pLocalConnectPtr->Open(m_pcConnection,"","",adConnectUnspecified);* K, o2 S. F* v* B6 ^" h8 n" ? K
2 D% |7 [7 U$ Y) r3 c( w pRstPtrTollRate.CreateInstance(__uuidof(Recordset));$ Y+ n1 H7 `0 R" f6 i
pRstPtrTollRate->Open(pcSQL,
$ D0 n! N) L. i" } pLocalConnectPtr.GetInterfacePtr(),. i, j" E' w3 J( b
adOpenStatic,: Y; o4 x# Y: y6 e# L( ?4 z
adLockPessimistic,
& Y# H- r Q4 i ` adCmdText);
$ o9 P+ B$ u- @ if(pRstPtrTollRate->RecordCount > 0)+ N9 [8 E# w9 y# \& s$ o" ~9 E
{3 m9 }. W# o$ y
fToll = pRstPtrTollRate->Fields->Item["TOLL_MONEY"]->Value;9 {5 m: u$ \1 c: Y# W
}else fToll = -1;8 {9 J9 w0 N. c- Z. g
: N3 g8 R( H q" G. v5 R pRstPtrTollRate->Close();- X- E3 d# f/ ] R2 K% M C$ E
pLocalConnectPtr->Close();3 ^+ H# t* e9 R$ ]5 r r
m_nStatus = DB_OK;* G h W; f% x- W
return(fToll);
* a! z) ^+ I3 i, l& U& ? }
: \1 H1 u* Y6 A3 j) t( t4 w1 L catch(_com_error e)
$ C9 B4 D K7 j0 f- s5 [# g {, ?# N. |) w6 v/ K4 T
g_ModelPrompt.strPrompt.Format("Êý¾Ý¿â²Ù×÷´íÎó£º%s£¬%s\nÇëÓëϵͳ¹ÜÀíÔ±ÁªÏµ£¡",e.ErrorMessage(),e.Description());, M2 X6 R! e8 e: F
g_ModelPrompt.Notify();
- H/ {1 d7 B& j, Z# a3 I m_nStatus = DB_ERROR;
) H3 i5 S' q" b. H! I5 C6 | return(fToll); 5 A; u% Y; z/ k1 ~
}+ ~5 i# Z+ S/ H/ b* z# |9 \
break;; @) Q9 j2 i& Y! O/ m. ?& i3 n
default:
/ y( ?0 `+ |: P; F* J6 B/ L m_nStatus = DB_ERROR;
( @6 k( ?$ P- z3 m* d3 j p break;* y7 Z4 W% d/ k7 R$ B. o
}
6 _6 G# g A4 }) D6 F% {3 K* u return(fToll); ! d2 Q) H- T; w. ^; r
} |
|