我有一个aspx页面,其中包含4个多视图控件和每个控件的不同视图。在第一个视图(详细信息视图)中,我输入了一些发票详细信息,并检查数据库的数据库以及付款详细信息。
代码正常工作,直到它显示数据行和支付控件,但支付控件(用户控件)没有正确触发其验证控件(必填字段和正则表达式控件)。除了按钮点击也不会触发验证代码,虽然如果我输入正确的详细信息它会保存数据。
你们中的任何人都可以查看下面的代码并告诉我这里有什么不对吗?
Protected Sub cmdPay_Click(sender As Object, e As EventArgs) Handles cmdPay.Click
mvwDetails.Visible = False
Try
' If Not Page.IsPostBack Then
If Me.CreditCard1.CCNumber.Length < 14 Or Me.CreditCard1.CCNumber.Length > 16 Then
Me.lblError.Text = "Please enter Valid Card details"
Else
Dim result As DateTime = Conversions.ToDate("1/1/1900")
If Not DateTime.TryParse(Me.CreditCard1.CCExpireDate, result) Then
Me.lblError.Text = "Please enter the Valid Expiry Date"
Me.lblError.Visible = True
' mvwMakePayment.Visible = True
' mvwMakePayment.SetActiveView(vwMakePayment)
ElseIf DateTime.Compare(result, DateTime.Today) < 0 Then
Me.lblError.Text = "Please enter the Valid Expiry Date"
Me.lblError.Visible = True
' mvwMakePayment.Visible = True
' mvwMakePayment.SetActiveView(vwMakePayment)
ElseIf Me.CreditCard1.CVV Is Nothing Or Not Versioned.IsNumeric(DirectCast(Me.CreditCard1.CVV, Object)) Then
Me.lblError.Text = "Invalid credit card details."
Me.lblError.Visible = True
' mvwMakePayment.Visible = True
' mvwMakePayment.SetActiveView(vwMakePayment)
ElseIf Strings.Len(Me.CreditCard1.CVV) > 4 Then
Me.lblError.Text = "Invalid cvv number."
Me.lblError.Visible = True
' mvwMakePayment.Visible = True
' mvwMakePayment.SetActiveView(vwMakePayment)
Else
Dim OrderID As String
OrderID = grdMain.Items(0).Cells(1).Text
If Page.IsValid Then
Dim dtOrderPerson As DataTable = Me.DataAction.GetDataTable("SELECT o.ID,o.BillToID,o.ShipToName,o.BillToCompanyID,o.OrganizationID,o.InvoiceNumber,OrderDate,GrandTotal,Balance,CurrencySymbol,NumDigitsAfterDecimal FROM " & Convert.ToString(Me.Database) & "..vwOrders o INNER JOIN " & Convert.ToString(Me.Database) & "..vwCurrencyTypes ct ON o.CurrencyTypeID=ct.ID where Balance > 0 AND o.OrderStatus <> 'Cancelled' And o.ID=" & CLng(OrderID), IAptifyDataAction.DSLCacheSetting.BypassCache)
If dtOrderPerson.Rows.Count > 0 Then
Me.mvwMakePayment.SetActiveView(vwMakePayment)
Me.mvwMakePayment.Visible = True
'lblkaj.Text = "returned a record"
FirstName = dtOrderPerson.Rows(0).Item("ShipToName").Trim.ToString()
Dim entityObject As AptifyGenericEntityBase = Me.AptifyApplication.GetEntityObject("Payments", -1)
entityObject.SetValue("EmployeeID", DirectCast(1, Object)) 'No web user is returned as the data is based on orderid and companyid , Employee id of the web user is 1 hence using the same
' entityObject.SetValue("EmployeeID", DirectCast(grdMain.Items(0).Cells(0).ToString(), Object))
entityObject.SetValue("PersonID", DirectCast(dtOrderPerson.Rows(0).Item("BillToID").ToString, Object))
entityObject.SetValue("CompanyID", DirectCast(dtOrderPerson.Rows(0).Item("BillToCompanyID").ToString, Object)) 'Me.dtOrders.Rows(0).Item("BilllToCompanyID").ToString
entityObject.SetValue("PaymentDate", DirectCast(DateTime.Today, Object))
entityObject.SetValue("DepositDate", DirectCast(DateTime.Today, Object))
entityObject.SetValue("EffectiveDate", DirectCast(DateTime.Today, Object))
entityObject.SetValue("PaymentTypeID", DirectCast(Me.CreditCard1.PaymentTypeID, Object))
entityObject.SetValue("CCAccountNumber", DirectCast(Me.CreditCard1.CCNumber, Object))
entityObject.SetValue("CCExpireDate", DirectCast(Me.CreditCard1.CCExpireDate, Object))
entityObject.SetAddValue("_xCCSecurityNumber", DirectCast(Me.CreditCard1.CVV, Object))
entityObject.SetValue("PaymentLevelID", DirectCast(1, Object))
' entityObject.SetValue("Comments", DirectCast("Created through the CGI e-Business Suite", Object))
entityObject.SetAddValue("_xConvertQuotesToRegularOrder", DirectCast("1", Object))
Dim genericEntityBase As AptifyGenericEntityBase = entityObject.SubTypes("PaymentLines").Add()
genericEntityBase.SetValue("Amount", DirectCast(dtOrderPerson.Rows(0).Item("Balance").ToString, Object))
genericEntityBase.SetValue("OrderID", DirectCast(dtOrderPerson.Rows(0).Item("ID").ToString, Object))
genericEntityBase.SetValue("Comments", DirectCast("Invoice paid from web", Object))
If entityObject.Save(True) Then
Dim dtPyments As DataTable = Me.DataAction.GetDataTable("select P.ID,P.PersonID,P.CompanyID,P.PaymentDate,Pl.OrderID,Pl.Amount from payment P inner join paymentdetail pl on P.id=Pl.paymentid where pl.orderid=" & CLng(OrderID))
' Me.grdReceipt.DataSource = DirectCast(dtPyments, Object)
' grdReceipt.DataBind()
' grdReceipt.Visible = False
lblInvo.Text = OrderID
lblPyNo.Text = dtPyments.Rows(0).Item("ID").ToString()
lblAmount0.Text = dtPyments.Rows(0).Item("Amount").ToString()
Dim amnt As Double = lblAmount0.Text
amnt = FormatNumber(amnt, 2)
lblAmount0.Text = amnt
' EmailID = txtEmail.Text.Trim.ToString
mvwMakePayment.Visible = False
mvwMessage.Visible = True
mvwMessage.SetActiveView(vwSuccessMessage)
Dim mailBody As New StringBuilder
mailBody.Append("Dear " & FirstName & ", ").AppendLine(Environment.NewLine)
mailBody.Append("Thank you, for your payment of invoice number " & lblInvo.Text & ". $ " & lblAmount0.Text & " " & "has been deducted from your nominated credit card. ").AppendLine(Environment.NewLine)
mailBody.Append("Your receipt number is " & lblPyNo.Text & ". Please keep this for your reference.").AppendLine(Environment.NewLine)
mailBody.Append("If you have any queries regarding this payment please contact our Accounts Receivable department on 04456666 and reference your invoice number.").AppendLine(Environment.NewLine)
' mailBody.Append("Receipt Number : " & lblPyNo0.Text)
sendEmail("Accounts Department", lblEmail.Text, "Payment Receipt’", mailBody.ToString)
' lblEmail.Text = EmailID
Else
mvwMessage.Visible = True
mvwMessage.SetActiveView(vwFailedMessage)
End If
End If
End If
End If
End If
'End If
Catch ex As ThreadAbortException
ExceptionManager.Publish(ex)
ProjectData.SetProjectError(DirectCast(ex, Exception))
ProjectData.ClearProjectError()
Catch ex As Exception
ProjectData.SetProjectError(ex)
ExceptionManager.Publish(ex)
ProjectData.ClearProjectError()
End Try
End Sub
答案 0 :(得分:0)
检查您是否有适当的验证组,如果您有条件地设置原因验证也会发生,如果是,也检查一下。