私は次のコードを書いています - その目的は、注文を保存した後にキャンセルされていることです。フォーム - これは正常に動作します!もう一つ別のものを開いた後にフォームを閉じる方法
ただし、新しいフォームが開かれたら、キャンセルされた注文の元のフォームを閉じてください。私がしようの開始と終了の両方でMe.Close()
を追加しようとした
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
は、しかし、両方は私に
列挙子が消耗されたのエラーメッセージを与え続けました。 Infragistics.Win.UltraWinGrid.RowEnumerator.MoveNextでInfragistics.Shared.SparseArray.CreateItemEnumerator.System.Collections.IEnumerator.MoveNext() でInfragistics.Shared.SparseArray.CreateItemEnumerator.EnsureNotExhausted() ()で
EDIT
保存ルーチンが別のサブルーチンから呼び出されていると思います。保存ボタンを押すと、別のボタンのボタンを押すサブルーチンが呼び出され、このコードはそのサブルーチンです。
しかし、このコードをボタンクリック(間接を削除)している実際のコードに変更しても、それはまだ発生しますか?
これで、新しいフォームを開くと同時に既存のフォームを閉じることができますか?また、開いているフォームと既存のフォームは同じフォーム(frmOrder
)ですが、既存のフォームにはデータが含まれているため、一部の側面が少し異なります。
ありがとうございました
グリッド上の何らかのループの内側からコードが呼び出されているようなエラーメッセージが表示されます – Plutonix
@Plutonix私はそれが私には分かりませんでした。実行のフルパスは上です。 'gOrder.Save'は' For Loop'を使って 'UltraGrid'の各行を追加しますが、これは関係する唯一のグリッドなので何が起きているのか分かりません –
コールスタックウィンドウを開き、その前提 – Plutonix