如果此时实际上正在登录阶段这个步骤才会起作用检查以查看是否己经验证用户如果没有验证则显示适当的错误消息通知用户他们这一次没有能够登录否则验证用户
Sub Wizard_NextButtonClick(ByVal sender As Object ByVal e As SystemWebUIWebControlsWizardNavigationEventArgs)
If eCurrentStepIndex = Then
Dim l As SystemWebUIWebControlsLogin = CType(WizardFindControl(Login) Login)
If MembershipValidateUser(lUserName lPassword) Then
FormsAuthenticationSetAuthCookie(lUserName lRememberMeSet)
eCancel = False
Else
TraceWrite(lUserName lPassword)
lInstructionText = Your login attempt was not successful Please try again
lInstructionTextStyleForeColor = SystemDrawingColorRed
eCancel = True
End If
End If
End Sub
FinishButtonClick包含或许是最长的代码集但它并不像看起来那么复杂在此处将用户的订单写入到数据库必须能够在发生错误时回滚这一点首先创建连接字符串并且创建事务然后将结账过程中提供的所有详情读入到参数中有许多参数!具有成员名递送地址信用卡详情和整个购物车总价
Sub Wizard_FinishButtonClick(ByVal sender As Object ByVal e As SystemWebUIWebControlsWizardNavigationEventArgs)
TODO: Move to component
Insert the order and order lines into the database
Dim conn As New SqlConnection(ConfigurationManagerConnectionStrings(WroxUnited)ConnectionString)
Dim trans As SqlTransaction = Nothing
Dim cmd As New SqlCommand()
Dim OrderID As Integer
Try
connOpen()
trans = connBeginTransaction
cmdConnection = conn
cmdTransaction = trans
cmdCommandType = DataCommandTypeStoredProcedure
set the order details
cmdCommandText = usp_OrderAdd
TODO: by default in beta creating a stored proc doesnt give execute perms
cmdCommandText = INSERT INTO Orders(MemberName OrderDate Name Address County PostCode Country SubTotal Discount Total) & _
VALUES (@MemberName @OrderDate @Name @Address @County @PostCode @Country @SubTotal @Discount @Total)
cmdParametersAdd(@MemberName DataSqlDbTypeVarChar )
cmdParametersAdd(@OrderDate DataSqlDbTypeDateTime)
cmdParametersAdd(@Name DataSqlDbTypeVarChar )
cmdParametersAdd(@Address DataSqlDbTypeVarChar )
cmdParametersAdd(@County DataSqlDbTypeVarChar )
cmdParametersAdd(@PostCode DataSqlDbTypeVarChar )
cmdParametersAdd(@Country DataSqlDbTypeVarChar )
cmdParametersAdd(@SubTotal DataSqlDbTypeMoney)
cmdParametersAdd(@Discount DataSqlDbTypeMoney)
cmdParametersAdd(@Total DataSqlDbTypeMoney)
cmdParameters(@MemberName)Value = UserIdentityName
cmdParameters(@OrderDate)Value = DateTimeNow()
cmdParameters(@Name)Value = CType(WizardFindControl(txtName) TextBox)Text
cmdParameters(@Address)Value = CType(WizardFindControl(txtAddress) TextBox)Text
cmdParameters(@County)Value = CType(WizardFindControl(txtCounty) TextBox)Text
cmdParameters(@PostCode)Value = CType(WizardFindControl(txtPostCode) TextBox)Text
cmdParameters(@Country)Value = CType(WizardFindControl(txtCountry) TextBox)Text
cmdParameters(@Total)Value = ProfileCartTotal
OrderID = Convert
ToInt
(cmd
ExecuteScalar())
[] [] [] [] [] [] [] []