RTFormwork/项目代码/RTBasicsV1/A00通用方法/U_CustomFun.pas

134 lines
4.0 KiB
ObjectPascal
Raw Permalink Normal View History

2024-08-27 15:48:31 +08:00
unit U_CustomFun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DBGrids, DB, cxDBData,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, ADODB, StrUtils, Midas,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxTimeEdit,
cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit,
cxGridExportLink, ExtCtrls, Buttons, DBClient, RTComboBox, cxDropDownEdit,
cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit, cxButtonEdit,
IniFiles, WinSock, IdHTTP, dxcore, cxTextEdit, FireDAC.Comp.Client,
Vcl.Clipbrd, cxMemo, dxLayoutControl;
procedure CreatCDSData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; FType: string);
procedure CreatLabelEdit(ADO1: TADOQuery; Tv1: TcxGridDBTableView; TMPanel: TPanel; FType: string);
implementation
uses
U_DataLink;
procedure CreatCDSData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; FType: string);
var
FieldName, Caption, FootNote, SqlStr: string;
Column: TcxGridDBColumn;
begin
SqlStr := 'SELECT ZDYName AS FieldName, Note AS Caption, Note1 AS FLabel, Note2 AS FootNote FROM KH_ZDY where Type=''' + FType + ''' ';
with ADO1 do
begin
Filtered := False;
Close;
sql.Clear;
sql.Add(SqlStr);
Open;
end;
Tv1.BeginUpdate;
try
while Tv1.ColumnCount > 0 do //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Tv1.Columns[0].Free;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
while not ADO1.Eof do
begin
FieldName := ADO1.FieldByName('FieldName').AsString;
Caption := ADO1.FieldByName('Caption').AsString;
FootNote := ADO1.FieldByName('FootNote').AsString;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Column := Tv1.CreateColumn;
Column.Caption := Caption;
Column.DataBinding.FieldName := FieldName;
Column.Width := 100;
Column.HeaderAlignmentHorz := taCenter;
ADO1.Next;
end;
finally
Tv1.EndUpdate;
end;
end;
procedure CreatLabelEdit(ADO1: TADOQuery; Tv1: TcxGridDBTableView; TMPanel: TPanel; FType: string);
var
LabelControl: TLabel;
EditControl: TEdit;
Caption, FLabel, FieldName, SqlStr: string;
I, CurrentTop, CurrentLeft, ControlWidth, LabelWidth: Integer;
begin
SqlStr := 'SELECT ZDYName AS FieldName, Note AS Caption, Note1 AS FLabel, Note2 AS FootNote FROM KH_ZDY where Type=''' + FType + ''' ';
with ADO1 do
begin
Filtered := False;
Close;
sql.Clear;
sql.Add('SELECT ZDYName AS FieldName, Note AS Caption, Note1 AS FLabel FROM KH_ZDY where Type=''WBGlide'' ');
Open;
end;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>пؼ<D0BF>
for I := TMPanel.ControlCount - 1 downto 0 do
begin
TMPanel.Controls[I].Free;
end;
// <20><>ʼ<EFBFBD><CABC>λ<EFBFBD><CEBB>(<28><><EFBFBD>пؼ<D0BF><D8BC>Ķ<EFBFBD><C4B6><EFBFBD>λ<EFBFBD><CEBB>,<2C><>һ<EFBFBD><D2BB><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>,Edit<69><74><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>)
CurrentTop := 10;
CurrentLeft := 10;
ControlWidth := 100;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ<EFBFBD>ͱ༭<CDB1><E0BCAD>
I := 0;
while not ADO1.Eof do
begin
Caption := ADO1.FieldByName('Caption').AsString;
FLabel := ADO1.FieldByName('FLabel').AsString;
FieldName := ADO1.FieldByName('FieldName').AsString;
if FLabel = '<27><>' then
begin
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Label
LabelControl := TLabel.Create(TMPanel);
LabelControl.Parent := TMPanel;
LabelControl.Caption := Caption;
LabelControl.Left := CurrentLeft;
LabelControl.Top := CurrentTop + 3; //<2F><><EFBFBD><EFBFBD>һ<EFBFBD>㣬Ϊ<E3A3AC>˺<EFBFBD>Edit<69><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LabelControl.AutoSize := True;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>
LabelWidth := LabelControl.Width;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Edit
EditControl := TEdit.Create(TMPanel);
EditControl.Parent := TMPanel;
EditControl.Left := CurrentLeft + LabelWidth + 3; // <20><>Label<65>ұߣ<D2B1><DFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
EditControl.Top := CurrentTop; // <20><><EFBFBD>þඥ<C3BE><E0B6A5><EFBFBD><EFBFBD>
EditControl.Width := ControlWidth; // <20><><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>
EditControl.Name := FieldName; // <20><><EFBFBD><EFBFBD>Name<6D><65><EFBFBD><EFBFBD>
EditControl.Tag := 2; // ˢ<>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
CurrentLeft := EditControl.Left + EditControl.Width + 20; // Ϊ<><CEAA>һ<EFBFBD><D2BB><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>
EditControl.Text := '';
Inc(I);
end;
ADO1.Next;
end;
end;
end.