/// <summary>
/// This class is a EventHandler of vend paramters
/// </summary>
class XDDVendParametersEventHandler
{
/// <summary>
/// This method is used to remove the image
/// </summary>
/// <param name="sender">FormControl</param>
/// <param name="e">FormControlEventArgs</param>
[FormControlEventHandler(formControlStr(VendParameters, Remove), FormControlEventType::Clicked),
SuppressBPWarning('BPParameterNotUsed','False positive')]
public static void Remove_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormDataSource vendParameters_ds = sender.formRun().dataSource(0) as FormDataSource;
VendParameters VendParameters = vendParameters_ds.cursor() as VendParameters;
if (VendParameters.RecId)
{
ttsbegin;
VendParameters.selectForUpdate(true);
VendParameters.XDDSignature = conNull();
VendParameters.update();
ttscommit;
}
vendParameters_ds.research(true);
}
/// <summary>
/// This method is used to change the image
/// </summary>
/// <param name="sender">FormControl</param>
/// <param name="e">FormControlEventArgs</param>
[FormControlEventHandler(formControlStr(VendParameters, Change), FormControlEventType::Clicked),
SuppressBPWarning('BPParameterNotUsed','False positive')]
public static void Change_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormDataSource vendParameters_ds = sender.formRun().dataSource(0) as FormDataSource;
VendParameters vendParameters = vendParameters_ds.cursor() as VendParameters;
str imageFilePathName;
;
imageFilePathName = XDDVendParametersEventHandler::uploadImageFile();
if (imageFilePathName && vendParameters)
{
ttsbegin;
vendParameters.selectForUpdate(true);
vendParameters.XDDSignature = ImageReference::GetPackedBinaryData(imageFilePathName);
vendParameters.update();
ttscommit;
}
vendParameters_ds.research(true);
}
/// <summary>
/// This method is used to call OnActivated
/// </summary>
/// <param name="sender">FormDataSource</param>
/// <param name="e">FormDataSourceEventArgs</param>
[FormDataSourceEventHandler(formDataSourceStr(VendParameters, VendParameters), FormDataSourceEventType::Activated),
SuppressBPWarning('BPParameterNotUsed','False positive')]
public static void VendParameters_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
VendParameters vendParameters = sender.cursor() as VendParameters;
FormWindowControl logoImage = sender.formRun().design().controlName(formControlStr(VendParameters, LogoImage)) as FormWindowControl;
Image image;
if (vendParameters.XDDSignature)
{
image = new Image();
image.setData(vendParameters.XDDSignature);
logoImage.image(image);
}
else
{
logoImage.image(null);
}
}
/// <summary>
/// This method is used to upload image file
/// </summary>
/// <returns>str</returns>
public static str uploadImageFile()
{
FormRun visualForm;
FileUpload fileUploadControl;
str imageFilePathName;
;
visualForm = classFactory::formRunClassOnClient(new Args(formstr(SysGetFileFromUser)));
visualForm.init();
visualForm.design().caption("@ApplicationPlatform:GetFileImageCaption");
fileUploadControl = visualForm.design().controlName('FileUpload1');
visualForm.run();
visualForm.wait();
FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult();
if (fileUploadResult != null && fileUploadResult.getUploadStatus())
{
imageFilePathName = fileUploadResult.getDownloadUrl();
}
return imageFilePathName;
}
}
No comments:
Post a Comment