Project Error



''NOTE : Dt.10/05/2004
''initially tmrReadFromSIM.interval=15000 now it's 1500
Option Explicit

Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

Const MSG_LEN = 130

''Following variables are usefull to get connection data from
zconfiguration.ini
Dim strDataSrc As String
Dim strUser As String
Dim strPwd As String
''Upto here

Dim strSMSC_NUMBER As String
'*Dim WithEvents SMSNotify As SMS3ASuiteLib.SMS_SuiteAdapter
'*Dim SMSSend As SMS3ASuiteLib.SMS_SuiteAdapter
'*Dim ShortMSG As SMS3ASuiteLib.ShortMessage
'*Dim SMSMemory_SIM As SMS3ASuiteLib.ISMSMemory

'Dim con As New ADODB.Connection
'Dim rst As Recordset


Dim gstrCallerNo As String
Public isClientConnected As Boolean 'by Ketan

''Related to user query from database (oracle 8i)
Private Type SMSInformation
PF_ID As String
PFBalance As String
ChequeNo As String
ChequeAmount As String
ChequeDate As String
CO7Number As String
CO6Number As String
BillRegistrationNumber As String
PPONumber As String
PPODate As String
PensionAmount As String
EnhancedFamilyPension As String
NormalFamilyPension As String
CommutedPensionAmount As String
NetPayablePensionAmount As String
CommutationAmount As String
DCRGAmount As String
PFSettlementAmount As String
DLIAmount As String
GISAmount As String
LeaveEncashmentAmount As String
LAP As String
LHAP As String
HalfSetPass As String
BillAmount As String
''June 07, 2004 - For some bank of Rajkot - Raj Info
Balance As String
''June 14, 2004 - To support SRCH option in Z.GSM GOLD 8.1
SRCHResult As String
End Type
Dim SMSInfo As SMSInformation

''''Following structure is usefull to display SMS details
''Private Type SMSDataStructure
'' SMSDS_CallerID As String
'' SMSDS_Type As String
'' SMSDS_Request As String
'' SMSDS_RequestDT As String
'' SMSDS_Response As String
'' SMSDS_ResponseDT As String
'' SMSDS_Status As String
''End Type
''Dim SMSData As SMSDataStructure
''''Upto here

Private Enum FillType
FT_ADD = 0
FT_UPDATE = 1
End Enum

Dim blnExplicitUnload As Boolean

Private Type SMSRequestType
SRT_PFI As Integer
SRT_PAI As Integer
SRT_PNI As Integer
SRT_PLI As Integer
SRT_BLI As Integer
SRT_UNKNOWN As Integer
End Type
Dim SRT As SMSRequestType


