Script Examples

Documentation

Script Examples

procedure msXMLTest;
var
root,
r: variant;
xDoc: variant;
begin
xDoc:= CreateOleObject(MSXML2.DOMDocument); //microsoft xml
xDoc.async:= false;
xDoc.load(D:\demo\delphi\x8.xml); //load from file
//xDoc.load(‘https://software-solutions-online.com/feed/’); //load from http
//upload to sql server
r:= prg.QueryValues(INSERT INTO _testXML(data,datXml) OUTPUT Inserted.ID VALUES(:1,:2), [xDoc.Xml,xDoc.Xml]);
//showmessage(r); //retrun ID
//get from sql server
r:= prg.QueryValues(select datXML from _testXML where id=:1, r);
xDoc.LoadXml(r);
root:= xDoc.documentElement; // is root node
root.insertBefore(xDoc.CreateNode(1,test1,), root.childNodes.item(0)); //insert element at position root.item(0)
root.appendChild(xDoc.createComment(Hello World!));
xDoc.Save(D:\demo\delphi\x8_save.xml); //save to file, or can save to http!!
end;
view raw use msxml.pas hosted with ❤ by GitHub
procedure SendEmail;
var
fs: tfileStream;
s: string;
begin
if not IsNull(newvalue) then begin
fs:= tfilestream.create(c:\htmlEmail.html, fmOpenRead);
fs.read(s, fs.size);
fs.free;
prg.SendEmail(xxx@gmail.com, , , subject, s, , true, true);
end;
end;
view raw SendEmail.pas hosted with ❤ by GitHub
Procedure callAction;
var
act: TActAction;
begin
try
act:= TActAction.Create(nil);
act.load({39929405-B13F-4113-930F-375FFF08E587});
act.run(true,true);
except
act.free;
doerror(Exceptionmessage);
end;
end;
view raw callAction.pas hosted with ❤ by GitHub
//Συναλλαγές, εργασία: “show φορμα” , στη φόρμα πατώντας κλικ εμφανίζει την εικόνα τους είδους (αν έχει)
var
f: Tform;
cImage: TImage;
procedure DoClick2;
begin
f.visible:= true;
end;
procedure cImage_OnClick;
var
ds: TclientDataSet;
begin
if itemtrnds[iteDescr].isnull then
exit;
ds:= prg.QueryDataSet(nil, exec usp_SelectImage :1, itemtrnds[itemID].value);
try
TBlobField(ds.fields[1]).SaveToFile(d:\test1.png);
cImage.Picture.loadfromfile(d:\test1.png);
finally
ds.free;
end;
f.caption:= itemtrnds[iteDescr].asstring;
end;
procedure BeforeLoad;
begin
showmessage(Hi);
end;
procedure init;
begin
frm.addinditask(show φορμα, @DoClick2, nil, true);
end;
Begin
bol.oninitialize:= @init;
f:= Tform.create(frm);
f.FormStyle:= fsStayOnTop;
f.SetBounds(800,200,200,200);
f.borderStyle:= bsSizeToolWin;
f.caption:= photo;
cImage:= TImage.create(f);
cImage.align:= alclient;
cImage.parent:= f;
cImage.OnClick:= @cImage_OnClick;
End.
view raw image_form.pas hosted with ❤ by GitHub
var
c: TWinControl;
ds :TDataSet
begin
c:= frm.GetControlFromLi(xxx);
ds:= prg.QueryDataSet(frm; select ***, Params);
c.SetDS(ds)
end;
procedure init;
begin
ItemBarCodeDS.IndexFieldNames:= ColorCode;SizeID; //by color and size
end;
view raw sortDataset.pas hosted with ❤ by GitHub
procedure textXML;
var
fs: tfilestream;
s: string;
r: variant;
begin
//TEST table is “create table _testXML(id int identity not null primary key, data varchar(max), datXML XML)”
//
//upload xml file to server
fs:= tfilestream.create(D:\demo\delphi\Synapse https\test1\sendInvoice.xml,fmOpenRead);
try
fs.read(s, fs.size);
r:= prg.QueryValues(INSERT INTO _testXML(data,datXml) OUTPUT Inserted.ID VALUES(:1,:2), [s,s]);
//showmessage(r);
finally
fs.free;
end;
//Get an XML from server and save to file
fs:= tfilestream.create(D:\demo\delphi\xxx.xml,fmCreate);
try
r:= prg.QueryValues(select datXML from _testXML where id=:1, r);
fs.write(r, length(r));
finally
fs.free;
end;
end;
procedure AddComboItem(c: TADC_ComboBox;const name, value: string);
begin
TstringList(c.propbyname[items]).add(name);
TstringList(c.propbyname[values]).add(value);
end;
procedure execForm;
var
btn: TControl;
cb: TADC_ComboBox;
begin
frmStatus:= TFormLayout.create(frm, FrmOrderStatus, Αλλαγή Status Παραγγελιών);
frmDS:= prg.QueryDataset(frmStatus,select cast(null as smallint) statusID,null);
frmDS.FieldByName(statusID).DisplayLabel:= Status;
cb:= TADC_ComboBox.CreateLiS(frmStatus, cbStatus, statusID, frmDS);
AddComboItem(cb, Σε επεξεργασία,0);
AddComboItem(cb, Ολοκληρωμένη,1);
frmStatus.addControl(cb);
btn:= TColorBitBtn.Create(frmStatus);
btn.name:= btnOk;
Tbutton(btn).onClick:= @btnOkClick;//On button click call procedure to do jobs
frmStatus.addControl(btn, Αποδοχή);
frmStatus.showmodal;
frmStatus.free;
end;
view raw createForm.pas hosted with ❤ by GitHub
function base64(user, pass, sn:string): string;
begin
result:= Basic + Prg.QueryValues(Select x.A from
+ (SELECT CAST(:0 as varbinary(max)) FOR XML PATH(””), BINARY BASE64) x(A), user+:+pass+#+sn);
end;
view raw base64.pas hosted with ❤ by GitHub