⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addresstx.vb

📁 采用Visual Bacis.NET开发的电子商务系统.
💻 VB
字号:
Imports System.Data
Imports System.Data.SqlClient
Imports System.EnterpriseServices
Imports EShopComm.Common

Namespace Services

    Public Interface IAddressesTx
        Function InsertAddresses(ByVal objCustomer As Customer) As Customer
    End Interface

    <Description("Contains methods for inserting Address records in the jyEShop system."), _
        Transaction(TransactionOption.Required), _
        Synchronization(SynchronizationOption.Required), _
        JustInTimeActivation(True)> _
    Public Class AddressesTx
        Inherits ServicedComponent
        Implements IAddressesTx

        Private Connstring As String = "Data Source=localhost;Initial Catalog=Shop;user id=sa;pwd=sa"

        <Description("Inserts new Address records in the jyEShop system.")> _
        Public Function InsertAddresses(ByVal objCustomer As Customer) As Customer _
                                        Implements IAddressesTx.InsertAddresses

            Try
                Dim objAddress As Address
                Dim sqlcmdInsertCustomerAddress As New SqlCommand("sp_Addresses_INS")
                With sqlcmdInsertCustomerAddress
                    .CommandType = CommandType.StoredProcedure
                    With .Parameters
                        .Add("@chrAddressID", SqlDbType.Char, 38)
                        .Add("@chrCustomerID", SqlDbType.Char, 38)
                        .Add("@nvchrAddress1", SqlDbType.NVarChar, 50)
                        .Add("@nvchrAddress2", SqlDbType.NVarChar, 30)
                        .Add("@nvchrCity", SqlDbType.NVarChar, 30)
                        .Add("@nvchrRegion", SqlDbType.NVarChar, 30)
                        .Add("@nvchrPostalCode", SqlDbType.NVarChar, 20)
                        .Add("@nvchrCountry", SqlDbType.NVarChar, 30)
                        .Add("@nchrTelphone", SqlDbType.NChar, 15)
                    End With
                End With
                Dim sqlconShop As New SqlConnection(Connstring)
                sqlconShop.Open()
                sqlcmdInsertCustomerAddress.Connection = sqlconShop
                If objAddress.AddressID.Length = 0 Then
                    objAddress.AddressID = System.Guid.NewGuid.ToString()
                End If
                With sqlcmdInsertCustomerAddress.Parameters
                    .Item("@chrAddressID").Value = objAddress.AddressID
                    .Item("@nvchrAddress1").Value = objAddress.Address1
                    .Item("@nvchrAddress2").Value = objAddress.Address2
                    .Item("@nvchrCity").Value = objAddress.City
                    .Item("@nvchrCountry").Value = objAddress.Country
                    .Item("@nchrTelphone").Value = objAddress.Telphone
                    .Item("@nvchrPostalCode").Value = objAddress.PostalCode
                    .Item("@nvchrRegion").Value = objAddress.Region
                    .Item("@chrCustomerID").Value = objCustomer.CustomerID
                End With
                sqlcmdInsertCustomerAddress.ExecuteNonQuery()
                sqlconShop.Close()
                ContextUtil.SetComplete()
                Return objCustomer
            Catch excp As System.Exception
                ContextUtil.SetAbort()
                Throw excp
            End Try

        End Function
    End Class
End Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -