Click here to Skip to main content
15,914,160 members

Comments by Aggeliki Asimakopoulou (Top 19 by date)

Aggeliki Asimakopoulou 13-May-24 2:16am View    
Thank you, I refered programmatically with source code in case it is possible of course, not manually!
Aggeliki Asimakopoulou 12-Apr-24 14:07pm View    
I have never written source code in Crystal Reports as the link you shared to me and it's not properly source code because I know visual basic .net and I tried it and it has several error the debugger hits. However you didn't explain to me. If I don't understand something, if I don't have any guidance how can I solve it? If your run your source code, you will definetely see, that yes it doesn't work, it give only the first record. Through OrderReport.SetParameterValue(columnName, values.ToArray()); you set all the values but the parameter only gets the first one...
If you had explained to me as I asked it, I could do that.
Anyway, I watched this video https://www.youtube.com/watch?v=rwc6oxOG0OQ, I followed step by step and it works for me, I get all values in a different way and I will include it to my main report as a subreport.
Excuse me, but I can't accept a solution that doesn't work and without a good example in order to try it, by my own. Thank you.
Aggeliki Asimakopoulou 12-Apr-24 7:40am View    
Excuse me, but I described it a lot from the start. All source code is written in C# and the question is refered to C#. I have never written code in crystal reports.
I have created a back - end application in C# with embedded microsft sql server.

I have a form represent orders management. So when the user runs the application, he enters an OrderID in the Search Text Box and the corresponding Order appears in the form controls. All these in C#. More detailed, the displayed Order comes with the appropriate Invoice Record, the appropriate Customer that made this order, all these appear in RichTextBoxes, and a DataGridView that displays the products that Customer ordered. Everything runs perfectly.

I also have button for my crystal report of the searched order, the btnPrint in a form.
I would like also to mention that report values are place to details section in C#.

The problem comes when I try to give values to the report from the DataGridView with GiveValuesToRpt function, all the other values appears correctly. I get to the Report only the last record of product details of the DataGridView and not all the records it's need. All the source code is written in C#, the crystal report is also created in C#. And the source code I shared is written in C#, both the print button on the OrdersForm and the GiveValuesToRpt which is called form the print button. Isn't something clear? I have tried with your code, even with parameters and I get only the first record of datagridview, with my source code I get only the last record of datagridview, what if I had dozens of records to the datagridview that they refer to order products? I don't want the first or the last record of the datagrid view data, I want all these records to be displayed one under the other in my crystal Report. My crystal report represent an Order Receipt.
Aggeliki Asimakopoulou 11-Apr-24 13:54pm View    
Your code doesn't work even with parameters and the crystal report is created in C# not in other platforms, not in other programming languages

if (dtGridViews.Any())
{
foreach (var dtGridV in dtGridViews)
{

for (int iC = 0; iC < dtGridV.Columns.Count; iC++)
{
string columnName = dtGridV.Columns[iC].Name;
List<string> values = new List<string>(dtGridV.Rows.Count);
for (int iR = 0; iR < dtGridV.Rows.Count; iR++)
{
if (dtGridV.Rows[iR].Cells[columnName].Value is string value)
{
pf = params_.FirstOrDefault(x => x.Name.Contains(columnName));
name = columnName.ToString();
//pf.EnableAllowMultipleValue = true;
values.Add(value);




//OrderReport.SetParameterValue(name, dtGridV.Rows[iR].Cells[columnName].Value);
//pf.CurrentValues.Clear();
//ParameterDiscreteValue paraDescritValue1 = new ParameterDiscreteValue();
//paraDescritValue1.Value = value;
//pf.CurrentValues.Add(paraDescritValue1);
//paraFields.Add(pf);

//OrderReport.SetParameterValue(columnName, value);
//pf.CurrentValues.Clear();
//ParameterDiscreteValue paraDescritValue1 = new ParameterDiscreteValue();
//paraDescritValue1.Value = value;// value;
//pf.CurrentValues.Add(paraDescritValue1);
//paraFields.Add(pf);
}
}

//var test = values.ToArray();
OrderReport.SetParameterValue(columnName, values.ToArray().Last().ToString());
pf.CurrentValues.Clear();
ParameterDiscreteValue paraDescritValue1 = new ParameterDiscreteValue();
paraDescritValue1.Value = values.ToArray().Last();

pf.CurrentValues.Add(paraDescritValue1);
paraFields.Add(pf);
}
Aggeliki Asimakopoulou 11-Apr-24 13:13pm View    
I don't understand the source code in the link. It is not writtern in C#. I don't understand at all the source in this unknown programming language... How can I change the code, when I understand nothing?