''''Following enum is usefull in fncRequestToCOM
''Private Enum ENUM_RequestType
'' enmInitialization = 0
'' enmReadFromSIM = 1
'' enmSendToSIM = 2
'' enmDeleteFromSIM = 3
''End Enum
'Dim bytLastCmd As Byte

'For msCOMMSIM control and msCOMMSIM_OnComm event
Dim DataRVFPort As Boolean
Dim mErrorMsg As String
'Dim mstrInputOne As String
Dim mbolDCStatus As Boolean

''

'Dim blnGoForRead As Boolean 'This variable will true if initilalize is
ok
'Dim blnGoForRespGen As Boolean 'This variable will true if read is ok
'Dim blnGoForSend As Boolean 'This variable will true if Response
Generation is ok
'Dim blnGoForDelete As Boolean 'This variable will true if send is ok
'Dim blnGoForNextIteration As Boolean 'This variable will true if delete
is ok


Dim blnSkipDeletion As Boolean ''This variable will true if two smss are
to be send for one request
Dim strResp1$, strResp2$ ''User more variables like strResp3,strResp4 if u
required to send more SMSs for one request
''
Dim mbln_IsInitializeComplete As Boolean

Dim tmpTimer

Dim intIndex As Integer 'This variable will keep values of lines in
lvwSMS
Dim LstItemCrntStatus As ListItem
Dim strFocusedLvw As String

Dim mblnDenyShowOnScreen As Boolean


Dim lstRequestID As Long
Dim blnInit As Boolean


Dim nClient 'Added by Ketan for Winsock Communication on Dt : 04/02/2005
for Server Use Only
Dim m_iBackColor As Long 'Added by Ketan on Dt : 13/07/2005 for Popup
Window Color


'Added by Ketan On Dt : 12/02/2005
Private Sub cmdCloseOnlineUser_Click()
fraOnlineUser.Visible = False
cmdShowOnlineUsers.Enabled = True
If gblnIsServer = False Then
lvwOnLineUsers.ListItems.Clear
End If
End Sub

'Added by Ketan On dt : 12/02/3005
Private Sub cmdCloseSendMessage_Click()
fraMessage.Visible = False
txtMsg.Text = ""
'cmdSendMsg.Enabled = True
'cmdCloseOnlineUser.Enabled = True
fraOnlineUser.Enabled = True
ChkBroadCast.Value = 0
fraMessage.Tag = ""
ChkBroadCast.Enabled = True
cmdSendToUser.Caption = "&Send"
End Sub

'Developer : Ketan Dt : 12/02/2005
'Purpose : Send Message to Internal Selected User
Private Sub cmdSendMsg_Click()
Dim i As Double
Dim nSelected As Double

If lvwOnLineUsers.ListItems.Count > 0 Then

nSelected = 0

For i = 1 To lvwOnLineUsers.ListItems.Count
If lvwOnLineUsers.ListItems(i).Checked = True Then
nSelected = nSelected + 1
End If
Next

If nSelected > 0 Then
fraOnlineUser.Enabled = False
fraMessage.Visible = True
fraMessage.ZOrder 0
'cmdSendMsg.Enabled = False
'cmdCloseOnlineUser.Enabled = False
Else
MsgBox "Please select user(s) for sending message",
vbInformation, "Send Message"
Exit Sub
End If

End If

End Sub

'by Ketan On Dt : 12/02/2005
Private Sub cmdSendToUser_Click()
Dim i As Double
Dim strIPAddr As String

If gblnIsServer = False Then
If isClientConnected = False Then
MsgBox "Z.GSMS Server is not Running, Please try
later....", vbCritical, "Z.GSMS Server"
Exit Sub
End If
End If

If Len(Trim(txtMsg.Text)) = 0 Then
MsgBox "Please enter message...", vbCritical, "Send Message"
txtMsg.SetFocus
Exit Sub
End If

strIPAddr = ""

If gblnIsServer = False Then

If Len(Trim(fraMessage.Tag)) > 0 Then
strIPAddr = fraMessage.Tag
End If

For i = 1 To lvwOnLineUsers.ListItems.Count
If lvwOnLineUsers.ListItems(i).Checked = True Then
If Len(Trim(strIPAddr)) = 0 Then
strIPAddr = lvwOnLineUsers.ListItems(i).Key
Else
strIPAddr = strIPAddr & "|" &
lvwOnLineUsers.ListItems(i).Key
End If
End If
Next

If Len(Trim(strIPAddr)) > 0 Then
If ChkBroadCast.Value = 0 Then
'Send Message to Selected User
tcpClient.SendData "SEND_MSG" & Chr(149) &
udfCompany.gstrCurrentUser & Chr(149) & txtMsg.Text & Chr(149) &
strIPAddr
Else
'Send Message to All Connected Users
tcpClient.SendData "BROADCAST" & Chr(149) &
udfCompany.gstrCurrentUser & Chr(149) & txtMsg.Text
End If
End If

Else

For i = 1 To lvwOnLineUsers.ListItems.Count
If ChkBroadCast.Value = 0 Then
If lvwOnLineUsers.ListItems(i).Checked = True Then
Send_Message_To_Client txtMsg.Text,
lvwOnLineUsers.ListItems(i).Key, udfCompany.gstrCurrentUser,
ZDLL.GetIPAddress
End If
Else
Send_Message_To_Client txtMsg.Text,
lvwOnLineUsers.ListItems(i).Key, udfCompany.gstrCurrentUser,
ZDLL.GetIPAddress
End If
Next

If Len(Trim(fraMessage.Tag)) > 0 Then
Send_Message_To_Client txtMsg.Text, fraMessage.Tag,
udfCompany.gstrCurrentUser, ZDLL.GetIPAddress
End If

End If

cmdCloseSendMessage_Click
End Sub

'by KEtan On dt : 12/02/2005
Private Sub cmdShowOnlineUsers_Click()
Dim strUsers As String

If gblnIsServer = True Then
fraOnlineUser.Visible = True
fraOnlineUser.ZOrder 0
Else
If tcpClient.State = sckConnected Then
cmdShowOnlineUsers.Enabled = False
tcpClient.SendData "ONLINE_USER" & Chr(149) 'Send Online User
Info Request to Server
Else
MsgBox "Server is not running...., Please try later...",
vbInformation, "Online Users"
'cmdShowOnlineUsers.Enabled = True
'fraOnlineUser.Visible = True
End If
End If

End Sub

''Dim TT As CTooltip

Private Sub Form_Load()
On Error GoTo ErrH

Screen.MousePointer = vbHourglass

Dim LstItem As ListItem
Dim SrvIP As String

'Me.Caption = gstrApplicationName
Me.Caption = ""
Me.Top = 0: Me.Left = 0

''Set limitations of Client - Server
If gblnIsServer = True Then 'Server

'Added by Ketan for Winsock Communication on Dt : 04/02/2005
'Open Winsock Port for Server
'-----------------------------------------------------------
nClient = 0 'Number of winsock
tcpServer(nClient).LocalPort = strLocalPort
tcpServer(nClient).Listen 'start listening (for clients)
'-----------------------------------------------------------

Add_OnLineUser udfCompany.gstrCurrentUser,
udfCompany.gstrUserDesig, ZDLL.GetIPAddress

MnuStartCOMPort.Visible = True
mnuF_Authority.Visible = True
MnuCOMPort.Visible = True
'MnuDelReadSMS.Visible = True
MnuSettings_DBConfiguration.Visible = True

''Set Authority rights
If UCase(AuthorityDesig) = UCase("Operator") Then
MnuStartCOMPort.Enabled = False
MnuStartSMSing.Enabled = False
MnuSendSMS.Enabled = False

mnuF_Authority.Enabled = False

MnuCOMPort.Enabled = False
MnuParameter.Enabled = False
MnuSettings_DBConfiguration.Enabled = False
MnuConnectedClients.Enabled = False
Else
MnuStartCOMPort.Enabled = True
MnuStartSMSing.Enabled = True
MnuSendSMS.Enabled = True

mnuF_Authority.Enabled = True

MnuCOMPort.Enabled = True
MnuParameter.Enabled = True
MnuSettings_DBConfiguration.Enabled = True
MnuConnectedClients.Enabled = True
End If

Else 'Client

If Len(Trim(strRemoteHost)) = 255 Or Len(Trim(strRemoteHost)) = 0
Then
SrvIP = InputBox("Enter Z.GSMS Server IP Address or Computer
Name", "Server IP")
If SrvIP = "" Then
MsgBox "Must be enter Z.GSMS Server IP Address"
End
Else
ZDLL.SaveToIni ZConfigurationINI, "COMSettings",
"RemoteHost", SrvIP
End If
End If

If Len(Trim(strRemotePort)) = 255 Or Len(Trim(strRemotePort)) = 0
Then
strRemotePort = 1001
End If

'Added by Ketan for Winsock Communication on Dt : 04/02/2005
'Connect with Winsock Server
'-----------------------------------------------------------
tcpClient.RemoteHost = strRemoteHost 'IP address
here...localip=ip you're using so that you can test client/server on your
own comp
tcpClient.RemotePort = strRemotePort 'assign port server will
listen for client on
tcpClient.Connect 'try to connect to server
'-----------------------------------------------------------

MnuStartCOMPort.Visible = False
MnuCOMPort.Visible = False
'MnuDelReadSMS.Visible = False
MnuSettings_DBConfiguration.Visible = True
MnuConnectedClients.Visible = False

''Set Authority rights
If UCase(AuthorityDesig) = UCase("Operator") Then
MnuStartSMSing.Enabled = False
MnuSendSMS.Enabled = False

mnuF_Authority.Enabled = False

MnuCOMPort.Enabled = False
MnuParameter.Enabled = False
MnuSettings_DBConfiguration.Enabled = False
ElseIf UCase(AuthorityDesig) = UCase("User") Then
mnuF_Authority.Enabled = False
MnuSettings_DBConfiguration.Enabled = False
Else
MnuStartSMSing.Enabled = True
MnuSendSMS.Enabled = True

MnuCOMPort.Enabled = True
MnuParameter.Enabled = True
MnuSettings_DBConfiguration.Enabled = True
End If
End If

If gblnIsServer = False Then
MnuSendSMS.Enabled = False
MnuPopupForward.Enabled = False
MnuPopupReply.Enabled = False
End If


'' strSMSC_NUMBER = ZDLL.GetFromIni("ZConfigurationINI", "Settings",
"SMSCN", "+919825001002")
'' strDataSrc = ZDLL.GetFromIni(ZConfigurationINI, "Data", "DataSrc",
"ZRLY90")
'' strUser = ZDLL.GetFromIni(ZConfigurationINI, "Data", "User",
"AFRES")
'' strPwd = ZDLL.GetFromIni(ZConfigurationINI, "Data", "Auth",
"GATES9")
''
'' If (ZIDLL.cnORA.State = 0) Then
'' 'open connection
'' If ZIDLL.OPEN_Connection(strDataSrc, strUser, strPwd) = 0 Then
'' gstrW2S = "Unable to connect DataSource." & vbCrLf & vbCrLf
_
'' & "Check for following possibilities " & vbCrLf & "[1] Check
for " _
'' & "parameters like DataSource, User, Password" & vbCrLf &
"[2] Oracle " _
'' & "database is not stared yet" & vbCrLf & vbCrLf & "This
application will be " _
'' & "closed."
'' MsgBox gstrW2S, vbExclamation
''
'' WriteToScreen txtCommStatus, gstrW2S
'' WriteToFile ZERRLOG_FILE_PATH, gstrW2S
''
'' blnExplicitUnload = True
'' Form_QueryUnload 0, 0
'' Else
'' WriteToFile ZLOG_FILE_PATH,
"---------------------------------------------"
'' WriteToFile ZLOG_FILE_PATH, "Database Connection Opened"
'' WriteToScreen txtCommStatus, "Database Connection Opened"
'' End If
'' End If

' Call GetRequestCntUpToDate 'this procedure will retrive latest
request count of each opt. code

'Set LstItem = lvwOnlineStatus.ListItems.Add(1, "A" & 1, "PFI"):
LstItem.SubItems(1) = SRT.SRT_PFI
'Set LstItem = lvwOnlineStatus.ListItems.Add(2, "A" & 2, "PNI"):
LstItem.SubItems(1) = SRT.SRT_PNI
'Set LstItem = lvwOnlineStatus.ListItems.Add(3, "A" & 3, "PAI"):
LstItem.SubItems(1) = SRT.SRT_PAI
'Set LstItem = lvwOnlineStatus.ListItems.Add(4, "A" & 4, "PLI"):
LstItem.SubItems(1) = SRT.SRT_PLI
'Set LstItem = lvwOnlineStatus.ListItems.Add(5, "A" & 5, "BLI"):
LstItem.SubItems(1) = SRT.SRT_BLI
'Set LstItem = lvwOnlineStatus.ListItems.Add(6, "A" & 6, "UNKNOWN"):
LstItem.SubItems(1) = SRT.SRT_UNKNOWN
Set LstItem = lvwOnlineStatus.ListItems.Add(1, "A" & 1, "Current
Status"): LstItem.SubItems(1) = 0
Set LstItemCrntStatus = lvwOnlineStatus.ListItems.Item(1)

If gblnIsServer = True Then
frmMain.stbrMain.Panels(3).Text = fncDisplayCOMSettings
Else
'frmMain.stbrMain.Panels(3).Visible = False
'Display Winsock Communication Setting
If isClientConnected = True Then
frmMain.stbrMain.Panels(3).Text = "Server : " & strRemoteHost
& ", Port : " & strRemotePort & " Connected"
Else
frmMain.stbrMain.Panels(3).Text = "Server : " & strRemoteHost
& ", Port : " & strRemotePort & " Disconnected"
'txtCommStatus.Text = txtCommStatus.Text & vbCrLf & " Server :
" & strRemoteHost & " not connected..."
End If
End If

''Populate all contacts from [AddressBook] into array to improve
performance
Call GetNPopulateContacts

' Call GetNPopulateContactsCollection

''Get GrpID from [GroupMaster] for 'General' group
udfGenDetail.udftGenDet_GeneralGrpID = fncGet_GrpID("General")

''Get values from ZConfiguration.Ini
tmrReadFromSIM.Interval = 1500 '5 Seconds ( 1000 mili second = 1
second)
' tmrReadFromSIM.Interval = ZDLL.GetFromIni(ZConfigurationINI,
"Properties", "ProcessInterval", 5) * 1000

If gblnIsServer = True Then
If ZDLL.GetFromIni(ZConfigurationINI, "COMSettings", "DCMode",
"Manually") = "Automatically" Then
Call MnuStartCOMPort_Click 'Start COM Port

'Changed by Ketan On Dt : 28/09/2005
If APPStat.appstCOMPortOn = True Then
If InitializeGSMDevice = False Then Exit Sub

If ZDLL.GetFromIni(ZConfigurationINI, "Properties",
"AutoRespReader", 0) = 1 Then
Call MnuStartSMSing_Click
End If
End If

End If
Else
If ZDLL.GetFromIni(ZConfigurationINI, "Properties",
"AutoRespReader", 0) = 1 Then
Call MnuStartSMSing_Click
End If
End If

'Read Response
ReadSMSFromDB gblnIsServer, False

'Read Request
ReadSMSFromDB gblnIsServer, True

'Added by Ketan On Dt : 05/03/3005 for Viewing sms by sent by all
user...
If gblnIsSpecialClientNode = True Then
ReadRequest
End If


'ReadSMSFromDB gblnIsServer, True

Load Tray
udfOPTCode.udftOPTCode_SRCH = "SRCH"
gstrFncABID_SRCH = fncGetFncAuthority(udfOPTCode.udftOPTCode_SRCH)

' Set TT = New CTooltip
' TT.Style = TTBalloon
' TT.Icon = TTIconInfo
'
' TT.Title = "Multiline tooltip"
' TT.TipText = "GATES"
' ''TT.Create Command1.hwnd
' TT.Create Tray.hwnd

Screen.MousePointer = vbDefault
Exit Sub

ErrH:
If Err.Number = 401 Then Resume Next
Screen.MousePointer = vbDefault

Call LogEntry("frmMain-->Form_Load", ErroLog, True, Err.Description,
Err.Number, Err.Description, Err.Source)

gstrW2S = "frmMain-->Form_Load"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
End
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error GoTo ErrH

Dim lngErrNo As Long, strErrDesc As String, strErrSrc As String

Screen.MousePointer = vbDefault
If gblnDoUWantToLogOff = False Then
If blnExplicitUnload = False Then
If MsgBox("Are you sure you want to quit application?",
vbExclamation + vbYesNo + vbDefaultButton2) = vbYes Then
UpdateClients False, AuthorityPerson, gblnIsServer

ZDLL.SaveToIni ZConfigurationINI, "Properties", "AppHwnd",
0
'ZDLL.WriteToUnknownCallLogFile App.Path &
"\ZUnknown.txt", "1"
'ZDLL.CloseWindow "ZToolTip"
ZDLL.DestroyWindows (ZDLL.GetHandle("ZToolTip"))
'ZDLL.WriteToUnknownCallLogFile App.Path &
"\ZUnknown.txt", "2"

If CloseApp = 1 Then 'This procedure will destroy dll
instance e.g. ZIVRS.dll, ZLINK.dll
'ZDLL.WriteToUnknownCallLogFile App.Path &
"\ZUnknown.txt", "3"
Call ClosePort
'ZDLL.WriteToUnknownCallLogFile App.Path &
"\ZUnknown.txt", "4"
''This will remove icon from system tray
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
WriteToFile ZLOG_FILE_PATH, "Connection Closed":
WriteToFile ZLOG_FILE_PATH,
"---------------------------------------------"
ZDLL.WriteToUnknownCallLogFile App.Path &
"\ZUnknown.txt", "5"
ZDLL.SaveToIni ZConfigurationINI, "Properties",
"AppStatus", 1 '1-normal shutdown,0-abnormal shutdown
Cancel = 0
End
End If
Else
Cancel = 1: gblnCloseApp = False
End If
Else
''This will remove icon from system tray
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
Cancel = 0: End
End If
Else
If gblnIsServer = True Then
Call ClosePort: APPStat.appstCOMPortOn = False
End If
Call STOP_SMSing: APPStat.appstSMSingOn = False
Cancel = 0
End If
Exit Sub

ErrH:
lngErrNo = Err.Number
strErrDesc = Err.Description
strErrSrc = Err.Source

gstrW2S = "frmMain-->Form_QueryUnload"
gstrW2S = gstrW2S & "|" & lngErrNo & "|" & strErrDesc & "|" &
strErrSrc
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S

Call LogEntry("frmMain-->Form_QueryUnload", ErroLog, True, strErrDesc,
lngErrNo, strErrDesc, strErrSrc)
End Sub


Private Sub Form_Resize()
On Error Resume Next

Dim intXPos As Integer
Dim strRes As String

intXPos = InStr(udfGenDetail.udftGenDet_ScreenResolution, "x")
strRes = Mid(udfGenDetail.udftGenDet_ScreenResolution, 1, intXPos -
1)

If Me.WindowState <> vbMinimized Then
Me.WindowState = vbMaximized

Screen.MousePointer = vbHourglass
'Select Case udfGenDetail.udftGenDet_ScreenResolution
Select Case strRes
'Case "800x600"
Case "800"
lvwOnScreen(0).Left = 75: lvwOnScreen(0).Top = 270:
lvwOnScreen(0).Height = 2430: lvwOnScreen(0).Width = 11790
fraCommnicationStatus.Left = 4545:
fraCommnicationStatus.Top = 5445: fraCommnicationStatus.Height = 2130:
fraCommnicationStatus.Width = 7350
txtCommStatus.Left = 120: txtCommStatus.Top = 225:
txtCommStatus.Height = 1785: txtCommStatus.Width = 7170
fraOnlineStatus.Left = 45: fraOnlineStatus.Top = 5445:
fraOnlineStatus.Height = 2130: fraOnlineStatus.Width = 4485
lvwOnlineStatus.Left = 120: lvwOnlineStatus.Top = 225:
lvwOnlineStatus.Height = 1815: lvwOnlineStatus.Width = 4230
stbrMain.Left = 0: stbrMain.Top = 7605: stbrMain.Height =
345: stbrMain.Width = 11940
FraControls.Left = 10395: FraControls.Top = 60:
FraControls.Height = 750: FraControls.Width = 1500
txtResp.Left = 765: txtResp.Top = 420: txtResp.Height =
285: txtResp.Width = 180
txtReq.Left = 1185: txtReq.Top = 360: txtReq.Height = 285:
txtReq.Width = 180
lvwOnScreen(1).Left = 75: lvwOnScreen(1).Top = 2970:
lvwOnScreen(1).Height = 2430: lvwOnScreen(1).Width = 11790
lblResponseTitle(0).Left = 60: lblResponseTitle(0).Top =
30: lblResponseTitle(0).Height = 270: lblResponseTitle(0).Width = 1110
lblResponseTitle(1).Left = 105: lblResponseTitle(1).Top =
2730: lblResponseTitle(1).Height = 270: lblResponseTitle(1).Width = 1200
lvwOnScreen(0).ColumnHeaders(5).Width = 5523
lvwOnScreen(1).ColumnHeaders(5).Width = 5523
cmdShowOnlineUsers.Move cmdShowOnlineUsers.Left,
lblResponseTitle(1).Top, cmdShowOnlineUsers.Width,
cmdShowOnlineUsers.Height

fraOnlineUser.Top = 2190 - 300
fraOnlineUser.Left = 3810 - 200
fraMessage.Top = 3180 - 300
fraMessage.Left = 4485 - 200

'Case "1024x740"
Case "1024"

lvwOnScreen(0).Left = 75: lvwOnScreen(0).Top = 270:
lvwOnScreen(0).Height = 3645: lvwOnScreen(0).Width = 15075
fraCommnicationStatus.Left = 4545:
fraCommnicationStatus.Top = 7905: fraCommnicationStatus.Height = 2130:
fraCommnicationStatus.Width = 10635
txtCommStatus.Left = 120: txtCommStatus.Top = 225:
txtCommStatus.Height = 1785: txtCommStatus.Width = 10395
fraOnlineStatus.Left = 45: fraOnlineStatus.Top = 7905:
fraOnlineStatus.Height = 2130: fraOnlineStatus.Width = 4485
lvwOnlineStatus.Left = 120: lvwOnlineStatus.Top = 225:
lvwOnlineStatus.Height = 1815: lvwOnlineStatus.Width = 4230
stbrMain.Left = 0: stbrMain.Top = 10425: stbrMain.Height =
345: stbrMain.Width = 15180
FraControls.Left = 10395: FraControls.Top = 285:
FraControls.Height = 750: FraControls.Width = 1500
txtResp.Left = 765: txtResp.Top = 420: txtResp.Height =
285: txtResp.Width = 180
txtReq.Left = 1185: txtReq.Top = 360: txtReq.Height = 285:
txtReq.Width = 180
lvwOnScreen(1).Left = 75: lvwOnScreen(1).Top = 4215:
lvwOnScreen(1).Height = 3645: lvwOnScreen(1).Width = 15075
lblResponseTitle(0).Left = 60: lblResponseTitle(0).Top =
30: lblResponseTitle(0).Height = 270: 'lblResponseTitle(0).Width = 1110
lblResponseTitle(1).Left = 105: lblResponseTitle(1).Top =
3975: lblResponseTitle(1).Height = 270: 'lblResponseTitle(1).Width = 1200
lvwOnScreen(0).ColumnHeaders(5).Width = 8800
lvwOnScreen(1).ColumnHeaders(5).Width = 8800

Case Else '800x600

lvwOnScreen(0).Left = 75: lvwOnScreen(0).Top = 270:
lvwOnScreen(0).Height = 2430: lvwOnScreen(0).Width = 11790
fraCommnicationStatus.Left = 4545:
fraCommnicationStatus.Top = 5445: fraCommnicationStatus.Height = 2130:
fraCommnicationStatus.Width = 7350
txtCommStatus.Left = 120: txtCommStatus.Top = 225:
txtCommStatus.Height = 1785: txtCommStatus.Width = 7170
fraOnlineStatus.Left = 45: fraOnlineStatus.Top = 5445:
fraOnlineStatus.Height = 2130: fraOnlineStatus.Width = 4485
lvwOnlineStatus.Left = 120: lvwOnlineStatus.Top = 225:
lvwOnlineStatus.Height = 1815: lvwOnlineStatus.Width = 4230
stbrMain.Left = 0: stbrMain.Top = 7605: stbrMain.Height =
345: stbrMain.Width = 11940
FraControls.Left = 10395: FraControls.Top = 60:
FraControls.Height = 750: FraControls.Width = 1500
txtResp.Left = 765: txtResp.Top = 420: txtResp.Height =
285: txtResp.Width = 180
txtReq.Left = 1185: txtReq.Top = 360: txtReq.Height = 285:
txtReq.Width = 180
lvwOnScreen(1).Left = 75: lvwOnScreen(1).Top = 2970:
lvwOnScreen(1).Height = 2430: lvwOnScreen(1).Width = 11790
lblResponseTitle(0).Left = 60: lblResponseTitle(0).Top =
30: lblResponseTitle(0).Height = 270: lblResponseTitle(0).Width = 1110
lblResponseTitle(1).Left = 105: lblResponseTitle(1).Top =
2730: lblResponseTitle(1).Height = 270: lblResponseTitle(1).Width = 1200
lvwOnScreen(0).ColumnHeaders(5).Width = 5923
lvwOnScreen(1).ColumnHeaders(5).Width = 5923

End Select
Screen.MousePointer = vbDefault
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim i

'DEVELOPER : Ketan Dt. 04/02/2005
'Purpose : Close Server's Clients Connections
'============================================
If gblnIsServer = True Then
For i = 0 To tcpServer.UBound
If tcpServer(i).State = sckOpen Then
tcpServer(i).Close
End If
Next
End If

'DEVELOPER : Ketan Dt. 04/02/2005
'Purpose : Close Server Connection
'============================================
If gblnIsServer = False Then
If tcpClient.State = sckOpen Then
tcpClient.Close
End If
End If

End Sub

Private Sub lvwOnLineUsers_ItemCheck(ByVal Item As MSComctlLib.ListItem)
If gblnIsServer = True Then
If lvwOnLineUsers.ListItems.Count > 0 Then
If Item.Checked = True Then
If
lvwOnLineUsers.ListItems(lvwOnLineUsers.SelectedItem.Index).SubItems(2) =
ZDLL.GetIPAddress Then

lvwOnLineUsers.ListItems(lvwOnLineUsers.SelectedItem.Index).Checked =
False
End If
End If
End If
End If
End Sub

''
''Private Sub Form_Resize()
'' On Error Resume Next
'' If Me.WindowState <> vbMinimized Then
'' Me.WindowState = vbMaximized
'''' lvwOnScreen(0).Width = Me.Width - 150: lvwOnScreen(1).Width =
Me.Width - 150
'''' fraCommnicationStatus.Width = (lvwOnScreen(0).Width + 100) -
(fraCommnicationStatus.Left)
''''
'''' txtCommStatus.Width = fraCommnicationStatus.Width - 200
''''
'''' fraCommnicationStatus.Top = Me.Height -
(fraCommnicationStatus.Height + stbrMain.Height)
'''' fraOnlineStatus.Top = fraCommnicationStatus.Top
''
'' End If
''
'''' Dim ctrl As Control
''''
'''' For Each ctrl In Me.Controls
'''' Debug.Print ctrl.Name & " - L:" & ctrl.Left & " - T:" &
ctrl.Top & " - H:" & ctrl.Height & " - W:" & ctrl.Width
'''' Next ctrl
''End Sub

Private Sub lvwOnScreen_DblClick(Index As Integer)
On Error GoTo ErrH

If lvwOnScreen(Index).ListItems.Count > 0 Then
If lvwOnScreen(Index).SelectedItem.Index = 0 Then
Exit Sub
End If
Else
Exit Sub
End If

If Index = 1 Then

If
InStr(lvwOnScreen(Index).ListItems(lvwOnScreen(Index).SelectedItem.Index).SubItems(1),
".") > 0 Then
txtMsg.Text =
lvwOnScreen(1).ListItems(lvwOnScreen(1).SelectedItem.Index).SubItems(5)
fraMessage.Tag =
lvwOnScreen(Index).ListItems(lvwOnScreen(Index).SelectedItem.Index).SubItems(1)
cmdSendToUser.Caption = "&Reply"
ChkBroadCast.Enabled = False
fraMessage.Visible = True
fraMessage.ZOrder 0
Exit Sub
End If

End If

If lvwOnScreen(Index).ListItems.Count > 0 Then

If
InStr(lvwOnScreen(Index).ListItems(lvwOnScreen(Index).SelectedItem.Index).SubItems(1),
".") > 0 Then
frmOnScreenDetail.cmdReply.Enabled = False
frmOnScreenDetail.cmdForward.Enabled = False
End If

If Len(Trim(lvwOnScreen(Index).SelectedItem.Tag)) > 0 Then

frmOnScreenDetail.nMsgID =
Val(lvwOnScreen(Index).SelectedItem.Tag)
If Len(Trim(lvwOnScreen(Index).SelectedItem.Tag)) = 0 Then
WriteToFile ZERRLOG_FILE_PATH, "Message ID Not Found"
End If
End If

frmOnScreenDetail.mbytIsRequest = Index
frmOnScreenDetail.mintLVWId =
lvwOnScreen(Index).ListItems(1).Text
frmOnScreenDetail.Show

End If

Exit Sub

ErrH:
Call LogEntry("frmMain-->lvwOnScreen_DblClick", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub lvwOnScreen_GotFocus(Index As Integer)
On Error GoTo ErrH

strFocusedLvw = Index
Exit Sub

ErrH:
Call LogEntry("frmMain-->lvwOnScreen_GotFocus", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub lvwOnScreen_KeyPress(Index As Integer, KeyAscii As Integer)
On Error GoTo ErrH

If KeyAscii = 13 Then Call MnuSMSDetail_Click
Exit Sub

ErrH:
Call LogEntry("frmMain-->lvwOnScreen_KeyPress", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub lvwOnScreen_MouseDown(Index As Integer, Button As Integer,
Shift As Integer, X As Single, Y As Single)
On Error GoTo ErrH

If Index = 1 Then
If lvwOnScreen(1).ListItems.Count > 0 Then

If
InStr(lvwOnScreen(1).ListItems(lvwOnScreen(1).SelectedItem.Index).SubItems(1),
".") = 0 Then
If Button = vbRightButton Then
MnuPopupForward.Visible = True
PopupMenu MnuPopup
End If
Else
If Button = vbRightButton Then
MnuPopupForward.Visible = False
PopupMenu MnuPopup
End If
End If
End If
End If
Exit Sub

ErrH:
Call LogEntry("frmMain-->lvwOnScreen_MouseDown", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

''Private Sub lvwOnScreen_MouseMove(Index As Integer, Button As Integer,
Shift As Integer, x As Single, y As Single)
'' If lvwOnScreen(1).ListItems.Count > 0 Then
'' TT.Title = App.Title
'' TT.TipText = "Caller ID : " &
lvwOnScreen(1).ListItems(1).SubItems(1) & vbCrLf _
'' & "SMS From : " &
lvwOnScreen(1).ListItems(1).SubItems(2) & vbCrLf _
'' & "Date Time : " &
lvwOnScreen(1).ListItems(1).SubItems(3) & vbCrLf _
'' & "Message : " &
lvwOnScreen(1).ListItems(1).SubItems(4)
'' TT.Create lvwOnScreen(1).hWnd
'' End If
''End Sub



Private Sub MnuAbout_Click()
On Error GoTo ErrH

frmAbout.Show 1
Exit Sub

ErrH:
Call LogEntry("frmMain-->MnuAbout_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuCalc_Click()
On Error GoTo ErrH

Dim strCalc$
strCalc = ZDLL.GetSystemDir & "\Calc.exe"
If Dir(strCalc) <> "" Then Shell strCalc
Exit Sub

ErrH:
gstrW2S = "frmMain-->Form_MnuCalc_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S

Call LogEntry("frmMain-->MnuCalc_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuCalendar_Click()
On Error GoTo ErrH

FrmCalendar.Show 1
Exit Sub

ErrH:
gstrW2S = "frmMain-->Form_MnuCalendar_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S

Call LogEntry("frmMain-->MnuCalendar_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuClearScreen_Click()
On Error GoTo ErrH

If MsgBox("Are you sure you want to clear the screen?", vbYesNo +
vbQuestion) = vbYes Then
'lvwSMS.ListItems.Clear: intIndex = 0
End If
Exit Sub

ErrH:
gstrW2S = "frmMain-->MnuClearScreen_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuClearScreen_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuCOMPort_Click()
On Error GoTo ErrH

'If gblnStartDC = True Then
If APPStat.appstCOMPortOn = True Then
MsgBox "Please stop COM Port to access COM Settings",
vbExclamation
Exit Sub
Else
frmCOMDetails.Show 1
End If
Exit Sub

ErrH:
gstrW2S = "frmMain-->MnuCOMPort_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuCOMPort_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuConnectedClients_Click()
On Error GoTo ErrH

FrmConnectedClients.Show
Exit Sub

ErrH:
Call LogEntry("frmMain-->MnuDeleteReq_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description)
End Sub

Private Sub MnuDeleteReq_Click()
On Error GoTo ErrH

If MsgBox("Are you sure you want to delete selected Request?",
vbExclamation + vbYesNo + vbDefaultButton2) = vbYes Then

End If
Exit Sub

ErrH:
Call LogEntry("frmMain-->MnuDeleteReq_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description)
End Sub

''Run this procedure to delete all read messages
Private Sub MnuDelReadSMS_Click()
On Error GoTo ErrH

Dim i As Integer
Screen.MousePointer = vbHourglass
If APPStat.appstSMSingOn = True Then
MsgBox "Please stop Response Reader before deleting all Read
messages", vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If
If APPStat.appstCOMPortOn = False Then
MsgBox "Please start COM Port before deleting all Read messages",
vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If

For i = 1 To 30
''Delete From SIM
bytLastCmd = enmDeleteFromSIM: mstrInputOne = ""
Call fncRequestToCOM(msCOMMSIM, enmDeleteFromSIM, i)
Do Until blnGoForNextIteration = True: DoEvents: Loop
Next i
gstrW2S = "User has tried to delete all Read messages"
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
gstrW2S = ""
Screen.MousePointer = vbDefault
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
gstrW2S = "frmMain-->MnuDelReadSMS_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuDelReadSMS_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuExit_Click()
On Error GoTo ErrH

' If APPStat.appstDatabaseRunning = True Then
' MsgBox "Please stop Database before closing application",
vbExclamation
' Screen.MousePointer = vbDefault
' Exit Sub
' End If
' If APPStat.appstCOMPortOn = True Then
' MsgBox "Please stop COM Port before closing application",
vbExclamation
' Screen.MousePointer = vbDefault
' Exit Sub
' End If
' If APPStat.appstSMSingOn = True Then
' 'MsgBox "Please stop SMS'ing before closing application",
vbExclamation
' MsgBox "Please stop Response Reading before closing application",
vbExclamation
' Screen.MousePointer = vbDefault
' Exit Sub
' End If
gblnDoUWantToLogOff = False
Unload Me
'' If gblnStartDC = True Then
'' MsgBox "Please stop SMS'ing before closing application",
vbExclamation
'' Else
'' Unload Me
'' End If
Exit Sub

ErrH:
gstrW2S = "frmMain-->MnuExit_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuExit_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub mnuF_A_AssignRights_Click()
On Error GoTo ErrH

'Assign Authority Rights
Set_Status "Authority Rights"
Load frmAuthorityMaster
Set_Status ""
frmAuthorityMaster.Show vbModal
Exit Sub

ErrH:
Call LogEntry("frmMain-->mnuF_A_AssignRights_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub mnuF_A_AuthorityGroup_Click()
On Error GoTo ErrH

'Assign Authority Group
Set_Status "Authority Group"
Load frmAuthorityGroupMaster
Set_Status ""
frmAuthorityGroupMaster.Show vbModal
Exit Sub

ErrH:
Call LogEntry("frmMain-->mnuF_A_AuthorityGroup_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub



''Private Sub MnuFile_AcBalEntry_Click()
'' On Error GoTo ErrH
''
'' frmAcBalEntry.AddFlag = True
'' frmAcBalEntry.Show vbModal
'' Exit Sub
''
''ErrH:
'' Call LogEntry("frmMain-->MnuFile_AcBalEntry_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
''End Sub

Private Sub MnuFile_AddressBook_Click()
frmContacts.Show
End Sub

Private Sub MnuFile_Functions_Click()
frmFunctions.AddFlag = True
frmFunctions.Show
End Sub

Private Sub MnuFile_QuickMessage_Click()
frmQuickMsg.AddFlag = True
frmQuickMsg.Show
End Sub

Private Sub MnuLogOff_Click()
gblnDoUWantToLogOff = True
'frmMDI.Hide
'Call MnuStartSMSing_Click
'frmAuthenticate.Show 1
Unload frmMain
frmAuthenticate.Show vbModal
End Sub

Private Sub MnuParameter_Click()
On Error GoTo ErrH

frmParameter.Show 1
Exit Sub

ErrH:
gstrW2S = "frmMain-->MnuParameter_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuParameter_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

''Private Function CloseApp() As Integer
'' On Error GoTo ErrH
''
'' CloseApp = 0
'' If ZIDLL.cnDB.State = 1 Then ZIDLL.cnDB.Close
''
'' Set ZIDLL.cnDB = Nothing
'' Set ZDLL = Nothing
'' CloseApp = 1
'' Exit Function
''
''ErrH:
'' CloseApp = 0
'' gstrW2S = "frmMain-->CloseApp"
'' gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
'' WriteToScreen txtCommStatus, gstrW2S
'' WriteToFile ZERRLOG_FILE_PATH, gstrW2S
''End Function

Private Sub FillOnlineStatus(strReqType As String)
On Error GoTo ErrH

Dim LstItem As ListItem
Dim intInc As Integer

Select Case UCase(SMSData.SMSDS_Type)
Case UCase("PFI")
SRT.SRT_PFI = SRT.SRT_PFI + 1
Case UCase("PNI")
SRT.SRT_PNI = SRT.SRT_PNI + 1
Case UCase("PLI")
SRT.SRT_PLI = SRT.SRT_PLI + 1
Case UCase("PAI")
SRT.SRT_PAI = SRT.SRT_PAI + 1
Case UCase("BLI")
SRT.SRT_BLI = SRT.SRT_BLI + 1
Case Else
SRT.SRT_UNKNOWN = SRT.SRT_UNKNOWN + 1
End Select

Select Case UCase(SMSData.SMSDS_Type)
Case UCase("PFI")
Set LstItem = lvwOnlineStatus.ListItems.Item(1)
LstItem.SubItems(1) = SRT.SRT_PFI
Case UCase("PNI")
Set LstItem = lvwOnlineStatus.ListItems.Item(2)
LstItem.SubItems(1) = SRT.SRT_PNI
Case UCase("PLI")
Set LstItem = lvwOnlineStatus.ListItems.Item(4)
LstItem.SubItems(1) = SRT.SRT_PLI
Case UCase("PAI")
Set LstItem = lvwOnlineStatus.ListItems.Item(3)
LstItem.SubItems(1) = SRT.SRT_PAI
Case UCase("BLI")
Set LstItem = lvwOnlineStatus.ListItems.Item(5)
LstItem.SubItems(1) = SRT.SRT_BLI
Case Else
Set LstItem = lvwOnlineStatus.ListItems.Item(6)
LstItem.SubItems(1) = SRT.SRT_UNKNOWN
End Select
intInc = intInc + 1
lvwOnlineStatus.ListItems(intInc).Selected = True
Exit Sub

ErrH:
gstrW2S = "frmMain-->FillOnlineStatus"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->FillOnlineStatus", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

'Private Sub FillSMS(bytFT As FillType)
' On Error GoTo ErrH
'
' Dim LstItem As ListItem
'
'
' If intIndex = 0 Then intIndex = 1
''' ''Z.GSM will reply same request from same mobile but following
lines are for checking of duplicate request
''' ''generated anyhow. e.g. if
smsdata.smsds_type,smsdata.smsds_request,smsdata.smsds_requestdt are same
then
''' ''consider this request as duplicate and avoid to display
''' ''Upto Here
'
' If bytFT = FT_ADD Then
' Set LstItem = lvwSMS.ListItems.Add(intIndex, "A" & intIndex,
SMSData.SMSDS_CallerID)
' If SMSData.SMSDS_Type = LstItem.SubItems(1) And _
' SMSData.SMSDS_Request = LstItem.SubItems(2) And _
' SMSData.SMSDS_RequestDT = LstItem.SubItems(3) Then
' Exit Sub
' End If
'
' LstItem.SubItems(1) = SMSData.SMSDS_Type
' LstItem.SubItems(2) = SMSData.SMSDS_Request
' LstItem.SubItems(3) = SMSData.SMSDS_RequestDT
' LstItem.SubItems(5) = SMSData.SMSDS_Status
'
' LstItem.Tag = intIndex
' intIndex = intIndex + 1
' Else
' Set LstItem = lvwSMS.ListItems.Item(intIndex - 1)
' LstItem.SubItems(4) = SMSData.SMSDS_ResponseDT
' LstItem.SubItems(5) = SMSData.SMSDS_Status
' LstItem.SubItems(6) = SMSData.SMSDS_Response
' End If
' lvwSMS.ListItems(intIndex - 1).Selected = False
' lvwSMS.ListItems(1).Selected = True
' Exit Sub
'
'ErrH:
'' Resume
' gstrW2S = "frmMain-->FillSMS"
' gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
' WriteToScreen txtCommStatus, gstrW2S
' WriteToFile ZERRLOG_FILE_PATH, gstrW2S
'End Sub

Private Sub MakeSMSDataEmpty()
SMSData.SMSDS_CallerID = ""
SMSData.SMSDS_Request = ""
SMSData.SMSDS_RequestDT = ""
SMSData.SMSDS_Response = ""
SMSData.SMSDS_ResponseDT = ""
SMSData.SMSDS_Status = ""
SMSData.SMSDS_Type = ""
End Sub

Private Sub MakeOtherVariablesEmpty()
blnGoForDelete = False
blnGoForNextIteration = False
blnGoForRead = False
blnGoForRespGen = False
blnGoForSend = False

strResp1 = ""
strResp2 = ""
End Sub

Private Sub MnuPopupForward_Click()
On Error GoTo ErrH

'frmSendSMS.txtSMSToContacts.Text =
lvwOnScreen(1).SelectedItem.ListSubItems(2)
'frmSendSMS.txtSMSTo.Text =
lvwOnScreen(1).SelectedItem.ListSubItems(1)
frmSendSMS.Caption = frmSendSMS.Caption & " - Forward"
frmSendSMS.txtSMSMsg.Text =
lvwOnScreen(1).SelectedItem.ListSubItems(4)
frmSendSMS.Show vbModal
Exit Sub

ErrH:
Call LogEntry("frmMain-->MnuPopupReply_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuPopupReply_Click()
On Error GoTo ErrH
If
InStr(lvwOnScreen(1).ListItems(lvwOnScreen(1).SelectedItem.Index).SubItems(1),
".") = 0 Then
frmSendSMS.txtSMSToContacts.Text =
lvwOnScreen(1).SelectedItem.ListSubItems(2)

frmSendSMS.txtSMSTo.Text =
lvwOnScreen(1).SelectedItem.ListSubItems(1)
frmSendSMS.Caption = frmSendSMS.Caption & " - Reply"
frmSendSMS.Show vbModal
Else
fraMessage.Tag =
lvwOnScreen(1).ListItems(lvwOnScreen(1).SelectedItem.Index).SubItems(1)
ChkBroadCast.Enabled = False
fraMessage.Visible = True
fraMessage.ZOrder 0
End If

Exit Sub

ErrH:
Call LogEntry("frmMain-->MnuPopupReply_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuRefreshSMS_Click()
On Error GoTo ErrH

Static nCnt As Byte

If APPStat.appstSMSingOn = True Then
'MsgBox "Please stop SMS'ing before deleting all Read messages",
vbExclamation
MsgBox "Please stop Response Reader before deleting all Read
messages", vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If
If APPStat.appstCOMPortOn = False Then
MsgBox "Please start COM Port before deleting all Read messages",
vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If

Screen.MousePointer = vbHourglass
stbrMain.Panels(1).Text = "Re-initializing GSM Device, Please wait
..."
''Initialize SIM
TTPTryAgain:
If nCnt >= 255 Then nCnt = 0
nCnt = nCnt + 1
bytLastCmd = enmInitialization: mstrInputOne = ""
Call fncRequestToCOM(msCOMMSIM, enmInitialization)
'Do Until blnGoForRead = True: DoEvents: Loop
'' Wait for few seconds
tmpTimer = ""
tmpTimer = Timer + 10
Do Until Timer > tmpTimer
If blnGoForRead = True Then
tmpTimer = "": Screen.MousePointer = vbDefault
stbrMain.Panels(1).Text = "": Exit Do
End If
DoEvents
Loop
tmpTimer = ""
If blnGoForRead = False Then
If MsgBox("Initialization failed. Check cable connection between
GSM device and computer" & vbCrLf & "Do you want to re-initialize GSM
now?", vbExclamation + vbYesNo + vbDefaultButton2, App.title & " - Attempt
: " & nCnt) = vbYes Then
GoTo TTPTryAgain
End If
End If
Screen.MousePointer = vbDefault
stbrMain.Panels(1).Text = ""
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
stbrMain.Panels(1).Text = ""
gstrW2S = "frmMain-->MnuRefreshSMS_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuRefreshSMS_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuRep_ConnectedClients_Click()
On Error GoTo ErrH

udfenmREPORTS = enmCONNECTEDCLIENTS
ZReports.Visible = True
ZReports.Show
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuRep_ConnectedClients_Click", ErroLog,
True, Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuRep_Contacts_Click()
On Error GoTo ErrH

udfenmREPORTS = enmContacts
ZReports.Visible = True
ZReports.Show
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuRep_Contacts_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuRep_Functions_Click()
On Error GoTo ErrH

udfenmREPORTS = enmFunctions
ZReports.Visible = False
ZReports.Show
Set ZReports = Nothing
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuRep_Functions_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuRep_GroupDetail_Click()
On Error GoTo ErrH

udfenmREPORTS = enmGroupDetail
ZReports.Visible = False
ZReports.Show
Set ZReports = Nothing
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuRep_GroupDetail_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuRep_OrganizationDetail_Click()
On Error GoTo ErrH

udfenmREPORTS = enmOrganizationDetail
ZReports.Visible = False
ZReports.Show
Set ZReports = Nothing
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuRep_OrganizationDetail_Click", ErroLog,
True, Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuRep_QuickMessages_Click()
On Error GoTo ErrH

udfenmREPORTS = enmQuickMessages
ZReports.Visible = False
ZReports.Show
Set ZReports = Nothing
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuRep_QuickMessages_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuRep_SMSTransactions_Click()
On Error GoTo ErrH

udfenmREPORTS = enmSMSTransaction
ZReports.Visible = True
ZReports.Show
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuRep_SMSTransactions_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuReports_Click()
' MsgBox "You are not registered to view reports", vbExclamation
End Sub

Private Sub MnuSendSMS_Click()
On Error GoTo ErrH

Screen.MousePointer = vbHourglass
If gblnIsServer = True Then
'' If APPStat.appstSMSingOn = True Then
'' MsgBox "Please stop Response Reader before sending SMS",
vbExclamation
'' Screen.MousePointer = vbDefault
'' Exit Sub
'' End If
If APPStat.appstCOMPortOn = False Then
MsgBox "Please start COM Port before sending SMS",
vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If

End If
Screen.MousePointer = vbDefault
frmSendSMS.Show 1
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuSendSMS_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub


Private Sub MnuSettings_DBConfiguration_Click()
On Error GoTo ErrH

frmDBConfiguration.bytDBProvider = dbProvider
frmDBConfiguration.Show vbModal
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
Call LogEntry("frmMain-->MnuSettings_DBConfiguration_Click", ErroLog,
True, Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuSMSDetail_Click()
On Error GoTo ErrH

'lvwOnScreen.Item.Index
If Len(strFocusedLvw) = 0 Then Exit Sub
'MsgBox lvwOnScreen(CInt(strFocusedLvw)).SelectedItem
If lvwOnScreen(CInt(strFocusedLvw)).ListItems().Count > 0 Then
frmOnScreenDetail.mbytIsRequest = CByte(strFocusedLvw)
frmOnScreenDetail.mintLVWId =
lvwOnScreen(CInt(strFocusedLvw)).ListItems(1).Text
frmOnScreenDetail.Show
End If
Exit Sub

ErrH:
Call LogEntry("frmMain-->MnuSMSDetail_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuStartDatabase_Click()
On Error GoTo ErrH

Screen.MousePointer = vbHourglass
If APPStat.appstDatabaseRunning = False Then
' strSMSC_NUMBER = ZDLL.GetFromIni("ZConfigurationINI", "Settings",
"SMSCN", "+919825001002")
strDataSrc = ZDLL.GetFromIni(ZConfigurationINI, "Data", "DataSrc",
"ZRLY90")
strUser = ZDLL.GetFromIni(ZConfigurationINI, "Data", "User",
"AFRES")
strPwd = ZDLL.GetFromIni(ZConfigurationINI, "Data", "Auth",
"GATES9")

If (ZIDLL.cnDB.State = 0) Then
'open connection
'If ZIDLL.OPEN_Connection(strDataSrc, strUser, strPwd) = 0
Then
If ZIDLL.OPEN_Connection(enmSQL, False) = 0 Then
gstrW2S = "Unable to connect DataSource." & vbCrLf &
vbCrLf _
& "Check for following possibilities " & vbCrLf & "[1]
Check for " _
& "parameters like DataSource, User, Password" & vbCrLf &
"[2] Oracle " _
& "database is not stared yet" & vbCrLf & vbCrLf & "This
application will be " _
& "closed."
MsgBox gstrW2S, vbExclamation

WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S

blnExplicitUnload = True
Form_QueryUnload 0, 0
Else
APPStat.appstDatabaseRunning = True
WriteToFile ZLOG_FILE_PATH,
"---------------------------------------------"
WriteToFile ZLOG_FILE_PATH, "Database Connection Opened"
WriteToScreen txtCommStatus, "Database Connection Opened"

MnuStartDatabase.Caption = "Stop Database"
Call GetRequestCntUpToDate 'this procedure will retrive
latest request count of each opt. code
Call ShowRequestCntUpToDate
End If
End If
Else
If APPStat.appstCOMPortOn = True Then
MsgBox "Please stop COM Port before closing Database",
vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If
If APPStat.appstSMSingOn = True Then
'MsgBox "Please stop SMS'ing before closing Database",
vbExclamation
MsgBox "Please stop Response Reader before closing Database",
vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If
If ZIDLL.cnDB.State = 1 Then ZIDLL.cnDB.Close
APPStat.appstDatabaseRunning = False
MnuStartDatabase.Caption = "Start Database"
WriteToFile ZLOG_FILE_PATH, "Database Connection Closed"
WriteToScreen txtCommStatus, "Database Connection Closed"
End If
Screen.MousePointer = vbDefault
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
gstrW2S = "frmMain-->MnuStartDatabase_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuStartDatabase_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuStartCOMPort_Click()
On Error GoTo ErrH

Screen.MousePointer = vbHourglass
'If gblnStartDC = False Then
If APPStat.appstCOMPortOn = False Then
'' temporary commented by Ashutosh on Dt.24/04/04 for demo at Nova
'' If APPStat.appstDatabaseRunning = False Then
'' MsgBox "Please start Database before starting COM Port",
vbExclamation
'' Screen.MousePointer = vbDefault
'' Exit Sub
'' End If

START_DC
' tmrReadFromSIM.Enabled = True
Else
'gblnStartDC = False
If APPStat.appstSMSingOn = True Then
MsgBox "Please stop Response Reading before closing COM Port",
vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If
If gblnIterationIsOn = False Then STOP_DC
' STOP_DC
tmrReadFromSIM.Enabled = False
APPStat.appstCOMPortOn = False
stbrMain.Panels(1).Text = ""
End If
Screen.MousePointer = vbDefault
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
gstrW2S = "frmMain-->MnuStartCOMPort_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuStartCOMPort_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub MnuStartSMSing_Click()
On Error GoTo ErrH

Screen.MousePointer = vbHourglass
If APPStat.appstSMSingOn = False Then
If gblnIsServer = True Then
If APPStat.appstCOMPortOn = False Then
MsgBox "Please start COM Port before starting Response
Reader", vbExclamation
Screen.MousePointer = vbDefault
Exit Sub
End If
End If

gblnStopDC = False
tmrReadFromSIM.Enabled = True
APPStat.appstSMSingOn = True

' MnuStartSMSing.Caption = "Stop SMS'ing"
' WriteToFile ZLOG_FILE_PATH, "SMS'ing is On"
' WriteToScreen txtCommStatus, "SMS'ing is On"
' stbrMain.Panels(1).Text = "Starting SMS'ing, Please Wait ..."

MnuStartSMSing.Caption = "Stop Response Reading"
WriteToFile ZLOG_FILE_PATH, "Response Reading is On"
WriteToScreen txtCommStatus, "Response Reading is On"
stbrMain.Panels(1).Text = "Starting Response Reading, Please Wait
..."

Else
gotoCloseSMSing:
'If gblnIterationIsOn = True Then gblnStopDC = True
gblnStopDC = True
'stbrMain.Panels(1).Text = "Stopping SMS'ing"
stbrMain.Panels(1).Text = "Stopping Response Reading"
End If
Screen.MousePointer = vbDefault
Exit Sub

ErrH:
Screen.MousePointer = vbDefault
gstrW2S = "frmMain-->MnuStartSMSing_Click"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->MnuStartSMSing_Click", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

''Private Sub STOP_SMSing()
'' On Error GoTo ErrH
''
'' tmrReadFromSIM.Enabled = False
'' APPStat.appstSMSingOn = False
'' 'MnuStartSMSing.Caption = "Start SMS'ing"
'' 'WriteToFile ZLOG_FILE_PATH, "SMS'ing is Off"
'' 'WriteToScreen txtCommStatus, "SMS'ing is Off"
'' MnuStartSMSing.Caption = "Start Response Reading"
'' WriteToFile ZLOG_FILE_PATH, "Response Reading is Off"
'' WriteToScreen txtCommStatus, "Response Reading is Off"
'' Exit Sub
''
''ErrH:
'' Call LogEntry("frmMain-->STOP_SMSing", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
''End Sub

''Private Sub MnuStartStopDC_Click()
'' On Error GoTo ErrH
''
'' If gblnStartDC = False Then
'' START_DC
'' tmrReadFromSIM.Enabled = True
'' Else
'' gblnStartDC = False
'' If gblnIterationIsOn = False Then STOP_DC
'' End If
'' Exit Sub
''
''ErrH:
'' gstrW2S = "frmMain-->MnuStartStopDC_Click"
'' gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
'' WriteToScreen txtCommStatus, gstrW2S
'' WriteToFile ZERRLOG_FILE_PATH, gstrW2S
''End Sub

Private Sub START_DC()
On Error GoTo ErrH

StartCommunication
If mbolDCStatus = False Then Exit Sub

'gblnStartDC = True
APPStat.appstCOMPortOn = True
MnuStartCOMPort.Caption = "&Stop COM Port"
Exit Sub

ErrH:
Call LogEntry("frmMain-->START_DC", ErroLog, True, Err.Description,
Err.Number, Err.Description, Err.Source)
End Sub

Private Sub STOP_DC()
On Error GoTo ErrH

'MnuStartStopDC.Caption = "&Start SMS'ing"
MnuStartCOMPort.Caption = "Start COM Port"
'MnuStartSMSing.Caption = "Start SMS'ing"
ClosePort
'tmrReadFromSIM.Enabled = False
APPStat.appstCOMPortOn = False
Exit Sub

ErrH:
Call LogEntry("frmMain-->STOP_DC", ErroLog, True, Err.Description,
Err.Number, Err.Description, Err.Source)
End Sub


Private Sub COMnSIM()

On Error GoTo ErrH

Dim i As Integer, LstItem As ListItem ', nCnt As Integer
Dim bytCnt As Byte, tmpTimer
Dim rsReadSMS As New ADODB.Recordset 'added by Ketan on Dt :
09/02/2005
Dim strReadSMS As String 'added by Ketan on Dt : 09/02/2005
Dim lstID As Double 'added by Ketan on Dt : 09/02/2005
Dim strCmdToolTip As String 'added by KEtan

gbytCnt = 0

'Read SMS from GSM Modem by SMS Slot Index
'=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-
'Read all 30 Slot of GSM Modem

For i = 1 To 30
gblnIterationIsOn = True

'Current Status
gbytCnt = gbytCnt + 1

'Set LstItem = lvwOnlineStatus.ListItems.Item(7)
'LstItem.SubItems(1) = gbytCnt

LstItemCrntStatus.ListSubItems(1).Bold = True
LstItemCrntStatus.SubItems(1) = gbytCnt

DoEvents
'Me.Caption = App.Title & " - Server " & " - Reading SIM Slot : "
& gbytCnt

'If gblnStartDC = False Then Exit Sub

If APPStat.appstCOMPortOn = False Then Exit Sub

'Set SMS Data entry type to blank
'====================================
MakeSMSDataEmpty
MakeOtherVariablesEmpty
'====================================

''Read From SIM
bytLastCmd = enmReadFromSIM: mstrInputOne = ""


'Send AT Commad to GMS Modem for Reading SMS
'=========================================================
Call fncRequestToCOM(msCOMMSIM, enmReadFromSIM, i)
'=========================================================

'=========================================================
'''' Wait for few seconds
'=========================================================
TTP1:
tmpTimer = "": tmpTimer = Timer + constWait4Reply
Do Until Timer > tmpTimer
If blnGoForRespGen = True Then tmpTimer = "": Exit Do
If blnGoForNextIteration = True Then GoTo NextIteration
DoEvents
Loop
tmpTimer = ""

