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

📄 customerstx.vb

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

Namespace Services

    Public Interface ICustomersTx
        Function CreateAccount(ByVal objCustomer As Customer) As Customer
        Function InsertCustomer(ByVal objCustomer As Customer) As Customer
    End Interface

    <Description("Contains methods for Creating Customers and inserting Customer records in the IBuyAdventure system."), _
        Transaction(TransactionOption.Required), _
        Synchronization(SynchronizationOption.Required), _
        JustInTimeActivation(True)> _
    Public Class CustomersTx
        Inherits ServicedComponent

        Implements ICustomersTx

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

        <Description("Creates a new Customer Account in the jyEShop system.")> _
        Public Function CreateAccount(ByVal objCustomer As Customer) As Customer _
        Implements ICustomersTx.CreateAccount

            Try
                objCustomer = Me.InsertCustomer(objCustomer)
                Dim objAddressesTx As New AddressesTx()
                objCustomer = objAddressesTx.InsertAddresses(objCustomer)
                ContextUtil.SetComplete()
                Return objCustomer
            Catch excp As System.Exception
                ContextUtil.SetAbort()
                Throw excp
            End Try

        End Function


        <Description("Inserts a new Customer record in the jyEShop system.")> _
        Public Function InsertCustomer(ByVal objCustomer As Customer) As Customer _
                                       Implements ICustomersTx.InsertCustomer
            Try
                If objCustomer.CustomerID.Length = 0 Then
                    objCustomer.CustomerID = System.Guid.NewGuid.ToString()
                End If
                Dim sqlcmdInsertCustomer As New SqlCommand("sp_Customers_INS")
                With sqlcmdInsertCustomer
                    .CommandType = CommandType.StoredProcedure
                    With .Parameters
                        .Add("@chrCustomerID", SqlDbType.Char, 38)
                        .Add("@nvchrCustomerName", SqlDbType.NVarChar, 50)
                        .Add("@nvchrEmailAddress", SqlDbType.NVarChar, 50)
                        .Add("@nvchrPassword", SqlDbType.NVarChar, 20)
                        .Add("@intCustomerType", SqlDbType.Int)
                        .Add("@intAccountStatus", SqlDbType.Int)

                        .Item("@chrCustomerID").Value = objCustomer.CustomerID
                        .Item("@nvchrCustomerName").Value = objCustomer.CustomerName
                        .Item("@nvchrEmailAddress").Value = objCustomer.EmailAddress
                        .Item("@nvchrPassword").Value = objCustomer.Password
                        .Item("@intCustomerType").Value = objCustomer.CustomerType
                        .Item("@intAccountStatus").Value = Customer.AccountStatusEnum.AccountStatus_启用
                    End With
                End With
                Dim sqlconShop As New SqlConnection(Connstring)
                sqlconShop.Open()
                sqlcmdInsertCustomer.Connection = sqlconShop
                sqlcmdInsertCustomer.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 + -