119 lines
3.5 KiB
ObjectPascal
119 lines
3.5 KiB
ObjectPascal
|
|
unit U_ControlData;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, ComCtrls, ToolWin, ShlObj, cxShellCommon, cxControls, cxDropDownEdit,
|
|||
|
|
cxContainer, cxShellTreeView, cxShellListView, StdCtrls, BtnEdit,
|
|||
|
|
OleCtnrs, DB, ADODB,ZLib;
|
|||
|
|
|
|||
|
|
function InitDevCombobox(ADOQueryTmp: TADOQuery; combobox: TcxCombobox; mFlag: string; selFlag:Boolean=true): Boolean;
|
|||
|
|
function InitDevCxGridCombobox(ADOQueryTmp: TADOQuery; ComboBoxProperties: TcxComboBoxProperties; mFlag: string): Boolean;
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
/// ////////////////////////////////////////////////
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>ȡ<EFBFBD><C8A1>ˮ<EFBFBD><CBAE>
|
|||
|
|
// mFlag:ǰ<C7B0><D7BA>mTable:<3A><><EFBFBD><EFBFBD>
|
|||
|
|
// mlen:<3A><>ˮ<EFBFBD>ų<EFBFBD><C5B3><EFBFBD>; mtype:<3A>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<><31><EFBFBD><EFBFBD> 0 <20><><EFBFBD><EFBFBD>
|
|||
|
|
/// ////////////////////////////////////////////////
|
|||
|
|
function InitDevCombobox(ADOQueryTmp: TADOQuery; combobox: TcxCombobox; mFlag: string; selFlag:Boolean=true): Boolean;
|
|||
|
|
var
|
|||
|
|
defaultValue:string;
|
|||
|
|
idx:integer;
|
|||
|
|
begin
|
|||
|
|
Result := false;
|
|||
|
|
try
|
|||
|
|
with ADOQueryTmp do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select a.* from SY_Dict_Item a');
|
|||
|
|
sql.Add(' inner join SY_Dict b on b.dictId=a.dictId');
|
|||
|
|
sql.Add(' where b.dictcode='+QuotedStr(mFlag));
|
|||
|
|
sql.Add('and a.valid=1 and b.valid=1');
|
|||
|
|
sql.Add('order by b.sortorder');
|
|||
|
|
Open;
|
|||
|
|
|
|||
|
|
if IsEmpty then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox(PWideChar('δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>(' + mFlag + ')'),'',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
combobox.Properties.BeginUpdate;
|
|||
|
|
combobox.Properties.Items.Clear;
|
|||
|
|
first;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
combobox.Properties.Items.Add(trim(FieldByName('itemText').AsString));
|
|||
|
|
if (findField('default_Sel_flag')<>nil) and FieldByName('default_Sel_flag').AsBoolean then
|
|||
|
|
defaultValue:= trim(FieldByName('itemText').AsString) ;
|
|||
|
|
next;
|
|||
|
|
end;
|
|||
|
|
if selFlag and (combobox.Properties.Items.Count>0) then
|
|||
|
|
begin
|
|||
|
|
combobox.ItemIndex:=0;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if (defaultValue<>'') and (combobox.Properties.Items.Count>0) then
|
|||
|
|
begin
|
|||
|
|
idx:= combobox.Properties.Items.IndexOf(defaultValue) ;
|
|||
|
|
if idx>=0 then
|
|||
|
|
combobox.ItemIndex:=idx;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
combobox.Properties.EndUpdate();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
except
|
|||
|
|
|
|||
|
|
raise Exception.Create(PWideChar('<27><>ȡ<EFBFBD>ֶ<EFBFBD><D6B6>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>(' + mFlag + ')ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!'));
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
////////////////////////////////////////////////
|
|||
|
|
//////////////////////////////////////////////////////////////
|
|||
|
|
///
|
|||
|
|
function InitDevCxGridCombobox(ADOQueryTmp: TADOQuery; ComboBoxProperties: TcxComboBoxProperties; mFlag: string): Boolean;
|
|||
|
|
var
|
|||
|
|
defaultValue:string;
|
|||
|
|
idx:integer;
|
|||
|
|
begin
|
|||
|
|
Result := false;
|
|||
|
|
try
|
|||
|
|
with ADOQueryTmp do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select a.itemText from SY_Dict_Item a');
|
|||
|
|
sql.Add(' inner join SY_Dict b on b.dictId=a.dictId');
|
|||
|
|
sql.Add(' where b.dictcode='+QuotedStr(mFlag));
|
|||
|
|
sql.Add('and a.valid=1 and b.valid=1');
|
|||
|
|
sql.Add('order by b.sortorder');
|
|||
|
|
Open;
|
|||
|
|
|
|||
|
|
if IsEmpty then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox(PWideChar('δ<><CEB4><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>(' + mFlag + ')'),'',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
ComboBoxProperties.Items.Clear;
|
|||
|
|
first;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
ComboBoxProperties.Items.Add(trim(FieldByName('itemText').AsString));
|
|||
|
|
next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
// if (defaultValue<>'') and (ComboBoxProperties.Items.Count>0) then
|
|||
|
|
// begin
|
|||
|
|
// ComboBoxProperties.de:=defaultValue ;
|
|||
|
|
// end;
|
|||
|
|
|
|||
|
|
except
|
|||
|
|
|
|||
|
|
raise Exception.Create(PWideChar('<27><>ȡ<EFBFBD>ֶ<EFBFBD><D6B6>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>(' + mFlag + ')ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!'));
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end.
|