Hello all, I am still having an issue where multiple Message Boxes are
being displayed to the user from the same form at one time. This issue
hides the boxes behind the forms since the forms take up the whole
desktop most of the time when maximumized and also the boxes are only
reachable when ALT is used. Once the multiple OK buttons are clicked
the application freezes up and needs to be restarted.
I have posted this before and the general response is
"MessageBox.Show() stops all code from being called until the user
clicks OK" - while in this situation, something happens that allows the
code to be looped through again while the OK Message Box is displayed
on screen BEFORE the OK is clicked which then shows a second Message
Box from the same form.
See for yourselves: http://img456.imageshack.us/img456/3747/untitled3dx.png
This small example application has displayed 2 Message Boxes, if this
were a larger sized program then the second box which needs to be
clicked OK first would be behind the whole program and only reachable
through ALT TAB or clicking on it in the taskbar. How is this
possible?!?! 12 1909
jburkle,
Code?
Kerry Moorman
"jburkle" wrote: Hello all, I am still having an issue where multiple Message Boxes are being displayed to the user from the same form at one time. This issue hides the boxes behind the forms since the forms take up the whole desktop most of the time when maximumized and also the boxes are only reachable when ALT is used. Once the multiple OK buttons are clicked the application freezes up and needs to be restarted.
I have posted this before and the general response is "MessageBox.Show() stops all code from being called until the user clicks OK" - while in this situation, something happens that allows the code to be looped through again while the OK Message Box is displayed on screen BEFORE the OK is clicked which then shows a second Message Box from the same form.
See for yourselves: http://img456.imageshack.us/img456/3747/untitled3dx.png
This small example application has displayed 2 Message Boxes, if this were a larger sized program then the second box which needs to be clicked OK first would be behind the whole program and only reachable through ALT TAB or clicking on it in the taskbar. How is this possible?!?!
- .....
-
-
Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
-
eventArgs As System.EventArgs) Handles cmdRenew.Click
-
-
Try
-
If x Is Nothing Then
-
Exit Sub
-
End If
-
If y > 0 Then
-
If z = 0 Then
-
MsgBox("Random Message")
-
Exit Sub
-
End If
-
Else
-
Exit Sub
-
End If
-
If a Then
-
MessageBox.Show("Random Message")
-
Exit Sub
-
End If
-
If (b Or c) Then
-
MsgBox("Random Message")
-
Exit Sub
-
Else
-
If d Then
-
...
-
If e Then
-
MsgBox("Random Message")
-
Exit Sub
-
End If
-
Else
-
If f Then
-
...
-
If g Then
-
MsgBox("Random Message")
-
Exit Sub
-
End If
-
Else
-
MsgBox("Random Message")
-
Exit Sub
-
End If
-
End If
-
End If
-
-
''Problem Here
-
-
If (h = 123) Then
-
MsgBox("This Message Displays to the User while Done!
-
MessageBox is also being Displayed")
-
Exit Sub
-
End If
-
If i <> "" Then
-
...
-
If j Then
-
MsgBox("Random Message")
-
Exit Sub
-
End If
-
If k Then
-
...
-
Else
-
If l Then
-
...
-
Else
-
...
-
End If
-
End If
-
-
''Gets to here
-
Call DoStuff() ''inside this, "h" set to 123
-
MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
-
Else
-
MsgBox("Random Message")
-
End If
-
Catch ex As Exception
-
ErrorTrap(ex,
-
System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
-
End Try
-
End Sub
-
-
First thing I would do is refactor all the if thens to guard clauses with
custom exceptions instead of exitSub's http://www.refactoring.com/catalog/r...rdClauses.html
--
--Eric Cathell, MCSA
"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... - .....
- Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
- eventArgs As System.EventArgs) Handles cmdRenew.Click
- Try
- If x Is Nothing Then
- Exit Sub
- End If
- If y > 0 Then
- If z = 0 Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- Exit Sub
- End If
- If a Then
- MessageBox.Show("Random Message")
- Exit Sub
- End If
- If (b Or c) Then
- MsgBox("Random Message")
- Exit Sub
- Else
- If d Then
- ...
- If e Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- If f Then
- ...
- If g Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- MsgBox("Random Message")
- Exit Sub
- End If
- End If
- End If
- ''Problem Here
- If (h = 123) Then
- MsgBox("This Message Displays to the User while Done!
- MessageBox is also being Displayed")
- Exit Sub
- End If
- If i <> "" Then
- ...
- If j Then
- MsgBox("Random Message")
- Exit Sub
- End If
- If k Then
- ...
- Else
- If l Then
- ...
- Else
- ...
- End If
- End If
- ''Gets to here
- Call DoStuff() ''inside this, "h" set to 123
- MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
- Else
- MsgBox("Random Message")
- End If
- Catch ex As Exception
- ErrorTrap(ex,
- System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
- End Try
- End Sub
-
Is there any place where I can get more information and VB examples
regarding guard clauses?
Thank you.
"ECathell" <ec******@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... First thing I would do is refactor all the if thens to guard clauses with custom exceptions instead of exitSub's
http://www.refactoring.com/catalog/r...rdClauses.html
-- --Eric Cathell, MCSA "jburkle" <jb*****@gmail.com> wrote in message news:11**********************@g44g2000cwa.googlegr oups.com... - .....
- Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
- eventArgs As System.EventArgs) Handles cmdRenew.Click
- Try
- If x Is Nothing Then
- Exit Sub
- End If
- If y > 0 Then
- If z = 0 Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- Exit Sub
- End If
- If a Then
- MessageBox.Show("Random Message")
- Exit Sub
- End If
- If (b Or c) Then
- MsgBox("Random Message")
- Exit Sub
- Else
- If d Then
- ...
- If e Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- If f Then
- ...
- If g Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- MsgBox("Random Message")
- Exit Sub
- End If
- End If
- End If
- ''Problem Here
- If (h = 123) Then
- MsgBox("This Message Displays to the User while Done!
- MessageBox is also being Displayed")
- Exit Sub
- End If
- If i <> "" Then
- ...
- If j Then
- MsgBox("Random Message")
- Exit Sub
- End If
- If k Then
- ...
- Else
- If l Then
- ...
- Else
- ...
- End If
- End If
- ''Gets to here
- Call DoStuff() ''inside this, "h" set to 123
- MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
- Else
- MsgBox("Random Message")
- End If
- Catch ex As Exception
- ErrorTrap(ex,
- System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
- End Try
- End Sub
-
jburkle,
A couple of points:
1. This is ugly code. (But it still should not display 2 message boxes).
2. You are not showing us a subset of your code in which the problem can be
reproduced. For example, you don't show any code for the DoStuff subprocedure.
Can you create a subset of your code that has the problem and that can be
used by others to reproduce the problem? In other words, no ellipses,
subprocedures present, no missing code that might be using threads, etc.
Kerry Moorman
"jburkle" wrote: - .....
- Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
- eventArgs As System.EventArgs) Handles cmdRenew.Click
- Try
- If x Is Nothing Then
- Exit Sub
- End If
- If y > 0 Then
- If z = 0 Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- Exit Sub
- End If
- If a Then
- MessageBox.Show("Random Message")
- Exit Sub
- End If
- If (b Or c) Then
- MsgBox("Random Message")
- Exit Sub
- Else
- If d Then
- ...
- If e Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- If f Then
- ...
- If g Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- MsgBox("Random Message")
- Exit Sub
- End If
- End If
- End If
- ''Problem Here
- If (h = 123) Then
- MsgBox("This Message Displays to the User while Done!
- MessageBox is also being Displayed")
- Exit Sub
- End If
- If i <> "" Then
- ...
- If j Then
- MsgBox("Random Message")
- Exit Sub
- End If
- If k Then
- ...
- Else
- If l Then
- ...
- Else
- ...
- End If
- End If
- ''Gets to here
- Call DoStuff() ''inside this, "h" set to 123
- MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
- Else
- MsgBox("Random Message")
- End If
- Catch ex As Exception
- ErrorTrap(ex,
- System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
- End Try
- End Sub
-
First, you need to give more code here in order for anyone to be able to
reproduce this. Your screenshot shows two message boxes but only one of
them is called from the code you posted. Post everythign you have, and
folks may be able to help you. Include a full screenshot as well, showing
your task bar. I suspect that you have other windows open as part of this
app that may have somethign to do with your problem.
Second, why are you using both messagebox.show() and msgbox() in your code?
Third, this code looks like it does nothgin at all, what exactly are you
trying to test here?
Lastly, why are you posting twice in the same newsgroup for the same issue?
There are still folks replying to yuour first post and you havent responded
to some of their questions/suggestions.
"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... - .....
- Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
- eventArgs As System.EventArgs) Handles cmdRenew.Click
- Try
- If x Is Nothing Then
- Exit Sub
- End If
- If y > 0 Then
- If z = 0 Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- Exit Sub
- End If
- If a Then
- MessageBox.Show("Random Message")
- Exit Sub
- End If
- If (b Or c) Then
- MsgBox("Random Message")
- Exit Sub
- Else
- If d Then
- ...
- If e Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- If f Then
- ...
- If g Then
- MsgBox("Random Message")
- Exit Sub
- End If
- Else
- MsgBox("Random Message")
- Exit Sub
- End If
- End If
- End If
- ''Problem Here
- If (h = 123) Then
- MsgBox("This Message Displays to the User while Done!
- MessageBox is also being Displayed")
- Exit Sub
- End If
- If i <> "" Then
- ...
- If j Then
- MsgBox("Random Message")
- Exit Sub
- End If
- If k Then
- ...
- Else
- If l Then
- ...
- Else
- ...
- End If
- End If
- ''Gets to here
- Call DoStuff() ''inside this, "h" set to 123
- MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
- Else
- MsgBox("Random Message")
- End If
- Catch ex As Exception
- ErrorTrap(ex,
- System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
- End Try
- End Sub
-
-
Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
-
eventArgs As System.EventArgs) Handles cmdRenew.Click
-
Me.EnableFrameSepAddressButtons(False)
-
Dim strMessage As String
-
Try
-
Dim intIndexfield As Integer
-
Dim strMagId As String
-
Dim intIssyr As Integer
-
Dim iProdIssues As Integer
-
Dim dr_selectMagazine As DataRow
-
Dim dr_MagInfo As DataRow
-
Dim dr_loadCustomerInfo As DataRow
-
Dim dt_RenewalDate As Date
-
-
'Implemented 3/31/2003
-
'Check the Magazine subscription plan versus the payment
-
plan first!
-
If Me.gridMagazineList.DataSource Is Nothing Then
-
Exit Sub
-
End If
-
'Check the status of the account before continuing.
-
Accounts that are not PIF
-
'wont' be allowed to renew magazines
-
Dim bm As BindingManagerBase =
-
Me.gridMagazineList.BindingContext(Me.gridMagazineList.DataSource,
-
Me.gridMagazineList.DataMember)
-
If bm.Count > 0 Then
-
Dim drDataRow As DataRow = CType(bm.Current,
-
DataRowView).Row
-
intIndexfield = IfIsNullInt(drDataRow("IndexField"))
-
If intIndexfield = 0 Then
-
strMessage = "Invalid Magazine Selection"
-
Exit Sub
-
End If
-
Else
-
Exit Sub
-
End If
-
dr_selectMagazine =
-
sql_fCustomer.selectMagazine(intIndexfield).Rows(0)
-
If (dr_selectMagazine("inactive") = 1) Then
-
strMessage = "The magazine is inactive and cannot be
-
renewed."
-
Exit Sub
-
End If
-
If (dr_selectMagazine("OD_Status") = 40 Or
-
dr_selectMagazine("OD_Status") = 94) Or
-
IfIsNullDate((dr_selectMagazine("OD_Next_prod_date"))) = "" Or
-
(dr_selectMagazine("Od_numiss") - dr_selectMagazine("od_issuessent"))
-
<= 0 Then
-
strMessage = "This magazine has been Cancelled or there
-
are not more issues left to be Renewed!"
-
Exit Sub
-
Else
-
'this is the override that allows
-
'for Renewal, even if the date isn't close.
-
If UserInfo.haveAccess("RenewalData_Entry_Override")
-
Then
-
'we do want to prevent too fast of a renewal... 4
-
month is set by Vikki
-
If dtoday <
-
(CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4)) Then
-
strMessage = "You must wait until [" &
-
CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4).Date.ToString
-
& "] to do renewal for this magazine."
-
Exit Sub
-
End If
-
Else
-
dr_loadCustomerInfo =
-
sql_fCustomer.loadCustomerInfo(lngCustNumber, mnordernumber).Rows(0)
-
'adding "IfIsNullSng" to Order_Amount_Due
-
strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
-
dr_MagInfo =
-
sql_fCustomer.MagInfo(strMagId).Rows(0)
-
'need to be able to renew single year half PIFs
-
' (dr_loadCustomerInfo("order_current_status") =
-
109)
-
-
If ((dr_loadCustomerInfo("order_current_status") =
-
109)) Or _
-
(dr_loadCustomerInfo("order_current_status") =
-
89) Or ((dr_loadCustomerInfo("Order_current_status") = 39) _
-
And
-
(IfIsNullSingle(dr_loadCustomerInfo("Order_Amount_Due")) <
-
IfIsNullSingle(dr_loadCustomerInfo("Order_current_monthly_Payment"))))
-
Then
-
dt_RenewalDate =
-
(CDate(dr_selectMagazine("OD_Prod_Date_1")).AddYears( _
-
(CSng(dr_selectMagazine("OD_Issuessent")) /
-
CSng(dr_selectMagazine("OD_Issues_Year"))))).AddMonths(-3)
-
If dtoday <= dt_RenewalDate Then
-
strMessage = "The current production for
-
this magazine hasn't expired yet, the next possible order date is after
-
[" & dt_RenewalDate & "]"
-
Exit Sub
-
End If
-
Else
-
strMessage = "This account needs to be PIF or
-
in good standing in order to renew Magazines!"
-
Exit Sub
-
End If
-
End If
-
End If
-
-
If (dr_selectMagazine("OD_Status") = 123) Then
-
strMessage = "The magazine is waiting production,
-
renewing at the moment. It cannot be renewed again until after next
-
production."
-
Exit Sub
-
End If
-
'Gets Information from tblMags on a specific magazine
-
strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
-
If strMagId <> "" Then
-
dr_MagInfo = sql_fCustomer.MagInfo(strMagId).Rows(0)
-
intIssyr = dr_MagInfo("IssYr")
-
If dr_MagInfo("inactive") Then
-
strMessage = "This magazine is Inactive!"
-
Exit Sub
-
End If
-
'The total # of issues left will be ordered, unless the
-
magazine is only for 1 year or the the maximum
-
'# of issues that can be sent is less than the issues
-
left
-
If dr_MagInfo("MagSingYear") Then
-
iProdIssues = intIssyr
-
Else
-
'Magazines, unless the MaxISS is smaller
-
(fulfillment house won't let us order any more).
-
If dr_MagInfo("MaxIss") >
-
dr_selectMagazine("OD_NUMIss") - dr_selectMagazine("Od_Issuessent")
-
Then
-
iProdIssues = dr_selectMagazine("OD_NUMIss") -
-
dr_selectMagazine("Od_issuessent")
-
Else
-
iProdIssues = dr_MagInfo("MaxIss")
-
End If
-
End If
-
-
sql_fCustomer.ProductionRenewal_Queue(lngCustNumber,
-
mnordernumber, intIndexfield, iProdIssues, dtoday, intIssyr, strMagId,
-
False)
-
-
sql_fCustomer.InsertMagEdit_Queue((dr_selectMagazine("Custnum")),
-
(dr_selectMagazine("Ordernum")), intIndexfield, "Renewed Magazine by
-
using the renew button: " & dr_selectMagazine("OD_Mag_ID"),
-
(UserInfo.userID), True)
-
strMessage = "Done!"
-
LoadMagInfo()
-
Exit Sub
-
Else
-
strMessage = "MagID is blank"
-
Exit Sub
-
End If
-
Catch ex As Exception
-
ErrorTrap(ex,
-
System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
-
Finally
-
If Not strMessage Is Nothing Then
-
MessageBox.Show(Me, strMessage, "",
-
MessageBoxButtons.OK, MessageBoxIcon.Information)
-
End If
-
Me.EnableFrameSepAddressButtons(True)
-
End Try
-
End Sub
-
-
-
Public Sub LoadMagInfo()
-
-
Dim dtMagInfo As DataTable
-
Dim iIndex As Integer
-
Dim strOD_Status As String
-
Dim dtDataTable As DataTable
-
-
Try
-
gridMagazineList.Redraw = False
-
dtMagInfo = sql_fCustomer.LoadMagazineInfo(lngCustNumber,
-
mnordernumber)
-
If dtMagInfo.Rows.Count > 0 Then
-
dtMagInfo.TableName = "Magazine List"
-
strOD_Status = dtMagInfo.Rows(0)("OD_Status")
-
-
'if the status is "UQ" we don't allow magazine change
-
TDP-05/07/04 >>>
-
If (strOD_Status = "Under Query") Then
-
EnableButtons(False)
-
Else
-
EnableButtons(True)
-
End If
-
'TDP-05/07/04 <<<
-
-
For iIndex = 0 To dtMagInfo.Rows.Count - 1
-
strOD_Status = dtMagInfo.Rows(iIndex)("OD_Status")
-
If (strOD_Status.Trim = "PendingCancel") Then
-
dtMagInfo.Rows(iIndex)("OD_Status") =
-
"Cancelled"
-
End If
-
-
If (dtMagInfo.Rows(iIndex)("UMC_NotUnique")) Then
-
dtDataTable =
-
sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
-
_
-
-
dtMagInfo.Rows(iIndex)("Ship_State"))
-
If dtDataTable.Rows.Count > 0 Then
-
dtMagInfo.Rows(iIndex)("MagName") =
-
dtDataTable.Rows(0)("MagName") & " (" &
-
dtMagInfo.Rows(iIndex)("MagName") & ")"
-
End If
-
-
End If
-
Next
-
-
dtMagInfo.DefaultView.AllowNew = False
-
gridMagazineList.DataSource = dtMagInfo
-
-
End If
-
-
Call SetupgridMagazineList()
-
-
gridMagazineList.Redraw = True
-
Call LoadComplaintInfo()
-
SetUpPermissions()
-
Catch ex As Exception
-
If ex.GetType Is GetType(System.IndexOutOfRangeException)
-
Or _
-
ex.GetType Is GetType(System.ArgumentException) Then
-
-
ErrorTrapNoMsgBox(ex,
-
System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreating Grid")
-
-
-
Me.tabCust_CustomerInformation.Controls.Remove(Me.gridMagazineList)
-
Dim gridMagazineList2 As New
-
LazarusControls.FlexDataGrid
-
CType(gridMagazineList2,
-
System.ComponentModel.ISupportInitialize).BeginInit()
-
-
gridMagazineList2.CaptionText = "Magazine List"
-
gridMagazineList2.DataMember = ""
-
gridMagazineList2.HeaderForeColor =
-
System.Drawing.SystemColors.ControlText
-
gridMagazineList2.Location = New
-
System.Drawing.Point(8, 8)
-
gridMagazineList2.Name = "gridMagazineList"
-
gridMagazineList2.Size = New System.Drawing.Size(640,
-
240)
-
gridMagazineList2.TabIndex = 194
-
-
CType(gridMagazineList2,
-
System.ComponentModel.ISupportInitialize).EndInit()
-
Me.gridMagazineList = gridMagazineList2
-
-
Me.tabCust_CustomerInformation.Controls.Add(Me.gridMagazineList)
-
-
Try
-
gridMagazineList.Redraw = False
-
dtMagInfo =
-
sql_fCustomer.LoadMagazineInfo(lngCustNumber, mnordernumber)
-
dtMagInfo.TableName = "Magazine List"
-
-
For iIndex = 0 To dtMagInfo.Rows.Count - 1
-
strOD_Status =
-
dtMagInfo.Rows(iIndex)("OD_Status")
-
If (strOD_Status.Trim = "PendingCancel") Then
-
dtMagInfo.Rows(iIndex)("OD_Status") =
-
"Cancelled"
-
End If
-
-
-
'Added on 7/21/2003 for those rogues at Game &
-
Fish cht
-
If (dtMagInfo.Rows(iIndex)("UMC_NotUnique"))
-
Then
-
dtDataTable =
-
sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
-
_
-
-
dtMagInfo.Rows(iIndex)("Ship_State"))
-
If dtDataTable.Rows.Count > 0 Then
-
dtMagInfo.Rows(iIndex)("MagName") =
-
dtDataTable.Rows(0)("MagName") & " (" &
-
dtMagInfo.Rows(iIndex)("MagName") & ")"
-
End If
-
-
End If
-
Next
-
-
dtMagInfo.DefaultView.AllowNew = False
-
gridMagazineList.DataSource = dtMagInfo
-
-
Call SetupgridMagazineList()
-
-
gridMagazineList.Redraw = True
-
Call LoadComplaintInfo()
-
Catch ex2 As Exception
-
ErrorTrap(ex2,
-
System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreate Grid
-
Failed")
-
End Try
-
-
Else
-
ErrorTrap(ex,
-
System.Reflection.MethodInfo.GetCurrentMethod.Name, "" _
-
)
-
End If
-
End Try
-
End Sub
-
Here is the onclick event that is causing the problem, I thought that
moving the MessageBox Call into the Finally block would fix the
problem, however it hasn't.
I guess the question woudl be which specific lines of code are generating
the two different message boxes you are referring to?
Also, how many seperate windows (forms) do you have open when this occurs,
and which forms are generating each of the message boxes?
"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... - Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
- eventArgs As System.EventArgs) Handles cmdRenew.Click
- Me.EnableFrameSepAddressButtons(False)
- Dim strMessage As String
- Try
- Dim intIndexfield As Integer
- Dim strMagId As String
- Dim intIssyr As Integer
- Dim iProdIssues As Integer
- Dim dr_selectMagazine As DataRow
- Dim dr_MagInfo As DataRow
- Dim dr_loadCustomerInfo As DataRow
- Dim dt_RenewalDate As Date
- 'Implemented 3/31/2003
- 'Check the Magazine subscription plan versus the payment
- plan first!
- If Me.gridMagazineList.DataSource Is Nothing Then
- Exit Sub
- End If
- 'Check the status of the account before continuing.
- Accounts that are not PIF
- 'wont' be allowed to renew magazines
- Dim bm As BindingManagerBase =
- Me.gridMagazineList.BindingContext(Me.gridMagazineList.DataSource,
- Me.gridMagazineList.DataMember)
- If bm.Count > 0 Then
- Dim drDataRow As DataRow = CType(bm.Current,
- DataRowView).Row
- intIndexfield = IfIsNullInt(drDataRow("IndexField"))
- If intIndexfield = 0 Then
- strMessage = "Invalid Magazine Selection"
- Exit Sub
- End If
- Else
- Exit Sub
- End If
- dr_selectMagazine =
- sql_fCustomer.selectMagazine(intIndexfield).Rows(0)
- If (dr_selectMagazine("inactive") = 1) Then
- strMessage = "The magazine is inactive and cannot be
- renewed."
- Exit Sub
- End If
- If (dr_selectMagazine("OD_Status") = 40 Or
- dr_selectMagazine("OD_Status") = 94) Or
- IfIsNullDate((dr_selectMagazine("OD_Next_prod_date"))) = "" Or
- (dr_selectMagazine("Od_numiss") - dr_selectMagazine("od_issuessent"))
- <= 0 Then
- strMessage = "This magazine has been Cancelled or there
- are not more issues left to be Renewed!"
- Exit Sub
- Else
- 'this is the override that allows
- 'for Renewal, even if the date isn't close.
- If UserInfo.haveAccess("RenewalData_Entry_Override")
- Then
- 'we do want to prevent too fast of a renewal... 4
- month is set by Vikki
- If dtoday <
- (CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4)) Then
- strMessage = "You must wait until [" &
- CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4).Date.ToString
- & "] to do renewal for this magazine."
- Exit Sub
- End If
- Else
- dr_loadCustomerInfo =
- sql_fCustomer.loadCustomerInfo(lngCustNumber, mnordernumber).Rows(0)
- 'adding "IfIsNullSng" to Order_Amount_Due
- strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
- dr_MagInfo =
- sql_fCustomer.MagInfo(strMagId).Rows(0)
- 'need to be able to renew single year half PIFs
- ' (dr_loadCustomerInfo("order_current_status") =
- 109)
- If ((dr_loadCustomerInfo("order_current_status") =
- 109)) Or _
- (dr_loadCustomerInfo("order_current_status") =
- 89) Or ((dr_loadCustomerInfo("Order_current_status") = 39) _
- And
- (IfIsNullSingle(dr_loadCustomerInfo("Order_Amount_Due")) <
- IfIsNullSingle(dr_loadCustomerInfo("Order_current_monthly_Payment"))))
- Then
- dt_RenewalDate =
- (CDate(dr_selectMagazine("OD_Prod_Date_1")).AddYears( _
- (CSng(dr_selectMagazine("OD_Issuessent")) /
- CSng(dr_selectMagazine("OD_Issues_Year"))))).AddMonths(-3)
- If dtoday <= dt_RenewalDate Then
- strMessage = "The current production for
- this magazine hasn't expired yet, the next possible order date is after
- [" & dt_RenewalDate & "]"
- Exit Sub
- End If
- Else
- strMessage = "This account needs to be PIF or
- in good standing in order to renew Magazines!"
- Exit Sub
- End If
- End If
- End If
- If (dr_selectMagazine("OD_Status") = 123) Then
- strMessage = "The magazine is waiting production,
- renewing at the moment. It cannot be renewed again until after next
- production."
- Exit Sub
- End If
- 'Gets Information from tblMags on a specific magazine
- strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
- If strMagId <> "" Then
- dr_MagInfo = sql_fCustomer.MagInfo(strMagId).Rows(0)
- intIssyr = dr_MagInfo("IssYr")
- If dr_MagInfo("inactive") Then
- strMessage = "This magazine is Inactive!"
- Exit Sub
- End If
- 'The total # of issues left will be ordered, unless the
- magazine is only for 1 year or the the maximum
- '# of issues that can be sent is less than the issues
- left
- If dr_MagInfo("MagSingYear") Then
- iProdIssues = intIssyr
- Else
- 'Magazines, unless the MaxISS is smaller
- (fulfillment house won't let us order any more).
- If dr_MagInfo("MaxIss") >
- dr_selectMagazine("OD_NUMIss") - dr_selectMagazine("Od_Issuessent")
- Then
- iProdIssues = dr_selectMagazine("OD_NUMIss") -
- dr_selectMagazine("Od_issuessent")
- Else
- iProdIssues = dr_MagInfo("MaxIss")
- End If
- End If
- sql_fCustomer.ProductionRenewal_Queue(lngCustNumber,
- mnordernumber, intIndexfield, iProdIssues, dtoday, intIssyr, strMagId,
- False)
- sql_fCustomer.InsertMagEdit_Queue((dr_selectMagazine("Custnum")),
- (dr_selectMagazine("Ordernum")), intIndexfield, "Renewed Magazine by
- using the renew button: " & dr_selectMagazine("OD_Mag_ID"),
- (UserInfo.userID), True)
- strMessage = "Done!"
- LoadMagInfo()
- Exit Sub
- Else
- strMessage = "MagID is blank"
- Exit Sub
- End If
- Catch ex As Exception
- ErrorTrap(ex,
- System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
- Finally
- If Not strMessage Is Nothing Then
- MessageBox.Show(Me, strMessage, "",
- MessageBoxButtons.OK, MessageBoxIcon.Information)
- End If
- Me.EnableFrameSepAddressButtons(True)
- End Try
- End Sub
-
- Public Sub LoadMagInfo()
- Dim dtMagInfo As DataTable
- Dim iIndex As Integer
- Dim strOD_Status As String
- Dim dtDataTable As DataTable
- Try
- gridMagazineList.Redraw = False
- dtMagInfo = sql_fCustomer.LoadMagazineInfo(lngCustNumber,
- mnordernumber)
- If dtMagInfo.Rows.Count > 0 Then
- dtMagInfo.TableName = "Magazine List"
- strOD_Status = dtMagInfo.Rows(0)("OD_Status")
- 'if the status is "UQ" we don't allow magazine change
- TDP-05/07/04 >>>
- If (strOD_Status = "Under Query") Then
- EnableButtons(False)
- Else
- EnableButtons(True)
- End If
- 'TDP-05/07/04 <<<
- For iIndex = 0 To dtMagInfo.Rows.Count - 1
- strOD_Status = dtMagInfo.Rows(iIndex)("OD_Status")
- If (strOD_Status.Trim = "PendingCancel") Then
- dtMagInfo.Rows(iIndex)("OD_Status") =
- "Cancelled"
- End If
- If (dtMagInfo.Rows(iIndex)("UMC_NotUnique")) Then
- dtDataTable =
- sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
- _
- dtMagInfo.Rows(iIndex)("Ship_State"))
- If dtDataTable.Rows.Count > 0 Then
- dtMagInfo.Rows(iIndex)("MagName") =
- dtDataTable.Rows(0)("MagName") & " (" &
- dtMagInfo.Rows(iIndex)("MagName") & ")"
- End If
- End If
- Next
- dtMagInfo.DefaultView.AllowNew = False
- gridMagazineList.DataSource = dtMagInfo
- End If
- Call SetupgridMagazineList()
- gridMagazineList.Redraw = True
- Call LoadComplaintInfo()
- SetUpPermissions()
- Catch ex As Exception
- If ex.GetType Is GetType(System.IndexOutOfRangeException)
- Or _
- ex.GetType Is GetType(System.ArgumentException) Then
- ErrorTrapNoMsgBox(ex,
- System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreating Grid")
- Me.tabCust_CustomerInformation.Controls.Remove(Me.gridMagazineList)
- Dim gridMagazineList2 As New
- LazarusControls.FlexDataGrid
- CType(gridMagazineList2,
- System.ComponentModel.ISupportInitialize).BeginInit()
- gridMagazineList2.CaptionText = "Magazine List"
- gridMagazineList2.DataMember = ""
- gridMagazineList2.HeaderForeColor =
- System.Drawing.SystemColors.ControlText
- gridMagazineList2.Location = New
- System.Drawing.Point(8, 8)
- gridMagazineList2.Name = "gridMagazineList"
- gridMagazineList2.Size = New System.Drawing.Size(640,
- 240)
- gridMagazineList2.TabIndex = 194
- CType(gridMagazineList2,
- System.ComponentModel.ISupportInitialize).EndInit()
- Me.gridMagazineList = gridMagazineList2
- Me.tabCust_CustomerInformation.Controls.Add(Me.gridMagazineList)
- Try
- gridMagazineList.Redraw = False
- dtMagInfo =
- sql_fCustomer.LoadMagazineInfo(lngCustNumber, mnordernumber)
- dtMagInfo.TableName = "Magazine List"
- For iIndex = 0 To dtMagInfo.Rows.Count - 1
- strOD_Status =
- dtMagInfo.Rows(iIndex)("OD_Status")
- If (strOD_Status.Trim = "PendingCancel") Then
- dtMagInfo.Rows(iIndex)("OD_Status") =
- "Cancelled"
- End If
- 'Added on 7/21/2003 for those rogues at Game &
- Fish cht
- If (dtMagInfo.Rows(iIndex)("UMC_NotUnique"))
- Then
- dtDataTable =
- sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
- _
- dtMagInfo.Rows(iIndex)("Ship_State"))
- If dtDataTable.Rows.Count > 0 Then
- dtMagInfo.Rows(iIndex)("MagName") =
- dtDataTable.Rows(0)("MagName") & " (" &
- dtMagInfo.Rows(iIndex)("MagName") & ")"
- End If
- End If
- Next
- dtMagInfo.DefaultView.AllowNew = False
- gridMagazineList.DataSource = dtMagInfo
- Call SetupgridMagazineList()
- gridMagazineList.Redraw = True
- Call LoadComplaintInfo()
- Catch ex2 As Exception
- ErrorTrap(ex2,
- System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreate Grid
- Failed")
- End Try
- Else
- ErrorTrap(ex,
- System.Reflection.MethodInfo.GetCurrentMethod.Name, "" _
- )
- End If
- End Try
- End Sub
-
Here is the onclick event that is causing the problem, I thought that moving the MessageBox Call into the Finally block would fix the problem, however it hasn't.
I am sorry if I am confusing anyone with this issue, the thing is that
I can't replicate the issue on our testing system, but it happens to
the end user and does so for different users on different computers.
the code is being called from a button that is on a
System.Windows.Forms.GroupBox which is in a
System.Windows.Forms.TabControl which is in the fCustomer.vb form.
this fCustomer.vb form is in the main mdi.vb form for the program.
The 2 message boxs displayed are the "Done!" box when it does the
updating in the end, and also the "The magazine is waiting production,
renewing at the moment. It cannot be renewed again until after next
production." message box at the OD_status = 123 check........ when the
"Done!" is reached the code before it sets OD_status = 123..... but i
looked for where it could be called again inside the onclick and
couldnt find it, also i added the EnableButtons(false) call to disable
all buttons to try and ensure that the user cant double click them.
This is odd...
Both of those lines of code appear to set strMessage and then exit the
subroutine without triggering the MessageBox.Show call at the end. I don't
understand how either of the messages are being generated by this code at
all. Moving the MessageBox.Show to the end should prevent all messages from
being displayed, as you are not allowing the code to get to that point. Is
it possible that the messages are actually being displayed someplace else in
your code? In another subroutine perhaps?
I suspect that somewhere along the line you are calling two simultaneous
functions in different forms, each of which are displaying a message. I'm
not sure how you would do this, but I can't see how this code would cause
the problem you are having.
"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com... I am sorry if I am confusing anyone with this issue, the thing is that I can't replicate the issue on our testing system, but it happens to the end user and does so for different users on different computers.
the code is being called from a button that is on a System.Windows.Forms.GroupBox which is in a System.Windows.Forms.TabControl which is in the fCustomer.vb form.
this fCustomer.vb form is in the main mdi.vb form for the program.
The 2 message boxs displayed are the "Done!" box when it does the updating in the end, and also the "The magazine is waiting production, renewing at the moment. It cannot be renewed again until after next production." message box at the OD_status = 123 check........ when the "Done!" is reached the code before it sets OD_status = 123..... but i looked for where it could be called again inside the onclick and couldnt find it, also i added the EnableButtons(false) call to disable all buttons to try and ensure that the user cant double click them.
i did have 10-15 MessageBox calls throughout all the if/then/else
blocks, but instead i tried to fix the problem by setting a string to
the message i would display, then in the Finally block if that string
was set to Anything then output a MessageBox with that string as the
message..... i thought that this would "fix" the issue with multiple
Message Boxes being displayed however it didn't so i am still suck with
the problem.
I am looking into the other methods called in this onclick() to see if
they display a message box but i checked before and didnt see any.
i think the problem is in the calls to MessageBox...... is there any
differences between calling MessageBox.Show() and creating a custom
form that acts like a message box by calling form.ShowDialog()? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve |
last post by:
I have several pairs of synchronized subforms in an application. I have a Delete
button for each pair that uses the following code or similar to delete a record
in the second subform:
...
|
by: Steve Grahovac |
last post by:
I have been having trouble the last few days opening any ASP.NET web
forms in the design view in the designer. Every time I clicked on an
aspx file I got a message box with the error "Unable to...
|
by: Cris Rock |
last post by:
In my ASP.Net application, validation rule demands that user has to select
one of the option buton(...WebControls.RadioButton).
I am doing these kind of validations in the server side when the user...
|
by: Mark |
last post by:
Hello all -
I'm not sure if this is an ASP.Net issue or a Crystal Reports issue but I built a web reporting website that runs under SSL. The way the reports are displayed to the user has it where...
|
by: JTrigger |
last post by:
When I compile my project using the IDE on a development machine it works
just fine. When I compile it on the server using csc.exe, I get the
following error when I try to bring it up in the web...
|
by: Jens Øster |
last post by:
Hi
I am writing a ASP.NET web application that must sent some e-mails.
I get the exception “Could not access 'CDO.Message' object” when I call SmtpMail.Send. This only happens when I send...
|
by: Richard Finnigan |
last post by:
Hi
I was wondering if anyone could help me with this problem. I've been using
VWD and my webhost ( a shared hosting package) have told me that the MSQL
express files wont work on thier server so...
|
by: Alex A. |
last post by:
I have this web application that runs for about 5 minutes doing to
database processing, about 50% of the time I get the error message
Thread was being aborted.
I am looking for hint at where to...
|
by: Ivan Weiss |
last post by:
Good morning all,
I am trying to access an access database to authenticate users upon
logging into my application.
Something is throwing an excecption. My error handling code should
display...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |