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

Delphi XE5 Android Kitkat Style下載

Delphi XE5提供 Andoird 4.4 Kitkat的樣式下載,使用的方式也相當簡單

1)在畫面上放一個TStyleBook元件

2)將 AndroidLight.fsf 或 AndroidDark.fsf 載入到TStyleBook元件

3)在 form oncreate事件加上~

{$IFDEF ANDROID}

if TOSVersion.Check(4, 4) then StyleBook := StyleBook1;

{$ENDIF}

下載網址: embarcadero網站

Delphi使用記憶體模擬表格的kbmmemtable

雖然在Delphi有clientdataset可以使用,但美中不足的是必需在程式部署時附上midas.dll,或是在程式中uses MidasLib。最近看到國外在討論的kbmmemtable,由於在寫餐飲的POS功能所以也來測試一下。

因為kbmmemtable不需要BDE支援,所以不用特別去設定DatabaseName, TableName和TableType這些屬性。

建立欄位很簡單,

with kbmMemTable1.FieldDefs do
begin
Clear;
Add(‘t01’, ftInteger, 0, false);
end;

建立index也只需要

Add(‘Index01’, ‘value’, []);

接著就可以像一般的ttable一樣,append新增edit修改delete刪除等動作…..

然後呢也可以直接讓datasource指定它,讓kbmmemtable的值顯示在dbgird上面。

它支援loadfromdataset的功能,如果需要cache資料在程式裡不要連結資料庫時,就可以利用這個功能。另外也可以支援savetofile的功能,共有二種

1)二進位資料

SaveToBinaryFile

LoadFromBinaryFile

2)csv格式

SaveToFile

LoadFromFile

 

Delphi 1stClass實現單選、複選按鈕

看到別人寫單選複選按鈕很簡單,於是努力的研究到底是用了什麼元件。才發現是用Woll2Woll 的1stCalss元件做到,自己寫的要死要活,別人簡單就達成了!orz

實現的方式很簡單,只要使用 TfcButtonGroup這個元件即可。

設定.ClickStyle 的屬性 bcsRadioGroup(單選)bcsCheckList(複選)

POS系統設備 – 餐飲點餐卡/ 餐飲業問卷調查

在餐飲業用餐後,某些比較大型的連鎖餐飲體系都會附上一張滿意度問卷調查表,或是在一些比較沒有過多調味變化的餐飲店中,也會出現學生時代答案卡形式的點餐卡。

點餐卡雖然沒有太深厚的技術,不過對於店家來說卻是蠻便利的,只要將客戶畫記好的點餐卡放入OMR光學閱讀機中,就可以輸入到POS系統畫面中。節省許多點餐及詢問的時間~

關閉清粥小菜_點餐卡

關閉鹽酥雞_點餐卡

關閉餐飲業

延伸連結:
名科資訊有限公司 http://www.dartgoal.com.tw/

 

POS系統設備 – 取餐呼叫器

在客戶那邊看到了蠻特別的機器「取餐呼叫器」,透過簡單的發送器及接收器,可以免除要廣播、大聲叫號的問題。等於手上的號碼牌(取餐牌)是會自動提醒的。操作也很簡單,只要透過發送器按下號碼後送出,手上對應的接收器就會閃爍,可以用在需要叫號的各行各業,甚至用在目前正夯的健康照護產業也可以。

 

 

延伸連結:
漢偉科技有限公司 http://www.ehanway.com.tw/

 

PHP產生透明的png縮圖

二個重點函數
imagealphablending($thumb,false)
imagesavealpha($thumb,true);

[php]
function pngthumb($sourePic,$smallFileName,$width,$heigh){
$image=imagecreatefrompng($sourePic);//PNG
imagesavealpha($image,true);
$BigWidth=imagesx($image);
$BigHeigh=imagesy($image);
$thumb = imagecreatetruecolor($width,$heigh);
imagealphablending($thumb,false);
imagesavealpha($thumb,true);
if(imagecopyresampled($thumb,$image,0,0,0,0,$width,$heigh,$BigWidth,$BigHeigh)){
imagepng($thumb,$smallFileName);}
return $smallFileName;
}
[/php]