'=========================================================

'Get SMS from Sim Card
'=========================================================
Call Timer5_Timer
'=========================================================


'''' Upto Here

If blnGoForRespGen = False Then
If blnGoForNextIteration = True Then
GoTo NextIteration
Else
gstrW2S = "Read failed in SIM Slot : " & i & ", sent for
next itteration"
WriteToFile ZLOG_FILE_PATH, gstrW2S
GoTo NextIteration
End If
End If

''Read smssender name from [addressbook] table using
smsdata.smsds_callerid
'SMSData.SMSDS_RequestDT = Replace(SMSData.SMSDS_RequestDT, "/",
"-")
'SMSData.SMSDS_RequestDT = Format(CDate(SMSData.SMSDS_RequestDT),
"yyyy-mm-dd HH:mm:ss")
'fncInsertInTo Format(SMSData.SMSDS_RequestDT, "yyyy-MM-dd
HH:mm:ss"), 1, SMSData.SMSDS_Request, 0, SMSData.SMSDS_CallerID,
SMSData.SMSDS_SenderName, gstrComputerName

If Len(SMSData.SMSDS_SenderName) = 0 Then
SMSData.SMSDS_SenderName = "Unknown"
''Insert new (unknown) caller id in contacts
InsertUpdateContacts True, "ud_InsertAB", "Unknown",
"Unknown", "Unknown", "Unknown", SMSData.SMSDS_CallerID,
Str(udfGenDetail.udftGenDet_GeneralGrpID), AuthorityPerson
End If

SMSData.SMSDS_Request = Replace(SMSData.SMSDS_Request, "OKRING",
"") 'Filter.... extra character
SMSData.SMSDS_Request = Replace(SMSData.SMSDS_Request, "OK+CMTI",
"") 'Filter.... extra character

If InStr(UCase(SMSData.SMSDS_Request),
UCase(udfOPTCode.udftOPTCode_SRCH)) > 0 Then
'If InStr(UCase(AuthorityFunctions),
UCase(udfOPTCode.udftOPTCode_SRCH)) > 0 Or UCase(AuthorityFunctions) =
UCase("ALL") Then
If fncCheckFunctionAuthority(SMSData.SMSDS_CallerID,
udfOPTCode.udftOPTCode_SRCH) = True Then

mblnDenyShowOnScreen = True
''Generate Response
Call GenerateResponse(SMSData.SMSDS_Request, False)

If blnGoForDelete = True Then GoTo TTP4
'''' Wait for few seconds
TTP2:
tmpTimer = ""
tmpTimer = Timer + constWait4Reply
Do Until Timer > tmpTimer
If blnGoForSend = True Then tmpTimer = "": Exit
Do
DoEvents
Loop
tmpTimer = ""
'''' Upto Here
If blnGoForSend = False Then
gstrW2S = "Response Generation failed for SIM Slot : "
& i & ", sent for next itteration"
WriteToFile ZLOG_FILE_PATH, gstrW2S
GoTo NextIteration
End If

If Len(Trim(strResp1)) > 0 Then
SMSData.SMSDS_Response = strResp1
''Send To SIM
bytLastCmd = enmSendToSIM: mstrInputOne = ""
Call fncRequestToCOM(msCOMMSIM, enmSendToSIM, i)



'''' Wait for few seconds
TTP3:
tmpTimer = ""
tmpTimer = Timer + constWait4Reply
Do Until Timer > tmpTimer
If blnGoForDelete = True Then tmpTimer = "": Exit
Do
DoEvents
Loop
tmpTimer = ""

'Delete Message
GoTo TTP4


Call Timer5_Timer
'''' Upto Here
If blnGoForDelete = False Then
gstrW2S = "Sent failed for SIM Slot : " & i & ",
sent for next itteration"
WriteToFile ZLOG_FILE_PATH, gstrW2S
GoTo NextIteration
End If
'' Do Until blnGoForDelete = True
'' DoEvents
'' Loop
End If
End If
Else
mblnDenyShowOnScreen = False
End If

'Added by Ketan On dt : 21/02/2005 for Demo Version Exe
'Demo exprity date compare with Incomming new SMS date
If isDemoVersion = True Then

'If SMSData.SMSDS_RequestDT > ExpryDate Then
' MsgBox "Z.GSMS 11.3 evaluation copy has been expired,
Please contact your vendor.", vbInformation, App.title
' End
'End If

'Check Total SMS validity for Demo Version
If fncGetTotalSMS > nTotalSMS Then
MsgBox "Z.GSMS 11.3 evaluation copy has been expired,
Please contact your vendor.", vbInformation, App.title
End
End If

End If

'Add new SMS Entry Here
fncInsertInTo SMSData.SMSDS_RequestDT, 1, SMSData.SMSDS_Request,
0, SMSData.SMSDS_CallerID, SMSData.SMSDS_SenderName, gstrComputerName,
IIf(mblnDenyShowOnScreen = True, 1, 0)

'Added by KEtan On Dt : 09/02/2005
'Get Last Message ID

'=====================================================================================
If dbProvider = enmSQL Then
strReadSMS = "Select max(ST_ID) From SMSTransaction"
ElseIf dbProvider = enmAccess Then
strReadSMS = "Select max(st_id) From SMSTransaction"
End If

If rsReadSMS.State = adStateOpen Then rsReadSMS.Close
rsReadSMS.CursorLocation = adUseClient
rsReadSMS.Open strReadSMS, ZIDLL.cnDB, adOpenForwardOnly,
adLockReadOnly, adCmdText

If rsReadSMS.RecordCount > 0 Then
lstID = IIf(IsNull(rsReadSMS.Fields(0)), 1,
rsReadSMS.Fields(0))
Else
lstID = 1
End If

If rsReadSMS.State = adStateOpen Then
rsReadSMS.Close
End If

Set rsReadSMS = Nothing

'======================================================================================

'Write BroadCast SMS to All Clients.... added by Ketan On Dt :
09/02/2005

'==========================================================================
Call fncBroadCast_SMS(ZDLL.AV(lstID),
ZDLL.AV(SMSData.SMSDS_Request), ZDLL.AV(SMSData.SMSDS_SenderName),
ZDLL.AV(SMSData.SMSDS_CallerID), ZDLL.AV(SMSData.SMSDS_RequestDT),
ZDLL.AV("0"))


ZDLL.SaveToIni ZConfigurationINI, "LastID", "ServerResp",
ZDLL.AV(lstID)

'Show New Message on Server Response Screen... added by Ketan On
Dt : 09/02/2005

'================================================================================
ShowOnScreen enmResponse, ZDLL.AV(SMSData.SMSDS_CallerID),
ZDLL.AV(SMSData.SMSDS_SenderName), ZDLL.AV(SMSData.SMSDS_Request),
ZDLL.AV("0"), ZDLL.AV(Format(SMSData.SMSDS_RequestDT, "DD/mm/yyyy
HH:MM:SS")), lstID

'Added by Ketan disply New SMS tooltip on Server Screen
'Show New SMS Tooltip

'===========================================================================================================================================================================================================================================================================================================================
'Comment by Ketan on Dt : 13/07/2005 for Adding new Popup Style
'***************************************************************
'strCmdToolTip = Chr(34) & " You have a new SMS(s)" & vbCrLf &
"SMS From : " & SMSData.SMSDS_SenderName & vbCrLf & " Caller ID: " &
SMSData.SMSDS_CallerID & vbCrLf & "Date Time: " &
Format(SMSData.SMSDS_RequestDT, "DD/mm/yyyy HH:MM:SS") & vbCrLf &
"Message: " & Mid(SMSData.SMSDS_Request, 1, 20) & "..." & Chr(34)
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " " & strCmdToolTip
'Shell strCmdToolTip, vbNormalFocus

'===========================================================================================================================================================================================================================================================================================================================

'Added by Ketan On dt : 13/07/2005 Adding new Popup Style

'************************************************************************
Dim AlertWindow As frmAlertWindow 'Added by Ketan on dt :
13/07/2005 for New Popup style
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)

If Len(Trim(SMSData.SMSDS_Request)) > 0 Then
strCmdToolTip = " You have a new SMS(s)" & vbCrLf & "SMS From
: " & SMSData.SMSDS_SenderName & vbCrLf & " Caller ID: " &
SMSData.SMSDS_CallerID & vbCrLf & "Date Time: " &
Format(SMSData.SMSDS_RequestDT, "DD/mm/yyyy HH:MM:SS") & vbCrLf & vbCrLf &
"Message: " & SMSData.SMSDS_Request
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False
End If

'************************************************************************

'Delete SMS from GSM Modem Sim Slot
'============================================================
TTP4:
bytLastCmd = enmDeleteFromSIM: mstrInputOne = ""
Call fncRequestToCOM(msCOMMSIM, enmDeleteFromSIM, i)
'''' Wait for few seconds
tmpTimer = ""
tmpTimer = Timer + constWait4Reply
Do Until Timer > tmpTimer
If blnGoForNextIteration = True Then tmpTimer = "": Exit Do
DoEvents
Loop
tmpTimer = ""
Call Timer5_Timer

If blnGoForNextIteration = False Then
gstrW2S = "Delete failed for SIM Slot : " & i & ", sent for
next itteration"
WriteToFile ZLOG_FILE_PATH, gstrW2S
GoTo NextIteration
End If
'================================================================


NextIteration:
gblnIterationIsOn = False
If gblnStopDC = True Then tmrReadFromSIM.Enabled = False:
STOP_SMSing: Exit Sub
Next i
Exit Sub

ErrH:
gstrW2S = "frmMain-->COMnSIM"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->COMnSIM", ErroLog, True, Err.Description,
Err.Number, Err.Description, Err.Source)
End Sub

'When GSM Server is Close, Shutted Down or Break Connection with
Client...... by KEtan
Private Sub tcpClient_Close()
On Error GoTo ErrHandler
tcpClient.Close
If Me.WindowState <> 1 Then
If gblnIsServer = False Then
' MsgBox "Z.GSMS Server is disconnected", vbCritical, "Z.GSMS"
End If
End If

