使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 0408576e9da10015ffa9da0079b8c985113ce4b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// MsgOwner.cpp : implementation file
//
 
#include "stdafx.h"
#include "mbamdb.h"
#include "MsgOwner.h"
#include "MBAMDBFun.h"
#include "Msg.h"
extern CCriticalSection      m_csConnectDB;
 
IMPLEMENT_DYNAMIC( CMsgOwnerItem, CObject )
// CMsgOwner
CMsgOwnerItem::CMsgOwnerItem()
{
    m_nRowType    = ROWTYPE_MSG;
    Clear();
}
 
CMsgOwnerItem::~CMsgOwnerItem()
{
}
void CMsgOwnerItem::operator =( const CMsgOwnerItem& item )
{
    m_strOwner            = item.m_strOwner;
    m_strOwnerName        = item.m_strOwnerName;
    m_tmOpenDate        = item.m_tmOpenDate;
    m_strAttitude        = item.m_strAttitude;
    m_strMsgID            = item.m_strMsgID;
    m_nOwnerType        = item.m_nOwnerType;
}
 
void CMsgOwnerItem::Clear()
{
    m_strOwner            = _T("");    
    m_strOwnerName        = _T("");
    m_tmOpenDate        = COleDateTime::GetCurrentTime( );
    m_strAttitude        = _T("");
    m_strMsgID            = GUID_EMPTY;
    m_nOwnerType = 0;
}
 
BOOL CMsgOwnerItem::GetItemValue( CString strName, COleVariant &varData )
{
    varData.Clear();
    if ( strName.IsEmpty() )
        return    false;
 
    if ( strName.CompareNoCase( _T( "Owner" ) ) == 0 )
        varData        = m_strOwner;
    else if ( strName.CompareNoCase( _T( "OwnerName" ) ) == 0 )
        varData        = m_strOwnerName;
    else if ( strName.CompareNoCase( _T( "OpenDate" ) ) == 0 )
    {
        COleDateTime    oleDate( m_tmOpenDate.GetYear(), m_tmOpenDate.GetMonth(), m_tmOpenDate.GetDay(),
                                m_tmOpenDate.GetHour(), m_tmOpenDate.GetMinute(), m_tmOpenDate.GetSecond() );
        varData        = oleDate;
    }
    else if ( strName.CompareNoCase( _T( "Attitude" ) ) == 0 )
        varData        = m_strAttitude;
    else if ( strName.CompareNoCase( _T( "OwnerType" ) ) == 0 )
        varData        = (long)m_nOwnerType;
    else
        return    false;
 
    return    true;
}
 
BOOL CMsgOwnerItem::InsertRecord( CDBConnect *pAConnect)
{
    CString            strSQL;
    BOOL            bReturn = true;
 
        strSQL.Format( _T("INSERT INTO TN_STK_MSGOWNER(G_C1, S_C2, S_C3, T_C4, S_C5,  N_C6  ) VALUES ( \
        '%s', '%s', '%s', '%s', '%s', %d)"), m_strMsgID, CMBAMDBFun::GetDBReplaceStr( m_strOwner ), CMBAMDBFun::GetDBReplaceStr( m_strOwnerName ), 
        CMBAMDBFun::FormatDBTIMEToStr(m_tmOpenDate), CMBAMDBFun::GetDBReplaceStr( m_strAttitude ), m_nOwnerType );
    try
    {
        bReturn = CDBSQLiteCommFun::RunSQL(strSQL, pAConnect);
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError = ex.GetErrInfo();
        CString        strErrInfo;
 
        strErrInfo = _T("InsertRecord - MsgOwner- ") + strError;
        CMBAMDBFun::WriteDBErrToFile( strErrInfo );
        return false;
    }
    return true;
}
BOOL CMsgOwnerItem::UpdateRecord( CDBConnect *pAConnect )
{
    CString            strSQL;
    BOOL            bReturn = true;
 
        strSQL.Format( _T("UPDATE TN_STK_MSGOWNER SET S_C3 = '%s', T_C4 = '%s', S_C5 = '%s' WHERE S_C2 = '%s' AND N_C6 = %d AND G_C1 = '%s'"), 
        CMBAMDBFun::GetDBReplaceStr( m_strOwnerName ), CMBAMDBFun::FormatDBTIMEToStr(m_tmOpenDate), 
        CMBAMDBFun::GetDBReplaceStr( m_strAttitude ), CMBAMDBFun::GetDBReplaceStr( m_strOwner ), m_nOwnerType, m_strMsgID );
    try
    {
        bReturn = CDBSQLiteCommFun::RunSQL(strSQL, pAConnect);
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError = ex.GetErrInfo();
        CString        strErrInfo;
 
        strErrInfo.Format( _T("UpdateRecord(%s) - MsgOwner - %s "),strSQL, strError);
        CMBAMDBFun::WriteDBErrToFile( strErrInfo );
        return false;
    }
    return true;
}
BOOL CMsgOwnerItem::UpdateUserAttitude( CDBConnect *pAConnect,CString strAttitude)
{
    CString            strSQL;
    BOOL            bReturn = true;
 
    strSQL.Format( _T("UPDATE TN_STK_MSGOWNER  S_C5 = '%s' WHERE S_C2 = '%s' AND N_C6 = %d AND G_C1 = '%s'"), 
        CMBAMDBFun::GetDBReplaceStr( strAttitude ), CMBAMDBFun::GetDBReplaceStr( m_strOwner ), m_nOwnerType, m_strMsgID );
    try
    {
        bReturn = CDBSQLiteCommFun::RunSQL(strSQL, pAConnect);
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError = ex.GetErrInfo();
        CString        strErrInfo;
 
        strErrInfo.Format( _T("UpdateRecord(%s) - InsertUserAttitude - %s "),strSQL, strError);
        CMBAMDBFun::WriteDBErrToFile( strErrInfo );
        return false;
    }
    return true;
}
 
CMsgOwners::CMsgOwners(CMBAMDBConnect *pAConnect)
{
    m_pMsgs        = NULL;
    m_pAConnect = pAConnect;
}
 
CMsgOwners::~CMsgOwners()
{
}
 
 
// CMsgOwner member functions
void CMsgOwners::operator =( const CMsgOwners& item )
{
    m_pMsgs                = item.m_pMsgs;
 
    m_pAConnect            = item.m_pAConnect;
    m_strSQL            = item.m_strSQL;
    m_nRowType            = item.m_nRowType;
 
    m_strOwner            = item.m_strOwner;
    m_strOwnerName        = item.m_strOwnerName;
    m_tmOpenDate        = item.m_tmOpenDate;
    m_strAttitude        = item.m_strAttitude;
    m_strMsgID            = item.m_strMsgID;
    m_nOwnerType        = item.m_nOwnerType;
}
 
void CMsgOwners::LoadData( CMsgOwnerItem msgOwner )
{
    m_strOwner            = msgOwner.m_strOwner;
    m_strOwnerName        = msgOwner.m_strOwnerName;
    m_tmOpenDate        = msgOwner.m_tmOpenDate;
    m_strAttitude        = msgOwner.m_strAttitude;
    m_strMsgID            = msgOwner.m_strMsgID;
    m_nOwnerType        = msgOwner.m_nOwnerType;
}
 
int CMsgOwners::ListSpMsgID(LPCTSTR lpszMsgID, LPCTSTR lpszOwner/*=NULL*/, int nOwnerType/* = 0*/)
{
    if ( lpszMsgID == NULL )
        return    0;
 
    CString            strSQL;
    int                nCount;
    
    if ( lpszOwner == NULL )
    {
        strSQL.Format( _T("SELECT S_C2, S_C3, T_C4, S_C5, N_C6, G_C1 \
                FROM TN_STK_MSGOWNER WHERE G_C1 = '%s'"), lpszMsgID );
    }
    else
    {
        strSQL.Format( _T("SELECT S_C2, S_C3, T_C4, S_C5, N_C6, G_C1 \
                FROM TN_STK_MSGOWNER WHERE G_C1 = '%s' AND S_C2 = '%s' AND N_C6 = %d"), lpszMsgID, lpszOwner, nOwnerType );
    }
 
    m_strSQL = strSQL;
    if( !m_pAConnect || !m_pAConnect->IsOpenDB())
        return    0;
 
    try
    {
        m_ARecordSet.Close();
        m_ARecordSet.Open( m_pAConnect->GetDBConnect(), strSQL );
        m_ARecordSet.MoveFirst();
        nCount = m_ARecordSet.GetRecordCount( );
    }
    catch( CDBSQliteException ex )
    {
        CString        strError;
 
        strError = (LPCTSTR)ex.GetErrInfo( );
 
        return 0;
    }
 
    return nCount;
}
 
bool CMsgOwners::GetMsg( CMsgs &msg )
{
    if ( m_pMsgs == NULL )
        return false;
 
    msg = (*m_pMsgs);
    return true;
}
 
bool CMsgOwners::GetData( )
{
    CString            strTempValue;
    int                nTempValue;
 
    try    
    {
        m_ARecordSet.GetValue( 1, strTempValue, true );
        m_strOwner    = (LPCTSTR)strTempValue;
        strTempValue= _T("");
 
        m_ARecordSet.GetValue( 2, strTempValue, true );
        m_strOwnerName = (LPCTSTR)strTempValue;
        strTempValue= _T("");
 
        m_ARecordSet.GetValue( 3, m_tmOpenDate );
 
        m_ARecordSet.GetValue( 4, strTempValue, true );
        m_strAttitude = (LPCTSTR)strTempValue;
 
        nTempValue=0;
        m_ARecordSet.GetValue( 5, nTempValue );
        m_nOwnerType = nTempValue;
 
 
        strTempValue= _T("");
        m_ARecordSet.GetValue( 6, strTempValue, true );
        m_strMsgID = (LPCTSTR)strTempValue;
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError;
 
        strError = (LPCTSTR)ex.GetErrInfo(  );
        return false;
    }
 
    return true;
}