************************************************************************* '//结束日期:2002年5月27日 '*********************************************************************** Option Explicit On 'Option Strict On '//*********************************************************************** '//Begin defined namespace Namespace Sunerp.CommClass.Comm '//Structure descriptoin '//本结构存取 数据库服务器名(Dbserver)、数据库用户ID(UserId)、 '//数据库用户密码(UserPWD)、数据库名(Dbase),为联接数据库提供参数。 '//为了满足某些简单查询的需要,提供了扩展的变量 常用表名(DBTable)、 '//查询字段名(QueryFieldName)、查询字段值 Public Structure PublicApplicationVal ' Public Dbserver, UserId UserPWD Dbase DBTable Aclearcase/" target="_blank" >ccount. Public Dbserver As String Public UserId As String Public UserPWD As String Public Dbase As String Public DBTable As String Public QueryFieldVale As String Public QueryFieldName As String End Structure '//End define Structure PublicApplicationVal '//******************************************************************** '//Begin defined Class Public Class DBaseBindComm ''***************************************************************** ''//**定义连接SQL Server Database的通用函数**// '//本函数创建一个到指定数据库的连接对象 SqlConnection '//本函数有1个参数,IPublicApplication 为公共数据结构 PublicApplicationVal, Public Overloads Function LinkedSqlServer() As System.Data.SqlClient.SqlConnection Dim conn As New SqlConnection() strconn = "server=" & "erp" & _ ";user id=" & "erpsa" & _ ";password=" & "erpsa" & _ ";database=" & "erpdata" & ";" conn = New SqlConnection(strconn) conn.Open() StateVal = True LinkedSqlServer = conn Catch ex As Exception ' MsgBox(ex.ToString) StateVal = False LinkedSqlServer = Nothing Exit Function End Try End Function ''End defined LinkedSqlServer ''*********************************************************************** ''//**定义连接SQL Server Database的通用函数**// '//本函数创建一个到指定数据库的连接对象 SqlConnection '//本函数有1个参数,IPublicApplication 为公共数据结构 PublicApplicationVal, Public Overloads Function LinkedSqlServer( _ ByVal IPublicApplication As PublicApplicationVal) _ As System.Data.SqlClient.SqlConnection Dim conn As New SqlConnection() strconn = "server=" & IPublicApplication.Dbserver & _ ";user id=" & IPublicApplication.UserId & _ ";password=" & IPublicApplication.UserPWD & _ ";database=" & IPublicApplication.Dbase & ";" conn = New SqlConnection(strconn) conn.Open() StateVal = True LinkedSqlServer = conn Catch ex As Exception ' MsgBox(ex.ToString) StateVal = False LinkedSqlServer = Nothing Exit Function End Try End Function ''End defined LinkedSqlServer ''************************************************************** ''定义类DBaseBindComm的ReadOnly属性State(创建连接的状态) ''True(创建成功),False(创建失败) Private StateVal As Boolean Public ReadOnly Property State() As Boolean Get Return StateVal End Get End Property '//Structure descriptoin '//本结构存取 企业组织机构Id '//顶层(DeptTopID)、一级(DeptMidId),二级ID(DeptLowId) Public Structure PublicOrganIDStructure Public DeptTopID As String Public DeptMidId As String Public DeptLowId As String End Structure '//End define Structure PublicOrganIDStructure '//****************************************************************** ''//**定义连接SQL Server Database的通用函数**// '//本函数创建一个到指定数据库的连接对象 SqlConnection '//本函数有1个参数,IPublicApplication 为公共数据结构 PublicApplicationVal, Public Function IParseDeptOrgid(ByVal IDeptOrgid As String) As PublicOrganIDStructure Dim OrganID As New PublicOrganIDStructure() Dim Orgid As String Orgid = Microsoft.VisualBasic.Left(Trim(IDeptOrgid), 12) OrganID.DeptMidId = Microsoft.VisualBasic.Right(Orgid, 6) OrganID.DeptLowId = Microsoft.VisualBasic.Right(IDeptOrgid, 6) End Function '//End define Function IParseDeptOrgid End Namespace '*******************************************************************************
'//开始日期:2002年5月27日
Imports System.Data.SqlClient
'//*************************************************************************
'//Defined Structure PublicApplicationVal
'//Begin define Structure PublicApplicationVal
'//Begin define Function LinkedSqlServer
Dim strconn As String
Try
'//Begin define Function LinkedSqlServer
Dim strconn As String
Try
End Class
Public Class OrganComm
'//Defined Structure PublicOrganIDStructure
'//Begin define Structure PublicOrganIDStructure
'//Begin define Function IParseDeptOrgid
IDeptOrgid = Trim(IDeptOrgid)
OrganID.DeptTopID = Microsoft.VisualBasic.Left(Orgid, 6)
IParseDeptOrgid = OrganID
End Class