How to access an RDLC variable from C# - c#

In a C# RDLC file, I have set up a report variable called test.
I have a table and based on the value in the row. I want to set the report variable.
Below is a field from the table. I check to see if the first letter is H, and set the variable to 1, otherwise, it displays a value 2.
=iif(Left(Fields!StockSymbol.Value,1)="H",Variables!test.Value = 1, "2")
So what happens is that test is not equal to 1, so the grid prints false. I actually, want it to print false and set the test variable to 1.
Anyone know how?

Related

Pass Text from form to formula field

I create a formula for conditional sum. Here is sample code.
` if {Customer.Region} = 'VA'
then 1
else 0
To sum records in the state of Virginia:
if {Customer.Region} = 'VA'
then {Orders.Amount}
else 0`
I want to input the value 'VA' from textbox of a form dynamically. When i input 'VA' in my form and click a button that value go to the formula if {Customer.Region} = 'textbox Value'. How can i do that?
Create a Parameter Field. This will allow you to be prompted by the report to input a value. So if you created a Parameter Field and name it "MyString", then you could do your comparison to your report field as:
If {Customer.Region} = {?MyString}
//Do something if true
Else
//Do something if false
Please note, this will only prompt you to input a value for the Parameter Field when the report is executed. If you want to compare using a second input value, you will need to run the report again for each additional value.

Get the data type from a field in MSproject

I'm trying to get the data type of a selected field in MSProject. there are 8 types of data(Cost, date, text,....) and I'd like to develop a small addin with Visual studio wich makes some calculation depending on the type of data I have selected.
With the help of this site, I found how to get the name of the field:
Application.ActiveSelection.FieldNameList[0]
(It could be helpful for the next step, If I select more than one field ==> Do nothing)
but I'm not able to find a way to return the data type of the selected field
Someone has an idea how I could do that?
For example, if I select this field, my programm has to return : text
You will need to build a map of FieldName or FieldID to data type.
Keep in mind that date fields can also contain text (e.g. ActualStart will contain NA until there is a date in that field).
Also, use the task's native property to get the data rather than the ActiveCell property or the GetField method which return the displayed value.
For example, if the active cell is a duration field showing 2 days:
ActiveCell returns "2 days", "2d", or "2 d", etc. depending on the user's configuration.
ActiveCell.Task.GetField(pjTaskDuration) returns the same thing.
ActiveCell.Task.Duration returns 960 (Int32).
Update
For custom fields that the end user creates, TryParse can be used to determine the likely data type. Here's a simplistic vb example:
Dim s As String
Dim d as Date
With Application.ActiveSelection
s = .Tasks(0).GetField(.FieldIDList(0))
End With
If Date.TryParse(s, d) Then
' it is a date
Else
' it's not a date, maybe check to see if it's an integer
End If

Crystal Reports C# formula returning false only

I have created one crystal report where I want to write a formula.
my formula:
IF {Sp_Get_DailyReport;1.Job_Status} = 'Workshop'
THEN {Sp_Get_DailyReport;1.Department_Name}
but, this formula doesn't returning a value.
i have edited my formula, now i'm getting as 'false' instead of Dept-name.
stringvar text := "";
IF {Sp_Get_DailyReport;1.Job_Status} = "Workshop"
THEN text = "{Sp_Get_DailyReport;1.Department_Name}"
In ReportFooter i have created one column for workshop where i want to display department name n unit name whose units are in workshop and i'm placing this formula field in ReportFooter where its returns only one value,
instead of each condition where its true &
why its returning 'false' i dont know, instead of dept name.
I want to select all those records whose jobstatus is workshop n display it in the reprotfooter.
Can anyone please help me...
Thanks
TROUBLE SHOOT
IF {Sp_Get_DailyReport;1.Job_Status} = "Workshop"
THEN {Sp_Get_DailyReport;1.Department_Name}
ELSE
{Sp_Get_DailyReport;1.Job_Status}
This function will return the value of the Job_Staus if the Job_Status value is anything BUT "Workshop"
Are you sure the Job_Status value contains "Workshop"
Check for Spaces as Well could try trimming Job_Status

Can we equate 2 parameters in crystal reports c# (oracle db)?

I have a simple search box in my web app and i want to provide options of searching the employee table for either name, employee id or position etc. Ie, basically a drop down and then a text box to enter the value. The columns currently being chosen are from the same table.
I have assumed i need 2 parameters equating both such that one refers to the column name and the other to its value. Is it right? And if so, how do we pass the sql query on formula editor?
Check the below code:
if ({?cat}="NAME")
then
{FATHIMA.NAME}={?val}
else
if({?cat}="POSITION")
then
{FATHIMA.POSITION}={?val}
Provided there should be value in {?val} and that value should match with the value in database.
Yes i have used Record Selection Formula. The code I've written there is:
if ({?cat}="NAME")
then
{?val}={FATHIMA.NAME}
else
if({?cat}="POSITION")
then
{?val}={FATHIMA.POSITION}
---where "NAME" and "POSITION" are column names. I have passed them manually as items in a drop down list. But the report gives an empty result. 'cat' is the parameter holding the selected value from the drop down.

Check whether an Object is empty or null

I have a DataGridView and added a column called SellQty and a Checkbox at index 0. User has to enter int value when he selects a checkbox. If not I am showing a message to enter the value. Now the problem is I am getting the value from the SellQty cell and storing it in an object and checking whether it is null.
object SellQty = gvProductBatch.Rows[i].Cells["txtSellQty"].Value;
if(SellQty!=null)
// do something
else
// ..Show message.
This works fine. But the problem is when the user enters a value and deletes it, the value stored in it is {} i.e. empty. I would like to know how to check an object is empty. I have googled for the same but didn't find answer to handle empty object. All results were for if object is null.
You can get the actual edited Value by using the .EditedFormattedValue
if (string.IsNullOrWhiteSpace(gvProductBatch.Rows[i].Cells["txtSellQty"].EditedFormattedValue.ToString())
{
//Do something
}

Categories