Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as VB.Net by dfgfg ( 13 years ago )
Imports MySql.Data.MySqlClient
Imports System.IO
Imports System.IO.Ports

Module SMSmodule
    'variable for database connection
    Public sQuery As String
    Public strCon As String
    Public consms As New MySqlConnection()
    Public smsread As MySqlDataReader
    Public conpdrrmo As New MySqlConnection()
    Public pdrrmoread As MySqlDataReader
    'variable use for sms
    Public port As New SerialPort()
    Public objclsSMS As New SMSclass
    Public objShortMsgCollection As New SMSC
    Public intMsgCount As Integer
    Public strCommand As String
    Public strMessage As String
    Public strCode As String
    Public strWBCode As String
    Public strContactNum As String
    Public strDivMsg(100) As String
    Public intCountDivMsg As Integer
    Public dbMsg As Double
    'displaying status
    Public Sub displayStatus(ByVal stat As String)
        smsfrm.status.Text = stat
    End Sub

    'divide the msg by 160
    Public Sub checkMsg(ByVal msg As String)
        If Len(msg) < 160 Then
            intCountDivMsg = 1
            strDivMsg(0) = (Mid(msg, 1, msg.Length))

        Else
            dbMsg = (Len(msg) / 160)
            If dbMsg > 1.0 And dbMsg <= 2.0 Then
                intCountDivMsg = 2
                strDivMsg(1) = (Mid(msg, 1, 160))
                strDivMsg(2) = (Mid(msg, 161, msg.Length))
            End If
        End If
    End Sub
    'sending message
    Public Sub sendMsg(ByVal num As String, ByVal msg As String, ByVal smsdate As String)
        With smsautosend
            Try
                .tsOutbox.Text = "Sending Message to : " & num
                If objclsSMS.sendMsg(port, num, msg) Then
                    .tsOutbox.Text = "Message sent"
                    setcon()
                    sQuery = "Update outbox Set Status = '0' Where number = '" & num & "' And message ='" & msg & "' And date ='" & smsdate & "'"
                    setrd()
                Else
                    .tsOutbox.Text = "Message not send"
                End If

            Catch ex As Exception
                .tsOutbox.Text = ex.Message
            End Try
        End With
    End Sub

    'read message
    Public Sub readMsg()
        Try

            intMsgCount = objclsSMS.CountSMSmessages(port)
            strCommand = "AT+CMGL=""ALL"""
            If intMsgCount = 0 Then
                smsautosend.tsInbox.Text = "No New Message"
                Exit Sub
            Else

                 objShortMsgCollecti strCommand)
                For Each msg As SMessage In objShortMsgCollection
                    newsms.Show()
                    smsautosend.tsInbox.Text = "New Message recieved"
                    pdrrmodbase()
                    sQuery = "Select * From trainee Where mobile = '" & msg.Sender & "'"
                    setpdrrmo()

                    If pdrrmoread.Read = True Then
                        setcon()
                        strCode = Mid(msg.Message, 1, 3)
                        strWBCode = Mid(msg.Message, 5, 7)
                        strMessage = Mid(msg.Message, 12, msg.Message.Length)
                        sQuery = "Select * From inbox Order By ID Desc"
                        setrd()

                        If smsread.Read = False Then
                            sQuery = "Insert Into inbox Values ('1', '" & msg.Sender & "', '" & msg.Message & "', '1', '" & 
        pdrrmoread = cmd.ExecuteReader()
    End Sub
End Module

 

Revise this Paste

Children: 67972
Your Name: Code Language: