您现在的位置是:首页 >

尤克里里教程入门教程 ASP.NET入门教程 13.4.5 计划结账[6]

火烧 2022-06-08 11:03:30 1077
ASP.NET入门教程 13.4.5 计划结账[6] 如果此时实际上正在登录阶段 这个步骤才会起作用 检查以查看是否己经验证用户 如果没有验证 则显示适当的错误消息 通知用户他们这一次没有能够登录 否

ASP.NET入门教程 13.4.5 计划结账[6]  

    如果此时实际上正在登录阶段 这个步骤才会起作用 检查以查看是否己经验证用户 如果没有验证 则显示适当的错误消息 通知用户他们这一次没有能够登录 否则 验证用户

 

Sub Wizard _NextButtonClick(ByVal sender As Object ByVal e As System Web UI WebControls WizardNavigationEventArgs)

 

        If e CurrentStepIndex = Then

 

            Dim l As System Web UI WebControls Login = CType(Wizard FindControl( Login ) Login)

 

            If Membership ValidateUser(l UserName l Password) Then

                FormsAuthentication SetAuthCookie(l UserName l RememberMeSet)

 

                e Cancel = False

            Else

                Trace Write(l UserName l Password)

                l InstructionText = Your login attempt was not successful Please try again

                l InstructionTextStyle ForeColor = System Drawing Color Red

 

                e Cancel = True

            End If

        End If

 

    End Sub

    FinishButtonClick包含或许是最长的代码集 但它并不像看起来那么复杂 在此处将用户的订单写入到数据库 必须能够在发生错误时回滚这一点 首先创建连接字符串 并且创建事务 然后将结账过程中提供的所有详情读入到参数中 有许多参数!具有成员名 递送地址 信用卡详情和整个购物车总价

 

Sub Wizard _FinishButtonClick(ByVal sender As Object ByVal e As System Web UI WebControls WizardNavigationEventArgs)

 

        TODO: Move to ponent

        Insert the order and order lines into the database

        Dim conn As New SqlConnection(ConfigurationManager ConnectionStrings( WroxUnited ) ConnectionString)

        Dim trans As SqlTransaction = Nothing

尤克里里教程入门教程 ASP.NET入门教程 13.4.5 计划结账[6]

        Dim cmd As New SqlCommand()

        Dim OrderID As Integer

 

 

        Try

            conn Open()

            trans = conn BeginTransaction

            cmd Connection = conn

            cmd Transaction = trans

            cmd CommandType = Data CommandType StoredProcedure

 

            set the order details

            cmd CommandText = usp_OrderAdd

            TODO: by default in beta creating a stored proc doesn t give execute perms

            cmd CommandText = INSERT INTO Orders(MemberName OrderDate Name Address County PostCode Country SubTotal Discount Total) & _

                             VALUES (@MemberName @OrderDate @Name @Address @County @PostCode @Country @SubTotal @Discount @Total)

            cmd Parameters Add( @MemberName Data SqlDbType VarChar )

            cmd Parameters Add( @OrderDate Data SqlDbType DateTime)

            cmd Parameters Add( @Name Data SqlDbType VarChar )

            cmd Parameters Add( @Address Data SqlDbType VarChar )

            cmd Parameters Add( @County Data SqlDbType VarChar )

            cmd Parameters Add( @PostCode Data SqlDbType VarChar )

            cmd Parameters Add( @Country Data SqlDbType VarChar )

            cmd Parameters Add( @SubTotal Data SqlDbType Money)

            cmd Parameters Add( @Discount Data SqlDbType Money)

            cmd Parameters Add( @Total Data SqlDbType Money)

 

            cmd Parameters( @MemberName ) Value = User Identity Name

            cmd Parameters( @OrderDate ) Value = DateTime Now()

            cmd Parameters( @Name ) Value = CType(Wizard FindControl( txtName ) TextBox) Text

            cmd Parameters( @Address ) Value = CType(Wizard FindControl( txtAddress ) TextBox) Text

            cmd Parameters( @County ) Value = CType(Wizard FindControl( txtCounty ) TextBox) Text

            cmd Parameters( @PostCode ) Value = CType(Wizard FindControl( txtPostCode ) TextBox) Text

            cmd Parameters( @Country ) Value = CType(Wizard FindControl( txtCountry ) TextBox) Text

           

            cmd Parameters( @Total ) Value = Profile Cart Total

 

            OrderID = Convert ToInt (cmd ExecuteScalar()) lishixinzhi/Article/program/net/201311/15649  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码