0% found this document useful (0 votes)
163 views

Script

The document contains C code that reads default property values from user archive databases for a product. It opens connections to two archives ("UA_Product" and "UA_Receipes"), sets filters based on the product name, reads fields for recipe ID, bottle ID, line ID, and recipe details, and writes the values to IO tags and dropdown controls on a picture for default display.

Uploaded by

Mhr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views

Script

The document contains C code that reads default property values from user archive databases for a product. It opens connections to two archives ("UA_Product" and "UA_Receipes"), sets filters based on the product name, reads fields for recipe ID, bottle ID, line ID, and recipe details, and writes the values to IO tags and dropdown controls on a picture for default display.

Uploaded by

Mhr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include "apdefap.

h"
void OnPropertyChanged(char* lpszPictureName, char* lpszObjectName, char*
lpszPropertyName, char* value)
{
char szFilter[300];
char szMyFunctionName[30];
char szTest[20];
char szSort[100];
char strBuffer[100];

double dRecId;
double dBottleID;
double dLineID;
long lRowCount;
double dST001;
double dST002;
double dST003;
double dSellIndex;

int iRecId;

int i = 0;

UAHCONNECT hConnect;
UAHARCHIVE hArchive;

sprintf(szMyFunctionName, "OpenPicture ProductX");

//*******************************Read UA_Prodduct for Default


Setting*******************************

// Verbindung zum UserArchiv herstellen


if(!openUserArchive(&hConnect, &hArchive, "UA_Product"))
{
trace('E', szMyFunctionName, "openUserArchive failed");
return;
}

//Filter
sprintf(szFilter, "Product LIKE 'PRODUCT%s'", value);
//printf("%s\r\n",szFilter);

// UserArchiv filter
if(!uaArchiveSetFilter(hArchive, szFilter))
{
trace('E', szMyFunctionName, "uaArchiveSetFilter failed");
return;
}

// update userarchive
if(!uaArchiveRequery(hArchive))
{
trace('E', szMyFunctionName, "uaArchiveRequery failed");
return;
}

// choose the first dataset


if(!UAArchiveMoveFirst(hArchive))
{
trace('E', szMyFunctionName, "UAArchiveMoveFirst failed");
return;
}

// Read ReceipeID
uaArchiveGetFieldValueDouble(hArchive, 1, &dSellIndex);
//printf("dSellIndex = %f\r\n", dSellIndex);

// Read ReceipeID
uaArchiveGetFieldValueDouble(hArchive, 3, &dRecId);
//printf("dRecID = %f\r\n", dRecId);

// Read BottleID
uaArchiveGetFieldValueDouble(hArchive, 4, &dBottleID);
//printf("dBottleID = %f\r\n", dBottleID);

/*
// Read ST001
uaArchiveGetFieldValueDouble(hArchive, 5, &dST001);
//printf("dST001 = %f\r\n", dST001);

// Read ST002
uaArchiveGetFieldValueDouble(hArchive, 6, &dST002);
//printf("dST002 = %f\r\n", dST002);

// Read ST003
uaArchiveGetFieldValueDouble(hArchive, 7, &dST003);
//printf("dST003 = %f\r\n", dST003);
*/

// Read LineID
uaArchiveGetFieldValueDouble(hArchive, 5, &dLineID);
//printf("dLineID = %f\r\n", dLineID);

// close connection to userarchive


if(!closeUserArchive(hConnect, hArchive))
{
trace('E', szMyFunctionName, "closeUserArchive failed");
return;
}

//******************************* End Read UA_Prodduct for Default


Setting*******************************

//*******************************Read UA_Receipes for Default


Setting*******************************

// Verbindung zum UserArchiv herstellen


if(!openUserArchive(&hConnect, &hArchive, "UA_Receipes"))
{
trace('E', szMyFunctionName, "openUserArchive failed");
return;
}

iRecId = dRecId;

//Filter
sprintf(szFilter, "R_ID = %i", iRecId);
//printf("%s\r\n",szFilter);

// UserArchiv filter
if(!uaArchiveSetFilter(hArchive, szFilter))
{
trace('E', szMyFunctionName, "uaArchiveSetFilter failed");
return;
}

// update userarchive
if(!uaArchiveRequery(hArchive))
{
trace('E', szMyFunctionName, "uaArchiveRequery failed");
return;
}

// choose the first dataset


if(!UAArchiveMoveFirst(hArchive))
{
trace('E', szMyFunctionName, "UAArchiveMoveFirst failed");
return;
}

// Read ST001
uaArchiveGetFieldValueDouble(hArchive, 3, &dST001);
//printf("dST001 = %f\r\n", dST001);

// Read ST002
uaArchiveGetFieldValueDouble(hArchive, 4, &dST002);
//printf("dST002 = %f\r\n", dST002);

// Read ST003
uaArchiveGetFieldValueDouble(hArchive, 5, &dST003);
//printf("dST003 = %f\r\n", dST003);

// close connection to userarchive


if(!closeUserArchive(hConnect, hArchive))
{
trace('E', szMyFunctionName, "closeUserArchive failed");
return;
}

//******************************* End Read UA_Receipes for Default


Setting*******************************

// ***************************************START write values in io fields


********************************************
//EA-Felder schreiben
SetTagDouble("amount",1); ////DefaultValue always 1
SetTagDouble("ST001", dST001);
SetTagDouble("ST002", dST002);
SetTagDouble("ST003", dST003);

// *************************************** ENDE write values in io fields


********************************************
//********************* 2. Dropdown Receipes***********************

//Set on actual value


SetPropWord(lpszPictureName,"CB_OrderRceipe","SelIndex", dRecId+1); // cause
default is on position 1

//************End 2. Dropdown
***********************************************************

//********************* 3. Dropdown BottleTypes***********************

//Set on actual value


SetPropWord(lpszPictureName,"CB_BottleType","SelIndex", dBottleID+1); // cause
default is on position 1

//************End 3. Dropdown
***********************************************************

//********************* 4. Dropdown Lines***********************

//Set on actual value


SetPropWord(lpszPictureName,"CB_Line","SelIndex", dLineID+1); // cause default is
on position 1

//************End 4. Dropdown
***********************************************************
sprintf(strBuffer, "PRODUCT%s", value);
SetTagChar("name",strBuffer);
SetTagDouble("receipe" , dRecId);
SetTagDouble("bottletype" , dBottleID);
SetTagDouble("line" , dLineID);

You might also like