txtCommStatus.Text = txtCommStatus.Text & vbCrLf & strRemoteHost & "
disconnected"
frmMain.stbrMain.Panels(3).Text = "Server : " & strRemoteHost & ",
Port : " & strRemotePort & " disconnected"
isClientConnected = False
LogEntry "Z.GSMS Server is Down", EventLog, False, "", 0, "Server is
Shutdown", "Nothing", Format(Now, "dd/mm/yyyy"), Format(Now, "HH:MM:SS")
MnuSendSMS.Enabled = False
MnuPopupForward.Enabled = False
MnuPopupReply.Enabled = False
Exit Sub
ErrHandler:
Call LogEntry("frmMain-->tcpClient_Close", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

'Added by Ketan for Winsock Connection establish with GSM Server
Private Sub tcpClient_Connect()
On Error GoTo ErrHandler
isClientConnected = True

frmMain.stbrMain.Panels(3).Text = "Server : " & strRemoteHost & ",
Port : " & strRemotePort & " Connected"

'tcpClient.SendData "CLIENT_INFO" & Chr(149) &
udfCompany.gstrCurrentUser & Chr(149) & udfCompany.gstrUserDesig &
Chr(149) & ZDLL.GetIPAddress

MnuSendSMS.Enabled = True
MnuPopupForward.Enabled = True
MnuPopupReply.Enabled = True
Exit Sub

ErrHandler:
Call LogEntry("frmMain-->tcpClient_Connect", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

'When Client Disconnected .... Ketan
Private Sub tcpServer_Close(Index As Integer)

If Remove_OnLineUser(tcpServer(Index).RemoteHostIP) = True Then
tcpServer(Index).Close
txtCommStatus.Text = txtCommStatus.Text & vbCrLf &
tcpServer(Index).RemoteHostIP & " Disconnected."
End If

'Unload tcpServer(Index)
End Sub

'When Client Send Request to Connect with Server...
Private Sub tcpServer_ConnectionRequest(Index As Integer, ByVal requestID
As Long)
nClient = nClient + 1 'increase number that hold # of winsocks
Load tcpServer(nClient) 'load new winsock for new client
tcpServer(nClient).Accept requestID 'accept request by getting ID
tcpServer(nClient).SendData "Connected" & Chr(149) 'send
"(Connected)" to client
txtCommStatus.Text = txtCommStatus.Text & vbCrLf & "Client : " &
tcpServer(nClient).RemoteHostIP & " Connected."
End Sub

'By Ketan
Private Sub tcpServer_Error(Index As Integer, ByVal Number As Integer,
Description As String, ByVal Scode As Long, ByVal Source As String, ByVal
HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
txtCommStatus.Text = txtCommStatus.Text & vbCrLf & Description
End Sub


''Interval of timer is 1000 milisecond = 1 second
Private Sub tmrReadFromSIM_Timer()
On Error GoTo ErrH

Dim LstItemCrntStatus As ListItem
Set LstItemCrntStatus = lvwOnlineStatus.ListItems.Item(1)
''rest of communication with SIM

tmrReadFromSIM.Enabled = False
''stbrMain.Panels(1).Text = "Re-Initializing..."
''Initialize SIM
''bytLastCmd = enmInitialization: mstrInputOne = ""
''Call fncRequestToCOM(msCOMMSIM, enmInitialization)
''Do Until blnGoForRead = True: DoEvents: Loop

stbrMain.Panels(1).Text = "Response Reader is Running"

If gblnIsServer = False Then
If isClientConnected = False Then
tcpClient.Close
tcpClient.RemoteHost = strRemoteHost
tcpClient.RemotePort = strRemotePort
tcpClient.Connect
End If
End If

If gblnIsServer = True Then
stbrMain.Panels(1).Text = "Response Reader is reading SMS from
SIM"

''Read All SMS from GSM Device Sim Slots

COMnSIM

''Send to SIM
'ReadSMSFromDB gblnIsServer, False
Else
LstItemCrntStatus.ListSubItems(1).Bold = True
LstItemCrntStatus.SubItems(1) = fnc_strDots()
End If


stbrMain.Panels(1).Text = "Response Reader is reading Response(s)"

'Change by Ketan On Dt : 07/02/2005
If gblnIsServer = True Then
'ReadSMSFromDB gblnIsServer, False 'Comment by Ketan on dt :
09/02/2005
End If



' lvwOnScreen(0).ListItems.Clear

stbrMain.Panels(1).Text = "Response Reader is reading Request(s)"

'Change by Ketan On Dt : 07/10/2005
If gblnIsServer = True Then
'ReadSMSFromDB gblnIsServer, True 'Comment by Ketan on Dt :
09/02/2005
End If

If gblnIsServer = True Then
stbrMain.Panels(1).Text = "Idle Mode"
' Sleep 10000 '10 seconds
Wait 10
End If

'' Following code is using cpu upto 100% because if condition in loop is
comparing time with Timer
'' which will use cpu to get current time for every time this line is
called
'' ''24th May 2004
'' ''Wait for 10 seconds
'' If gblnIsServer = True Then
'' stbrMain.Panels(1).Text = "Idle Mode"
'' Dim tmpTimer As Variant
''TTPWait10Sec:
'' tmpTimer = "": tmpTimer = Timer + 10
'' Do Until Timer > tmpTimer: DoEvents: Loop
'' If Timer < tmpTimer Then GoTo TTPWait10Sec
'' tmpTimer = ""
'' End If
'' ''upto here


stbrMain.Panels(1).Text = ""

'If gblnStartDC = True Then
If gblnStopDC = True Then
tmrReadFromSIM.Enabled = False
Else
tmrReadFromSIM.Enabled = True
End If
Exit Sub

ErrH:
gstrW2S = "frmMain-->tmrReadFromSIM_Timer"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->tmrReadFromSIM_Timer", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
Resume Next
End Sub

Private Sub Wait(seconds As Integer)
Dim startTime As Date
Dim endTime As Date

startTime = Now
endTime = DateAdd("s", seconds, startTime)
Do While Now < endTime
Sleep 10: DoEvents
Loop
End Sub

'Private Function fncRequestToCOM(msCOM As MSComm, enmRType As
ENUM_RequestType, Optional intIndex As Integer) As Integer
Public Function fncRequestToCOM(msCOM As MSComm, enmRType As
ENUM_RequestType, Optional intIndex As Integer) As Integer
On Error GoTo ErrH

Select Case enmRType

Case 0 'Initialization

If GSMModem = VISIONTEK_FCT_ROUTER Then 'Added by Ketan On Dt
: 28/09/2005
msCOM.Output = "ATH" & vbCrLf
ElseIf GSMModem = MATRIX_GMS_ROUTER Then 'Added by Ketan On Dt
: 28/09/2005
msCOM.Output = "at+cmgf=1"
End If

Case 1 'ReadFromSIM

''MSCOM control will listen response of SIM
msCOM.Output = "AT+CMGR=" & intIndex & Chr(13)

Case 2 'SendToSIM

''vbCrLf - vbCr(set cursor to next line) + vbLf (insert one
line from current position of cursor)
' msCOM.Output = "AT+CMGS=" & SMSData.SMSDS_CallerID & vbCrLf &
SMSData.SMSDS_Response & Chr(26)

' msCOM.Output = "AT+CMGS=" & SMSData.SMSDS_CallerID & vbcr &
SMSData.SMSDS_Response & Chr(26)

If GSMModem = VISIONTEK_FCT_ROUTER Then
msCOM.Output = "AT+CMGS=" & SMSData.SMSDS_CallerID &
Chr(13) & SMSData.SMSDS_Response & Chr(26)
ElseIf GSMModem = MATRIX_GMS_ROUTER Then
msCOM.Output = "AT+CMGS=" & Chr(34) &
SMSData.SMSDS_CallerID & Chr(34) & Chr(13) & SMSData.SMSDS_Response &
Chr(26)
End If

Case 3 'DeleteFromSIM
msCOM.Output = "AT+CMGD=" & intIndex & vbCrLf
Sleep 200

Case 4 'Hangup Line
msCOM.Output = "ATH" 'Hangup Line

End Select

Exit Function

ErrH:
gstrW2S = "frmMain-->fncRequestToCOM "
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->fncRequestToCOM", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Function

''Following Functions and Procedures are for communication with SIM
Private Sub msCOMMSIM_OnComm()
On Error GoTo ErrH

DataRVFPort = True
If ErrorFound() = True Then
'If Len(FrmOnlineStatus.txtFault.Text) > 30000 Then
FrmOnlineStatus.txtFault.Text = Right(FrmOnlineStatus.txtFault.Text,
Len(FrmOnlineStatus.txtFault.Text) - 5000)
'FrmOnlineStatus.txtFault.Text = "Output One -> " &
FrmOnlineStatus.txtFault.Text & mErrorMsg & vbCrLf & "Error corrected." &
" - " & Now & vbCrLf
'FrmOnlineStatus.txtFault.SelStart =
Len(FrmOnlineStatus.txtFault.Text)
Else
Select Case msCOMMSIM.CommEvent
' Events
Case comEvCD ' Change in the CD line.
Case comEvCTS ' Change in the CTS line.
Case comEvDSR ' Change in the DSR line.
Case comEvRing ' Change in the Ring Indicator.
Case comEvReceive ' Received RThreshold # of chars.
WriteSMDRDataOutPut
Case comEvSend ' There are SThreshold number of characters in
the transmit buffer.
Case comEvEOF ' An EOF charater was found in ' the input
stream
End Select
End If
DataRVFPort = False
Exit Sub

ErrH:
gstrW2S = "frmMain-->msCOMMSIM_OnComm"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->msCOMMSIM_OnComm", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Function ErrorFound() As Boolean

'Dim mErrorFound As Boolean
Select Case msCOMMSIM.CommEvent
' Errors
Case comEventBreak ' A Break was received.
mErrorMsg = "Communication Break received." & vbCrLf & "Please
check cable connection."
Case comEventCDTO ' CD (RLSD) Timeout.
mErrorMsg = "CD (RLSD) Timeout."
Case comEventCTSTO ' CTS Timeout.
mErrorMsg = "CTS Timeout."
Case comEventDSRTO ' DSR Timeout.
mErrorMsg = "DSR Timeout."
Case comEventFrame ' Framing Error
mErrorMsg = "Framing Error"
Case comEventOverrun ' Data Lost.
mErrorMsg = "Data Overrun: Changing to Overdrive State."
Case comEventRxOver ' Receive buffer overflow.
mErrorMsg = "Data Received: Changing to Overdrive State."
Case comEventRxParity ' Parity Error.
mErrorMsg = "Parity Error."
Case comEventTxFull ' Transmit buffer full.
mErrorMsg = "Transmit buffer full."
Case comEventDCB ' Unexpected error retrieving DCB
mErrorMsg = "Unexpected Communication Error. Corrected!"
Case Else
ErrorFound = False
Exit Function
End Select
ErrorFound = True
End Function

Private Sub WriteSMDRDataOutPut()
On Error GoTo ErrH
Dim splt

Dim ComString As Variant
Dim strCallText As Variant
Dim intTemp1%, varTempData, arrParseData() As String, varTemp
Dim cCallerNAME As String
Dim strCmdToolTip
Dim lngErrNo As Long, strErrDesc As String, strErrSrc As String
Dim bytServerValue
Dim strFilter As String
Dim AlertWindow As frmAlertWindow 'Added by Ketan on dt : 13/07/2005
for New Popup style


Dim sSlotNo As String

strCallText = "": ComString = ""
'Sleep 100

'Get SMS Value from GSM Modem
'==============================

ComString = msCOMMSIM.Input ': txtOutput.Text = txtOutput.Text &
vbCrLf & ComString
'==============================


'***************************************************************************************************
'Developer : Ketan Jadhav On Dt : 11/04/2006
'Purpose : Read SMS when new message arrived.

'***************************************************************************************************

If ComString Like "*+CMTI: " & Chr(34) & "SM" & Chr(34) & "*" Then
splt = Split(ComString, ",")
If UBound(splt) > 0 Then
sSlotNo = splt(UBound(splt))
sSlotNo = Replace(sSlotNo, "", Chr(13))
splt = Split(sSlotNo, Chr(13))

'Reading is ON then exit sub
If gblnStopDC <> True Or gblnIterationIsOn = True Then
Exit Sub
End If

sSlotNo = splt(0)

If IsNumeric(sSlotNo) = True Then

'Set SMS Data entry type to blank
'====================================
MakeSMSDataEmpty
MakeOtherVariablesEmpty
'====================================

''Read From SIM
bytLastCmd = enmReadFromSIM: mstrInputOne = ""

Call fncRequestToCOM(msCOMMSIM, enmReadFromSIM,
CInt(sSlotNo))


'=========================================================
'''' Wait for few seconds

'=========================================================
Dim tmpTimer
Dim rsReadSMS As New ADODB.Recordset
Dim strReadSMS As String
Dim lstID As Integer

tmpTimer = "": tmpTimer = Timer + constWait4Reply
Do Until Timer > tmpTimer
If blnGoForRespGen = True Then tmpTimer = "": Exit Do
DoEvents
Loop

tmpTimer = ""


'=========================================================
'Get SMS from Sim Card

'=========================================================
Call Timer5_Timer

'=========================================================

If Len(SMSData.SMSDS_SenderName) = 0 Then
SMSData.SMSDS_SenderName = "Unknown"
''Insert new (unknown) caller id in contacts
InsertUpdateContacts True, "ud_InsertAB", "Unknown",
"Unknown", "Unknown", "Unknown", SMSData.SMSDS_CallerID,
Str(udfGenDetail.udftGenDet_GeneralGrpID), AuthorityPerson
End If

SMSData.SMSDS_Request = Replace(SMSData.SMSDS_Request,
"OKRING", "") 'Filter.... extra character
SMSData.SMSDS_Request = Replace(SMSData.SMSDS_Request,
"OK+CMTI", "") 'Filter.... extra character

'Add new SMS Entry Here
fncInsertInTo SMSData.SMSDS_RequestDT, 1,
SMSData.SMSDS_Request, 0, SMSData.SMSDS_CallerID,
SMSData.SMSDS_SenderName, gstrComputerName, IIf(mblnDenyShowOnScreen =
True, 1, 0)

'Added by KEtan On Dt : 09/02/2005
'Get Last Message ID

'=====================================================================================
If dbProvider = enmSQL Then
strReadSMS = "Select max(ST_ID) From SMSTransaction"
ElseIf dbProvider = enmAccess Then
strReadSMS = "Select max(st_id) From SMSTransaction"
End If

If rsReadSMS.State = adStateOpen Then rsReadSMS.Close
rsReadSMS.CursorLocation = adUseClient
rsReadSMS.Open strReadSMS, ZIDLL.cnDB, adOpenForwardOnly,
adLockReadOnly, adCmdText

If rsReadSMS.RecordCount > 0 Then
lstID = IIf(IsNull(rsReadSMS.Fields(0)), 1,
rsReadSMS.Fields(0))
Else
lstID = 1
End If

If rsReadSMS.State = adStateOpen Then
rsReadSMS.Close
End If

Set rsReadSMS = Nothing

'======================================================================================

'Write BroadCast SMS to All Clients.... added by Ketan On
Dt : 09/02/2005

'==========================================================================
Call fncBroadCast_SMS(ZDLL.AV(lstID),
ZDLL.AV(SMSData.SMSDS_Request), ZDLL.AV(SMSData.SMSDS_SenderName),
ZDLL.AV(SMSData.SMSDS_CallerID), ZDLL.AV(SMSData.SMSDS_RequestDT),
ZDLL.AV("0"))


ZDLL.SaveToIni ZConfigurationINI, "LastID", "ServerResp",
ZDLL.AV(lstID)

'Show New Message on Server Response Screen... added by
Ketan On Dt : 09/02/2005

'================================================================================
ShowOnScreen enmResponse, ZDLL.AV(SMSData.SMSDS_CallerID),
ZDLL.AV(SMSData.SMSDS_SenderName), ZDLL.AV(SMSData.SMSDS_Request),
ZDLL.AV("0"), ZDLL.AV(Format(SMSData.SMSDS_RequestDT, "DD/mm/yyyy
HH:MM:SS"))


'************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new Popup Style

'************************************************************************
'Dim AlertWindow As frmAlertWindow 'Added by Ketan on dt :
13/07/2005 for New Popup style
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)

If Len(Trim(SMSData.SMSDS_Request)) > 0 Then
strCmdToolTip = " You have a new SMS(s)" & vbCrLf &
"SMS From : " & SMSData.SMSDS_SenderName & vbCrLf & " Caller ID: " &
SMSData.SMSDS_CallerID & vbCrLf & "Date Time: " &
Format(SMSData.SMSDS_RequestDT, "DD/mm/yyyy HH:MM:SS") & vbCrLf & vbCrLf &
"Message: " & SMSData.SMSDS_Request
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False
End If

'************************************************************************


'============================================================
'Delete SMS from GSM Modem Sim Slot

'============================================================
bytLastCmd = enmDeleteFromSIM: mstrInputOne = ""
Call fncRequestToCOM(msCOMMSIM, enmDeleteFromSIM,
CInt(sSlotNo))

End If

End If
End If



'***************************************************************************************************
'Developer : Ketan Jadhav On Dt : 12/07/2005
'Purpose : Display Popup Alert message on Server and Every Client PC
of Dialing Number,
' Incomming Call and Hangup call


'***************************************************************************************************

'----------------------------------------
'Call Hangup.... Alert.... Message...
'----------------------------------------
If ComString Like "*ATH*" Then

bytServerValue = ZDLL.GetFromIni(ZConfigurationINI,
"ApplicationType", "Server")

strCmdToolTip = vbCrLf & vbCrLf & " GSM Line is free now..." &
vbCrLf

fncBroadCast_CALL ZDLL.AV(strCmdToolTip) 'Broadcast Caller Number
to all client...

If bytServerValue = 1 Then


'**************************************************************************************
'Comment by Ketan On Dt : 13/07/2005

'**************************************************************************************
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " " & Chr(34) &
strCmdToolTip & Chr(34)
'Shell strCmdToolTip, vbNormalFocus

'**************************************************************************************


'**************************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new Popup Style

'**************************************************************************************

If ZDLL.GetFromIni(ZConfigurationINI, "Notification",
"LINEFREE", "1") = "1" Then
Set AlertWindow = New frmAlertWindow

m_iBackColor = RGB(160, 195, 255)
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False
End If

'**************************************************************************************

End If

End If

'------------------------
'Dialing.... alert...
'------------------------
If ComString Like "*ATD*" Then

Debug.Print ComString & " Input Len : " & msCOMMSIM.InputLen & "
Buffer : " & msCOMMSIM.InBufferCount
splt = Split(ComString, "ATD")

If UBound(splt) = 1 Then

strFilter = Mid(splt(1), 1, InStr(1, splt(1), ";"))
splt(1) = strFilter
splt(1) = Replace(splt(1), ";", "")

cCallerNAME = fncGetSenderNameFromDB(ZDLL.AV(splt(1)))


bytServerValue = ZDLL.GetFromIni(ZConfigurationINI,
"ApplicationType", "Server")

strCmdToolTip = vbCrLf & " Dailing to ..." & vbCrLf & vbCrLf &
" Date Time : " & Format(Now, "dd/MM/yyyy hh:mm:ss") & vbCrLf & " Number :
" & splt(1) & vbCrLf & " Name : " & cCallerNAME

txtCommStatus.Text = txtCommStatus.Text & vbCrLf &
strCmdToolTip

fncBroadCast_CALL ZDLL.AV(strCmdToolTip) 'Broadcast Caller
Number to all client...

If bytServerValue = 1 Then

'**************************************************************************************
'Comment by Ketan On Dt : 13/07/2005

'**************************************************************************************
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " " &
Chr(34) & strCmdToolTip & Chr(34)
'Shell strCmdToolTip, vbNormalFocus

'**************************************************************************************


'**************************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new Popup Style

'**************************************************************************************
If ZDLL.GetFromIni(ZConfigurationINI, "Notification",
"OUTGOINGCALL", "1") = "1" Then
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False
End If

'**************************************************************************************

End If

End If
End If

'----------------------------------------
'Incomming Call..... alert....
'----------------------------------------
If ComString Like "*CLIP*" Then
splt = Split(ComString, Chr(34))

If UBound(splt) > 1 Then
Debug.Print "Call Detected.... " & splt(1)

cCallerNAME = fncGetSenderNameFromDB(ZDLL.AV(splt(1)))

bytServerValue = ZDLL.GetFromIni(ZConfigurationINI,
"ApplicationType", "Server")

strCmdToolTip = vbCrLf & " Calling From ... " & vbCrLf &
vbCrLf & " Date Time : " & Format(Now, "dd/MM/yyyy hh:mm:ss") & vbCrLf & "
Caller ID: " & splt(1) & vbCrLf & " Caller Name : " & cCallerNAME

txtCommStatus.Text = txtCommStatus.Text & vbCrLf &
strCmdToolTip

If Len(Trim(glbCallerID)) = 0 Then
fncBroadCast_CALL ZDLL.AV(strCmdToolTip) 'Broadcast
Caller Number to all client...
End If

If bytServerValue = 1 Then


'**************************************************************************************
'Comment by Ketan On Dt : 13/07/2005

'**************************************************************************************
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " " &
Chr(34) & strCmdToolTip & Chr(34)
'Shell strCmdToolTip, vbNormalFocus

'**************************************************************************************

If Len(Trim(glbCallerID)) = 0 Then

'**************************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new Popup
Style

'**************************************************************************************
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False

'**************************************************************************************
glbCallerID = splt(1)
End If

End If
Else
ComString = ComString & " -> Call not detected...."
WriteToFile ZLOG_FILE_PATH, ZDLL.AV(ComString)
End If
Else
'WriteToFile ZLOG_FILE_PATH, ZDLL.AV("Clip Not Found")
End If

'*********************************** Up to here
************************************************

mstrInputOne = mstrInputOne & ComString 'for Live Processing

strCallText = mstrInputOne


''Check success of Initialization command - 0
''output should be ATHvbcrlfvbcrlfOKvbcrlfs

If bytLastCmd = 0 Then

If GSMModem = VISIONTEK_FCT_ROUTER Then 'Added by Ketan On Dt :
28/09/2005
If UCase(Mid(mstrInputOne, 1, 3)) = UCase("ATH") Then
If UCase(Mid(mstrInputOne, 8, 2)) = UCase("OK") Then
blnGoForRead = True
WriteToFile SMDR_OUTPUT_PATH, " Initialized : " &
CStr(strCallText)
End If
End If
ElseIf GSMModem = MATRIX_GMS_ROUTER Then 'Added by Ketan On Dt :
28/09/2005
If UCase(Mid(mstrInputOne, 1, 9)) = UCase("AT+CMGF=1") Then
'If UCase(Mid(mstrInputOne, 8, 2)) = UCase("OK") Then
blnGoForRead = True
WriteToFile SMDR_OUTPUT_PATH, " Initialized : " &
CStr(strCallText)
'End If
End If
End If

''Check success of Read command - 1
ElseIf bytLastCmd = 1 Then
''Check for +CMGR:

arrParseData = Split(strCallText, ",")

''Check for SMS UnRead
'If UCase(Right(arrParseData(0), 7)) = UCase("UNREAD") & Chr(34)
Then

If UCase(Right(arrParseData(0), 5)) = UCase("READ") & Chr(34)
Then
''Check for Caller ID (Otherendaddress)
SMSData.SMSDS_CallerID = Replace(arrParseData(1), Chr(34),
"")

'don't read from sim, read from [addressbook] table
'SMSData.SMSDS_SenderName = IIf(Len(arrParseData(2)) > 0,
arrParseData(2), "Unknown Sender")
''Search caller id in array, if not available then search in
database

'==========================================================================================
If Len(SMSData.SMSDS_CallerID) > 0 Then
SMSData.SMSDS_SenderName =
fncGetSenderNameFromArr(SMSData.SMSDS_CallerID)
If Len(Trim(SMSData.SMSDS_SenderName)) = 0 Then
SMSData.SMSDS_SenderName =
fncGetSenderNameFromDB(SMSData.SMSDS_CallerID)
End If
End If

''Check for date
arrParseData(3) = Replace(arrParseData(3), Chr(34), "")
SMSData.SMSDS_RequestDT =
Format(DateSerial(Mid(arrParseData(3), 1, 2), Mid(arrParseData(3), 4, 2),
Mid(arrParseData(3), 7, 2)), "yyyy-MM-dd")

''check for time
varTempData = Replace(Mid(arrParseData(4), 1, InStr(1,
arrParseData(4), Chr(34))), Chr(34), "")
varTempData = Format(Left(varTempData, 8), "HH:mm:ss")

SMSData.SMSDS_RequestDT = SMSData.SMSDS_RequestDT & " " &
varTempData

''check for Request
varTempData = Mid(arrParseData(4), InStr(1, arrParseData(4),
Chr(34)) + 1, Len(arrParseData(4)))
varTempData = Replace(varTempData, vbCrLf, "")
If UCase(Right(varTempData, 2)) = UCase("OK") Then
varTempData = Mid(varTempData, 1, Len(varTempData) - 2)
End If

If UBound(arrParseData) > 4 Then
Dim i As Byte

For i = 5 To UBound(arrParseData)
'arrParseData (i)
arrParseData(i) = Mid(arrParseData(i), 1,
InStr(arrParseData(i), vbCrLf & vbCrLf & "OK") - 1)
varTemp = Replace(arrParseData(i), vbCrLf, "")

varTempData = varTempData & "," & varTemp
Next i
End If

'sometimes varTempData contains OK+CMTI: "SM",1 - use
following lines to avoid this data
Dim intCnt As Integer
intCnt = InStr(varTempData, "OK+CMTI:")
If intCnt > 0 Then
varTempData = Mid(varTempData, 1, intCnt)
End If

SMSData.SMSDS_Request = varTempData
'OK+CMTI: "SM",1
blnGoForRespGen = True
WriteToFile SMDR_OUTPUT_PATH, " Read : " & CStr(strCallText)
ElseIf InStr(strCallText, "ERROR") > 0 Then
blnGoForNextIteration = True
End If

''Check success of Send command - 2
ElseIf bytLastCmd = 2 Then
arrParseData = Split(strCallText, Chr(26))
varTempData = Replace(arrParseData(1), vbCrLf, "")
If Left(UCase(Trim(varTempData)), 6) = UCase("+CMGS:") Then
blnGoForDelete = True

SMSData.SMSDS_ResponseDT = Format(Now, "dd/MM/yyyy HH:mm:ss"):
SMSData.SMSDS_Status = "Completed"
'FillSMS FT_UPDATE: FillOnlineStatus SMSData.SMSDS_Type
WriteToFile ZLOG_FILE_PATH, "Caller ID : " &
SMSData.SMSDS_CallerID & ", Response : " & SMSData.SMSDS_Response & ",
Date Time : " & SMSData.SMSDS_ResponseDT
WriteToFile SMDR_OUTPUT_PATH, " Sent : " & CStr(strCallText)
' fncUpdateInTo CDate(SMSData.SMSDS_ResponseDT),
SMSData.SMSDS_Response, SMSData.SMSDS_Status,
fncintGet_TimeUnit(enmSecond, CDate(SMSData.SMSDS_ResponseDT)) -
fncintGet_TimeUnit(enmSecond, CDate(SMSData.SMSDS_RequestDT))
End If
''Check success of Delete command - 2
ElseIf bytLastCmd = 3 Then
strCallText = Replace(strCallText, vbCrLf, "")
If Right(UCase(Trim(strCallText)), 2) = UCase("OK") Then
blnGoForNextIteration = True
WriteToFile SMDR_OUTPUT_PATH, " Deleted : " &
CStr(strCallText)
End If
End If
''Upto Here
Exit Sub

ErrH:
' Resume
lngErrNo = Err.Number
strErrDesc = Err.Description
strErrSrc = Err.Source

If Not (Err.Number = 9 Or Err.Number = 5 Or Err.Number = 13) Then
gstrW2S = "frmMain-->WriteSMDROutput"
'gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description &
"|" & Err.Source
gstrW2S = gstrW2S & "|" & lngErrNo & "|" & strErrDesc & "|" &
strErrSrc
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->WriteSMDRDataOutPut", ErroLog, False,
strErrDesc, lngErrNo, strErrDesc, strErrSrc)
End If
If Err.Number = 52 Or Err.Number = 76 Or Err.Number = 70 Then Resume
Next
'Resume
Resume Next
End Sub

Private Function GetProperDate(strDate As String) As String
On Error GoTo ErrH

Dim strTempDate As String, strYear$, strMonth$, strDay$

strTempDate = strDate
''Remove Non-Numeric Characters
While Not IsNumeric(Left$(strTempDate, 1)) And Len(strTempDate) > 0
'And Left$(strTempDate, 1) <> Chr(32)
strTempDate = Right(strTempDate, Len(strTempDate) - 1)
Wend
''Get Year
strYear = Mid(strTempDate, 1, 2)
''Get Month
strMonth = Mid(strTempDate, 4, 2)
''Get Day
strDay = Mid(strTempDate, 7, 2)

strTempDate = strDay & "/" & strMonth & "/" & strYear
strTempDate = Format(strTempDate, "dd/MM/yyyy")
GetProperDate = CDate(strTempDate)
Exit Function

ErrH:
Call LogEntry("frmMain-->GetProperDate", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Function


Public Sub StartCommunication()
On Error GoTo ErrH

If Port_Initialized = True Then
'Changed by Ketan On Dt : 28/09/2005
If OpenPort = True Then
Timer5.Enabled = True
WriteToFile ZLOG_FILE_PATH, "COM Port is Opened"
WriteToScreen txtCommStatus, "COM Port is Opened"
mbolDCStatus = True
Else
WriteToFile ZErrLog_FILE, "COM Port is not opened"
WriteToScreen txtCommStatus, "COM Port is not opened"
mbolDCStatus = False
End If


Else
mbolDCStatus = False
End If
Exit Sub

ErrH:
gstrW2S = "frmMain-->StartCommunication"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->StartCommunication", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
Resume Next
End Sub

Public Function Port_Initialized() As Boolean
On Error GoTo ErrH

Dim commport As String
Dim Handshaking As String
Dim Settings As String


Settings = ZDLL.GetFromIni(ZConfigurationINI, "COMSettings",
"BaudRate", 9600) & ","
Settings = Settings & Left(ZDLL.GetFromIni(ZConfigurationINI,
"COMSettings", "Parity", "None"), 1) & ","
Settings = Settings & ZDLL.GetFromIni(ZConfigurationINI,
"COMSettings", "DataBits", 8) & ","
Settings = Settings & ZDLL.GetFromIni(ZConfigurationINI,
"COMSettings", "StopBits", 1)

Handshaking = ZDLL.GetFromIni(ZConfigurationINI, "COMSettings",
"FlowControl", 0)
commport = Right(ZDLL.GetFromIni(ZConfigurationINI, "COMSettings",
"COMPort", 0), 1)

'SMDR_OUTPUT_PATH = ZDLL.GetFromIni(ZConfigurationINI, "COMSettings",
"BufferFile", App.Path & "\Caracas\host.ft#")
SMDR_OUTPUT_PATH = ZDLL.GetFromIni(ZConfigurationINI, "COMSettings",
"BufferFile", App.Path & "\ZCOMLog.txt")
msCOMMSIM.RThreshold = MAX_REC_LEN
msCOMMSIM.SThreshold = 0

If Trim(Settings) <> "" Then
msCOMMSIM.Settings = Settings
Else
MsgBox "There was an error setting default values for COM-Port." &
vbCrLf & "Data capture could not be started" & vbCrLf & vbCrLf & "Please
select proper COM-Port settings and start Data Capture again",
vbExclamation
Exit Function
End If
If Trim(Handshaking) <> "" Then
msCOMMSIM.Handshaking = Handshaking
Else
MsgBox "There was an error setting COM-Port values" & vbCrLf &
"Data capture could not be started." & vbCrLf & vbCrLf & "Please select
proper COM-Port settings and start Data Capture again", vbExclamation
Exit Function
End If
If commport > 0 Then
msCOMMSIM.commport = commport
Else
MsgBox "There was an error setting default COM-Port values" &
vbCrLf & "Data capture could not be started" & vbCrLf & vbCrLf & "Please
select proper COM-Port settings and start Data Capture again",
vbExclamation
Exit Function
End If
Port_Initialized = True
Exit Function

ErrH:
gstrW2S = "frmMain-->Port_Initialized"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->Port_Intialized", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
Resume Next
End Function

Public Function OpenPort() As Boolean
On Error GoTo ErrH

If msCOMMSIM.PortOpen = False Then
msCOMMSIM.RThreshold = MAX_REC_LEN: msCOMMSIM.DTREnable = True
msCOMMSIM.PortOpen = True: mbolDCStatus = False
If Err Then
MsgBox "There was an error opening COM-Port"
mbolDCStatus = True
OpenPort = False
Exit Function
End If
'Me.Caption = App.Title & " [ SMS'ing : ON ]"
'frmMain.MnuStartCOMPort.Caption = "&Stop SMS'ing"
'Tray.MnuStartStopDC.Caption = "&Stop SMS'ing"
'Me.Caption = App.Title & " [ Response Reader : ON ]"
frmMain.MnuStartCOMPort.Caption = "&Stop Response Reader"
'Tray.MnuStartStopDC.Caption = "&Stop Response Reader"
End If
mbolDCStatus = False
OpenPort = True
Exit Function

ErrH:
OpenPort = False
gstrW2S = "frmMain-->OpenPort"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S

'Changed by Ketan On dt : 28/09/2005
Call LogEntry("frmMain-->OpenPort", ErroLog, False, Err.Description,
Err.Number, Err.Description, Err.Source)

End Function

'----------------------------------------
Public Sub Timer5_Timer()
On Error GoTo ErrH

Dim INT_STRING_LENGTH As Integer


'To periodically flush whole data from input buffer to mstrinput
If DataRVFPort = True Then Exit Sub
'For Port One
INT_STRING_LENGTH = msCOMMSIM.RThreshold
With msCOMMSIM
If .InBufferCount > 0 Then 'And .InBufferCount < MAX_REC_LEN And
msCOMMSIM.RThreshold <> 1 Then
.RThreshold = 0
If .InBufferCount Then
.InputLen = .InBufferCount

'Read SMS via Com Port from GSM Modem
'====================================
WriteSMDRDataOutPut
'====================================
End If
.RThreshold = MAX_REC_LEN
End If
End With
Exit Sub

ErrH:
gstrW2S = "frmMain-->Timer5_Timer"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Resume Next
End Sub

Public Function ClosePort() As Boolean
On Error GoTo ErrH

If msCOMMSIM.PortOpen = True Then
msCOMMSIM.PortOpen = False: mbolDCStatus = True
Timer5.Enabled = False

'Me.Caption = App.Title & " [SMS'ing : OFF ]"
'Me.Caption = App.Title & " [Response Reader : OFF ]"

MnuStartCOMPort.Caption = "&Start COM Port"
'frmMain.MnuStartSMSing.Caption = "&Start SMS'ing"

WriteToFile ZLOG_FILE_PATH, "COM Port is Closed"
WriteToScreen txtCommStatus, "COM Port is Closed"
End If
Exit Function

ErrH:
gstrW2S = "frmMain-->ClosePort"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->ClosePort", ErroLog, True, Err.Description,
Err.Number, Err.Description, Err.Source)
Resume Next
End Function

Private Sub GenerateResponse(strReq As String, Optional blnShowInList As
Boolean = False)
On Error GoTo ErrH

'Dim strTemp$,
Dim arrGenResp() As String, blnIsRespGenrated As Boolean
Dim blnCommCriteria As Boolean
Dim nCnt As Integer

strResp1 = "": strResp2 = ""

If Len(SMSData.SMSDS_CallerID) < 5 Then blnGoForDelete = True: Exit
Sub
If Len(strReq) = 0 Then
'strResp1 = "Your request does not match pre-defined format,
re-format it" _
' & " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>, PAI
<pfcode>, BLI <bill no.>"
'blnGoForSend = True: FillSMS FT_ADD: Exit Sub
blnGoForSend = True: Exit Sub
End If

arrGenResp = Split(strReq, " ")
SMSData.SMSDS_Type = arrGenResp(0)
If UBound(arrGenResp) < 1 Then
'strResp1 = "Your request does not match pre-defined format,
re-format it" _
' & " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>, PAI
<pfcode>, BLI <bill no.>"
'blnGoForSend = True: FillSMS FT_ADD
blnGoForSend = True ': FillSMS FT_ADD
'SMSData.SMSDS_Status = "Pending..."
'If (InStr(SMSData.SMSDS_Request, "'") <= 0) Or
(InStr(SMSData.SMSDS_Type, "'") <= 0) Then
' blnIsRespGenrated =
fncInsertInTo(CDate(SMSData.SMSDS_RequestDT), SMSData.SMSDS_Type,
SMSData.SMSDS_Request, SMSData.SMSDS_Status, SMSData.SMSDS_CallerID)
'End If
Exit Sub
ElseIf Len(arrGenResp(1)) = 0 Then
'strResp1 = "Your request does not match pre-defined format,
re-format it" _
' & " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>, PAI
<pfcode>, BLI <bill no.>"
blnGoForSend = True ': FillSMS FT_ADD
'fncInsertInTo CDate(SMSData.SMSDS_RequestDT), SMSData.SMSDS_Type,
SMSData.SMSDS_Request, SMSData.SMSDS_Status, SMSData.SMSDS_CallerID
Exit Sub
End If

'SMSInfo.PF_ID = arrGenResp(1)
Dim strCriteria As String, arrCriteria() As String
Dim strSRCHContactName As String, strSRCHCallerID As String


If UCase(SMSData.SMSDS_Type) = UCase("SRCH") Then
strCriteria = Mid(strReq, Len(SMSData.SMSDS_Type) + 1,
Len(strReq))
If InStr(strCriteria, ",") > 0 Then
strCriteria = arrGenResp(1)
arrCriteria = Split(strCriteria, ",")
blnCommCriteria = True
Else
strCriteria = Trim(strCriteria)
blnCommCriteria = False
End If
End If

' If UBound(arrCriteria) < 1 Then
' blnGoForSend = True: Exit Sub
' ElseIf Len(arrCriteria(1)) = 0 Then
' blnGoForSend = True: Exit Sub
' End If

If blnCommCriteria = True Then
'Select Case UBound(arrCriteria)
' Case 1
strSRCHContactName = arrCriteria(0)
' Case 2
strSRCHCallerID = arrCriteria(1)
' Case Else
'strSRCHContactName = arrCriteria(0)
' strSRCHContactName = strCriteria
'End Select
Else
strSRCHContactName = strCriteria
End If

'SMSData.SMSDS_Status = "Pending..."
WriteToFile ZLOG_FILE_PATH, "Caller ID : " & SMSData.SMSDS_CallerID &
", Request : " & SMSData.SMSDS_Request & ", Date Time : " &
SMSData.SMSDS_RequestDT

'' If blnShowInList = True Then
'' 'FillSMS FT_ADD
'' If (InStr(SMSData.SMSDS_Request, "'") <= 0) Or
(InStr(SMSData.SMSDS_Type, "'") <= 0) Then
'' blnIsRespGenrated =
fncInsertInTo(CDate(SMSData.SMSDS_RequestDT), SMSData.SMSDS_Type,
SMSData.SMSDS_Request, SMSData.SMSDS_Status, SMSData.SMSDS_CallerID)
'' End If
'' DoEvents
'' End If
''
'' If blnIsRespGenrated = False Then
'' strResp1 = "Unable to connect to server. System shall send your
reply when reconnected": blnGoForSend = True: Exit Sub
'' Else
'' If ZIDLL.GET_Information(SMSInfo.PF_ID, CODE, ZC_SMS,
CT_EqualTo) <> SMSInfo.PF_ID Then
'' If UCase(SMSData.SMSDS_Type) = UCase("BLI") Then
'' strResp1 = "Sorry, This Bill No. does not exist, Please
Contact Your Divisional Finance Manager"
'' ElseIf UCase(SMSData.SMSDS_Type) = UCase("PFI") Or
UCase(SMSData.SMSDS_Type) = UCase("PLI") Or UCase(SMSData.SMSDS_Type) =
UCase("PNI") Or UCase(SMSData.SMSDS_Type) = UCase("PAI") Then
'' strResp1 = "Sorry, This PF No. does not exist, Please
Contact Your Divisional Finance Manager"
'' Else
'' strResp1 = "Your Request does not match pre-defined
format, re-format it" _
'' & " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>,
PAI <pfcode>, BLI <bill no.>"
'' End If
'' blnGoForSend = True: Exit Sub
'' End If
'' End If

Select Case UCase(SMSData.SMSDS_Type)
'' Case UCase("PFI")
'' SMSInfo.PFBalance = ZIDLL.GET_Information(SMSInfo.PF_ID,
PFBalance, ZC_SMS, CT_EqualTo)
'' strResp1 = "Your PF Balance as on Date is Rs. " +
SMSInfo.PFBalance
'' Case UCase("PNI")
'' SMSInfo.PPONumber = ZIDLL.GET_Information(SMSInfo.PF_ID,
PPONumber, ZC_SMS, CT_EqualTo)
'' SMSInfo.PPODate = ZIDLL.GET_Information(SMSInfo.PF_ID,
PPODate, ZC_SMS, CT_EqualTo)
'' SMSInfo.PensionAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
PensionAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.EnhancedFamilyPension =
ZIDLL.GET_Information(SMSInfo.PF_ID, EnhancedFamilyPension, ZC_SMS,
CT_EqualTo)
'' SMSInfo.NormalFamilyPension =
ZIDLL.GET_Information(SMSInfo.PF_ID, NormalFamilyPension, ZC_SMS,
CT_EqualTo)
'' SMSInfo.CommutedPensionAmount =
ZIDLL.GET_Information(SMSInfo.PF_ID, CommutedPensionAmount, ZC_SMS,
CT_EqualTo)
'' SMSInfo.NetPayablePensionAmount =
ZIDLL.GET_Information(SMSInfo.PF_ID, NetPayablePensionAmount, ZC_SMS,
CT_EqualTo)
'' SMSInfo.CommutationAmount =
ZIDLL.GET_Information(SMSInfo.PF_ID, CommutationAmount, ZC_SMS,
CT_EqualTo)
'' SMSInfo.DCRGAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
DCRGAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.PFSettlementAmount =
ZIDLL.GET_Information(SMSInfo.PF_ID, PFSettlementAmount, ZC_SMS,
CT_EqualTo)
'' SMSInfo.DLIAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
DLIAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.GISAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
GISAmount, ZC_SMS, CT_EqualTo)
''
'' 'Got all values...
'' Dim strUserDataORG As String, strUserData As String
''
'' strUserDataORG = "Case Passed, Your PPO No:" &
SMSInfo.PPONumber & ", Dt." & SMSInfo.PPODate & ", Pen.:Rs." &
SMSInfo.PensionAmount _
'' & ", EFPen:Rs." & SMSInfo.EnhancedFamilyPension & ",
NFPen:Rs." & SMSInfo.NormalFamilyPension & ", CommPen:Rs." &
SMSInfo.CommutedPensionAmount & " ..."
'' strResp1 = strUserDataORG
''
'' strUserDataORG = ", NetPen:Rs." &
SMSInfo.NetPayablePensionAmount & ", CommAmt:Rs." &
SMSInfo.CommutedPensionAmount & ", DCRG:Rs." & SMSInfo.DCRGAmount _
'' & ", PF Settl:Rs." & SMSInfo.PFSettlementAmount & ",
DLI:Rs." & SMSInfo.DLIAmount & ", GIS:Rs." & SMSInfo.GISAmount
'' strResp2 = strUserDataORG
''
'' 'strResp1 = strResp1 & strUserDataORG
'' Case UCase("PLI")
'' SMSInfo.HalfSetPass = ZIDLL.GET_Information(SMSInfo.PF_ID,
HalfSetPass, ZC_SMS, CT_EqualTo)
'' SMSInfo.LAP = ZIDLL.GET_Information(SMSInfo.PF_ID, LAP,
ZC_SMS, CT_EqualTo)
'' SMSInfo.LHAP = ZIDLL.GET_Information(SMSInfo.PF_ID, LHAP,
ZC_SMS, CT_EqualTo)
''
'' strResp1 = "The Pass to your Credit is " +
SMSInfo.HalfSetPass + " Sets, LAP to your Credit is " + SMSInfo.LAP + ",
LHAP to your Credit is " + SMSInfo.LHAP
'' Case UCase("PAI")
'' SMSInfo.ChequeNo = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeNo, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeDate = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeDate, ZC_SMS, CT_EqualTo)
''
'' SMSInfo.CO7Number = ZIDLL.GET_Information(SMSInfo.PF_ID,
CO7Number, ZC_SMS, CT_EqualTo)
'' SMSInfo.CO6Number = ZIDLL.GET_Information(SMSInfo.PF_ID,
CO6Number, ZC_SMS, CT_EqualTo)
'' SMSInfo.BillRegistrationNumber =
ZIDLL.GET_Information(SMSInfo.PF_ID, BillRegistrationNumber, ZC_SMS,
CT_EqualTo)
''
'' If Len(Trim(SMSInfo.ChequeNo)) = 0 Or
IsNull(SMSInfo.ChequeNo) = True Or SMSInfo.ChequeNo = Null Then
'' If Len(Trim(SMSInfo.CO7Number)) = 0 Or
IsNull(SMSInfo.CO7Number) = True Or SMSInfo.CO7Number = Null Then
'' If Len(Trim(SMSInfo.CO6Number)) = 0 Or
IsNull(SMSInfo.CO6Number) = True Or SMSInfo.CO6Number = Null Then
'' If Len(Trim(SMSInfo.BillRegistrationNumber)) = 0
Or IsNull(SMSInfo.BillRegistrationNumber) = True Or
SMSInfo.BillRegistrationNumber = Null Then
'' strResp1 = "Sorry, No such application has
been reigstered against your PF no. Please contact your Controlling
Officer"
'' Else
'' strResp1 = "Your information is Registered,
Please contact after 3 days"
'' End If
'' Else
'' strResp1 = "Case Registered, Your CO6 No. is " +
SMSInfo.CO6Number
'' End If
'' Else
'' strResp1 = "Case Passed, Your CO7 No. is " +
SMSInfo.CO7Number
'' End If
'' Else
'' strResp1 = "Your Cheque No. is " + SMSInfo.ChequeNo + ",
Cheque Amount is Rs. " + SMSInfo.ChequeAmount + ", Cheque Date is " +
SMSInfo.ChequeDate
'' End If
'' Case UCase("BLI")
'' SMSInfo.ChequeNo = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeNo, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeDate = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeDate, ZC_SMS, CT_EqualTo)
''
'' SMSInfo.CO7Number = ZIDLL.GET_Information(SMSInfo.PF_ID,
CO7Number, ZC_SMS, CT_EqualTo)
'' SMSInfo.CO6Number = ZIDLL.GET_Information(SMSInfo.PF_ID,
CO6Number, ZC_SMS, CT_EqualTo)
''
'' SMSInfo.BillRegistrationNumber =
ZIDLL.GET_Information(SMSInfo.PF_ID, BillRegistrationNumber, ZC_SMS,
CT_EqualTo)
'' SMSInfo.BillAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
BillAmount, ZC_SMS, CT_EqualTo)
''
'' If Len(Trim(SMSInfo.ChequeNo)) = 0 Or
IsNull(SMSInfo.ChequeNo) = True Or SMSInfo.ChequeNo = Null Then
'' If Len(Trim(SMSInfo.CO7Number)) = 0 Or
IsNull(SMSInfo.CO7Number) = True Or SMSInfo.CO7Number = Null Then
'' If Len(Trim(SMSInfo.CO6Number)) = 0 Or
IsNull(SMSInfo.CO6Number) = True Or SMSInfo.CO6Number = Null Then
'' strResp1 = "Your Bill has been registered,
Please contact after 3 days"
'' Else
'' strResp1 = "Your CO6 No. is " +
SMSInfo.CO6Number
'' End If
'' Else
'' strResp1 = "Your CO7 No. is " + SMSInfo.CO7Number
'' End If
'' Else
'' strResp1 = "Your Cheque No. is " + SMSInfo.ChequeNo + ",
Cheque Amount is Rs. " + SMSInfo.ChequeAmount + ", Cheque Date is " +
SMSInfo.ChequeDate
'' End If
Case UCase("SRCH")
'' If Len(Trim(strSRCHContactName)) > 0 Then
'' SMSInfo.SRCHResult =
ZIDLL.fncGeneric_GETInformation("AB_MobileNoALL", "AddressBook",
"AB_ContactPerson='" & strSRCHContactName & "'")
'' If SMSInfo.SRCHResult = 0 Then
'' strResp1 = strSRCHContactName & " is not available
in our Contact(s)"
'' Else
'' strResp1 = "Mobile No. of " & strSRCHContactName & "
is " & SMSInfo.SRCHResult
'' End If
'' ElseIf Len(Trim(strSRCHCallerID)) > 0 Then
'' SMSInfo.SRCHResult =
ZIDLL.fncGeneric_GETInformation("AB_ContactPerson", "AddressBook",
"AB_MobileNoALL='" & strSRCHCallerID & "'")
'' strResp1 = "Contact Person of Mobile No." &
strSRCHCallerID & " is " & SMSInfo.SRCHResult
'' End If
If Len(Trim(strSRCHContactName)) > 0 Then
If
ZIDLL.fncGeneric_GETInformation("AB_MobileNoALL,AB_ContactPerson",
"AddressBook", "AB_ContactPerson Like '%" & strSRCHContactName & "%'") = 0
Then
strResp1 = strSRCHContactName & " is not available in
our Contact(s)"
Else
For nCnt = 0 To ZIDLL.mIntRecCnt - 1
Call ZIDLL.fncGetData(nCnt)
If Len(strResp1) > 0 Then
strResp1 = strResp1 & "," & ZIDLL.gstrOutput2
& "-" & ZIDLL.gstrOutput1
Else
strResp1 = ZIDLL.gstrOutput2 & "-" &
ZIDLL.gstrOutput1
End If
Next nCnt
strResp1 = "Search result is as follows-" & vbCrLf &
strResp1
End If
ElseIf Len(Trim(strSRCHCallerID)) > 0 Then
If
ZIDLL.fncGeneric_GETInformation("AB_MobileNoALL,AB_ContactPerson",
"AddressBook", "AB_MobileNoALL Like '%" & strSRCHCallerID & "%'") = 0
Then
strResp1 = strSRCHCallerID & " is not available in our
Contact(s)"
Else
For nCnt = 0 To ZIDLL.mIntRecCnt - 1
Call ZIDLL.fncGetData(nCnt)
If Len(strResp1) > 0 Then
strResp1 = strResp1 & "," & ZIDLL.gstrOutput2
& "-" & ZIDLL.gstrOutput1
Else
strResp1 = ZIDLL.gstrOutput2 & "-" &
ZIDLL.gstrOutput1
End If
Next nCnt
strResp1 = "Search result is as follows-" & vbCrLf &
strResp1
End If
End If
End Select

''After handling the SMS with request and sending proper response...
''Delete that SMS from the MObile phone so that the space gets
freedup...
'Call SMSMemory_SIM.Delete(SMSMemory, index)
blnGoForSend = True
Exit Sub

ErrH:
Call LogEntry("frmMain.frm-->GenerateResponse", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub GetRequestCntUpToDate()
On Error GoTo ErrH

Dim rsReqCnt As New ADODB.Recordset

''Get request count for PFI
If rsReqCnt.State = adStateOpen Then rsReqCnt.Close
rsReqCnt.Open "Select count(ST_ReqType) from SMSTransaction Where
ST_ReqType='PFI' and ST_Status='Completed'", ZIDLL.cnDB,
adOpenForwardOnly, adLockReadOnly, adCmdText
With rsReqCnt
If Not (.BOF And .EOF) Then
SRT.SRT_PFI = .Fields(0)
Else
SRT.SRT_PFI = 0
End If
End With

''Get request count for PNI
If rsReqCnt.State = adStateOpen Then rsReqCnt.Close
rsReqCnt.Open "Select count(ST_ReqType) from SMSTransaction where
ST_ReqType='PNI' and ST_Status='Completed'", ZIDLL.cnDB,
adOpenForwardOnly, adLockReadOnly, adCmdText
With rsReqCnt
If Not (.BOF And .EOF) Then
SRT.SRT_PNI = .Fields(0)
Else
SRT.SRT_PNI = 0
End If
End With

''Get request count for PLI
If rsReqCnt.State = adStateOpen Then rsReqCnt.Close
rsReqCnt.Open "Select count(ST_ReqType) from SMSTransaction where
ST_ReqType='PLI' and ST_Status='Completed'", ZIDLL.cnDB,
adOpenForwardOnly, adLockReadOnly, adCmdText
With rsReqCnt
If Not (.BOF And .EOF) Then
SRT.SRT_PLI = .Fields(0)
Else
SRT.SRT_PLI = 0
End If
End With

''Get request count for PAI
If rsReqCnt.State = adStateOpen Then rsReqCnt.Close
rsReqCnt.Open "Select count(ST_ReqType) from SMSTransaction where
ST_ReqType='PAI' and ST_Status='Completed'", ZIDLL.cnDB,
adOpenForwardOnly, adLockReadOnly, adCmdText
With rsReqCnt
If Not (.BOF And .EOF) Then
SRT.SRT_PAI = .Fields(0)
Else
SRT.SRT_PAI = 0
End If
End With

''Get request count for BLI
If rsReqCnt.State = adStateOpen Then rsReqCnt.Close
rsReqCnt.Open "Select count(ST_ReqType) from SMSTransaction where
ST_ReqType='BLI' and ST_Status='Completed'", ZIDLL.cnDB,
adOpenForwardOnly, adLockReadOnly, adCmdText
With rsReqCnt
If Not (.BOF And .EOF) Then
SRT.SRT_BLI = .Fields(0)
Else
SRT.SRT_BLI = 0
End If
End With

''Get request count for Unknown
If rsReqCnt.State = adStateOpen Then rsReqCnt.Close
rsReqCnt.Open "Select count(ST_ReqType) from SMSTransaction where
ST_ReqType not in ('BLI','PNI','PFI','PAI','PLI') and
ST_Status='Completed'", ZIDLL.cnDB, adOpenForwardOnly, adLockReadOnly,
adCmdText
With rsReqCnt
If Not (.BOF And .EOF) Then
SRT.SRT_UNKNOWN = .Fields(0)
Else
SRT.SRT_UNKNOWN = 0
End If
End With

rsReqCnt.Close: Set rsReqCnt = Nothing
Exit Sub

ErrH:
gstrW2S = "frmMain-->GetRequestCntUpToDate"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->GetRequestCntUpToDate", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

Private Sub ShowRequestCntUpToDate()
On Error GoTo ErrH

Dim LstItem As ListItem

Set LstItem = lvwOnlineStatus.ListItems.Item(1): LstItem.SubItems(1) =
SRT.SRT_PFI
Set LstItem = lvwOnlineStatus.ListItems.Item(2): LstItem.SubItems(1) =
SRT.SRT_PNI
Set LstItem = lvwOnlineStatus.ListItems.Item(3): LstItem.SubItems(1) =
SRT.SRT_PLI
Set LstItem = lvwOnlineStatus.ListItems.Item(4): LstItem.SubItems(1) =
SRT.SRT_PAI
Set LstItem = lvwOnlineStatus.ListItems.Item(5): LstItem.SubItems(1) =
SRT.SRT_BLI
Set LstItem = lvwOnlineStatus.ListItems.Item(6): LstItem.SubItems(1) =
SRT.SRT_UNKNOWN
Exit Sub

ErrH:
gstrW2S = "frmMain-->ShowRequestCntUpToDate"
gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
WriteToScreen txtCommStatus, gstrW2S
WriteToFile ZERRLOG_FILE_PATH, gstrW2S
Call LogEntry("frmMain-->ShowRequestCntUpToDate", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

'------------ Backup Procedures ---
''Private Sub COMnSIM()
'''' SAMPLE CODE TO KEEP CURSOR WAITTING
''''[1]
'''' ''Wait for few seconds
'''' If bytCnt >= constWait4Reply Then
'''' GoTo NextIteration
'''' Else
'''' bytCnt = bytCnt + 1
'''' End If
'''' ''Upto Here
''''[2]
'''' tmptimer = Timer + 15
''''TTP:
'''' Do Until Timer > tmptimer
'''' DoEvents
'''' Loop
'''' If Timer < tmptimer Then GoTo TTP
'''' tmptimer = ""
''
'' On Error GoTo ErrH
''
'' Dim i As Integer, LstItem As ListItem ', nCnt As Integer
'' Dim bytCnt As Byte, tmpTimer
''
'' gbytCnt = 0
'' For i = 1 To 30
'' gblnIterationIsOn = True
''
'' 'Current Status
'' gbytCnt = gbytCnt + 1
'' Set LstItem = lvwOnlineStatus.ListItems.Item(7)
'' LstItem.SubItems(1) = gbytCnt
''
'' 'If gblnStartDC = False Then Exit Sub
'' If APPStat.appstCOMPortOn = False Then Exit Sub
'' MakeSMSDataEmpty
'' MakeOtherVariablesEmpty
''
'' ''Read From SIM
'' bytLastCmd = enmReadFromSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmReadFromSIM, i)
''
'' bytCnt = 0
'' Do Until blnGoForRespGen = True
'' If blnGoForNextIteration = True Then GoTo NextIteration
'''' ''Wait for few seconds
'''' tmpTimer = Timer + constWait4Reply
''''TTP1:
'''' Do Until Timer > tmpTimer
'''' If blnGoForRespGen = True Then tmpTimer = "": Exit Do
'''' DoEvents
'''' Loop
'''' 'If Timer < tmpTimer Then GoTo TTP1
'''' tmpTimer = ""
'''' 'Upto Here
'' DoEvents
'' Loop
''
''
'' ''Generate Response
'' Call GenerateResponse(SMSData.SMSDS_Request, True)
'' bytCnt = 0
'' Do Until blnGoForSend = True
'''' ''Wait for few seconds
'''' If bytCnt >= constWait4Reply Then
'''' GoTo NextIteration
'''' Else
'''' bytCnt = bytCnt + 1
'''' End If
'''' ''Upto Here
'' DoEvents
'' Loop
''
'''' Following lines are proper as per flow, but if any response data
(text) is out of capacity of one SMS
'''' i.e. morethan 128 or 130 characters, we have to split it in two
SMSs. To send sms in these kind of conditions
'''' code lines to send SMS are written after individual response.
''
'' If Len(Trim(strResp1)) > 0 Then
'' SMSData.SMSDS_Response = strResp1
'' ''Send To SIM
'' bytLastCmd = enmSendToSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmSendToSIM, i)
'' bytCnt = 0
'' Do Until blnGoForDelete = True
'''' ''Wait for few seconds
'''' If bytCnt >= constWait4Reply Then
'''' GoTo NextIteration
'''' Else
'''' bytCnt = bytCnt + 1
'''' End If
'''' ''Upto Here
'' DoEvents
'' Loop
''
'''' If Len(Trim(strResp2)) > 0 Then
'''' SMSData.SMSDS_Response = strResp2
'''' ''Send To SIM
'''' bytLastCmd = enmSendToSIM: mstrInputOne = ""
'''' Call fncRequestToCOM(msCOMMSIM, enmSendToSIM, i)
'''' Do Until blnGoForDelete = True: DoEvents: Loop
'''' strResp2 = ""
'''' End If
'' End If
''
'' ''Delete From SIM
'' bytLastCmd = enmDeleteFromSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmDeleteFromSIM, i)
'' bytCnt = 0
'' Do Until blnGoForNextIteration = True
'''' ''Wait for few seconds
'''' If bytCnt >= constWait4Reply Then
'''' GoTo NextIteration
'''' Else
'''' bytCnt = bytCnt + 1
'''' End If
'''' ''Upto Here
'' DoEvents
'' Loop
''
'' If Len(Trim(strResp2)) > 0 Then
'' SMSData.SMSDS_Response = strResp2
'' ''Send To SIM
'' bytLastCmd = enmSendToSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmSendToSIM, i)
'' bytCnt = 0
'' Do Until blnGoForDelete = True
'''' ''Wait for few seconds
'''' If bytCnt >= constWait4Reply Then
'''' GoTo NextIteration
'''' Else
'''' bytCnt = bytCnt + 1
'''' End If
'''' ''Upto Here
'' DoEvents
'' Loop
'' strResp2 = ""
'' End If
''
''NextIteration:
'' gblnIterationIsOn = False
'' If gblnStopDC = True Then tmrReadFromSIM.Enabled = False:
STOP_SMSing: Exit Sub
'' Next i
''
'' Exit Sub
''
''ErrH:
'' gstrW2S = "frmMain-->COMnSIM"
'' gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
'' WriteToScreen txtCommStatus, gstrW2S
'' WriteToFile ZERRLOG_FILE_PATH, gstrW2S
''End Sub

''''------------- Backup Procedure 12th APR 2004
''Private Sub COMnSIM()
'''' SAMPLE CODE TO KEEP CURSOR WAITTING
''''[1]
'''' ''Wait for few seconds
'''' If bytCnt >= constWait4Reply Then
'''' GoTo NextIteration
'''' Else
'''' bytCnt = bytCnt + 1
'''' End If
'''' ''Upto Here
''''[2]
'''' tmptimer = Timer + 15
''''TTP:
'''' Do Until Timer > tmptimer
'''' DoEvents
'''' Loop
'''' If Timer < tmptimer Then GoTo TTP
'''' tmptimer = ""
''
'' On Error GoTo ErrH
''
'' Dim i As Integer, LstItem As ListItem ', nCnt As Integer
'' Dim bytCnt As Byte, tmpTimer
''
'' gbytCnt = 0
'' For i = 1 To 30
'' gblnIterationIsOn = True
''
'' 'Current Status
'' gbytCnt = gbytCnt + 1
'' Set LstItem = lvwOnlineStatus.ListItems.Item(7)
'' LstItem.SubItems(1) = gbytCnt
''
'' 'If gblnStartDC = False Then Exit Sub
'' If APPStat.appstCOMPortOn = False Then Exit Sub
'' MakeSMSDataEmpty
'' MakeOtherVariablesEmpty
''
'' ''Read From SIM
'' bytLastCmd = enmReadFromSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmReadFromSIM, i)
''
'''' Wait for few seconds
''TTP1:
'' tmpTimer = ""
'' tmpTimer = Timer + constWait4Reply
'' Do Until Timer > tmpTimer
'' If blnGoForRespGen = True Then tmpTimer = "": Exit Do
'' DoEvents
'' Loop
'' tmpTimer = ""
'''' Upto Here
'' bytCnt = 0
'' If blnGoForRespGen = False Then
'' If bytCnt >= 2 Then
'' GoTo NextIteration
'' Else
'' bytCnt = bytCnt + 1
'' GoTo TTP1
'' End If
'' End If
''' Do Until blnGoForRespGen = True
''' If blnGoForNextIteration = True Then GoTo NextIteration
''' DoEvents
''' Loop
''
''
'' ''Generate Response
'' Call GenerateResponse(SMSData.SMSDS_Request, True)
'''' Wait for few seconds
''TTP2:
'' tmpTimer = ""
'' tmpTimer = Timer + constWait4Reply
'' Do Until Timer > tmpTimer
'' If blnGoForSend = True Then tmpTimer = "": Exit Do
'' DoEvents
'' Loop
'' tmpTimer = ""
'''' Upto Here
'' bytCnt = 0
'' If blnGoForSend = False Then
'' If bytCnt >= 2 Then
'' GoTo NextIteration
'' Else
'' bytCnt = bytCnt + 1
'' GoTo TTP2
'' End If
'' End If
'''' Do Until blnGoForSend = True
'''' DoEvents
'''' Loop
''
'''' Following lines are proper as per flow, but if any response data
(text) is out of capacity of one SMS
'''' i.e. morethan 128 or 130 characters, we have to split it in two
SMSs. To send sms in these kind of conditions
'''' code lines to send SMS are written after individual response.
'' If Len(Trim(strResp1)) > 0 Then
'' SMSData.SMSDS_Response = strResp1
'' ''Send To SIM
'' bytLastCmd = enmSendToSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmSendToSIM, i)
'' bytCnt = 0
'''' Wait for few seconds
''TTP3:
'' tmpTimer = ""
'' tmpTimer = Timer + constWait4Reply
'' Do Until Timer > tmpTimer
'' If blnGoForDelete = True Then tmpTimer = "": Exit Do
'' DoEvents
'' Loop
'' tmpTimer = ""
'''' Upto Here
'' bytCnt = 0
'' If blnGoForDelete = False Then
'' If bytCnt >= 2 Then
'' GoTo NextIteration
'' Else
'' bytCnt = bytCnt + 1
'' GoTo TTP3
'' End If
'' End If
'''' Do Until blnGoForDelete = True
'''' DoEvents
'''' Loop
'' End If
''
'' ''Delete From SIM
'' bytLastCmd = enmDeleteFromSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmDeleteFromSIM, i)
'''' Wait for few seconds
''TTP4:
'' tmpTimer = ""
'' tmpTimer = Timer + constWait4Reply
'' Do Until Timer > tmpTimer
'' If blnGoForNextIteration = True Then tmpTimer = "": Exit Do
'' DoEvents
'' Loop
'' tmpTimer = ""
'''' Upto Here
'' bytCnt = 0
'' If blnGoForNextIteration = False Then
'' If bytCnt >= 2 Then
'' GoTo NextIteration
'' Else
'' bytCnt = bytCnt + 1
'' GoTo TTP4
'' End If
'' End If
'''' Do Until blnGoForNextIteration = True
'''' DoEvents
'''' Loop
''
'' If Len(Trim(strResp2)) > 0 Then
'' SMSData.SMSDS_Response = strResp2
'' ''Send To SIM
'' bytLastCmd = enmSendToSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmSendToSIM, i)
''TTP5:
'' tmpTimer = ""
'' tmpTimer = Timer + constWait4Reply
'' Do Until Timer > tmpTimer
'' If blnGoForDelete = True Then tmpTimer = "": Exit Do
'' DoEvents
'' Loop
'' tmpTimer = ""
'''' Upto Here
'' bytCnt = 0
'' If blnGoForDelete = False Then
'' If bytCnt >= 2 Then
'' GoTo NextIteration
'' Else
'' bytCnt = bytCnt + 1
'' GoTo TTP5
'' End If
'' End If
'''' Do Until blnGoForDelete = True
'''' DoEvents
'''' Loop
'' strResp2 = ""
'' End If
''
''NextIteration:
'' gblnIterationIsOn = False
'' If gblnStopDC = True Then tmrReadFromSIM.Enabled = False:
STOP_SMSing: Exit Sub
'' Next i
'' Exit Sub
''
''ErrH:
'' gstrW2S = "frmMain-->COMnSIM"
'' gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
'' WriteToScreen txtCommStatus, gstrW2S
'' WriteToFile ZERRLOG_FILE_PATH, gstrW2S
''End Sub

''Public Sub SendSMS(strSMSMsg As String)
'' On Error GoTo ErrH
''
'' SMSData.SMSDS_Response = strSMSMsg
'' ''Send To SIM
'' bytLastCmd = enmSendToSIM: mstrInputOne = ""
'' Call fncRequestToCOM(msCOMMSIM, enmSendToSIM)
'' Exit Sub
''
''ErrH:
'' MsgBox Err.Number & "|" & Err.Description & "|" & Err.Source
''End Sub

'-----------------------------------------------------------------------------------------
'Developer : Ketan Jadhav
'Date : 05/03/2005
'Comment : Design for Special Client Node for Viewing Send message by
all users...
'-----------------------------------------------------------------------------------------
Private Sub ReadRequest()
On Error GoTo ErrH

Dim rsReadSMS As New ADODB.Recordset
Dim strSQL As String
Dim lngErrNo As Long, strErrDesc As String, strErrSrc As String

strSQL = "SELECT * From SMSTransaction Where (Month(ST_StartDateTime)
= " & Month(Date) & " ) And (Day(ST_StartDateTime) = " & Day(Date) & ")
And (Year(ST_StartDateTime) = " & Year(Date) & ") And (ST_Type = 0)"

lvwOnScreen(0).ListItems.Clear

If rsReadSMS.State = adStateOpen Then rsReadSMS.Close
rsReadSMS.Open strSQL, ZIDLL.cnDB, adOpenForwardOnly, adLockReadOnly,
adCmdText

Do Until rsReadSMS.EOF
ShowOnScreen enmRequest, ZDLL.AV(rsReadSMS.Fields("ST_CallerID")),
ZDLL.AV(rsReadSMS.Fields("ST_RequestFrom")),
ZDLL.AV(rsReadSMS.Fields("ST_Message")),
ZDLL.AV(rsReadSMS.Fields("ST_Status")),
ZDLL.AV(rsReadSMS.Fields("ST_StartDateTime"))
rsReadSMS.MoveNext
Loop

rsReadSMS.Close
Set rsReadSMS = Nothing
Exit Sub

ErrH:
' Resume
lngErrNo = Err.Number: strErrDesc = Err.Description: strErrSrc =
Err.Source
Call LogEntry("frmMain-->ReadRequest()", ErroLog, False, strErrDesc,
lngErrNo, strErrDesc, strErrSrc)
End Sub

'ShowOnScreen enmResponse, SMSData.SMSDS_CallerID,
SMSData.SMSDS_SenderName, SMSData.SMSDS_Request
Private Sub ReadSMSFromDB(blnIsServer As Boolean, blnIsRequest As
Boolean)
On Error GoTo ErrH

Dim rsReadSMS As New ADODB.Recordset
Dim strReadSMS As String
Dim strLastID As String
Dim bytType As Byte '0 - Req, 1 - Resp
Dim nID As Double
Dim dTry As Double
Dim dSTID As Double

Dim strCmdToolTip$, strSMSCnt$
Dim lngErrNo As Long, strErrDesc As String, strErrSrc As String
Dim i As Double
gblnIterationIsOn = True

bytType = IIf(blnIsRequest = True, 0, 1)
If blnIsServer = True Then
If blnIsRequest = True Then
If dbProvider = enmSQL Then
'strReadSMS = "Select * From SMSTransaction Where ST_Type=
0 and ST_Status = 0 and ST_StartDateTime >= '" & Format(Date, "yyyy-mm-dd")
& "' Order By ST_ID"
strReadSMS = "Select * From SMSTransaction Where ST_Type=
0 and ST_Status = 0 Order By ST_ID"
ElseIf dbProvider = enmAccess Then
'strReadSMS = "Select * From SMSTransaction Where ST_Type=
0 and ST_Status = 0 and ST_StartDateTime >= '" & Format(Date, "yyyy-mm-dd")
& "' Order By ST_ID"
strReadSMS = "Select * From SMSTransaction Where ST_Type=
0 and ST_Status = 0 Order By ST_ID"
End If
Else 'Response
If dbProvider = enmSQL Then
strLastID = Replace(ZDLL.GetFromIni(ZConfigurationINI,
"LastID", "ServerResp"), Chr(0), "")
strLastID = IIf(Len(strLastID) = 0, 0, strLastID)

nID = Val(strLastID)
nID = GetMaxID(enmResponse)

'----
ZDLL.SaveToIni ZConfigurationINI, "LastID", "ServerResp",
CStr(nID)
nID = nID - Val(strLastID)
'---

If nID > 10 Then
'Show Last 10 Pending SMS
nID = nID - 10
strLastID = CStr(nID)
strReadSMS = "SELECT TOP 10 * From dbo.SMSTransaction
Where (ST_Type = 1) ORDER BY ST_ID DESC"
Else
'strReadSMS = "Select * From SMSTransaction Where
ST_Type= 1 and ST_StartDateTime >= '" & Format(Date, "yyyy-mm-dd") & "'
and ST_ID > '" & strLastID & "' Order By ST_ID"
strReadSMS = "Select * From SMSTransaction Where
ST_Type= 1 and ST_ID > '" & strLastID & "' Order By ST_ID"
End If

ElseIf dbProvider = enmAccess Then
strLastID = Replace(ZDLL.GetFromIni(ZConfigurationINI,
"LastID", "ServerResp"), Chr(0), "")
strLastID = IIf(Len(strLastID) = 0, 0, strLastID)

nID = Val(strLastID)
nID = GetMaxID(enmResponse)


'----
ZDLL.SaveToIni ZConfigurationINI, "LastID", "ServerResp",
CStr(nID)
nID = nID - Val(strLastID)
'---

If nID > 10 Then
'Show Last 10 Pending SMS
nID = nID - 10
strLastID = CStr(nID)
strReadSMS = "SELECT TOP 10 * From dbo.SMSTransaction
Where (ST_Type = 1) ORDER BY ST_ID DESC"
Else
'strReadSMS = "Select * From SMSTransaction Where
ST_Type= 1 and ST_StartDateTime >= '" & Format(Date, "yyyy-mm-dd") & "'
and ST_ID > '" & strLastID & "' Order By ST_ID"
strReadSMS = "Select * From SMSTransaction Where
ST_Type= 1 and ST_ID > " & strLastID & " Order By ST_ID"
End If

End If
End If
Else 'Client

If blnIsRequest = True Then
If dbProvider = enmSQL Then
strLastID = Replace(ZDLL.GetFromIni(ZConfigurationINI,
"LastID", "ClientReq"), Chr(0), "")
strLastID = IIf(Len(strLastID) = 0, 0, strLastID)

nID = Val(strLastID)
nID = GetMaxID(enmRequest)


'----
ZDLL.SaveToIni ZConfigurationINI, "LastID", "ClientReq",
CStr(nID)
nID = nID - Val(strLastID)
'---

If nID > 10 Then
'Show Last 10 Pending SMS
nID = nID - 10
strLastID = CStr(nID)
If gblnIsSpecialClientNode = False Then
strReadSMS = "SELECT TOP 10 * From
dbo.SMSTransaction Where (ST_Type = 0) and ST_ComputerName='" &
gstrComputerName & "' ORDER BY ST_ID DESC"
Else
strReadSMS = "SELECT TOP 10 * From
dbo.SMSTransaction Where (ST_Type = 0) ORDER BY ST_ID DESC"
End If
Else
If gblnIsSpecialClientNode = False Then
strReadSMS = "Select * From SMSTransaction Where
ST_Type= 0 and ST_Status=0 and ST_ComputerName='" & gstrComputerName & "'
and ST_ID > '" & strLastID & "' Order By ST_ID"
Else
strReadSMS = "Select * From SMSTransaction Where
ST_Type= 0 and ST_Status=0 and ST_ID > '" & strLastID & "' Order By
ST_ID"
End If
End If

ElseIf dbProvider = enmAccess Then
strLastID = Replace(ZDLL.GetFromIni(ZConfigurationINI,
"LastID", "ClientReq"), Chr(0), "")
strLastID = IIf(Len(strLastID) = 0, 0, strLastID)

nID = Val(strLastID)
nID = GetMaxID(enmRequest)


'----
ZDLL.SaveToIni ZConfigurationINI, "LastID", "ClientReq",
CStr(nID)
nID = nID - Val(strLastID)
'---

If nID > 10 Then
'Show Last 10 Pending SMS
nID = nID - 10
strLastID = CStr(nID)

If gblnIsSpecialClientNode = False Then
strReadSMS = "SELECT TOP 10 * From
dbo.SMSTransaction Where (ST_Type = 0) and ST_ComputerName='" &
gstrComputerName & "' ORDER BY ST_ID DESC"
Else
strReadSMS = "SELECT TOP 10 * From
dbo.SMSTransaction Where (ST_Type = 0) ORDER BY ST_ID DESC"
End If
Else
If gblnIsSpecialClientNode = False Then
strReadSMS = "Select * From SMSTransaction Where
ST_Type= 0 and ST_Status=0 and ST_ComputerName='" & gstrComputerName & "'
and ST_ID > '" & strLastID & "' Order By ST_ID"
Else
strReadSMS = "Select * From SMSTransaction Where
ST_Type= 0 and ST_Status=0 and ST_ID > '" & strLastID & "' Order By
ST_ID"
End If
End If

End If
Else 'Response

If dbProvider = enmSQL Then
strLastID = Replace(ZDLL.GetFromIni(ZConfigurationINI,
"LastID", "ClientResp"), Chr(0), "")
strLastID = IIf(Len(strLastID) = 0, 0, strLastID)
'strReadSMS = "Select * From SMSTransaction Where
ST_StartDateTime >= '" & Format(Date, "yyyy-mm-dd") & "'"
'strReadSMS = strReadSMS & " and ST_Type=1 and ST_ID > '"
& strLastID & "' Order By ST_ID"

nID = Val(strLastID)
nID = GetMaxID(enmResponse)
'----
ZDLL.SaveToIni ZConfigurationINI, "LastID", "ClientResp",
CStr(nID)
nID = nID - Val(strLastID)
'---
If nID > 10 Then
'Show Last 10 Pending SMS
nID = nID - 10
strLastID = CStr(nID)
strReadSMS = "SELECT TOP 10 * From dbo.SMSTransaction
Where (ST_Type = 1) ORDER BY ST_ID DESC"
Else
strReadSMS = "Select * From SMSTransaction Where
ST_Type=1 and ST_ID > '" & strLastID & "' Order By ST_ID"
End If


ElseIf dbProvider = enmAccess Then
strLastID = Replace(ZDLL.GetFromIni(ZConfigurationINI,
"LastID", "ClientResp"), Chr(0), "")
strLastID = IIf(Len(strLastID) = 0, 0, strLastID)

nID = Val(strLastID)
nID = GetMaxID(enmResponse)

'----
ZDLL.SaveToIni ZConfigurationINI, "LastID", "ClientResp",
CStr(nID)
nID = nID - Val(strLastID)
'---

If nID > 10 Then
'Show Last 10 Pending SMS
nID = nID - 10
strLastID = CStr(nID)
strReadSMS = "SELECT TOP 10 * From dbo.SMSTransaction
Where (ST_Type = 1) ORDER BY ST_ID DESC"
Else
strReadSMS = "Select * From SMSTransaction Where
ST_Type=1 and ST_ID > " & strLastID & " Order By ST_ID"
End If

End If
End If
End If

If rsReadSMS.State = adStateOpen Then rsReadSMS.Close

rsReadSMS.CursorLocation = adUseClient
rsReadSMS.Open strReadSMS, ZIDLL.cnDB, adOpenForwardOnly,
adLockReadOnly, adCmdText

With rsReadSMS
If Not (.BOF And .EOF) Then
Do While Not .EOF
If blnIsServer = True Then

'Send Requested SMS(s) by Clients
If blnIsRequest = True Then
SMSData.SMSDS_CallerID = ZDLL.AV(!ST_CallerID)
SMSData.SMSDS_Response = ZDLL.AV(!ST_Message)

dSTID = CDbl(!ST_ID)
dTry = CDbl(IIf(IsNull(!ST_Try), 1, !ST_Try))

''Send SMS to SIM
bytLastCmd = enmSendToSIM: mstrInputOne = ""
Call frmMain.fncRequestToCOM(frmMain.msCOMMSIM,
enmSendToSIM)

''''Wait for few seconds
TTP5:
tmpTimer = "": tmpTimer = Timer + constWait4Reply
Do Until Timer > tmpTimer
If blnGoForDelete = True Then tmpTimer = "":
Exit Do
DoEvents
Loop
tmpTimer = ""
Call Timer5_Timer

