?? cwebutils.pas
字號:
{-----------------------------------------------------------------------------
Unit Name: CWebUtils
Author: hubdog(陳省)
Purpose: 常用的Web例程
BeginDate: 2002-7-1
History:
-----------------------------------------------------------------------------}
unit CWebUtils;
interface
uses DB,Classes,SysUtils,IWInit, IWTypes,IWAppForm, IWCompListbox;
//釋放當前界面,顯示下一個界面
procedure Move(AFormClass: TIWAppFormClass);
//獲取數據字典
function GetDataDicList(DS:TDataSet;const KeyName, ValueName:String):TStrings;
//用數據字典填充進ComboBox
procedure FillValueToCombo(ACombo:TIWComboBox;AStrings:TStrings);
//獲取ComboBox的Value所對應的Key
function GetKeyFromCombo(ACombo:TIWComboBox; AStrings:TStrings):string;
//根據Value設定ComboBox
procedure SetComboKeyByValue(ACombo:TIWComboBox; Value:string; AStrings:TStrings);
//根據Value獲得Name
function GetValueByKey(AStrings:TStrings; Value:string):string;
implementation
function GetValueByKey(AStrings:TStrings; Value:string):string;
var
I:Integer;
begin
Result:='';
for I:=0 to AStrings.Count-1 do
if AStrings.Values[AStrings.Names[I]]=Value then
Break;
Result:=AStrings.Names[I];
end;
procedure SetComboKeyByValue(ACombo:TIWComboBox; Value:string; AStrings:TStrings);
begin
ACombo.ItemIndex:=ACombo.Items.IndexOf(GetValueByKey(AStrings, Value));
end;
function GetKeyFromCombo(ACombo:TIWComboBox; AStrings:TStrings):string;
begin
Result:=AStrings.Values[ACombo.Text];
end;
procedure FillValueToCombo(ACombo:TIWComboBox;AStrings:TStrings);
var
I:Integer;
begin
ACombo.Items.Clear;
for I:=0 to AStrings.Count-1 do
begin
ACombo.Items.Add(AStrings.Names[I]);
end;
ACombo.ItemIndex:=0;
end;
procedure Move(AFormClass: TIWAppFormClass);
begin
// 釋放當前窗體
TIWAppForm(RWebApplication.ActiveForm).Release;
// 創建下一個窗體
AFormClass.Create(RWebApplication).Show;
end;
function GetDataDicList(DS:TDataSet;const KeyName, ValueName:String):TStrings;
begin
DS.Active:=True;
DS.First;
Result:=TStringList.Create;
while not DS.Eof do
begin
Result.Add(format('%s=%s', [ds.FieldByName(ValueName).AsString, ds.FieldByName(KeyName).AsString]));
DS.Next;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -