jackba / wy-internal-system

Automatically exported from code.google.com/p/wy-internal-system
0 stars 0 forks source link

pricing for the system #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
as title

Original issue reported on code.google.com by Giggs...@gmail.com on 13 Feb 2012 at 7:31

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Imports System.Data.SqlClient
Imports System.Data.OleDb

Public Class CSQLConnector
    Private myConnection As OleDbConnection = Nothing
    Private m_strConnect As String
    Private myConnectFlag As Boolean = False
    Public Shared logger As log4net.ILog = log4net.LogManager.GetLogger("BatchUpload_DistributorLogger")

    Public Function SelectTable(ByVal table As String, ByVal columnList As ArrayList, ByVal selectCondition As String) As ArrayList
        Dim myDataSet As DataSet = Nothing
        Dim rowHash As Hashtable
        Dim column As String
        Dim executeSQLResult As Boolean
        Dim select_sql As String
        Dim i As Integer
        Dim myTable As DataTable
        Dim myColumn As DataColumn
        Dim list As New ArrayList

        Try
            'Build the selct sql
            select_sql = "select "

            For Each column In columnList
                select_sql += column + ","
            Next
            select_sql = select_sql.Substring(0, select_sql.LastIndexOf(","))

            select_sql += " from " + table + " where "

            select_sql += selectCondition

            'logger.Debug("Database sql select statement: " + select_sql)
            'logger.Debug(select_sql)

            executeSQLResult = ExecuteSQL(select_sql, myDataSet)

            If executeSQLResult = True Then
                For Each myTable In myDataSet.Tables
                    Dim myValues() As String = New String(myTable.Columns.Count) {}
                    Dim myRow As DataRow
                    For Each myRow In myTable.Rows
                        rowHash = New Hashtable
                        i = 0
                        For Each myColumn In myTable.Columns
                            rowHash.Add(columnList.Item(i), myRow(myColumn).ToString())
                            i += 1
                        Next
                        list.Add(rowHash)
                    Next
                Next
                Return list
            Else
                Return list
            End If
        Catch e As Exception
            'logger.Error(e.Message)
            Return New ArrayList
        End Try

    End Function

    Public Function InsertTable(ByVal table As String, ByVal dataToBeInsert As Hashtable) As Boolean
        Try

            Dim myDataSet As DataSet = Nothing
            Dim insert_sql As String
            Dim hashKey As String
            'Build the selct sql
            insert_sql = "insert into " + table + " ( "

            For Each hashKey In dataToBeInsert.Keys
                insert_sql += hashKey + ","
            Next
            insert_sql = insert_sql.Substring(0, insert_sql.LastIndexOf(","))
            insert_sql += " ) values ( "

            For Each hashKey In dataToBeInsert.Keys
                'insert_sql += "'" + dataToBeInsert.Item(hashKey).ToString + "',"
                insert_sql += "'" & dataToBeInsert(hashKey) & "',"
            Next

            insert_sql = insert_sql.Substring(0, insert_sql.LastIndexOf(","))
            insert_sql += " )"

            'logger.Debug("Database sql insert statement: " + insert_sql)

            Return ExecuteSQL(insert_sql, myDataSet)
        Catch e As Exception
            'logger.Error(e.Message)
            Return False
        End Try

    End Function

    Public Function UpdateTable(ByVal table As String, ByVal dataTobeUpdated As Hashtable, ByVal selectCondition As Hashtable) As Boolean
        Dim myDataSet As DataSet = Nothing

        Dim executeSQLResult As Boolean
        Dim select_sql As String
        Dim update_sql As String
        Dim hashKey As String
        Try
            'Build the selct sql
            select_sql = "select 1 from " + table + " where "

            For Each hashKey In selectCondition.Keys
                select_sql += hashKey + "='" + selectCondition.Item(hashKey).ToString + "' and "
            Next
            select_sql = select_sql.Substring(0, select_sql.LastIndexOf(" and "))

            'Build the update sql
            update_sql = "update " + table + " set "
            For Each hashKey In dataTobeUpdated.Keys
                update_sql += hashKey + "='" + dataTobeUpdated.Item(hashKey).ToString + "',"
            Next
            update_sql = update_sql.Substring(0, update_sql.LastIndexOf(","))
            update_sql += " where "
            For Each hashKey In selectCondition.Keys
                update_sql += hashKey + "='" + selectCondition.Item(hashKey).ToString + "' and "
            Next
            update_sql = update_sql.Substring(0, update_sql.LastIndexOf(" and "))

            'logger.Debug("Database sql update statement: " + update_sql)

            executeSQLResult = ExecuteSQL(select_sql, myDataSet)

            If executeSQLResult = True Then
                Dim myTable As DataTable
                For Each myTable In myDataSet.Tables
                    If myTable.Rows.Count <= 0 Then
                        logger.Debug("Can't find the record in table:" + table + "; select sql:" + select_sql + " update sql: " + update_sql)
                        Return False
                    End If
                    If myTable.Rows.Count > 1 Then
                        logger.Debug("More than record in table:" + table + "; select sql:" + select_sql + " update sql: " + update_sql)
                        Return False
                    End If
                Next
            Else
                Return False
            End If
            Return ExecuteSQL(update_sql, myDataSet)
        Catch e As Exception
            logger.Error(e.Message)
            Return False
        End Try

    End Function

    Public Function ExecuteSQL(ByRef mySQL As String, ByRef myDataSet As DataSet) As Boolean
        Try
            connectString = connString
            Connect()
            Dim result As Boolean = Execute(mySQL, myDataSet)
            Disconnect()
            Return result

        Catch ex As Exception
            logger.Error("Exception - " & ex.Message)
        End Try

    End Function

    Private Function Execute(ByRef mySQL As String, ByRef myDataSet As DataSet) As Boolean
        Dim mylocalDataSet As DataSet = New DataSet()
        Dim mySQLError As String = Nothing
        Dim mySuccessFlag As Boolean = False
        Try
            If (myConnectFlag) Then
                Dim myCommand As OleDbCommand = New OleDbCommand(mySQL, myConnection)
                Dim myDataSetCommand As OleDbDataAdapter = New OleDbDataAdapter(myCommand)

                myDataSetCommand.Fill(mylocalDataSet, "temp")

                mySuccessFlag = True
            Else
                mySQLError = "[Connection Failed]: Invalid Connection parameters."
            End If
        Catch e As OleDbException
            Dim myError As OleDbError
            For Each myError In e.Errors
                mySQLError += "[Error Source]: " + myError.Source + "[Error Message]: " + myError.Message
            Next
        Finally
            If mySQLError IsNot Nothing Then
                logger.Error(mySQLError)
            End If
            myDataSet = mylocalDataSet
        End Try
        Return mySuccessFlag
    End Function

    Public Function Connect() As Boolean
        Try
            myConnection = New OleDbConnection(m_strConnect)
            'logger.Debug(m_strConnect)
            myConnection.Open()
            myConnectFlag = True
        Catch e As Exception
            logger.Debug(e.ToString())
        End Try
        Return myConnectFlag
    End Function

    Public Property connectString() As String
        Get
            Return m_strConnect
        End Get
        Set(ByVal value As String)

            m_strConnect = value
        End Set
    End Property
    Public Function Disconnect() As Boolean
        Try
            If myConnectFlag Then
                myConnection.Close()
            End If
        Catch e As Exception
            logger.Debug(e.Message)
            Return False
        End Try
        Return True
    End Function

End Class

Original comment by Giggs...@gmail.com on 30 Mar 2012 at 10:21

GoogleCodeExporter commented 9 years ago
http://test-temp.googlecode.com/svn/trunk/done/hhsj.txt

Original comment by Giggs...@gmail.com on 2 Apr 2012 at 6:51

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
AFX_MANAGE_STATE(AfxGetStaticModuleState());

Original comment by Giggs...@gmail.com on 17 May 2012 at 6:28

GoogleCodeExporter commented 9 years ago
http://tinyurl.com/3e3k442 直连: http://is.gd/1SzG66

Original comment by Giggs...@gmail.com on 22 May 2012 at 11:13

GoogleCodeExporter commented 9 years ago
static void DeleteMem(void *p, ...)
{
    va_list ap;
    va_start(ap, p);
    p = va_arg(ap, void *);
    while(-1 != (int)p)
    {
        if (p)
        {
            //::AfxMessageBox("delete p...");   //TEST
            delete p;
        }
        p = va_arg(ap, void *);
    } 
            //::AfxMessageBox("exit while");    //TEST
}

Original comment by Giggs...@gmail.com on 1 Jun 2012 at 2:41