Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to keep boolean value after page load. 1

Status
Not open for further replies.

MzKitty

Programmer
Oct 28, 2003
254
US
I am using vs2008, vb.net, and crystal reports 10.5 to develop a ticketing system. I have a web page with 3 cr viewers that print the 3 different ticket copies (as activex reports). I set a boolean switch saying the that this has printed (True). But when I go to load the next cr viewer and go to process it, the switch has reset to false and wants to print the same ticket copy again. I have the switch dimmed as "Public CustPrinted As Boolean". Down in a separate sub which is triggered with a button click, I have the following code:

If CustPrinted = False Then
PrintCustomer()' In here the CustPrinted is set to true
Else
PrintWarehouse()
End If

PrintWarehouse is never hit because CustPrinted is reset to false after I print the Customer Copy.

I would appreciate any help. This is being executed on a Intranet web server, so I can't use the crReport.PrintToPrinter(1, False, 0, 0) command.

Thanks
Cathy
 
Need more info.
Is there a postback between each load of the cr viewers?
Need to post more of the relevant code.
 
Here's most of the code from the web page, I didn't include my dims of the strings. I do the Office copy print before the postback. Then when the user clicks the Return button(Exit), that's where I print the customer copy and try to print the warehouse copy.

Private Sub frmPrintTickets_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

strCustPOJob = Session.Item("strCustPOJob")
intTicketNo = Session.Item("intTicketNo")
strShipName = Session.Item("strShipName")
strShipStreet = Session.Item("strShipStreet")
strShipCity = Session.Item("strShipCity")
strShipState = Session.Item("strShipState")
strShipZip = Session.Item("strShipZip")
boolCOD = Session.Item("boolCOD")
If IsPostBack Then
Else
PrintOffice()
End If

End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub
Protected Sub PrintOffice()
crViewer2.Visible = False
crViewer3.Visible = False
saveCustPOJob = strCustPOJob
saveShipName = strShipName
saveShipStreet = strShipStreet
saveShipCity = strShipCity
saveShipState = strShipState
saveShipZip = strShipZip
saveTicketNo = intTicketNo
saveCOD = boolCOD

crReport = New RptTktOfficeCopy
crReport.SetParameterValue("CustJobPO", strCustPOJob)
crReport.SetParameterValue("ShipName", strShipName)
crReport.SetParameterValue("TicketNo", intTicketNo)
crReport.SetParameterValue("ShipStreet", strShipStreet)
crReport.SetParameterValue("ShipCity", strShipCity)
crReport.SetParameterValue("ShipState", strShipState)
crReport.SetParameterValue("ShipZip", strShipZip)
crReport.SetParameterValue("COD", boolCOD)
crViewer1.Visible = True
crViewer1.Zoom(100)
crViewer1.ReportSource = crReport
'crReport.PrintToPrinter(1, False, 0, 0)
End Sub
Protected Sub PrintCustomer()
'print customer
crViewer1.Visible = False
crViewer3.Visible = False
saveCustPOJob = strCustPOJob
saveShipName = strShipName
saveShipStreet = strShipStreet
saveShipCity = strShipCity
saveShipState = strShipState
saveShipZip = strShipZip
saveTicketNo = intTicketNo
saveCOD = boolCOD
crReport2 = New RptTktCustCopy
CrystalReportSource1.Report.FileName = "RptTktCustCopy"
crReport2.SetParameterValue("CustJobPO", saveCustPOJob)
crReport2.SetParameterValue("ShipName", saveShipName)
crReport2.SetParameterValue("TicketNo", saveTicketNo)
crReport2.SetParameterValue("ShipStreet", saveShipStreet)
crReport2.SetParameterValue("ShipCity", saveShipCity)
crReport2.SetParameterValue("ShipState", saveShipState)
crReport2.SetParameterValue("ShipZip", saveShipZip)
crReport2.SetParameterValue("COD", saveCOD)
crViewer2.Visible = True
crViewer2.Zoom(100)
crViewer2.ReportSource = CrystalReportSource2
'crReport2.PrintToPrinter(1, False, 0, 0)
CustPrinted = True
End Sub

