使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 4905e2e7537d507f218e8e9595485e09d9f3a2b4
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
// MsgFolder.cpp : implementation file
//
 
#include "stdafx.h"
#include "mbamdb.h"
#include "MsgFolder.h"
#include "MBAMDBFun.h"
 
 
extern CCriticalSection      m_csConnectDB;
 
CMsgFolderItem::CMsgFolderItem()
{
    m_nRowType    = ROWTYPE_MSGFOLDER;
    Clear();
}
 
CMsgFolderItem::~CMsgFolderItem()
{
    
}
 
void CMsgFolderItem::Clear()
{
    m_nID            = 0;
    m_strName        = _T("");
    m_nParentID        = 0;
}
 
BOOL CMsgFolderItem::GetItemValue( CString strName, COleVariant &varData )
{
    varData.Clear();
    if ( strName.IsEmpty() )
        return    false;
 
    if ( strName.CompareNoCase( _T( "ID" ) ) == 0 )
        varData        = (long)m_nID;
    else if ( strName.CompareNoCase( _T( "Name" ) ) == 0 )
        varData        = m_strName;
    else if ( strName.CompareNoCase( _T( "ParentID" ) ) == 0 )
        varData        = (long)m_nParentID;
    else
        return    false;
    return    true;
}
 
BOOL CMsgFolderItem::InsertRecord( CDBConnect *pAConnect)
{
    CString            strSQL;
    BOOL            bReturn = true;
 
    strSQL.Format( _T("INSERT INTO TN_STK_MSGFOLDER( N_C1, S_C2, N_C3 ) VALUES ( \
                      %d, '%s', %d)"), m_nID, CMBAMDBFun::GetDBReplaceStr( m_strName ), m_nParentID );
    try
    {
        bReturn = CDBSQLiteCommFun::RunSQL(strSQL, pAConnect);
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError = ex.GetErrInfo();
        CString        strErrInfo;
 
        strErrInfo = _T("InsertRecord - MsgFolder- ") + strError;
        CMBAMDBFun::WriteDBErrToFile( strErrInfo );
        return false;
    }
    return true;
}
BOOL CMsgFolderItem::UpdateRecord( CDBConnect *pAConnect )
{
    CString            strSQL;
    BOOL            bReturn = true;
 
    strSQL.Format( _T("UPDATE TN_STK_MSGFOLDER SET S_C2 = '%s', N_C3 = %d WHERE N_C1 = %d"), 
        CMBAMDBFun::GetDBReplaceStr( m_strName ), m_nParentID, m_nID );
 
    try
    {
        bReturn = CDBSQLiteCommFun::RunSQL(strSQL, pAConnect);
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError = ex.GetErrInfo();
        CString        strErrInfo;
 
        strErrInfo.Format( _T("UpdateRecord(%s) - MsgFolder - %s "),strSQL, strError);
        CMBAMDBFun::WriteDBErrToFile( strErrInfo );
        return false;
    }
    return true;
}
 
// CMsgFolder
 
CMsgFolders::CMsgFolders(CMBAMDBConnect *pAConnect)
{
    m_pAConnect = pAConnect;
}
 
CMsgFolders::~CMsgFolders()
{
}
 
 
// CMsgFolder member functions
void CMsgFolders::operator =( const CMsgFolders& item )
{
//    m_ARecordSet    = item.m_ARecordSet;
    m_pAConnect        = item.m_pAConnect;
    m_strSQL        = item.m_strSQL;
    m_nRowType        = item.m_nRowType;
 
    m_nID            = item.m_nID;
    m_strName        = item.m_strName;
    m_nParentID        = item.m_nParentID;
    m_pAConnect        = item.m_pAConnect;
}
 
int CMsgFolders::ListFolder( long nParentFolderID  )
{
    CString            strSQL;
    int                    nCount;
    if(nParentFolderID < 0)
        strSQL.Format( _T("SELECT N_C1, S_C2, N_C3 FROM TN_STK_MSGFOLDER ORDER BY S_C2") );
    else
        strSQL.Format( _T("SELECT N_C1, S_C2, N_C3 FROM TN_STK_MSGFOLDER WHERE N_C3 = %d ORDER BY S_C2"), nParentFolderID );
    m_strSQL = strSQL;
 
    if( !m_pAConnect || !m_pAConnect->IsOpenDB())
        return    0;
    try
    {
        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;
}
 
int CMsgFolders::ListSpFolder( long nFolderID )
{
    //if ( nFolderID <= 0 )
    //    return    0;
 
    CString            strSQL;
    int                    nCount;
    
    if( !m_pAConnect || !m_pAConnect->IsOpenDB())
        return    0;
 
    strSQL.Format( _T("SELECT N_C1, S_C2, N_C3 FROM TN_STK_MSGFOLDER WHERE N_C1 = %d"), nFolderID );
    m_strSQL = strSQL;
 
    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;
}
 
int CMsgFolders::ListSpFolder( long nParentFolderID, LPCTSTR lpszFolderName )
{
    if ( nParentFolderID < 0 || lpszFolderName == NULL )
        return    0;
 
    CString            strSQL;
    int                    nCount;
    
    if( !m_pAConnect || !m_pAConnect->IsOpenDB())
        return    0;
    strSQL.Format( _T("SELECT N_C1, S_C2, N_C3 FROM TN_STK_MSGFOLDER WHERE N_C3 = %d \
        AND S_C2 = '%s'"), nParentFolderID, lpszFolderName );
    m_strSQL = strSQL;
 
    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 CMsgFolders::GetData( )
{
    CString        strTempValue;
 
    try    
    {
        m_ARecordSet.GetValue( 1, m_nID );
 
        m_ARecordSet.GetValue( 2, strTempValue, true );
        m_strName   = (LPCTSTR)strTempValue;
 
        m_ARecordSet.GetValue( 3, m_nParentID );
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError;
 
        strError = (LPCTSTR)ex.GetErrInfo( );
        return false;
    }
 
    return true;
}
 
long CMsgFolders::GetMaxFolderID( )
{
    long                nMax    = 0;    
    int                    nData    = 0;
    CString                strSQL;
    CDBRecord            ARecordset;
 
    strSQL        = _T("SELECT N_C1 FROM TN_STK_MSGFOLDER ORDER BY N_C1 DESC limit 0, 1");
    if( !m_pAConnect || !m_pAConnect->IsOpenDB())
        return    0;
    try
    {
        ARecordset.Close();
        ARecordset.Open( m_pAConnect->GetDBConnect(), strSQL );
        if ( S_OK == ARecordset.MoveNext()  )
            ARecordset.GetValue( 1, nData );
    }
    catch( CDBSQliteException ex )
    {
        CString        strError;
 
        strError = (LPCTSTR)ex.GetErrInfo( );
        return 0;
    }
    nMax = nData;
 
    return nMax;
}
void CMsgFolders::AddFloder( CMsgFolderItem *pItem )
{
    if( !pItem )
        return;
    if( !m_pAConnect || !m_pAConnect->IsOpenDB())
        return;
    {
        pItem->InsertRecord(m_pAConnect->GetDBConnect());
    }
 
}
long CMsgFolders::ListRecordCount(  )
{
    return m_ARecordSet.GetRecordCount();
}