How to know DialogResult with ReportViewer.PrintDialog() - printing

I have encountered this problem a lot of times on the internet, but didn't find a good way to fix this.
What I want is to print a report from the ReportViewer control, and if it has been printed, I need to change some stuff in the database (like the user that printed, what time the reports has been printed).
Now I used the reportViewer.PrintDialog() method (which prints fine) but I can't figure out a way to learn if the user actually printed the document, or cancelled the PrintDialog box.
I also tried the System.Windows.Controls.PrintDialog() which does return a DialogResult, but I couldn't find a way to set the reportViewer's report as the PrintDocument's source.
Has anyone of you found a way to do it?
Thanks in advance, and more info/code can be provided if asked.

Oh
If it's C#
Dialog boxes return a value of type DialogResult
so something like
if (System.Windows.Controls.PrintDialog().ShowDialog() == DialogResult.OK)
{
// Mark item as Prionted by User U
}

In VB.NET, try the following:
If reportViewer.PrintDialog() = Windows.Forms.DialogResult.OK Then
'Put your stuff here
End If

Related

else statement need to be added in watson conversation dialog

Need help for adding else condition if the input answer is not correct.
Please find the screen shot of If statement I have added.
Sample_Condition
I think you can't put the else because it's just another intent.
So you could just create another node with an IF test corresponding to the ELSE you want to write.
I can't give you the extract but I hope this screenshot will help you.
This is a small test case for a virtual assistant helping you to do simple banking tasks.

Get all current forms via code

I can identify (find) an element with a certain RanoreXPath via Ranorex Spy, but not via Ranorex API.
Is there a method to output all current \forms on the computer to be able to debug the problem?
var FormElementList = Host.Local.Find("/form");
foreach (var formElement in FormElementList) {
Report.Info(formElement.GetPath(PathBuildMode.Default, Ranorex.Host.Local).ToString());
}
By identify, do you really mean find?
When I encouter problems with troubleshooting an issue, I usually insert Report.Screenshot and Report.Snapshot at strategic places in recordings (or user code).
When Report.Screenshot has no element specified, it captures a screenshot of the entire desktop which can be useful (when tests are executed unattended).
Report.Snapshot does however need an element (/form could be used as suggested by RanorexPro), but if your XPath is incorrect, this won't help much...
Hoping this gives you ideas...

MonthToDate errors in Crystal Reports

I am trying to produce a report that will provide what was shipped out from the 1st of the current month to the current day. I found something called MonthToDate. Thought, that was pretty simple until I tried using it.
Seems like no matter what I change, I get "A String is required here" error message.
{#shipdate}=If {C_SHIP_HIST.SHIPDATE} in MonthToDate Then
{C_SHIP_HIST.ARINVT_ID} Else
"TG"
What am I doing wrong?
Thank-you for your help
your syntax is wrong.. you can't take one argument as number and one argument as String in if. Try below
If {C_SHIP_HIST.SHIPDATE} in MonthToDate Then
{#shipdate}=ToText({C_SHIP_HIST.ARINVT_ID})
Else {#shipdate}="TG"

Oracle Forms - Display message blocks rest of the code execution or message doesn't show

I'm trying to show a message on a form without success.
What I'm doing is: When a new line is clicked, I use the WHEN-NEW-RECORD-INSTANCE to do some verifications and some enabling/disabling on the form and showing up the message. The problem is sometimes it does the enabling/disabling but not the message, then I click another line and it shows the previous message but doesn't do the enabling/disabling...
I've already tried some stuff like:
message('message');
n := Show_alert('message');
with and without SYNCHRONIZE;
I don't think it's the code itself blocking the messages... or I'm missing something...
Does anyone ever had this problem?
Can someone tell me the various options to display messages and their differences?
Thanks.
I managed to fix this using the WHEN-MOUSE-CLICK trigger instead.
I didn't want to use this at first because when I clicked the already selected line it would show the message again but I made some code verification and fixed it.
Someone can close this.
thanks.

NHibernate IQuery.List Error "Invalid index 4 for this SqlParameterCollection with Count=4."

Long title, I know but I searched all over and couldn't find that error message coming from that function call so I thought this might be more useful.
This is the code snippet:
string hql = " from LabRequest r where 1 = 1 ";
hql += " and 0 < (select count(rs) ";
hql += " from r.Statuses rs ";
hql += " where rs.StatusType.Description IN ('Assigned','Submitted')";
hql += " ) ";
//Session.Clear();
IQuery query = Session.CreateQuery(hql);
IQueryable<LabRequest> requests = query.List<LabRequest>().AsQueryable<LabRequest>();
This is a function (or most of it) in my Data Access Object in an MVC app I'm working on. It's for a search page and when the page runs this function gets called exactly like you see in the code and works.
Then, without changing anything, I refresh the page which goes through the same steps and calls this code, exactly as you see it, again. But the second time through it crashes on the query.List() portion of the last line with the error in the subject.
Session is defined in another DAO as:
session = NHibernateHelper.GetCurrentSession();
I know this is hard to analyze without the actual DB but I just wanted to see if anyone could maybe point me in the right direction, or maybe point out something obvious about NHibernate since I know basically nothing about it.
Edit: forgot to mention that when I uncomment the Session.Clear() it works fine, so was thinking the answer has something to do with that, and if it does how I should handle when to clear()?
Edit 2: This is part of the answer, but I call a very similar function prior to this one the second time around. What I can't figure out is why that one is affecting the one I posted. The 'query' variable is local, so it seems to be something with Session.CreateQuery. Anyone know what that would be?
Thanks,
Jeff
While I'm not sure why exactly it seems the 'Statistics' property on the Session has data on it from the first query and I think this is what's causing the error because if I do a Session.Clear it removes the collections in the Statistics property.
As my current, and possibly temporary fix, I just created an extension method for the CreateQuery function that takes a bool asking whether to clear the Session and am just using this instead of the one provided.
If anyone else has any real answer to this please add it.
Relating to your "Edit 1" and "Edit 2" notes, yes, it has to do with the session that is shared (assuming you're using one of the standard methods of handling sessions in NHibernate).
Is there a good reason for using Session.Clear()? In general, Clear is only used after a flush, to make sure the Session cache doesn't get too big causing a performance hit. Are you using it that way, or for some business reason not mentioned in your question?

Resources