''Uptade status=1 for each successfully sent sms
AppendSMSTrnsaction False, , , ZDLL.AV(dSTID),
ZDLL.AV(dTry), CInt(bytType), CInt(1)

''Show SMS on Request screen
ShowOnScreen enmRequest, ZDLL.AV(!ST_CallerID),
ZDLL.AV(!ST_RequestFrom) & "@" & ZDLL.AV(!ST_ComputerName),
ZDLL.AV(!ST_Message), ZDLL.AV(!ST_Status), ZDLL.AV(!ST_StartDateTime),
ZDLL.AV(!ST_ID)

'Developer : Ketan Dt : 07/02/2005
'Send ShowOnScreen Command to Perticular Client

'========================================================
'Write ShowOnScreen Command Function here
On Error GoTo nxt
For i = 1 To tcpServer.UBound
If tcpServer(i).State = sckConnected Then
If tcpServer(i).RemoteHostIP =
!ST_ComputerName Then
tcpServer(i).SendData "REQUEST" &
Chr(149) & ZDLL.AV(!ST_CallerID) & Chr(149) & ZDLL.AV(!ST_RequestFrom) &
Chr(149) & ZDLL.AV(!ST_ComputerName) & Chr(149) & ZDLL.AV(!ST_Message) &
Chr(149) & ZDLL.AV(!ST_Status) & Chr(149) & ZDLL.AV(!ST_StartDateTime)
Exit For
End If
End If
nxt:
Next

