Delphi Xe5二行程式碼搞定iOS讀取QR、UPC、EAN條碼

TMS Software 看到TMSFMXZBarReader這個元件,只要在要出現Barcode Scanner的地方寫一行

TMSFMXZBarReader1.show

取得掃到的內容則是在TMSFMXZBarReader的GetResult的AResult(文字)

元件下載網址: http://www.tmssoftware.net/public/TMSFMXZBarReaderPkgDXE5.zip

   

 

相關網址:
ZBar bar code reader

Delphi POS餐飲系統開發支援多國語言作法

開發餐飲POS或是其他系統,如果想打入國際市場的話,都會考量多國語系的問題,大部份就是使用mapping的方式。

在Delphi裡面的做法也很簡單~

先取得form上面的元件數(ComponentCount)

接下來用一個迴圈去比對即可。

資料表也可以開成一個

表單名稱、元件名稱、語言1、語言2、語言3的欄位…

不過因為裡面使用了infopower的wwdbgrid元件,寫在formcreate或formshow都抓不到值,後來是放到FormActivate才順利抓到

以下提供簡單的範例

 
[pascal]
var
sFormName:String;
i:integer;
begin
sFormName:= Self.Name; // 表單名稱
for i:=0 to self.ComponentCount -1 do begin
if Components[i] is TLabel then begin
if (TLabel(components[i]).Caption <>”) then begin
TLabel(components[i]).Caption := 取得語系….;
end;
end;
if Components[i] is TButton then begin
if (TButton (components[i]).Caption <>”) then begin
TButton (components[i]).Caption := 取得語系….;
end;
end;
end;
end;
[/pascal]
wwDBGrid的話關鍵有:
s:= TwwDBGrid(Components[i]).DataSource.DataSet.Fields[j].FieldName;
TwwDBGrid(Components[i]).ColumnByName(s).DisplayLabel
TwwDBGrid(Components[i]).ColumnByName(s).GroupName

Delphi透過MySQL存入檔案備份

MySQL存Blog的大小
TINYBLOB – 255 bytes
BLOB – 65535 bytes
MEDIUMBLOB – 16,777,215 bytes (2^24 – 1)
LONGBLOB – 4G bytes (2^32 – 1)

透過資料庫存取的方式重點:

TBlobField – LoadFromStream、SaveToStream
Tmemorystream – LoadFromFile、SaveToFile(.Position :=0)

存入資料庫

[pascal]
var
astream : Tmemorystream;
begin
AStream := TMemoryStream.Create;
try
astream.LoadFromFile(filename);
AStream.Position := 0;
if adotable1.Active then
begin
adotable1.Edit;
TBlobField(adotable1.FieldByName(‘t2’)).LoadFromStream(AStream);
adotable1.Post;
end;
finally
AStream.free;
end;
end;
[/pascal]

存回檔案

[pascal]
var
Ms:Tmemorystream;
begin
Ms := Tmemorystream.Create;
try
if adotable1.Active then
begin
TBlobField(adotable1.FieldByName(‘t2’)).SaveToStream(Ms);
Ms.Position := 0;
MS.SaveToFile(sname);
end;
finally
ms.Free;
end;
end;
[/pascal]

MySQL預設的BLOB為1M
別忘了 My.ini調整
max_allowed_packet = XXM