Protected Sub PrintWarehouse()
'print warehouse
crViewer1.Visible = False
crViewer2.Visible = False
saveCustPOJob = strCustPOJob
saveShipName = strShipName
saveShipStreet = strShipStreet
saveShipCity = strShipCity
saveShipState = strShipState
saveShipZip = strShipZip
saveTicketNo = intTicketNo
saveCOD = boolCOD
crReport3 = New RptWarehouseCopy
crReport3.SetParameterValue("CustJobPO", saveCustPOJob)
crReport3.SetParameterValue("ShipName", saveShipName)
crReport3.SetParameterValue("TicketNo", saveTicketNo)
crReport3.SetParameterValue("ShipStreet", saveShipStreet)
crReport3.SetParameterValue("ShipCity", saveShipCity)
crReport3.SetParameterValue("ShipState", saveShipState)
crReport3.SetParameterValue("ShipZip", saveShipZip)
crReport3.SetParameterValue("COD", saveCOD)
crViewer3.Visible = True
crViewer3.Zoom(100)
crViewer3.ReportSource = CrystalReportSource3
'crReport3.PrintToPrinter(1, False, 0, 0)
' Response.Redirect("default.aspx")

End Sub

Protected Sub cmdExit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdExit.Click
If CustPrinted = False Then
PrintCustomer()
Else
PrintWarehouse()
End If
Response.Redirect("default.aspx")
End Sub

Thanks Cathy
 
. Then when the user clicks the Return button(Exit), that's where I print the customer copy and try to print the warehouse copy.
There is the problem. If the user has to click a button(asp.net button) between printing the reports, then a post back happens and your variable is reset.
 
If I put each report on a separate webpage, how do I get back to the the previous webpage to continue on? In a windows app we did a with frmPrtTktOffice and when we exited frmPrtTktOffice we went back to the end with and continued with the processing. But on a webpage when I exit(Response.Redirect("TicketEntry.aspx"), that form reloads itself. I hope I'm making sense.

'print office copy
Session.Add("strCustPOJob", strCustPOJob)
Session.Add("intTicketNo", intTicketNo)
Session.Add("strShipName", strShipName)
Session.Add("strShipStreet", strShipStreet)
Session.Add("strShipCity", strShipCity)
Session.Add("strShipState", strShipState)
Session.Add("strShipZip", strShipZip)
Session.Add("boolCOD", boolCOD)
Response.Redirect("frmPrtTktOffice.aspx")
'print customer copy

this is where I want to comeback to after I have printed the office ticket copy.

Session.Add("strCustPOJob", strCustPOJob)
Session.Add("intTicketNo", intTicketNo)
Session.Add("strShipName", strShipName)
Session.Add("strShipStreet", strShipStreet)
Session.Add("strShipCity", strShipCity)
Session.Add("strShipState", strShipState)
Session.Add("strShipZip", strShipZip)
Session.Add("boolCOD", boolCOD)
Response.Redirect("frmPrtTktCust.aspx")
'print warehouse copy

this is where I want to comeback to after I have printed the customer ticket copy.


Session.Add("strCustPOJob", strCustPOJob)
Session.Add("intTicketNo", intTicketNo)
Session.Add("strShipName", strShipName)
Session.Add("strShipStreet", strShipStreet)
Session.Add("strShipCity", strShipCity)
Session.Add("strShipState", strShipState)
Session.Add("strShipZip", strShipZip)
Session.Add("boolCOD", boolCOD)
Response.Redirect("frmPrtTktWarehouse.aspx")

Thanks
Cathy
 
I am not sure why your logic would be this way in a Windows or Web app. As for a Web app, this could potentially work, but you have to remember the web is stateless, so you would have to track your status(es) in session. However, this seems like a cumbersome way to do this sort of thing wether it be Web or Windows.
Off the top of my head, I would say to create one page. On this page have a multiview. In that multiview have a view for each CR report you want to print. You can then swicht views and print each report automatically or let the user do it. If you do it automatically, then you can use a page level variable. If you want the user to choose and press a button, then a post back will happen and you will have to track the boolean var(s) in session or better yet viewstate.
 
Thanks for all your help. I'm going to go back to the page with multiple views and do it that way. You've been alot of help with this and other issues over the years!
 
Glad I could help you. Post back if you run into any more problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top