'========================================================

Else 'Response of Server
AppendSMSTrnsaction False, , , ZDLL.AV(!ST_ID), ,
CInt(bytType), 1
'ShowOnScreen enmResponse, ZDLL.AV(!ST_CallerID),
ZDLL.AV(!ST_RequestFrom) & "@" & ZDLL.AV(!ST_ComputerName),
ZDLL.AV(!ST_Message), ZDLL.AV(!ST_Status)

ShowOnScreen enmResponse, ZDLL.AV(!ST_CallerID),
ZDLL.AV(!ST_RequestFrom), ZDLL.AV(!ST_Message), ZDLL.AV(!ST_Status),
ZDLL.AV(!ST_StartDateTime), ZDLL.AV(!ST_ID)
ZDLL.SaveToIni ZConfigurationINI, "LastID",
"ServerResp", ZDLL.AV(!ST_ID)

''To terminate instance of exe change value in
ZConfiguration.ini as follows
ZDLL.SaveToIni ZConfigurationINI, "ZToolTip",
"Terminate", 1

''Wait for few seconds
tmpTimer = "": tmpTimer = Timer + 1
Do Until Timer > tmpTimer: DoEvents: Loop
tmpTimer = ""
''Upto Here

strCmdToolTip = Chr(34) & "You have a new SMS(s)"
& vbCrLf & "Caller ID: " & ZDLL.AV(!ST_CallerID) & vbCrLf & "SMS From: " &
ZDLL.AV(!ST_RequestFrom) & vbCrLf & "Date Time: " &
ZDLL.AV(!ST_StartDateTime) & vbCrLf & vbCrLf & "Message: " &
Mid(ZDLL.AV(!ST_Message), 1, 10) & "..." & Chr(34)

