How to Display all fields/records of a Recipe on a Grid

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
andrea
Posts: 72
Joined: Tue Dec 11, 2012 5:44 am

How to Display all fields/records of a Recipe on a Grid

Post by andrea »

Hello,

we are creating a receipt with addtional fields as you can see in attached image (Recipe.jpg).
Then we would like to display and eventually modify all fields (name, date, note, watchdog) of the receipt on a grid in a screen.

Is it possible? How?

Thank you
Attachments
Recipe.jpg
Recipe.jpg (78.29 KiB) Viewed 11396 times

andrea
Posts: 72
Joined: Tue Dec 11, 2012 5:44 am

Re: How to Display all fields/records of a Recipe on a Grid

Post by andrea »

We are writing a code like this

List<string> myRecipeNames;
myRecipeNames = Globals.Constant1.FieldNames;

//List<Receipt> listReceipt1;
Recipe myRecipe = Globals.Constant1;


List<Receipt> listReceipt = new List<Receipt>();


foreach( string i in myRecipeNames) {
listReceipt.Add(new Receipt(){
Name = i,

Note = "Programming C#",

Date = new DateTime(1982, 4, 12),

WatchDog = true
});

}

I can scroll and update the name but cannot read and update other fields created by us...

I know that that there is this possibility (using Intellisense)

Globals.Constant1.Date;
Globals.Constant1.Note;
Globals.Constant1.WatchDog;

but not how to integrate it in my cycle.

Thank you

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: How to Display all fields/records of a Recipe on a Grid

Post by mark.monroe »

In the Recipe Tag configuration you associate a Recipe Item with a tag. In your case "Date" has been associated with SystenTagDateTime. Which means that when you save a Recipe, the value at that point in time will be saved to a column in a database called "Date".

You can create recipes during design time by adding them to the Runtime Data tab. The Runtime Recipe Title is the name of the recipe that shows up when the operator runs the Load Recipe action.

If you want to create recipes at runtime through script you would set the value of the tags associated with your recipe items, then save the recipe using a name.

Code: Select all

Globals.Tags.WatchDog_Recipe.Value = 12344;
//Now save the recipe and it will add the new recipe and the Watchdog 
//recipe item will have a value of 12344 in the recipe called MyNewRecipe
Globals.Recipe1.SaveRecipe("MyNewRecipe");
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

andrea
Posts: 72
Joined: Tue Dec 11, 2012 5:44 am

Re: How to Display all fields/records of a Recipe on a Grid

Post by andrea »

My main problem is not to add a new receipt programmatically but to display all fields compiled in a grid as in attached image.
Attachments
RecipeGrid.png
RecipeGrid.png (31.57 KiB) Viewed 11390 times

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: How to Display all fields/records of a Recipe on a Grid

Post by mark.monroe »

To get at the values of each individual recipe saved, you are going to need to access the database where all the recipes are stored. Here is a forum thread on how to write SQL queries. The recipes are stored in the same database, the table is named the same as your recipe group is named, table name would be "Constant1".

You might also want to take a look at the iX database viewer, it allows you to list the values in a table on a iX HMI.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

andrea
Posts: 72
Joined: Tue Dec 11, 2012 5:44 am

Re: How to Display all fields/records of a Recipe on a Grid

Post by andrea »

Thank you, is this the only one solution?

Do I have in some properties/tag the entire connection string of local SQL database or do I have create a new tag for it?

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: How to Display all fields/records of a Recipe on a Grid

Post by mark.monroe »

There is no connection string tag. If you want one you will have to create it and populate it with the correct information.

This is the connection string code from the Database script example provide in the previously mentioned thread.

Code: Select all

// Create a new sql connection object.
			m_SqlConnection = new SqlCeConnection();
			// Specify the connectionstring, with the full path to the database.
			m_SqlConnection.ConnectionString = string.Format("data source={0}", Path.Combine(ExcecutingPath, "Database.sdf"));
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Post Reply