Wednesday, February 8, 2017


How to insert/remove image in a table from Form

According to the Requirement we insert the images in to the Tables through forms.For this we use “getData()” method of the “Bin Data” class
Here i found the 2 scenarios
scenario 1;- 
Create a field in table of Type contianer which must extend EDT:Bitmap
public Bitmap getImage()
{
Bitmap bitmap;
Bindata     binData ;
FileIOPermission perm;
FilePath _filepath = “c:\\sample.jpg
;
perm = new FileIOPermission(_filePath, ‘r’);
perm.assert();
binData = new BinData();
if (binData.loadFile(_filepath))
{
bitmap = binData.getData();
}
CodeAccessPermission::revertAssert();
return bitmap;
}
after that you assign this method to contianer  = > table.Field = class.getImage()
scenario 2;-
Create a field in table of Type container which must extend EDT:Bitmap
void clicked()
{
FilenameFilter filter = [‘Image Files’,’*.bmp;*.jpg;*.gif;*.jpeg’];
BinData binData = new BinData();
str extention, path, nameOfFile;
Str imageFilePathName ;
super();
imageFilePathName = WinAPI::getOpenFileName(element.hWnd(),filter,”, “@SYS53008″, ”,”);
if (imageFilePathname && WinAPI::fileExists(imageFilePathName))
{
[path, nameOfFile, extention] = fileNameSplit(imageFilePathName);
if (extention == ‘.bmp’ ||
extention == ‘.jpg’ ||
extention == ‘.gif’ ||
extention == ‘.jpeg’)
{
binData.loadFile(imageFilePathName);
imageContainer = binData.getData();
element.showLogo();
Thy_InventSymbolsIcons.Image = imageContainer;
}
else
{
throw error(“@SYS89176″);
}
}
element.Query_cntRecords();
}
then if you want to remove an image :
void clicked()
{
super();
element.delete();
}
and the delete mehtod is defined as follows:
void delete()
{;
Thy_InventSymbolsIcons.Image = connull();
Thy_InventSymbolsIcons_ds.refresh();
}

No comments:

Post a Comment