'Show New SMS Alert on Server Screen

'====================================================================
'strCmdToolTip = "You have a new SMS(s)"


'****************************************************************************
'Comment by : Ketan Jadhav On dt : 13/07/2005

'****************************************************************************
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " "
& strCmdToolTip

''Following line will execute ZToolTip.exe with
commandline parameter
'Shell strCmdToolTip, vbNormalFocus

'****************************************************************************


'****************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new
Popup Style

'****************************************************************************
Dim AlertWindow As frmAlertWindow 'Added by Ketan
on dt : 13/07/2005 for New Popup style
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)

If Len(Trim(SMSData.SMSDS_Request)) > 0 Then
strCmdToolTip = " You have a new SMS(s)" &
vbCrLf & "SMS From : " & SMSData.SMSDS_SenderName & vbCrLf & " Caller ID:
" & SMSData.SMSDS_CallerID & vbCrLf & "Date Time: " &
Format(SMSData.SMSDS_RequestDT, "DD/mm/yyyy HH:MM:SS") & vbCrLf & vbCrLf &
"Message: " & SMSData.SMSDS_Request
AlertWindow.DisplayMessage strCmdToolTip, 4,
_
True, True, True, m_iBackColor, False
End If

'****************************************************************************


'Developer : Ketan Dt : 07/02/2005
'Purpose : Broadcast New SMS to all connected
clients

'============================================================
Call fncBroadCast_SMS(ZDLL.AV(!ST_ID),
ZDLL.AV(!ST_Message), ZDLL.AV(!ST_RequestFrom), ZDLL.AV(!ST_CallerID),
ZDLL.AV(!ST_StartDateTime), ZDLL.AV(!ST_Status))

'============================================================

End If
Else 'Client

If blnIsRequest = True Then
'Dt.14/05/2004
' AppendSMSTrnsaction False, , , ZDLL.AV(!ST_ID), ,
0, 1
If InStr(Trim(ZDLL.AV(!ST_Message)),
udfOPTCode.udftOPTCode_SRCH) = 0 Then
ShowOnScreen enmRequest,
ZDLL.AV(!ST_CallerID), ZDLL.AV(!ST_RequestFrom) & "@" &
ZDLL.AV(!ST_ComputerName), ZDLL.AV(!ST_Message), ZDLL.AV(!ST_Status),
ZDLL.AV(!ST_StartDateTime)
End If
ZDLL.SaveToIni ZConfigurationINI, "LastID",
"ClientReq", ZDLL.AV(!ST_ID)
Else 'Response of Client
'Dt.14/05/2004
' AppendSMSTrnsaction False, , , ZDLL.AV(!ST_ID), ,
1, 1
'ShowOnScreen enmResponse, ZDLL.AV(!ST_CallerID),
ZDLL.AV(!ST_RequestFrom) & "@" & ZDLL.AV(!ST_ComputerName),
ZDLL.AV(!ST_Message), ZDLL.AV(!ST_Status)
If mblnDenyShowOnScreen = False Then
ShowOnScreen enmResponse,
ZDLL.AV(!ST_CallerID), ZDLL.AV(!ST_RequestFrom), ZDLL.AV(!ST_Message),
ZDLL.AV(!ST_Status), ZDLL.AV(!ST_StartDateTime), ZDLL.AV(!ST_ID)
End If
ZDLL.SaveToIni ZConfigurationINI, "LastID",
"ClientResp", ZDLL.AV(!ST_ID)

'' Dim strCmdToolTip$ , varCmdLine
'' strCmdToolTip = "You have " & i & " new SMS(s)"
'' varCmdLine = App.Path & "\ZToolTip.exe" & " " &
strCmdToolTip
If mblnDenyShowOnScreen = False Then
''To terminate instance of exe change value in
ZConfiguration.ini as follows
ZDLL.SaveToIni ZConfigurationINI, "ZToolTip",
"Terminate", 1

' Dim strCmdToolTip$, strSMSCnt$
''Wait for few seconds
tmpTimer = "": tmpTimer = Timer + 1
Do Until Timer > tmpTimer: DoEvents: Loop
tmpTimer = ""
''Upto Here

'strSMSCnt =
ZDLL.GetFromIni(ZConfigurationINI, "Properties", "SMSCnt", 0)
'strSMSCnt = strSMSCnt + 1

'ZDLL.SaveToIni ZConfigurationINI,
"Properties", "SMSCnt", strSMSCnt

'strCmdToolTip = "You have " & strSMSCnt & "
new SMS(s)"

''Original - Dt.28/06/2003
''strCmdToolTip = "You have a new SMS(s)"

'strCmdToolTip = Chr(34) & "You have a new
SMS(s)" & vbCrLf & "Caller ID: " & ZDLL.AV(!ST_CallerID) & vbCrLf & "SMS
From: " & ZDLL.AV(!ST_RequestFrom) & vbCrLf & "Date Time: " &
ZDLL.AV(!ST_StartDateTime) & vbCrLf & "Message: " &
Mid(ZDLL.AV(!ST_Message), 1, 10) & "..." & Chr(34)
'strCmdToolTip = Chr(34) & "You have a new
SMS(s)" & vbCrLf & "SMS From: " & ZDLL.AV(!ST_RequestFrom) & vbCrLf &
"Caller ID: " & ZDLL.AV(!ST_CallerID) & vbCrLf & "Date Time: " &
ZDLL.AV(!ST_StartDateTime) & vbCrLf & "Message: " &
Mid(ZDLL.AV(!ST_Message), 1, 20) & "..." & Chr(34)
'strCmdToolTip = App.Path & "\ZToolTip.exe" &
" " & strCmdToolTip

''Following line will execute ZToolTip.exe
with commandline parameter
'Shell strCmdToolTip, vbNormalFocus
End If
End If
End If
.MoveNext
Loop
End If
.Close
End With
Set rsReadSMS = Nothing
gblnIterationIsOn = False
If gblnStopDC = True Then tmrReadFromSIM.Enabled = False: STOP_SMSing:
Exit Sub
Exit Sub

ErrH:
' Resume
lngErrNo = Err.Number: strErrDesc = Err.Description: strErrSrc =
Err.Source
Call LogEntry("frmMain-->ReadSMSFromDB", ErroLog, False, strErrDesc,
lngErrNo, strErrDesc, strErrSrc)
Resume Next
End Sub

Private Function fnc_strDots() As String
On Error GoTo ErrH

Static nCnt As Byte, i As Byte

If gblnDoUWantToLogOff = True Then i = 0: gblnDoUWantToLogOff = False
i = i + 1
If i > 20 Then i = 1
For nCnt = 1 To i
fnc_strDots = fnc_strDots & "-"
'fnc_strDots = nCnt
Next nCnt
Exit Function

ErrH:
Call LogEntry("frmMain-->fnc_strDots", ErroLog, True, Err.Description,
Err.Number, Err.Description, Err.Source)
End Function

Private Function InitializeGSMDevice() As Boolean
On Error GoTo ErrH

InitializeGSMDevice = False

''Initialize SIM
bytLastCmd = enmInitialization: mstrInputOne = ""
Call fncRequestToCOM(msCOMMSIM, enmInitialization)
'Do Until blnGoForRead = True: DoEvents: Loop
'' Wait for few seconds
TTP0:
tmpTimer = "": tmpTimer = Timer + constWait4Reply
Do Until Timer > tmpTimer
If blnGoForRead = True Then tmpTimer = "": Exit Do
DoEvents
Loop
tmpTimer = ""
'' Upto Here
If blnGoForRead = False Then
Screen.MousePointer = vbDefault
gstrW2S = App.title & " fails to initialize system." & vbCrLf &
vbCrLf & "Check followig possibilities " & vbCrLf & vbCrLf _
& "[1] GSM Router is on and displaying message 'GSM Router' or
'PC Control'" & vbCrLf _
& "[2] COM port is on"
MsgBox gstrW2S, vbExclamation, App.title
WriteToFile ZLOG_FILE_PATH, gstrW2S & vbCrLf &
"@frmMain-->Form_Load": WriteToScreen txtCommStatus, gstrW2S
Exit Function
End If
InitializeGSMDevice = True
Exit Function

