📄 c_gsendsms.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "c_gsendsms"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public cnnstr As String
'SELECT gsid, cid, imsend, cname, isall,stime, rtime
'From dbo.vwgsendsms
Public Sub openrs(rs As Recordset)
With rs
.ActiveConnection = Me.cnnstr
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Open "SELECT* From vwgsendsms"
Set .ActiveConnection = Nothing
End With
End Sub
Public Sub searchsms(str As String, rs As Recordset)
rs.Open "SELECT cid, birth, cname, sex, mobile, phone, memo From customer"
End Sub
Public Function getrec(id As Integer) As m_gsendsms
On Error GoTo errh
Dim value As New m_gsendsms
Dim rs As New Recordset
With rs
.ActiveConnection = Me.cnnstr
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Open "SELECT * From vwgsendsms where gsid=" & id
Set .ActiveConnection = Nothing
End With
If rs.BOF And rs.EOF Then
GoTo errh
End If
value.gsid = rs("gsid")
value.cid = rs("cid")
value.cname = rs("cname")
value.stime = rs("stime")
value.imsend = rs("imsend")
value.rtime = rs("rtime")
value.isall = rs("isall")
rs.Close
releObject rs
Set getrec = value
Exit Function
errh:
Set value = Nothing
Set getrec = Nothing
End Function
'SELECT mid, text
'From dbo.m_gsendsmss
Public Function addrec(sms As String, cid As Integer, imsend As Boolean, isall As Boolean, rtime As Date, stime As Date) As Boolean
Dim cnnx As New ADODB.Connection
Dim rs As New Recordset
Dim strSql As String
On Error GoTo errhand
cnnx.ConnectionString = cnnstr
cnnx.Open
strSql = "INSERT INTO gsendsms (cid,sms, imsend, isall,stime, rtime) values (" & cid & "" _
& ",'" & sms & "'" _
& "," & CInt(imsend) & "" _
& "," & CInt(isall) & "" _
& ",'" & DATETODB(stime) & "'" _
& ",'" & DATETODB(rtime) _
& "')"
cnnx.Execute strSql
With rs
.ActiveConnection = cnnx
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
If isall Then
.Open "select cid,mobile from customer "
Else
' SELECT gid, ccid, cid, cname, cusname, mobile
' From dbo.vwgroup
.Open "select cid,mobile from vwgroup where ccid= " & cid
End If
End With
While Not rs.EOF
strSql = "INSERT INTO sendsms (mobile, sms,cid, sendisok, smsfrom, imsend, rtime, stime) values ('" & rs("mobile") & "'" _
& ",'" & sms & "'" _
& "," & rs("cid") & "" _
& "," & 0 & "" _
& "," & -1 & "" _
& "," & CInt(imsend) & "" _
& ",'" & DATETODB(rtime) & "'" _
& ",'" & DATETODB(stime) _
& "')"
cnnx.Execute strSql
rs.MoveNext
Wend
rs.Close
releObject rs
cnnx.Close
releObject cnnx
addrec = True
Exit Function
errhand:
If cnnx.State = adStateOpen Then
cnnx.Close
End If
rs.Close
releObject rs
releObject cnnx
addrec = False
End Function
Public Function updaterec(gsid As Integer, cid As Integer, imsend As Boolean, isall As Boolean, rtime As Date, stime As Date) As Boolean
Dim cnnx As New ADODB.Connection
Dim strSql As String
On Error GoTo errhand
cnnx.ConnectionString = cnnString
cnnx.Open
strSql = "update gsendsms set cid=" & cid & "" _
& ",imsend=" & CInt(imsend) & "" _
& ",isall=" & CInt(isall) & "" _
& ",rtime='" & DATETODB(rtime) & "'" _
& ",stime='" & DATETODB(stime) & "'" _
& "' where gsid=" & gsid
cnnx.Execute strSql
cnnx.Close
releObject cnnx
updaterec = True
Exit Function
errhand:
If cnnx.State = adStateOpen Then
cnnx.Close
End If
releObject cnnx
updaterec = False
End Function
Public Function deleterec(id As Integer) As Boolean
On Error GoTo errh
Dim cnnx As New ADODB.Connection
Dim strSql As String
cnnx.ConnectionString = cnnString
cnnx.Open
strSql = "delete from gsendsms where gsid=" & id
cnnx.Execute strSql
cnnx.Close
releObject cnnx
deleterec = True
Exit Function
errh:
If cnnx.State = adStateOpen Then
cnnx.Close
End If
releObject cnnx
deleterec = False
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -