使用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
// ExtProperty.cpp : implementation file
//
 
#include "stdafx.h"
#include "mbamdb.h"
#include "ExtProperty.h"
#include "MBAMDBFun.h"
 
extern CCriticalSection      m_csConnectDB;
// CExtProperty
CExtPropertyItem::CExtPropertyItem()
{
    m_nRowType    = ROWTYPE_EXTPROPERTY;
    Clear();
}
 
CExtPropertyItem::~CExtPropertyItem()
{
    
}
 
void CExtPropertyItem::Clear()
{
    m_strClass    = _T("");
    m_strName    = _T("");
    m_strValue    = _T("");
}
 
BOOL CExtPropertyItem::GetItemValue( CString strName, COleVariant &varData )
{
    varData.Clear();
    if ( strName.IsEmpty() )
        return    false;
    if ( strName.CompareNoCase( _T( "Class" ) ) == 0 )
        varData        = m_strClass;
    else if ( strName.CompareNoCase( _T( "Name" ) ) == 0 )
        varData        = m_strName;
    else if ( strName.CompareNoCase( _T( "Value" ) ) == 0 )
        varData        = m_strValue;
    else
        return    false;
 
    return    true;
}
 
BOOL CExtPropertyItem::InsertRecord( CDBConnect *pAConnect)
{
    CString            strSQL;
    BOOL            bReturn = true;
 
    strSQL.Format( _T("INSERT INTO TN_STK_EXTPROPERTY( S_C1, S_C2, S_C3 ) VALUES ( \
        '%s', '%s', '%s')"), CMBAMDBFun::GetDBReplaceStr( m_strClass ), CMBAMDBFun::GetDBReplaceStr( m_strName ), CMBAMDBFun::GetDBReplaceStr( m_strValue ) );
    try
    {
        bReturn = CDBSQLiteCommFun::RunSQL(strSQL, pAConnect);
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError = ex.GetErrInfo();
        CString        strErrInfo;
 
        strErrInfo = _T("InsertRecord - ExtProperty - ") + strError;
        CMBAMDBFun::WriteDBErrToFile( strErrInfo );
        return false;
    }
    return true;
}
BOOL CExtPropertyItem::UpdateRecord( CDBConnect *pAConnect )
{
    CString            strSQL;
    BOOL            bReturn = true;
 
    strSQL.Format( _T("UPDATE TN_STK_EXTPROPERTY SET S_C3 = '%s' WHERE S_C1 = '%s' AND S_C2 = '%s'"), 
        CMBAMDBFun::GetDBReplaceStr( m_strValue ), CMBAMDBFun::GetDBReplaceStr( m_strClass ), 
        CMBAMDBFun::GetDBReplaceStr( m_strName ) );
    try
    {
        bReturn = CDBSQLiteCommFun::RunSQL(strSQL, pAConnect);
    }
    catch ( CDBSQliteException ex )
    {
        CString        strError = ex.GetErrInfo();
        CString        strErrInfo;
 
        strErrInfo.Format( _T("UpdateRecord(%s) - ExtProperty - %s "),strSQL, strError);
        CMBAMDBFun::WriteDBErrToFile( strErrInfo );
        return false;
    }
    return true;
}
 
CExtPropertys::CExtPropertys(CMBAMDBConnect *pAConnect)
{
    m_pAConnect = pAConnect;
}
 
CExtPropertys::~CExtPropertys()
{
 
}
int CExtPropertys::LoadValue( LPCTSTR lpszClass, LPCTSTR lpszName )
{
    if ( lpszClass == NULL || lpszName == NULL )
        return    0;
 
    CString            strSQL;
    int                    nCount;
    
    strSQL.Format( _T("SELECT S_C1, S_C2, S_C3 FROM TN_STK_EXTPROPERTY WHERE S_C1 = '%s' AND \
        S_C2 = '%s'"), lpszClass, lpszName );
    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 = ex.GetErrInfo(  );
 
        return 0;
    }
 
    return nCount;
}
 
bool CExtPropertys::RemoveValue( LPCTSTR lpszClass, LPCTSTR lpszName )
{
    if ( lpszClass == NULL || lpszName == NULL )
        return    0;
 
    CString            strSQL;
    BOOL                bReturn = false;
 
    if( !m_pAConnect || !m_pAConnect->IsOpenDB())
        return    0;
    strSQL.Format( _T("DELETE FROM TN_STK_EXTPROPERTY WHERE S_C1 = '%s' AND S_C2 = '%s'"), lpszClass, lpszName );
    bReturn        =  CDBSQLiteCommFun::RunSQL( strSQL , m_pAConnect->GetDBConnect() );
 
    return ( bReturn != 0 );
}
 
bool CExtPropertys::GetData( )
{
    CString        strTempValue;
 
    try    
    {
        strTempValue = _T("");
        m_ARecordSet.GetValue( 1, strTempValue, true );
        m_strClass        = (LPCTSTR)strTempValue;
 
        strTempValue = _T("");
        m_ARecordSet.GetValue( 2, strTempValue, true );
        m_strName       = (LPCTSTR)strTempValue;
 
        strTempValue = _T("");
        m_ARecordSet.GetValue( 3, strTempValue, true );
        m_strValue        = (LPCTSTR)strTempValue;
    }
    catch( CDBSQliteException ex )
    {
        CString        strError;
 
        strError = ex.GetErrInfo(  );
 
        return false;
    }
 
    return true;
}
BOOL CExtPropertys::SaveData()
{
    if( !m_pAConnect || !m_pAConnect->IsOpenDB())
        return    0;
    {
        
        if ( LoadValue( m_strClass,m_strName ) > 0 )
        {
            UpdateRecord(m_pAConnect->GetDBConnect());
        }
        else
        {
            InsertRecord(m_pAConnect->GetDBConnect());
        }
    }
    return TRUE;
}