ErrH:
Call LogEntry("frmMain-->InitializeGSMDevice", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Function

Public Function fncGetSenderNameFromArr(StrCallerID As String) As String
On Error GoTo ErrH

Dim nCnt As Integer

For nCnt = 1 To udfGenDetail.udftGenDet_CntContacts
If arrSetContacts(1, nCnt) = StrCallerID Then
fncGetSenderNameFromArr = arrSetContacts(0, nCnt)
Exit Function
End If
Next nCnt
Exit Function

ErrH:
Call LogEntry("frmMain-->fncGetSenderNameFromArr", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Function

Private Function fncGetSenderNameFromDB(StrCallerID As String) As String
On Error GoTo ErrH

Dim rsGetSN As New ADODB.Recordset
Dim strGetSN As String

strGetSN = "Select * From AddressBook Where AB_MobileNoALL Like '%" &
StrCallerID & "%'"

If rsGetSN.State = adStateOpen Then rsGetSN.Close
rsGetSN.Open strGetSN, ZIDLL.cnDB, adOpenForwardOnly, adLockReadOnly,
adCmdText
With rsGetSN
If Not (.BOF And .EOF) Then
fncGetSenderNameFromDB = ZDLL.AV(!AB_ContactPerson)
End If
End With
rsGetSN.Close: Set rsGetSN = Nothing
Exit Function

ErrH:
Call LogEntry("frmMain-->fncGetSenderNameFromDB", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Function

Private Function fncCheckFunctionAuthority(StrCallerID As String,
strFunction As String) As Boolean
On Error GoTo ErrH

fncCheckFunctionAuthority = False

Dim rsCFAuth As New ADODB.Recordset
Dim strCFAuth As String

strCFAuth = "Select AB_ID From AddressBook Where AB_MobileNoALL Like
'%" & StrCallerID & "%'"

If rsCFAuth.State = adStateOpen Then rsCFAuth.Close
rsCFAuth.Open strCFAuth, ZIDLL.cnDB, adOpenForwardOnly,
adLockReadOnly, adCmdText
With rsCFAuth
If Not (.BOF And .EOF) Then
If InStr(gstrFncABID_SRCH, ZDLL.AV(!AB_ID)) > 0 Then
fncCheckFunctionAuthority = True
End If
End If
End With
rsCFAuth.Close: Set rsCFAuth = Nothing
Exit Function

ErrH:
fncCheckFunctionAuthority = False
Call LogEntry("frmMain-->fncCheckFunctionAuthority", ErroLog, True,
Err.Description, Err.Number, Err.Description, Err.Source)
End Function


''Private Sub GenerateResponse(strReq As String, Optional blnShowInList As
Boolean = False)
'' On Error GoTo ErrH
''
'' 'Dim strTemp$,
'' Dim arrGenResp() As String, blnIsRespGenrated As Boolean
''
'' strResp1 = "": strResp2 = ""
''
'' If Len(SMSData.SMSDS_CallerID) < 5 Then blnGoForDelete = True: Exit
Sub
'' If InStr(UCase(SMSData.SMSDS_CallerID), UCase("AirTel")) > 0 Or _
'' InStr(UCase(SMSData.SMSDS_CallerID), UCase("Hutch")) > 0 Or _
'' InStr(UCase(SMSData.SMSDS_CallerID), UCase("Idea")) > 0 Then
''
'' blnGoForDelete = True: Exit Sub
'' End If
''
'' If Len(strReq) = 0 Then
'''' strResp1 = "Your request does not match pre-defined format,
re-format it" _
'''' & " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>, PAI
<pfcode>, BLI <bill no.>"
'' strResp1 = "Your request does not match pre-defined format,
re-format it" _
'' & " e.g. SRCH <contactname>,<mobileno>, BAL <accountno>
<pin>"
'' blnGoForSend = True
'' 'FillSMS FT_ADD
'' Exit Sub
'' End If
''
'' arrGenResp = Split(strReq, " ")
'' SMSData.SMSDS_Type = arrGenResp(0)
'' If UBound(arrGenResp) < 1 Then
'' strResp1 = "Your request does not match pre-defined format,
re-format it" _
'' & " e.g. SRCH <contactname>,<mobileno>, BAL <accountno>
<pin>"
'' '& " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>, PAI
<pfcode>, BLI <bill no.>"
'' blnGoForSend = True
'' 'FillSMS FT_ADD
'' SMSData.SMSDS_Status = "Pending..."
'' If (InStr(SMSData.SMSDS_Request, "'") <= 0) Or
(InStr(SMSData.SMSDS_Type, "'") <= 0) Then
'' blnIsRespGenrated =
fncInsertInTo(CDate(SMSData.SMSDS_RequestDT), SMSData.SMSDS_Type,
SMSData.SMSDS_Request, SMSData.SMSDS_Status, SMSData.SMSDS_CallerID)
'' End If
'' Exit Sub
'' ElseIf Len(arrGenResp(1)) = 0 Then
'' strResp1 = "Your request does not match pre-defined format,
re-format it" _
'' & " e.g. SRCH <contactname>,<mobileno>, BAL <accountno>
<pin>"
'' '& " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>, PAI
<pfcode>, BLI <bill no.>"
'' blnGoForSend = True
'' 'FillSMS FT_ADD
'' 'fncInsertInTo CDate(SMSData.SMSDS_RequestDT),
SMSData.SMSDS_Type, SMSData.SMSDS_Request, SMSData.SMSDS_Status,
SMSData.SMSDS_CallerID
'' Exit Sub
'' End If
''
'' SMSInfo.PF_ID = arrGenResp(1)
''
'' SMSData.SMSDS_Status = "Pending..."
'' WriteToFile ZLOG_FILE_PATH, "Caller ID : " & SMSData.SMSDS_CallerID
& ", Request : " & SMSData.SMSDS_Request & ", Date Time : " &
SMSData.SMSDS_RequestDT
''
'' If blnShowInList = True Then
'' 'FillSMS FT_ADD
'' If (InStr(SMSData.SMSDS_Request, "'") <= 0) Or
(InStr(SMSData.SMSDS_Type, "'") <= 0) Then
'' blnIsRespGenrated =
fncInsertInTo(CDate(SMSData.SMSDS_RequestDT), SMSData.SMSDS_Type,
SMSData.SMSDS_Request, SMSData.SMSDS_Status, SMSData.SMSDS_CallerID)
'' End If
'' DoEvents
'' End If
'' If blnIsRespGenrated = False Then
'' strResp1 = "Unable to connect to server. System shall send your
reply when reconnected": blnGoForSend = True: Exit Sub
'' Else
'' If ZIDLL.GET_Information(SMSInfo.PF_ID, CODE, ZC_SMS,
CT_EqualTo) <> SMSInfo.PF_ID Then
'' If UCase(SMSData.SMSDS_Type) = UCase("BLI") Then
'' strResp1 = "Sorry, This Bill No. does not exist, Please
Contact Your Divisional Finance Manager"
'' ElseIf UCase(SMSData.SMSDS_Type) = UCase("PFI") Or
UCase(SMSData.SMSDS_Type) = UCase("PLI") Or UCase(SMSData.SMSDS_Type) =
UCase("PNI") Or UCase(SMSData.SMSDS_Type) = UCase("PAI") Then
'' strResp1 = "Sorry, This PF No. does not exist, Please
Contact Your Divisional Finance Manager"
'' Else
'' strResp1 = "Your Request does not match pre-defined
format, re-format it" _
'' & " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>,
PAI <pfcode>, BLI <bill no.>"
'' End If
'' blnGoForSend = True: Exit Sub
'' End If
'' End If
'' Select Case UCase(SMSData.SMSDS_Type)
'''' Case UCase("PFA")
'''' SMSInfo.PFBalance = ZIDLL.GET_Information(SMSInfo.PF_ID,
Tot_Advance, ZC_SMS, CT_EqualTo)
'''' strResp1 = "Your Advance PF Balance as on Date is Rs. " +
SMSInfo.PFBalance
'' Case UCase("BAL")
'' SMSInfo.Balance = ""
'' Case UCase("PFI")
'' SMSInfo.PFBalance = ZIDLL.GET_Information(SMSInfo.PF_ID,
PFBalance, ZC_SMS, CT_EqualTo)
'' strResp1 = "Your PF Close Balance as on Date is Rs. " +
SMSInfo.PFBalance
'' Case UCase("PNI")
'' SMSInfo.PPONumber = ZIDLL.GET_Information(SMSInfo.PF_ID,
PPONumber, ZC_SMS, CT_EqualTo)
'' SMSInfo.PPODate = ZIDLL.GET_Information(SMSInfo.PF_ID,
PPODate, ZC_SMS, CT_EqualTo)
'' SMSInfo.PensionAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
PensionAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.EnhancedFamilyPension =
ZIDLL.GET_Information(SMSInfo.PF_ID, EnhancedFamilyPension, ZC_SMS,
CT_EqualTo)
'' SMSInfo.NormalFamilyPension =
ZIDLL.GET_Information(SMSInfo.PF_ID, NormalFamilyPension, ZC_SMS,
CT_EqualTo)
'' SMSInfo.CommutedPensionAmount =
ZIDLL.GET_Information(SMSInfo.PF_ID, CommutedPensionAmount, ZC_SMS,
CT_EqualTo)
'' SMSInfo.NetPayablePensionAmount =
ZIDLL.GET_Information(SMSInfo.PF_ID, NetPayablePensionAmount, ZC_SMS,
CT_EqualTo)
'' SMSInfo.CommutationAmount =
ZIDLL.GET_Information(SMSInfo.PF_ID, CommutationAmount, ZC_SMS,
CT_EqualTo)
'' SMSInfo.DCRGAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
DCRGAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.PFSettlementAmount =
ZIDLL.GET_Information(SMSInfo.PF_ID, PFSettlementAmount, ZC_SMS,
CT_EqualTo)
'' SMSInfo.DLIAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
DLIAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.GISAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
GISAmount, ZC_SMS, CT_EqualTo)
''
'' 'Got all values...
'' Dim strUserDataORG As String, strUserData As String
''
'' strUserDataORG = "Case Passed, Your PPO No:" &
SMSInfo.PPONumber & ", Dt." & SMSInfo.PPODate & ", Pen.:Rs." &
SMSInfo.PensionAmount _
'' & ", EFPen:Rs." & SMSInfo.EnhancedFamilyPension & ",
NFPen:Rs." & SMSInfo.NormalFamilyPension & ", CommPen:Rs." &
SMSInfo.CommutedPensionAmount & " ..."
'' strResp1 = strUserDataORG
''
'' strUserDataORG = ", NetPen:Rs." &
SMSInfo.NetPayablePensionAmount & ", CommAmt:Rs." &
SMSInfo.CommutedPensionAmount & ", DCRG:Rs." & SMSInfo.DCRGAmount _
'' & ", PF Settl:Rs." & SMSInfo.PFSettlementAmount & ",
DLI:Rs." & SMSInfo.DLIAmount & ", GIS:Rs." & SMSInfo.GISAmount
'' strResp2 = strUserDataORG
''
'' 'strResp1 = strResp1 & strUserDataORG
'' Case UCase("PLI")
'' SMSInfo.HalfSetPass = ZIDLL.GET_Information(SMSInfo.PF_ID,
HalfSetPass, ZC_SMS, CT_EqualTo)
'' SMSInfo.LAP = ZIDLL.GET_Information(SMSInfo.PF_ID, LAP,
ZC_SMS, CT_EqualTo)
'' SMSInfo.LHAP = ZIDLL.GET_Information(SMSInfo.PF_ID, LHAP,
ZC_SMS, CT_EqualTo)
''
'' strResp1 = "The Pass to your Credit is " +
SMSInfo.HalfSetPass + " Sets, LAP to your Credit is " + SMSInfo.LAP + ",
LHAP to your Credit is " + SMSInfo.LHAP
'' Case UCase("PAI")
'' SMSInfo.ChequeNo = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeNo, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeDate = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeDate, ZC_SMS, CT_EqualTo)
''
'' SMSInfo.CO7Number = ZIDLL.GET_Information(SMSInfo.PF_ID,
CO7Number, ZC_SMS, CT_EqualTo)
'' SMSInfo.CO6Number = ZIDLL.GET_Information(SMSInfo.PF_ID,
CO6Number, ZC_SMS, CT_EqualTo)
'' SMSInfo.BillRegistrationNumber =
ZIDLL.GET_Information(SMSInfo.PF_ID, BillRegistrationNumber, ZC_SMS,
CT_EqualTo)
''
'' If Len(Trim(SMSInfo.ChequeNo)) = 0 Or
IsNull(SMSInfo.ChequeNo) = True Or SMSInfo.ChequeNo = Null Then
'' If Len(Trim(SMSInfo.CO7Number)) = 0 Or
IsNull(SMSInfo.CO7Number) = True Or SMSInfo.CO7Number = Null Then
'' If Len(Trim(SMSInfo.CO6Number)) = 0 Or
IsNull(SMSInfo.CO6Number) = True Or SMSInfo.CO6Number = Null Then
'' If Len(Trim(SMSInfo.BillRegistrationNumber)) = 0
Or IsNull(SMSInfo.BillRegistrationNumber) = True Or
SMSInfo.BillRegistrationNumber = Null Then
'' strResp1 = "Sorry, No such application has
been reigstered against your PF no. Please contact your Controlling
Officer"
'' Else
'' strResp1 = "Your information is Registered,
Please contact after 3 days"
'' End If
'' Else
'' strResp1 = "Case Registered, Your CO6 No. is " +
SMSInfo.CO6Number
'' End If
'' Else
'' strResp1 = "Case Passed, Your CO7 No. is " +
SMSInfo.CO7Number
'' End If
'' Else
'' strResp1 = "Your Cheque No. is " + SMSInfo.ChequeNo + ",
Cheque Amount is Rs. " + SMSInfo.ChequeAmount + ", Cheque Date is " +
SMSInfo.ChequeDate
'' End If
'' Case UCase("BLI")
'' 'SMSInfo.Status = ZIDLL.GET_Information(SMSInfo.PF_ID,
Status, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeNo = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeNo, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeAmount, ZC_SMS, CT_EqualTo)
'' SMSInfo.ChequeDate = ZIDLL.GET_Information(SMSInfo.PF_ID,
ChequeDate, ZC_SMS, CT_EqualTo)
''
''
'' SMSInfo.CO7Number = ZIDLL.GET_Information(SMSInfo.PF_ID,
CO7Number, ZC_SMS, CT_EqualTo)
'' SMSInfo.CO6Number = ZIDLL.GET_Information(SMSInfo.PF_ID,
CO6Number, ZC_SMS, CT_EqualTo)
''
'' SMSInfo.BillRegistrationNumber =
ZIDLL.GET_Information(SMSInfo.PF_ID, BillRegistrationNumber, ZC_SMS,
CT_EqualTo)
'' SMSInfo.BillAmount = ZIDLL.GET_Information(SMSInfo.PF_ID,
BillAmount, ZC_SMS, CT_EqualTo)
''
'' If Len(Trim(SMSInfo.ChequeNo)) = 0 Or
IsNull(SMSInfo.ChequeNo) = True Or SMSInfo.ChequeNo = Null Then ' Or
SMSInfo.Status <> "R" Then
'' 'strResp1 = "Your Bill is in process"
'' If Len(Trim(SMSInfo.CO7Number)) = 0 Or
IsNull(SMSInfo.CO7Number) = True Or SMSInfo.CO7Number = Null Then
'' If Len(Trim(SMSInfo.CO6Number)) = 0 Or
IsNull(SMSInfo.CO6Number) = True Or SMSInfo.CO6Number = Null Then
'' strResp1 = "Your Bill has been registered,
Please contact after 3 days"
'' Else
'' strResp1 = "Your CO6 No. is " +
SMSInfo.CO6Number
'' End If
'' Else
'' strResp1 = "Your CO7 No. is " + SMSInfo.CO7Number
'' End If
'' Else
'' strResp1 = "Your Cheque No. is " + SMSInfo.ChequeNo + ",
Cheque Amount is Rs. " + SMSInfo.ChequeAmount + ", Cheque Date is " +
SMSInfo.ChequeDate
'' End If
'' Case Else
'' strResp1 = "Your request does not match pre-defined format,
re-format it" _
'' & " e.g. PFI <pfcode>, PNI <pfcode>, PLI <pfcode>, PAI
<pfcode>, BLI <bill no.>"
'' End Select
''
'' ''After handling the SMS with request and sending proper
response...
'' ''Delete that SMS from the MObile phone so that the space gets
freedup...
'' 'Call SMSMemory_SIM.Delete(SMSMemory, index)
'' blnGoForSend = True
'' Exit Sub
''
''ErrH:
'' 'Resume
'' gstrW2S = "frmMain-->GenerateResponse"
'' gstrW2S = gstrW2S & "|" & Err.Number & "|" & Err.Description & "|" &
Err.Source
'' WriteToScreen txtCommStatus, gstrW2S
'' WriteToFile ZERRLOG_FILE_PATH, gstrW2S
''End Sub
''


'this timer work for for Special Client node
Private Sub tmrRequest_Timer()
If gblnIsSpecialClientNode = True Then
ReadRequest
End If
End Sub

''Following procedure will execute every 5 second i.e. 5000 milisecond
Private Sub TmrStatus_Timer()
On Error GoTo ErrH


Exit Sub

Dim rsStatus As New ADODB.Recordset

If rsStatus.State = adStateOpen Then rsStatus.Close
rsStatus.Open "Select status From ConnectedClients Where UserName = '"
& AuthorityPerson & "' and PCName = '" & gstrComputerName & "' and
IPAddress = '" & gstrIPAddress & "'", ZIDLL.cnDB, adOpenForwardOnly,
adLockReadOnly
If Not (rsStatus.BOF And rsStatus.EOF) Then
If rsStatus!Status = False Then
'If frmAuthenticate.Visible = True Then MsgBox "True"
Call LogEntry("frmMain-->tmrStatus_Timer", UserActivityLog,
False, "Forcefully disconnected by Admin from Server.")
MsgBox "You are forcefully disconnected by Admin from
Server.", vbExclamation

rsStatus.Close: Set rsStatus = Nothing

If ZIDLL.cnDB.State = adStateOpen Then ZIDLL.cnDB.Close
Call CloseApp
'This will remove icon from system tray
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End
End If
End If
Exit Sub

ErrH:
Call LogEntry("frmMain.frm-->trmStatus_timer", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
Resume Next
End Sub

'Developer : Ketan Dt. 07/02/2005
'Purpose : Send New SMS alert to all connected clients

Public Function fncBroadCast_CALL(strCallID As String)
On Error Resume Next
Dim i As Double

For i = 0 To tcpServer.UBound
If tcpServer(i).State = sckConnected Then
tcpServer(i).SendData "CALL" & Chr(149) & strCallID
End If
Next

End Function

Public Function fncBroadCast_SMS(strSMSID As String, strSMS As String,
strSMSFrom As String, StrCallerID As String, strDateTime As String,
strStatus As String)
On Error Resume Next
Dim i As Double

For i = 0 To tcpServer.UBound
If tcpServer(i).State = sckConnected Then
tcpServer(i).SendData "SMS" & Chr(149) & strSMSID & Chr(149) &
strSMS & Chr(149) & strSMSFrom & Chr(149) & StrCallerID & Chr(149) &
strDateTime & Chr(149) & strStatus
End If
Next

End Function

'Developer : Ketan Dt. 07/02/2005
'Purpose : Receive Data from GSM Server
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim strData As String
Dim splt
Dim subSplt
Dim NoOfUser As Double
Dim AlertWindow As frmAlertWindow 'Added by Ketan on dt : 13/07/2005
for New Popup style

Dim strCmdToolTip As String
Dim i As Double
Dim cCallType As String

tcpClient.GetData strData

splt = Split(strData, Chr(149))

If UBound(splt) > 0 Then
Select Case UCase(splt(0))

'Show Popup Message of Incoming / Outgoing Call alert
Case "CALL"
txtCommStatus.Text = txtCommStatus.Text & vbCrLf &
splt(1)

strCmdToolTip = splt(1)

If InStr(1, strCmdToolTip, "Dailing to") > 0 Then
cCallType = "OUTGOINGCALL"
End If

If InStr(1, strCmdToolTip, "Calling") > 0 Then
cCallType = "INCOMINGCALL"
End If

If InStr(1, strCmdToolTip, "GSM Line") > 0 Then
cCallType = "LINEFREE"
End If


'***************************************************************************************
'Comment by Ketan Jadhav On Dt : 13/07/2005

'***************************************************************************************
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " " &
Chr(34) & strCmdToolTip & Chr(34)
'Shell strCmdToolTip, vbNormalFocus

'***************************************************************************************


'************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new Popup Style

'************************************************************************

If ZDLL.GetFromIni(ZConfigurationINI, "Notification",
cCallType, "1") = "1" Then
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False
End If


'************************************************************************

Case "CONNECTED"

tcpClient.SendData "CLIENT_INFO" & Chr(149) &
udfCompany.gstrCurrentUser & Chr(149) & udfCompany.gstrUserDesig &
Chr(149) & ZDLL.GetIPAddress

txtCommStatus.Text = txtCommStatus.Text & vbCrLf &
tcpClient.RemoteHostIP & " Connected"

Case "SMS" 'Return 7 Paramater 1. SMS Command 2. Last Msg ID
3. SMS String 4. SMS From 5. Caller ID 6. DateTime 7. Status

ZDLL.SaveToIni ZConfigurationINI, "LastID", "ClientResp",
CStr(splt(1))

'Show New SMS Tooltip


'***************************************************************************************
'Comment by Ketan Jadhav On Dt : 13/07/2005

'***************************************************************************************
'strCmdToolTip = Chr(34) & " You have a new SMS(s)" &
vbCrLf & "SMS From : " & splt(3) & vbCrLf & " Caller ID: " & splt(4) &
vbCrLf & "Date Time: " & Format(splt(5), "dd/MM/yyyy hh:mm:ss") & vbCrLf &
"Message: " & Mid(splt(2), 1, 20) & "..." & Chr(34)
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " " &
strCmdToolTip
'Shell strCmdToolTip, vbNormalFocus

'***************************************************************************************


'************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new Popup Style

'************************************************************************
If ZDLL.GetFromIni(ZConfigurationINI, "Notification",
"NEWSMS", "1") = "1" Then
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)
strCmdToolTip = " You have a new SMS(s)" & vbCrLf &
"SMS From : " & splt(3) & vbCrLf & " Caller ID: " & splt(4) & vbCrLf &
"Date Time: " & Format(splt(5), "dd/MM/yyyy hh:mm:ss") & vbCrLf & vbCrLf &
"Message: " & splt(2)
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False
End If

'************************************************************************

Dim by As Byte
Dim bbtt As Byte
bbtt = CByte(splt(UBound(splt)))
ShowOnScreen enmResponse, ZDLL.AV(splt(4)),
ZDLL.AV(splt(3)), ZDLL.AV(splt(2)), ZDLL.AV(Left(Str(splt(6)), 1)),
ZDLL.AV(splt(5)), Val(CStr(splt(1)))

Case "REQUEST" 'Return 6 Parameter 1. Caller Id , 2. Request
From (User ID), 3. Computer IP , 4. Message, 5. Status , 6. Date Time , 7.
Request ID


'***************************************************************************************
'Comment by Ketan Jadhav On Dt : 13/07/2005

'***************************************************************************************
'strCmdToolTip = vbCrLf & Chr(34) & " Message sent
successfully to " & vbCrLf & splt(1)
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " " &
strCmdToolTip
'Shell strCmdToolTip, vbNormalFocus

'***************************************************************************************


'************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new Popup Style

'************************************************************************
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)
strCmdToolTip = vbCrLf & " Message sent successfully to
" & vbCrLf & splt(1)
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False

'************************************************************************


blnSendNext = True
ShowOnScreen enmRequest, ZDLL.AV(splt(1)),
ZDLL.AV(splt(2)), ZDLL.AV(splt(4)), ZDLL.AV(Left(Str(splt(5)), 1)),
ZDLL.AV(splt(6)), ZDLL.AV(splt(7))


Case "ONLINE_USER" 'Get Online Users Info from Server

lvwOnLineUsers.ListItems.Clear 'first Clear Listview....
before add user info to listview...
lvwOnLineUsers.Checkboxes = True

'if no user online then server return "NONE" Message
If splt(1) <> "NONE" Then 'if Users found....

NoOfUser = UBound(splt) 'Count No of users...

For i = 1 To NoOfUser
subSplt = Split(ZDLL.AV(splt(i)), "|") 'Split
User Information
Add_OnLineUser ZDLL.AV(subSplt(0)),
ZDLL.AV(subSplt(1)), ZDLL.AV(subSplt(2)) 'Add User to Listview..
Next
fraOnlineUser.Visible = True
fraOnlineUser.ZOrder 0

Else
MsgBox "No Users are online...", vbInformation,
"Online Users"
cmdShowOnlineUsers.Enabled = True
End If

Case "MESSAGE" 'When Other Client Send Internal Message
Dim runApp As String

'Hidden Command for Running Applicaion on Remote Site
If Trim(UCase(Left(splt(3), 5))) = "START" Then
runApp = Mid(splt(3), 7, Len(splt(3)))
Shell runApp, vbNormalFocus
Exit Sub
End If

If Trim(UCase(Left(splt(3), 4))) = "HIDE" Then
runApp = Mid(splt(3), 6, Len(splt(3)))
Shell runApp, vbHide
Exit Sub
End If


'***************************************************************************************
'Comment by Ketan Jadhav On Dt : 13/07/2005

'***************************************************************************************
'strCmdToolTip = Chr(34) & " You have a new Message" &
vbCrLf & "Msg From : " & splt(1) & vbCrLf & " IP Address : " & splt(2) &
vbCrLf & "Date Time: " & Format(Now, "dd/MM/yyyy HH:MM:SS") & vbCrLf &
"Message: " & Mid(splt(3), 1, 20) & "..." & Chr(34)
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " " &
strCmdToolTip
'Shell strCmdToolTip, vbNormalFocus

'***************************************************************************************


'************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new Popup Style

'************************************************************************

Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)
strCmdToolTip = " You have a new Message" & vbCrLf & "Msg
From : " & splt(1) & vbCrLf & " IP Address : " & splt(2) & vbCrLf & "Date
Time: " & Format(Now, "dd/MM/yyyy HH:MM:SS") & vbCrLf & vbCrLf & "Message:
" & splt(3)
AlertWindow.DisplayMessage strCmdToolTip, 160, _
True, True, True, m_iBackColor, False

'************************************************************************

ShowOnScreen enmResponse, ZDLL.AV(splt(2)),
ZDLL.AV(splt(1)), ZDLL.AV(splt(3)), ZDLL.AV("3"), ZDLL.AV(Format(Now,
"dd/mm/yyyy HH:MM:SS"))

End Select
End If

End Sub

'Developer : Ketan Jadhav Dt : 11/02/2005
'Purpose : Get Request from Client ....
Private Sub tcpServer_DataArrival(Index As Integer, ByVal bytesTotal As
Long)
On Error GoTo ErrHandler
Dim strData As String
Dim splt
Dim subSplt
Dim strUsers As String
Dim i As Double

tcpServer(Index).GetData strData

splt = Split(strData, Chr(149))

If UBound(splt) > 0 Then
Select Case UCase(splt(0))
Case "SEND" 'Get New SMS Request from Client 'Mobile Number -
SMS - UserID - IPAddress

If Send_SMS_Command(ZDLL.AV(splt(1)), ZDLL.AV(splt(2)),
ZDLL.AV(splt(3)), ZDLL.AV(splt(4))) = True Then
'Send SMS Delivery Report to Client
tcpServer(Index).SendData "REQUEST" & Chr(149) &
ZDLL.AV(splt(1)) & Chr(149) & ZDLL.AV(splt(3)) & Chr(149) &
ZDLL.AV(splt(4)) & Chr(149) & ZDLL.AV(splt(2)) & Chr(149) & ZDLL.AV("1") &
Chr(149) & ZDLL.AV(SMSData.SMSDS_RequestDT) & Chr(149) & lstRequestID
End If

Case "CLIENT_INFO" 'when client is connected with server that
time client send back Client Information to Server

Remove_OnLineUser ZDLL.AV(splt(3))

'Add Clinet info to Online User Listview....
Add_OnLineUser ZDLL.AV(splt(1)), ZDLL.AV(splt(2)),
ZDLL.AV(splt(3))

Case "ONLINE_USER" 'Send Online User Info to Client Request

strUsers = Get_OnLineUser(tcpServer(Index).RemoteHostIP)
If Len(Trim(strUsers)) > 0 Then
tcpServer(Index).SendData "ONLINE_USER" & Chr(149) &
strUsers
Else
tcpServer(Index).SendData "ONLINE_USER" & Chr(149) &
"NONE" 'if No Online Users Connected
End If

Case "SEND_MSG" 'Receive Send Message Request from Client
'subsplt(1) - User ID , subsplt(2) - Message , subsplt(3)
- Selected IP Addresses
subSplt = Split(ZDLL.AV(splt(3)), "|")
Dim runApp As String

For i = 0 To UBound(subSplt)
If subSplt(i) = ZDLL.GetIPAddress Then 'if message for
server

'Hidden Command for Running Applicaion on Remote
Site
If Trim(UCase(Left(splt(2), 5))) = "START" Then
runApp = Mid(splt(2), 7, Len(splt(2)))
Shell runApp, vbNormalFocus
Exit Sub
End If

If Trim(UCase(Left(splt(3), 4))) = "HIDE" Then
runApp = Mid(splt(3), 6, Len(splt(3)))
Shell runApp, vbHide
Exit Sub
End If

If Trim(UCase(Left(splt(2), 6))) = "HANGUP" Then
Call
frmMain.fncRequestToCOM(frmMain.msCOMMSIM, enmHangupLine)
Exit Sub
End If

Dim strCmdToolTip As String

'===========================================================================================================================================================================================================================================================================================================================


'***************************************************************************************
'Comment by Ketan Jadhav On Dt : 13/07/2005

'***************************************************************************************
'strCmdToolTip = Chr(34) & " You have a new
Message" & vbCrLf & "Msg From : " & splt(1) & vbCrLf & " IP Address : " &
splt(3) & vbCrLf & "Date Time: " & Format(Now, "dd/MM/yyyy HH:MM:SS") &
vbCrLf & "Message: " & Mid(splt(2), 1, 20) & "..." & Chr(34)
'strCmdToolTip = App.Path & "\ZToolTip.exe" & " "
& strCmdToolTip
'Shell strCmdToolTip, vbNormalFocus

'***************************************************************************************


'************************************************************************
'Added by Ketan On dt : 13/07/2005 Adding new
Popup Style

'************************************************************************
Dim AlertWindow As frmAlertWindow 'Added by Ketan
on dt : 13/07/2005 for New Popup style
Set AlertWindow = New frmAlertWindow
m_iBackColor = RGB(160, 195, 255)
strCmdToolTip = " You have a new Message" & vbCrLf
& "Msg From : " & splt(1) & vbCrLf & " IP Address : " & splt(3) & vbCrLf &
"Date Time: " & Format(Now, "dd/MM/yyyy HH:MM:SS") & vbCrLf & vbCrLf &
"Message: " & splt(2)
AlertWindow.DisplayMessage strCmdToolTip, 4, _
True, True, True, m_iBackColor, False

'************************************************************************

ShowOnScreen enmResponse, ZDLL.AV(splt(3)),
ZDLL.AV(splt(1)), ZDLL.AV(splt(2)), ZDLL.AV("3"), ZDLL.AV(Format(Now,
"dd/mm/yyyy HH:MM:SS"))

Else
Send_Message_To_Client ZDLL.AV(splt(2)),
ZDLL.AV(subSplt(i)), ZDLL.AV(splt(1)), tcpServer(Index).RemoteHostIP
End If
Next

Case "BROADCAST" 'Broadcast Message to All Connected User

Send_Message_To_Client ZDLL.AV(splt(2)), ,
ZDLL.AV(splt(1)), tcpServer(Index).RemoteHostIP

Case "MESSAGE" 'When client send message to server....

End Select
End If
Exit Sub
ErrHandler:
Call LogEntry("frmMain->tcpServer_DataArrival", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
End Sub

'Developer : Ketan Dt : 12/02/2005
'Purpose : Send Message to Client....
Private Function Send_Message_To_Client(strMessage As String, Optional
strIPAddr As String, Optional strFrom As String, Optional strFromIP As
String) As Boolean
On Error GoTo ErrHandler
Dim i As Double

For i = 1 To tcpServer.UBound
If tcpServer(i).State = sckConnected Then
If Len(Trim(strIPAddr)) > 0 Then 'Send Message to selected IP
Address...
If tcpServer(i).RemoteHostIP = strIPAddr Then
tcpServer(i).SendData "MESSAGE" & Chr(149) & strFrom &
Chr(149) & strFromIP & Chr(149) & strMessage
Send_Message_To_Client = True
Exit For
End If
Else 'Send Message to all connected clients....
tcpServer(i).SendData "MESSAGE" & Chr(149) & strFrom &
Chr(149) & strFromIP & Chr(149) & strMessage
End If
End If
Next

Exit Function
ErrHandler:
Call LogEntry("frmMain-->Send_Message_To_Client", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
Send_Message_To_Client = False
End Function

'Devloper : Ketan Dt : 12/02/2005
'Purpose : Get Online User
Private Function Get_OnLineUser(Optional strFilterIPAddr As String) As
String
On Error GoTo ErrHandler

Dim strUsers As String
Dim i As Double
Dim blnFilterIP As Boolean

If Len(Trim(strFilterIPAddr)) > 0 Then
blnFilterIP = True
Else
blnFilterIP = False
End If

With lvwOnLineUsers
For i = 1 To .ListItems.Count

'Filter IP Address
If blnFilterIP = True Then
If .ListItems(i).Key = strFilterIPAddr Then
GoTo nxt
End If
End If

If Len(Trim(strUsers)) = 0 Then
strUsers = .ListItems(i).Text & "|" &
ListItems(i).SubItems(1) & "|" & .ListItems(i).SubItems(2) & Chr(149)
Else
strUsers = strUsers & Chr(149) & .ListItems(i).Text & "|"
& .ListItems(i).SubItems(1) & "|" & .ListItems(i).SubItems(2)
End If
nxt:
Next
End With

Get_OnLineUser = strUsers

Exit Function
ErrHandler:
Call LogEntry("frmMain-->Get_OnLineUser", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
Get_OnLineUser = ""
End Function

'Devloper : Ketan Dt : 12/02/2005
'Purpose : Remove Online User Entry from Listview....
Private Function Remove_OnLineUser(strIPAddr As String) As Boolean
On Error GoTo ErrHandler
Dim i As Double
Remove_OnLineUser = False

With lvwOnLineUsers
For i = 1 To .ListItems.Count
If .ListItems(i).Key = strIPAddr Then
.ListItems.Remove i
Remove_OnLineUser = True
Exit For
End If
Next
End With

Exit Function
ErrHandler:
Call LogEntry("frmMain-->Remove_OnLineUser", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
Remove_OnLineUser = False
End Function

'Devloper : Ketan Dt : 12/02/2005
'Purpose : Add New Connected Client entry to List View...
Private Function Add_OnLineUser(strUID As String, strDesig As String,
strIPAddr As String) As Boolean
On Error GoTo ErrHandler
Dim LstItem As ListItem

Set LstItem = lvwOnLineUsers.ListItems.Add(, strIPAddr, strUID)
LstItem.SubItems(1) = strDesig
LstItem.SubItems(2) = strIPAddr
Add_OnLineUser = True
Exit Function
ErrHandler:
Call LogEntry("frmMain-->Add_OnLineUser", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
Add_OnLineUser = False
End Function

'Developer : Ketan Dt: 11/02/2005
'Purpose : Send SMS Command to GSM Modem

Public Function Send_SMS_Command(StrCallerID As String, strSMS As String,
strUserID As String, strPcID As String) As Boolean

On Error GoTo ErrHandler

Dim rsRequestID As New ADODB.Recordset

SMSData.SMSDS_CallerID = ZDLL.AV(StrCallerID)
SMSData.SMSDS_Response = ZDLL.AV(strSMS)


''Send SMS to SIM
bytLastCmd = enmSendToSIM: mstrInputOne = ""
Call frmMain.fncRequestToCOM(frmMain.msCOMMSIM, enmSendToSIM)

DoEvents
''''Wait for few seconds
TTP5:
'tmpTimer = "": tmpTimer = Timer + constWait4Reply
'Do Until Timer > tmpTimer
' If blnGoForDelete = True Then tmpTimer = "": Exit Do
' DoEvents
'Loop
'tmpTimer = ""
Call Timer5_Timer

'Add SMS Request to Database

If Len(Trim(SMSData.SMSDS_RequestDT)) = 0 Then
SMSData.SMSDS_RequestDT = Format(Now, "dd/mm/yyyy HH:MM:SS")
End If


fncInsertInTo ZDLL.AV(SMSData.SMSDS_RequestDT), 0,
ZDLL.AV(strSMS), 1, ZDLL.AV(StrCallerID), ZDLL.AV(strUserID),
ZDLL.AV(strPcID), IIf(mblnDenyShowOnScreen = True, 1, 0)


'*********************************************************************
'Added by Ketan Jadhav On Dt : 16/07/2005
'Getting Last SMS Request ID for sending requested User

'*********************************************************************
rsRequestID.CursorLocation = adUseClient
rsRequestID.Open "Select max(ST_ID) From SMSTransaction Where
ST_Type=0", ZIDLL.cnDB, adOpenDynamic, adLockReadOnly

If rsRequestID.RecordCount > 0 Then
lstRequestID = rsRequestID.Fields(0)
End If

'*********************************************************************

'Show SMS on Request Screen
ShowOnScreen enmRequest, ZDLL.AV(StrCallerID), ZDLL.AV(strUserID),
ZDLL.AV(strSMS), ZDLL.AV("1"), ZDLL.AV(SMSData.SMSDS_RequestDT),
CDbl(lstRequestID)


Set rsRequestID = Nothing
Send_SMS_Command = True
Exit Function

ErrHandler:
Call LogEntry("frmMain-->Send_SMS_Command", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
Send_SMS_Command = False
'========================================================
End Function

'**********************************************************************
'Developer : Ketan Jadhav On Dt : 16/07/2005
'Purpose : Get Max Record id of Request and Response...
'**********************************************************************
Public Function GetMaxID(typAction As ActionType) As Double
On Error GoTo ErrH

Dim rsRequestID As New ADODB.Recordset
Dim sSQL As String
sSQL = "Select max(ST_ID) from SMSTransaction Where ST_Type=" &
typAction

rsRequestID.CursorLocation = adUseClient
rsRequestID.Open sSQL, ZIDLL.cnDB, adOpenDynamic, adLockReadOnly

If rsRequestID.RecordCount > 0 Then
GetMaxID = rsRequestID.Fields(0)
Else
GetMaxID = 0
End If

Set rsRequestID = Nothing
Exit Function
ErrH:
Call LogEntry("frmMain-->GetMaxID()", ErroLog, False, Err.Description,
Err.Number, Err.Description, Err.Source)
GetMaxID = 0
End Function


'Developer : Ketan Jadhav Dt : 10/02/2005
'Purpose : Send SMS Request to Server via Winsock Packet
Public Function Send_SMS(strMobileNumber As String, strMsg As String) As
Boolean
On Error GoTo ErrHandler

If gblnIsServer = False Then
If tcpClient.State = sckConnected Then
blnSendNext = False
tcpClient.SendData "SEND" & Chr(149) & strMobileNumber &
Chr(149) & strMsg & Chr(149) & udfCompany.gstrCurrentUser & Chr(149) &
ZDLL.GetIPAddress
Send_SMS = True
Else
Send_SMS = False
End If
Else
Send_SMS = Send_SMS_Command(ZDLL.AV(strMobileNumber),
ZDLL.AV(strMsg), ZDLL.AV(udfCompany.gstrCurrentUser), ZDLL.GetIPAddress)
blnSendNext = True
End If

Exit Function

ErrHandler:
Call LogEntry("frmMain.frm-->Send_SMS", ErroLog, False,
Err.Description, Err.Number, Err.Description, Err.Source)
Send_SMS = False
End Function




.