How to load report file in the printing control? - DevExpress - winforms

I created report(XtraReport) and i drag reporting tool PrintBarManager or PrintControl to form. Now I need to load that report to that PrintControl. How to load ? Help me.
I tried this code but showing error - Object reference is not set to instance of object
var test = new XtraReport1();
printControl1.Container.Add(test); // Object reference not set to instance of object
test.ShowPreview();
I tried this code but it showing - Best overloaded method match.....
var test = new XtraReport1();
printControl1.Controls.Add(test); // Best overloaded method, invalid arguments
test.ShowPreview();
How to load my report to PrintControl ?

Use the following code:
//Set the printing system
printControl.PrintingSystem = report.PrintingSystem;
//Create and build your report
XtraReport1 report = new XtraReport1();
report.CreateDocument();
P.S. Take a look at How to: Add a Print Preview to a Windows Forms Application guidance.

Related

Concurrency Error WinForms Binding Source Navigator

I have a form with customer info that needs to be processed one transaction per page. I'm using the binding navigator to manage my pagination.
It works in all but some cases. In the cases where it doesn't work, I have to open a different window to look up information and return it to the main form. Here is the code for that:
// save current work
updateDataTable();
// Open a window and get new customer info
// CurrentCustomer is returned from the opened window
using (SqlConnection cx = new SqlConnection(GetConnectionString()))
{
DataRowView dataRow = (DataRowView)procBindingSource.Current;
dataRow.BeginEdit();
dataRow["CUSTOMER"] = CurrentCustomer;
dataRow.EndEdit();
updateDataItems();
SqlCommand cmd = new SqlCommand(
#" select acct_no from cust_processing where id = #id ", cx);
cmd.Parameters.AddWithValue("#id", (int)dataRow["ID"]);
cx.Open();
var results = cmd.ExecuteScalar();
if (results != null)
{
dataRow.BeginEdit();
dataRow["ACCT_NO"] = results.ToString();
dataRow.EndEdit();
updateDataItems(); <------ CONCURRENCY ERROR
}
}
The error I am getting is a concurrency error. I think that I have more than one version of the row possibly ? I thought I was making sure that I was on the most recent version of the row by calling updateDataTable(). I am the only user so I know I am creating the problem myself.
Here is my update method which is called when I change pages or save and exit or want to write the commit the data:
void updateDataItems()
{
this.procBindingSource.EndEdit();
this.procTableAdapter.Update(xyzDataSet);
xyzDataSet.AcceptChanges();
}
I have tried executing updateDataItems from various places such as after I assign dataRow["ACCT_NO"] = results.ToString() or before and after assigning that.
I'm pretty much down to guess and check so any thoughts, help and advice will be appreciated and +1.
Okay -- so the problem was that I was trying to update the current row from the program and also using the binding navigator. They were not working together properly.
The solution was to add a text box to the form in the forms designer and set visible = false and bind it to ACCT_NO. Once I got the results from my other form, I just needed to set the .text property of the ACCT_NO textbox to the new value and the binding navigator managed all my updates for me correctly.
txtAcct_No.text = results.ToString();

Displaying Parse Data to ContainerList

I want to display data from Parse in a list from GamesScores class using Container in Codename One, this is what I've tried so far and it's not showing anything nor giving any errors:
Container container = findListCont();
container.setLayout(BoxLayout.y());
container.setScrollableY(true);
ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
List<ParseObject> results = (List<ParseObject>) query.find();
System.out.println("Size: " + results.size());
container.addComponent(results, f);
Please help me out, I'm a new in Codename One. If there tutorials on it, please share or anything to help me achieve the desired results.
I'm actually shocked this isn't failing. You are using the add constraint to place the object result as a constraint and you add the form object into the container...
You need to loop over the results and convert them to components to add into the layout. It also seems that you are using the old GUI builder which I would recommend against.
Generally something like this rough pseudo code should work assuming you are using a box Y layout:
for(ParseObject o : results) {
MultiButton mb = new MultiButton(o.getDisplayValue());
f.add(mb);
}
f.revalidate();

How to open a second report from original on ssrs

I would like to create a report like this:
I have a column called "hatalar". And if I click data in "hatalar" column,
I would like to open a new report.
New report should be like this:
How can I open a new report when I click data in report?
There are two main ways to do this, open in new window or 'drill through' to the next report in question.
New window: Create a javascript expression that checks whether the report is rendered as a report or excel/pdf and creates a link that will open a new window with the correct URL:
=IIF(Globals!RenderFormat.Name = "RPL", "javascript:void(window.open('http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=" & Fields!ReportMonthId.Value & "','_blank'))", "http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=" & Fields!ReportMonthId.Value)
Additional MS documentation on how to pass report parameters via the report URL can be found here but the gist is like this:
Native Mode URL:
http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=3&ReportYear=2008
SharePoint Mode URL:
http://myspsite/subsite/_vti_bin/reportserver?http://myspsite/subsite/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2.rdl&ReportMonth=3&ReportYear=2008
Drillthrough: Set the action of the hatalar textbox to 'drillthrough' and pass report parameters. This will result in the current page being replaced with the sub page.
Additional documentation can be found on the MS documentation page for drillthroughs.

Does anyone have a C# example of using an UltraDataSource as the DataSource to a UltraComboEditor please

Does anyone have a C# example of using an UltraDataSource as the DataSource to a UltraComboEditor please.
I can get so far but it doesn't seem to bind.
I have tried a simple project to use an UltraDataSource as datasource for a simple UltraComboEditor. Set the properties of the ComboEditor to
this.ultraComboEditor1.DataMember = "Band 0";
this.ultraComboEditor1.DataSource = this.udsTest; // <- crashed here
this.ultraComboEditor1.DisplayMember = "Description";
this.ultraComboEditor1.Name = "ultraComboEditor1";
this.ultraComboEditor1.ValueMember = "ID";
The sample program crashed with a NullReferenceException inside the InitializeComponent code where I set the UltraDataSource instance.
Then I have removed the setting of the property DataMember (Not just blanked out, but right-click and selected Reset). Now the program works.

Database.open - 'The name 'database does not exist in the current context'

I followed the following tutorial to help me create a datagrid (http://www.asp.net/web-pages/videos/aspnet-razor-pages/displaying-data-in-a-grid), however, I keep getting the error in the title under the word database. I've tried replacing it with the name of my database (Products) however that didnt work. Does anyone know why it could be happening? This piece of code sits at the top of my view page:
#{
var _db = database.open("Products");
var selectQueryString = "SELECT * FROM Products ORDER BY DateBought, SortOrder";
var data = _db.query(selectQueryString);
var grid = new WebGrid(Model);
}
When I check the values I receive in the drop down menu when I type var _db = datab.. I only have the following available:
Databinding, Databinder, DatabindingCollection, Databindinghandlerattribute, databindingliteralcontrol, Designerdataboundliteralcontrol, Idatabindingsassessor
You need to add a Reference to WebMatrix.Data.dll
Database class is part of WebMatrix.Data there for is only available through that dll.
You can find WebMatrix.Data.dll in [Program Files Directory]\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies or v2.0\Assemblies regarding the version you have installed.
I had the same error and I found this solution that worked for me:
http://www.w3schools.com/aspnet/webpages_database.asp
It seems that Webmatrix2 doesn't include the said .dll by default. I only had to download the nuget package from Webmatrix's gallery and it worked.
I hope it helps others.

Resources