我有以下代码 - 目的是在保存订单后,它已被设置为取消,然后我希望它显示“新订单”表单 - 这样可以正常工作!
但是,一旦打开新表单,我希望原始表单与已取消的订单一起关闭。
Try
cmdCheck_Click(sender, New EventArgs)
cmdTotals_Click(sender, New EventArgs)
For Each ugr As UltraGridRow In ugProducts.Rows
If IsDBNull(ugr.Cells("Commission_Value").Value) = True Then
MsgBox("Unable to save an order where one or more lines has a commission value of 0", MsgBoxStyle.OkOnly, "Error")
Exit Sub
Else
If ugr.Cells("Commission_Value").Value <= 0 Then
MsgBox("Unable to save an order where one or more lines has a commission value of 0", MsgBoxStyle.OkOnly, "Error")
Exit Sub
End If
End If
Next
If chCancel.Checked = True Then
If MsgBox("Are you sure you would like to cancel this order?", MsgBoxStyle.YesNo, "Confirm") = MsgBoxResult.No Then
Exit Sub
End If
End If
If cmbCustCode.Value = "" Or cmbSupplier.Value = "" Or txtOVal.Text = "" Or txtPVol.Text = "" Or txtPVal.Text = "" Then
MsgBox("Not enough required data has been entered, cannot save this order", MsgBoxStyle.OkCancel, "Error")
Exit Sub
End If
If isClear = True Then
Try
setNewValues()
Catch ex As Exception
errorLog(ex)
MsgBox("Unable to save data, refer to error log", MsgBoxStyle.OkOnly, "Error")
Exit Sub
End Try
End If
gOrder.Freight = CDec(txtFVal.Text)
gOrder.AmendedVal = CDec(txtOVal.Text)
gOrder.AmendedVol = CDec(txtPVol.Text)
gOrder.externalNotes = rtbExternalNotes.Text
gOrder.InternalNotes = rtbInternalNotes.Text
gOrder.OrderCancelled = chCancel.Checked
gOrder.CommTotal = CDec(txtCVal.Text)
gOrder.CommVAT = CDec(txtCVat.Text)
Dim dtLines As New DataTable
dtLines = ugProducts.DataSource
Dim dsLines As New DataSet
dsLines.Tables.Add(dtLines.Copy)
Select Case gOrder.Stage
Case 4
Dim proceed As Integer = 0
For Each ugr As UltraGridRow In ugProducts.Rows
If ugr.Cells("Goods_Delivered").Value = False Then
If IsDBNull(ugr.Cells("Final_Delivery").Value) = False Then
ugr.Cells("Final_Delivery").Value = DBNull.Value
End If
If isamend = False Then
MsgBox("Unable to proceed to next stage until supplier(s) goods have been delivered", MsgBoxStyle.OkOnly, "Goods not delivered")
End If
proceed = proceed + 1
End If
If dtFreight Is Nothing Then
gOrder.Save(dsLines, , dtfCleared, isClear)
If chCancel.Checked = True Then
Try
Dim f As New frmOrder(con, False, True, currentUser, , admin)
f.MdiParent = Me.ParentForm
f.Show()
Catch ex As Exception
errorLog(ex)
End Try
End If
我尝试在Try的开头和结尾添加了Me.Close()
,但是,两者都一直给我错误信息
调查员已经筋疲力尽了。 在Infragistics.Shared.SparseArray.CreateItemEnumerator.EnsureNotExhausted() 在Infragistics.Shared.SparseArray.CreateItemEnumerator.System.Collections.IEnumerator.MoveNext() 在Infragistics.Win.UltraWinGrid.RowEnumerator.MoveNext()
编辑
我认为这是因为从另一个子例程调用了保存例程。按下的保存按钮调用处理按下另一个按钮按钮的子程序,该代码就是该子程序。
但是,即使将此代码更改为按钮单击中的实际代码(删除间接性),它仍然会发生?
那么,如何在打开新表格的同时关闭现有表格呢?另外,请记住打开表单并且现有表单是相同的表单frmOrder
,除了现有表单中包含数据,因此某些方面稍有不同。
由于
答案 0 :(得分:0)
您已经在编辑中解决了这个问题。
最初可能会有太多潜艇一下子使用/打开。移动它现在没有用,因为它仍在Select Case
。
如果您将Me.Close()
移到Select Case
之外,那么它会正常工作。