MonthToDate errors in Crystal Reports - crystal-reports-xi

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"

Related

How to know DialogResult with ReportViewer.PrintDialog()

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

How do I debug bad SVG parsing in Firefox? (ie. "Unexpected value X parsing Y attribute" in error console)

Summary:
I want to see more detailed XML/SVG parsing error messages. I want to know where the errors are happening. How can I do this?
Background:
I'm working with some complicated javascript-generated SVG in Firefox. As I'm developing, sometimes while hunting down a big I'll see errors in the Firefox error console (or firebug) "Unexpected value NaN parsing y attribute". This is pretty clear. However, there's no line number, no code shown in Firebug - basically no way to track down where this error occurs.
With simple JS, it's a matter of tracking down the bad code. However, as my JS gets more complicated, I really need to be able to see which of hundreds of potential lines is causing this.
Ideally, I'd like to see this parsing error the same way I see JS errors or HTML errors:
Unexpected value NaN parsing y attribute.
Line 103: svgElement.setAttribute('x', some_bad_js_variable);
Is there any way to do this? Even knowing which SVG element is being affected would help, anything besides "There was an error somewhere". Thanks!
Nearly three years later and using Firefox 29.0.1, I have the same difficulty. I ended up commenting out successive blocks of code until I found the offending line.
FWIW, in my case Firefox didn't like the fact that I had created a node with blank attributes:
<clipPath id="chart_area">
<rect x="" y="" width="" height=""/>
</clipPath>
Once I removed the attributes or set them to any value, the problem went away. I was surprised because I'd expected the error to be in the Javascript instead. I hope this helps someone else.
Raise a bug in bugzilla and ask for the element tag name to be added to the error message: https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=SVG
Adding a line number would be more difficult. If want that too then create another bug specifically for it as you're less likely to get it.

What is a "NullReferenceError" in ASP.NET MVC?

I keep getting "NullReferenceError" in my output, could someone kindly explain what exactly this statement means.
Somewhere in your code, you are trying to access a member of a reference type, but the variable actually is null. Without code and a stacktrace it's impossible to say what exactly happens. It might be because some parameter is expecting a value but isn't supplied one.
If it helps, a decent description of NullReferenceException -- why/when they occur, and how to prevent them -- at http://www.dotnetperls.com/nullreferenceexception

Ruby: How to check if a string is a valid time?

I'm pulling data from a feed that I have no control over and I need to verify if a string I'm given is a valid time.
Most of the time I'm correctly sent something like "2:35" or "15:41" but other times it's things like "AM" or "PM" (and no numbers)...so I ultimately just need to ignore those.
So, how can I verify if the data is a valid time?
You haven't exactly specified what you assume to be a valid time (e.g. whether you should accept optional seconds), so here's one guess:
data =~ /^([01]?[0-9]|2[0-3])\:[0-5][0-9]$/
Using Time.parse() is not a good solution, as shown in the example of the comments.
I'll leave the answer here for 'historical reasons', to keep the comments, and as a warning for future readers!
You can use Time.parse() and check for the ArgumentError exception for invalid times.
Extra advantage is that you also have the time in a usable format to work with if it is valid!

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