📄 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 + -