建表会吧?删除行的时候,到删除事件,把编号数据新增到编号表会吧?到生成编号的代码里,先到【断号表】查询,查询数据会吧?如果查询有结果,就取编号。如果没有按正常方式生成编号。
在服务端的OpenQQ服务端事件ReceivedMessage中编写代码:
Dim msg As String = e.Message
If msg.StartsWith(":f") AndAlso msg.EndsWith("f:") Then
msg = msg.SubString(2, msg.Length - 4)
Dim cmd As new SQLCommand()
cmd.ConnectionName = "Orders" '指定数据源
Try
cmd.BeginTransaction() '开启事务
cmd.CommandText = "select top 1 * From 断号表 Where 类型 = " & msg & " order by 编号"
Dim dt As DataTable = cmd.ExecuteReader()
'继续使用同一个SQLCommand执行其它SQL语句.
If dt.dataraows.count > 0 Then
cmd.CommandText = "Delete From 断号表 Where [_Identify] = " & dt.dataraows(0)("_Identify")
cmd.ExecuteNonQuery()
cmd.Commit() '提交事务
e.ReturnValue = dt.dataraows(0)("编号")
Return
end if
cmd.Commit() '提交事务
Catch ex As Exception '如果出错
cmd.Rollback() '则回滚事务
End Try
If flbhs.ContainsKey(msg) Then '如果存在这个类别的编号
flbhs(msg) = flbhs(msg) + 1 '将该类别最大编号加1
Else
flbhs.Add(msg,1) '如果是这个列表的首次编号,则编号等于1
End If
e.ReturnValue = flbhs(msg) '将编号返回给客户端
End If