RTFormwork/public10/design/U_WindowFormdesign.pas
2024-11-27 14:50:11 +08:00

1105 lines
36 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_WindowFormdesign;
interface
uses
Windows, SysUtils, Messages, Classes, Controls, StdCtrls, ComCtrls, Forms,
ExtCtrls, ComObj, DXCORE, ActiveX, cxMemo, cxButtons, Graphics, IniFiles, DBClient,
Dialogs, Menus, DB, ADODB, cxLabel, BtnEdit, RTComboBox, cxTextEdit, cxMRUEdit,
cxDBData, cxGridLevel, cxButtonEdit, cxCurrencyEdit, cxGridTableView, cxGrid,
cxGridCustomTableView, cxGraphics, cxCalendar, cxCheckBox, cxGridDBTableView,
cxGridDBBandedTableView, cxStyles, cxPc, cxGroupBox, U_cxGridCustomCss,
cxCustomData, cxClasses, cxTimeEdit, cxEdit, cxLookAndFeels,dxLayoutControl,
cxLookAndFeelPainters, cxGridCustomView, Buttons, cxDropDownEdit,FrameDateSel;
type
TWindowFormDeSign = class(TObject)
private
fFontSize: integer;
fWhatDesign: string;
fFormCaption: string;
fDllName: string;
fFormName: string;
fFormId: integer;
fIsShowColumnfilter: boolean;
ADOQueryCmd: TADOQuery;
ADOQueryTmp: TADOQuery;
client1:TClientDataSet ;
// procedure SetCxGridColumnBestWidth(cxGrid: TcxGridDBTableView);
// function SaveFormGridInfo(mCxGridView: TcxGridDBTableView; ADOCmd: TADOQuery; mdesignCode: string; mGridName: string; mGridType: integer): boolean;
// procedure SetFormOperRight(mParent: TwinControl; mRightCaptions: string);
function GetMaxId(): integer;
procedure cxGridViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure cxGridViewSelectionChanged(Sender: TcxCustomGridTableView);
function InitCtrlData(mCtrl: TControl; mSql: string; mdefault: string): boolean;
procedure OpenGridDesignWin(mCxGridView: TcxGridDBTableView);
function getChgDefaultValue(mValue: string): string;
procedure dxLayoutControl1DblClick(Sender: TObject);
procedure setGridClick(Sender: TObject);
function getColumnRelation(tv1:TcxGridDBTableView):TclientDataSet;
procedure cxGridViewCustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
public
fProcedureName:string;
function FormStyleInit(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
function FormStyleInit1(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
function FormStyleInit10(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
procedure QueryDataPlus(ADOTmp: TADOQuery);
procedure OpenGridDesignWin10(mdesignCode:string;mGridName:string;mCxGridView: TcxGridDBTableView);
end;
const
// panel<65><6C><EFBFBD><EFBFBD>
clPanelBack = TColor($00FAF8F7);
clToolBarBack = TColor($00FAF8F7);
// <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ɫ
clFormBack = TColor($00FAF8F7);
implementation
uses
U_DataLink, U_globalVar,U_cxGridCustomSet,U_FormLayOutDesign;
/// //////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ã<EFBFBD>
/// //////////////////////////////////////////////////////
function TWindowFormDeSign.FormStyleInit(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
var
i: integer;
cxStyle_GridOddRow: TcxStyle;
cxStyle_GridEvenRow: TcxStyle;
cxStyle_active: TcxStyle;
cxStyle_gridGroupBox: TcxStyle;
cxStyle_gridFoot: TcxStyle;
cxStyle_selection: TcxStyle;
mvalue: TcxStyleValues;
mCtl3D, mToolBarList: boolean;
mIsCustomBackColor: boolean;
mIsDrawGridHeader: boolean;
mdesignCode: string;
setGridButton: TToolButton;
begin
ADOQueryCmd := ADOQCmd;
ADOQueryTmp := ADOTmp;
fDllName := gDllFileName;
fFormName := mForm.name;
fFormId := mFormId;
gIsCanDesign :=IsHasDesignRight(ADOTmp,PWideChar(dCode)) ;
//
//if trim(mStyleCode) = '' then
// mStyleCode := '01';
if gFontSize>=9 then
begin
fFontSize:= gFontSize ;
end
else
begin
fFontSize:= getSystemFontSize(ADOTmp,PWideChar(mStyleCode));
if fFontSize < 9 then
fFontSize := 12;
gFontSize:=fFontSize;
end;
mForm.Font.Size := fFontSize;
// <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ɫ
try
for i := 0 to mForm.ComponentCount - 1 do
begin
if not(mForm.Components[i] is Twincontrol) then
begin
continue;
end;
if ((mForm.Components[i] is TcxTextEdit and TcxTextEdit(mForm.Components[i]).ParentFont)
or (mForm.Components[i] is TcxComboBox and TcxComboBox(mForm.Components[i]).ParentFont)
or (mForm.Components[i] is TcxdateEdit) and TcxdateEdit(mForm.Components[i]).ParentFont ) then
Continue;
if mForm.Components[i] is TcxTextEdit then
begin
if (mForm.Components[i].Tag<999) and not TcxTextEdit(mForm.Components[i]).ParentFont then
TcxTextEdit(mForm.Components[i]).ParentFont:=True;
continue;
end;
if (mForm.Components[i] is TcxComboBox) then
begin
if (mForm.Components[i].Tag<999) and not TcxComboBox(mForm.Components[i]).ParentFont then
TcxComboBox(mForm.Components[i]).ParentFont:=True;
continue;
end;
if mForm.Components[i] is TcxButtonEdit then
begin
if (mForm.Components[i].Tag<999) and not TcxButtonEdit(mForm.Components[i]).ParentFont then
TcxButtonEdit(mForm.Components[i]).ParentFont:=True;
continue;
end;
if mForm.Components[i] is TcxdateEdit then
begin
if mForm.Components[i].Tag<999 then
TcxdateEdit(mForm.Components[i]).ParentFont:=True;
continue;
end;
if mForm.Components[i] is TcxCurrencyEdit then
begin
if mForm.Components[i].Tag<999 then
TcxCurrencyEdit(mForm.Components[i]).ParentFont:=True;
continue;
end;
if mForm.Components[i] is TfrmFrameDateSel then
begin
TfrmFrameDateSel(mForm.Components[i]).Font.Size:= fFontSize;
TfrmFrameDateSel(mForm.Components[i]).cbbType.ParentFont:= true;
TfrmFrameDateSel(mForm.Components[i]).BegDate.ParentFont:=true;
TfrmFrameDateSel(mForm.Components[i]).endDate.ParentFont:=true;
// TfrmFrameDateSel(mForm.Components[i]).TimeType.ParentFont:=true;
continue;
end;
if mForm.Components[i] is TcxMemo then
begin
if mForm.Components[i].Tag<999 then
TcxMemo(mForm.Components[i]).ParentFont:=True;
continue;
end;
// Tcxgroup
if mForm.Components[i] is TcxgroupBox then
begin
if mForm.Components[i].Tag<999 then
TcxgroupBox(mForm.Components[i]).ParentFont:=True;
// if mIsCustomBackColor then
// TcxgroupBox(mForm.Components[i]).Color := clPanelBack;
// TcxgroupBox(mForm.Components[i]).Ctl3D := mCtl3D;
// mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + TcxgroupBox(mForm.Components[i]).name;
continue;
end;
if mForm.Components[i] is TToolBar then
begin
if mForm.Components[i].Tag>=999 then exit;
if mForm.Components[i].Tag<999 then
TToolBar(mForm.Components[i]).ParentFont:=True;
TToolBar(mForm.Components[i]).AutoSize := true;
TToolBar(mForm.Components[i]).Flat := true;
//
if gIsCanDesign then
begin
if mForm.Components[i].FindComponent('TgridLiSet')=nil then
begin
TToolBar(mForm.Components[i]).Wrapable:=false;
setGridButton := TToolButton.Create(mForm); //
setGridButton.Left := TToolBar(mForm.Components[i]).ButtonWidth * TToolBar(mForm.Components[i]).ButtonCount;
setGridButton.Parent := TToolBar(mForm.Components[i]);
setGridButton.ImageIndex := 16; //<2F><>
setGridButton.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
setGridButton.Style := tbsButton;
setGridButton.AutoSize:=true;
setGridButton.OnClick := setGridClick; //
end;
end;
if mIsCustomBackColor then
TToolBar(mForm.Components[i]).Color := clToolBarBack;
if mForm.Components[i].Tag = 0 then
begin
if ADOTmp.IsEmpty then
TToolBar(mForm.Components[i]).List := false
else
TToolBar(mForm.Components[i]).List := mToolBarList;
end;
if mRightCaptions<>'' then
SetFormOperRight(application,TToolBar(mForm.Components[i]), PWideChar(mRightCaptions));
continue;
end;
if mForm.Components[i] is TcxTabControl then
begin
if mForm.Components[i].Tag<999 then
TdxLayoutControl(mForm.Components[i]).ParentFont:=true;
continue;
end;
if mForm.Components[i] is TcomBoBox then
begin
if mForm.Components[i].Tag<999 then
TcomBoBox(mForm.Components[i]).ParentFont:=true;
continue;
end;
if mForm.Components[i] is TdxCustomLayoutControl then
begin
if mForm.Components[i].Tag<999 then
TdxLayoutControl(mForm.Components[i]).ParentFont:=true;
if mForm.Components[i].Tag<>1000 then
begin
TdxLayoutControl(mForm.Components[i]).OnDblClick := dxLayoutControl1DblClick ;
readLayOut(TdxLayoutControl(mForm.Components[i]),ADOTmp,PWideChar( fDllFileName+'|'+mForm.name+'|'+TdxLayoutControl(mForm.Components[i]).Name+'.ini'));
end;
continue;
end;
// Tpanel
if mForm.Components[i] is Tpanel then
begin
if mForm.Components[i].Tag<999 then
Tpanel(mForm.Components[i]).ParentFont:=True;
if mIsCustomBackColor and (Tpanel(mForm.Components[i]).Tag < 99) then
Tpanel(mForm.Components[i]).Color := clPanelBack;
Tpanel(mForm.Components[i]).Ctl3D := mCtl3D;
// mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + Tpanel(mForm.Components[i]).name;
continue;
end;
// TScrollBox
if mForm.Components[i] is TScrollBox then
begin
if mForm.Components[i].Tag<999 then
TScrollBox(mForm.Components[i]).ParentFont:=true;
if mIsCustomBackColor and (Tpanel(mForm.Components[i]).Tag < 99) then
Tpanel(mForm.Components[i]).Color := clPanelBack;
Tpanel(mForm.Components[i]).Ctl3D := mCtl3D;
mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + TScrollBox(mForm.Components[i]).name;
continue;
end;
// Tcxgroup
if mForm.Components[i] is TgroupBox then
begin
if mForm.Components[i].Tag<999 then
TgroupBox(mForm.Components[i]).ParentFont:=true;
if mIsCustomBackColor then
TgroupBox(mForm.Components[i]).Color := clPanelBack;
TgroupBox(mForm.Components[i]).Ctl3D := mCtl3D;
continue;
end;
if mForm.Components[i] is TdatetimePicker then
begin
if TdatetimePicker(mForm.Components[i]).Width <= 90 then
TdatetimePicker(mForm.Components[i]).Width := TdatetimePicker(mForm.Components[i]).Width + ffontsize * 2;
continue;
end;
// end;
// TcxPageControl
if mForm.Components[i] is TcxPageControl then
begin
if mForm.Components[i].Tag<999 then
TcxPageControl(mForm.Components[i]).ParentFont:=True;
if mIsCustomBackColor then
TcxPageControl(mForm.Components[i]).Color := clPanelBack;
continue;
end;
if mForm.Components[i] is Tcxtimeedit then
begin
if mForm.Components[i].Tag<999 then
Tcxtimeedit(mForm.Components[i]).ParentFont:=true;
Tcxtimeedit(mForm.Components[i]).Style.BorderStyle := ebsFlat;
continue;
end;
// TcxGrid and gIsCustomDrawGridHeader
if mForm.Components[i] is TcxGrid then
begin
if mForm.Components[i].Tag>=999 then Continue;
TcxGrid(mForm.Components[i]).ParentFont:=true;
//TcxGrid(mForm.Components[i]).LookAndFeel.ScrollbarMode := sbmClassic;
//<2F>Զ<EFBFBD><D4B6><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).dataController.filter.AutoDataSetFilter := true;
// TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnKeyDown := cxGridViewKeyDown;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnSelectionChanged := cxGridViewSelectionChanged;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnCustomDrawIndicatorCell := cxGridViewCustomDrawIndicatorCell;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).optionsCustomize.columnfiltering := true;
mdesignCode := fDllFileName +'|'+mForm.name+ '|' + intTostr(fFormId) + '|' + TcxGrid(mForm.Components[i]).name;
CreateCxGridColumn(application, TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]),ADOQueryTmp,PWideChar(mdesignCode));
continue;
end;
end;
except
showMessage('<27><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>쳣!');
end;
end;
/// //////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ã<EFBFBD>
/// //////////////////////////////////////////////////////
function TWindowFormDeSign.FormStyleInit1(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
var
i: integer;
cxStyle_GridOddRow: TcxStyle;
cxStyle_GridEvenRow: TcxStyle;
cxStyle_active: TcxStyle;
cxStyle_gridGroupBox: TcxStyle;
cxStyle_gridFoot: TcxStyle;
cxStyle_selection: TcxStyle;
mvalue: TcxStyleValues;
mCtl3D, mToolBarList: boolean;
mIsCustomBackColor: boolean;
mIsDrawGridHeader: boolean;
mdesignCode: string;
setGridButton: TToolButton;
SaveRedraw:boolean;
begin
ADOQueryCmd := ADOQCmd;
ADOQueryTmp := ADOTmp;
fDllName := gDllFileName;
fFormName := mForm.name;
fFormId := mFormId;
// gIsCanDesign :=IsHasDesignRight(ADOTmp,PWideChar(dCode)) ;
//
// if gFontSize>=9 then
// begin
// fFontSize:= gFontSize ;
// end
// else
// begin
// fFontSize:= getSystemFontSize(ADOTmp,PWideChar(mStyleCode));
// if fFontSize < 9 then
// fFontSize := 12;
// gFontSize:=fFontSize;
// end;
// mForm.Font.Size := fFontSize;
//if gFontName<>'' then
// mForm.Font.Name:=gFontName;
// <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ɫ
//exit;
try
// SaveRedraw := (GetWindowLong(mForm.Handle, GWL_STYLE) and WS_VISIBLE) <> 0;
for i := 0 to mForm.ComponentCount - 1 do
begin
if not ( mForm.Components[i] is TcxGrid) and not( mForm.Components[i] is TToolBar) and not( mForm.Components[i] is TdxCustomLayoutControl) then Continue;
if mForm.Components[i] is TcxGrid then
begin
if mForm.Components[i].Tag>=999 then Continue;
TcxGrid(mForm.Components[i]).ParentFont:=true;
//<2F>Զ<EFBFBD><D4B6><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).dataController.filter.AutoDataSetFilter := true;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).optionsCustomize.columnfiltering := true;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnSelectionChanged := cxGridViewSelectionChanged;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).OnCustomDrawIndicatorCell := cxGridViewCustomDrawIndicatorCell;
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).optionsCustomize.columnfiltering := true;
mdesignCode := fDllFileName +'|'+mForm.name+ '|' + intTostr(fFormId) + '|' + TcxGrid(mForm.Components[i]).name;
CreateCxGridColumn(application, TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]),ADOQueryTmp,PWideChar(mdesignCode));
continue;
end;
//
if mForm.Components[i] is TToolBar then
begin
if mForm.Components[i].Tag>=999 then exit;
if mForm.Components[i].Tag<999 then
TToolBar(mForm.Components[i]).ParentFont:=True;
TToolBar(mForm.Components[i]).AutoSize := true;
TToolBar(mForm.Components[i]).Flat := true;
//
if gIsCanDesign then
begin
if mForm.Components[i].FindComponent('TgridLiSet')=nil then
begin
TToolBar(mForm.Components[i]).Wrapable:=false;
setGridButton := TToolButton.Create(mForm); //
setGridButton.Left := TToolBar(mForm.Components[i]).ButtonWidth * TToolBar(mForm.Components[i]).ButtonCount;
setGridButton.Parent := TToolBar(mForm.Components[i]);
setGridButton.ImageIndex := 16; //<2F><>
setGridButton.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
// setGridButton.Name:='TgridLiSet';
setGridButton.Style := tbsButton;
setGridButton.AutoSize:=true;
setGridButton.OnClick := setGridClick; //
end;
end;
if mIsCustomBackColor then
TToolBar(mForm.Components[i]).Color := clToolBarBack;
if mForm.Components[i].Tag = 0 then
begin
if ADOTmp.IsEmpty then
TToolBar(mForm.Components[i]).List := false
else
TToolBar(mForm.Components[i]).List := mToolBarList;
end;
if mRightCaptions<>'' then
SetFormOperRight(application,TToolBar(mForm.Components[i]), PWideChar(mRightCaptions));
continue;
end;
if mForm.Components[i] is TdxCustomLayoutControl then
begin
if mForm.Components[i].Tag<999 then
TdxLayoutControl(mForm.Components[i]).ParentFont:=true;
if mForm.Components[i].Tag<>1000 then
begin
TdxLayoutControl(mForm.Components[i]).OnDblClick := dxLayoutControl1DblClick ;
readLayOut(TdxLayoutControl(mForm.Components[i]),ADOTmp,PWideChar( fDllFileName+'|'+mForm.name+'|'+TdxLayoutControl(mForm.Components[i]).Name+'.ini'));
end;
continue;
end;
end;
except
showMessage('<27><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>쳣!');
end;
end;
/// //////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ã<EFBFBD>
/// //////////////////////////////////////////////////////
function TWindowFormDeSign.FormStyleInit10(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
var
i: integer;
cxStyle_GridOddRow: TcxStyle;
cxStyle_GridEvenRow: TcxStyle;
cxStyle_active: TcxStyle;
cxStyle_gridGroupBox: TcxStyle;
cxStyle_gridFoot: TcxStyle;
cxStyle_selection: TcxStyle;
mvalue: TcxStyleValues;
mCtl3D, mToolBarList: boolean;
mIsCustomBackColor: boolean;
mIsDrawGridHeader: boolean;
mdesignCode: string;
setGridButton: TToolButton;
begin
ADOQueryCmd := ADOQCmd;
ADOQueryTmp := ADOTmp;
fDllName := gDllFileName;
fFormName := mForm.name;
fFormId := mFormId;
exit;
gIsCanDesign :=IsHasDesignRight(ADOTmp,PWideChar(dCode)) ;
//
if gFontSize>=9 then
begin
fFontSize:= gFontSize ;
end
else
begin
fFontSize:= getSystemFontSize(ADOTmp,PWideChar(mStyleCode));
if fFontSize < 9 then
fFontSize := 12;
gFontSize:=fFontSize;
end;
mForm.Font.Size := fFontSize;
end;
/// ////////////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD>е<EFBFBD>ԭʼ<D4AD><CABC>Ϣ
/// ///////////////////////////////////////////////////////////////////////
//function TWindowFormDeSign.SaveFormGridInfo(mCxGridView: TcxGridDBTableView; ADOCmd: TADOQuery; mdesignCode: string; mGridName: string; mGridType: integer): boolean;
//var
// i: integer;
// mfieldName: string;
//begin
// result := false;
// try
// /// ////////////////
// /// ////////////////
// with ADOQueryCmd do
// begin
// close;
// sql.Clear;
// sql.Add('select * from SD_FormGrid_Main A');
// sql.Add('where A.designCode=' + quotedStr(mdesignCode));
// open;
// if RecordCount <= 0 then
// begin
// append;
// fieldByName('designCode').value := mdesignCode;
// fieldByName('GridType').value := mGridType;
// fieldByName('gridName').value := TcxGrid(TcxGridLevel(mCxGridView.level).Control).name;
// end
// else
// edit;
//
// fieldByName('ProcedureParam').value := '';
// fieldByName('newProcedureName').value := '';
// post;
//
// close;
//
// end;
// // <20><><EFBFBD><EFBFBD>Ϣ
// with ADOCmd do
// begin
// close;
// sql.Clear;
// sql.Add('select * from SD_FormGrid_Design');
// sql.Add('where designCode=' + quotedStr(mdesignCode));
// sql.Add('and formId=' + intTostr(fFormId));
// sql.Add('and formName=' + quotedStr(fFormName));
// // sql.Add('and GridName='+QuotedStr(mgridName));
// open;
//
// for i := mCxGridView.ColumnCount - 1 downto 0 do
// begin
// mfieldName := TcxGridDBColumn(mCxGridView.Columns[i]).DataBinding.FieldName;
//
// if locate('fieldName', mfieldName, []) then
// begin
// continue;
// end
// else
// begin
// append;
// fieldByName('Id').value := GetMaxId();
// fieldByName('formId').value := fFormId;
// fieldByName('formName').value := fFormName;
// fieldByName('designCode').value := mdesignCode;
// fieldByName('GridName').value := mGridName;
//
// fieldByName('ColumnName').value := mCxGridView.Columns[i].name;
// fieldByName('Visible').value := mCxGridView.Columns[i].Visible;
// fieldByName('ColumnHide').value := mCxGridView.Columns[i].Hidden;
// fieldByName('oldCaption').value := mCxGridView.Columns[i].Caption;
// fieldByName('Valid').value := 1;
// end;
//
// fieldByName('GridIndex').value := mGridType;
// fieldByName('FieldName').value := trim(TcxGridDBColumn(mCxGridView.Columns[i]).DataBinding.FieldName);
// fieldByName('Caption').value := mCxGridView.Columns[i].Caption;
// fieldByName('ColumnType').value := trim(TcxGridDBColumn(mCxGridView.Columns[i]).DataBinding.ValueType);
//
// fieldByName('Width').value := mCxGridView.Columns[i].Width;
// fieldByName('IsOrder').value := 1;
// fieldByName('ColumnFilter').value := mCxGridView.Columns[i].Filtered;
// fieldByName('ColumnOrder').value := mCxGridView.Columns[i].Index;
// if mCxGridView.Columns[i].FixedKind= fkLeftDynamic then
// begin
// fieldByName('fixColumn').value := True;
// end
// else
// begin
// fieldByName('fixColumn').value := false;
// end;
// post;
// end;
//
// close;
// end;
//
// /// /////////////////////////////////////////////
// //
// for i := 0 to mCxGridView.dataController.DataSet.FieldCount - 1 do
// begin
// mfieldName := trim(mCxGridView.dataController.DataSet.Fields[i].FieldName);
// if mfieldName = '' then
// continue;
// with ADOCmd do
// begin
// close;
// sql.Clear;
// sql.Add('select * from SD_FormGrid_Design');
// sql.Add('where designCode=' + quotedStr(mdesignCode));
// // sql.Add('and GridName='+QuotedStr(mgridName));
// sql.Add('and fieldName=' + quotedStr(mfieldName));
// open;
// if RecordCount <= 0 then
// begin
// append;
// fieldByName('Id').value := GetMaxId();
// fieldByName('formName').value := fFormName;
// fieldByName('formId').value := fFormId;
// fieldByName('GridName').value := mGridName;
// fieldByName('GridIndex').value := mGridType;
// fieldByName('designCode').value := mdesignCode;
//
// fieldByName('fieldName').value := mfieldName;
//
// fieldByName('ColumnType').value := mCxGridView.dataController.DataSet.Fields[i].DataType;
// fieldByName('Caption').value := 'δ<><CEB4><EFBFBD><EFBFBD>';
// fieldByName('ColumnName').value := mCxGridView.name + mfieldName;
// fieldByName('Visible').value := false;
// fieldByName('AddFlag').value := true;
//
// fieldByName('Width').value := 60;
// fieldByName('ColumnOrder').value := 99;
//
// fieldByName('Valid').value := 0;
// post;
// end;
// close;
// end;
// end;
// result := true;
// except
// application.MessageBox('<27><><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>Ϣʱ<CFA2><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
// end;
//end;
/// /////////////////////////////////////////////////
//
/// ///////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////
// <20><>ʼ<EFBFBD><CABC><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>SQL<51>Ŀؼ<C4BF>
/// ////////////////////////////////////////////////////////////////
function TWindowFormDeSign.InitCtrlData(mCtrl: TControl; mSql: string; mdefault: string): boolean;
var
idx: integer;
begin
result := false;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add(mSql);
open;
end;
if mCtrl is TcomBoBox then
begin
if ADOQueryTmp.RecordCount > 0 then
TcomBoBox(mCtrl).Clear;
while not ADOQueryTmp.Eof do
begin
TcomBoBox(mCtrl).Items.Add(trim(ADOQueryCmd.Fields[0].AsString));
ADOQueryCmd.Next;
end;
if mdefault <> '' then
begin
idx := TcomBoBox(mCtrl).Items.IndexOf(mdefault);
if idx >= 0 then
begin
TcomBoBox(mCtrl).ItemIndex := idx;
end;
end;
exit;
end;
/// //////////////
if mCtrl is TcxComboBox then
begin
if ADOQueryCmd.RecordCount > 0 then
begin
TcxComboBox(mCtrl).Clear;
TcxComboBox(mCtrl).Properties.Items.Clear;
end;
while not ADOQueryCmd.Eof do
begin
TcxComboBox(mCtrl).Properties.Items.Add(trim(ADOQueryCmd.Fields[0].AsString));
ADOQueryCmd.Next;
end;
if mdefault <> '' then
begin
idx := TcxComboBox(mCtrl).Properties.Items.IndexOf(mdefault);
if idx >= 0 then
begin
TcxComboBox(mCtrl).ItemIndex := idx;
end;
end;
exit;
end;
if mCtrl is Tdatetimepicker then
begin
Tdatetimepicker(mCtrl).Date := ADOQueryCmd.Fields[0].AsDateTime;
exit;
end;
if mCtrl is TcxDateEdit then
begin
TcxDateEdit(mCtrl).Date := ADOQueryCmd.Fields[0].AsDateTime;
exit;
end;
result := true;
except
application.MessageBox('<27><>ʼ<EFBFBD><CABC><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
/// ///////////////////////////////////////////////////////////////////////////////////////
//
/// ///////////////////////////////////////////////////////////////////////////////////////
//procedure TWindowFormDeSign.SetCxGridColumnBestWidth(cxGrid: TcxGridDBTableView);
//var
// i: integer;
// mCaption: string;
// mMinWidth: integer;
//begin
// try
// cxGrid.BeginUpdate;
// for i := 0 to cxGrid.ColumnCount - 1 do
// begin
// if cxGrid.ColumnCount < 6 then
// begin
// cxGrid.Columns[i].Width := 120;
// continue;
// end;
// mCaption := trim(cxGrid.Columns[i].Caption);
// if length(mCaption) <= 2 then
// mMinWidth := (length(mCaption) + 3) * 12
// else if (length(mCaption) > 2) and (length(mCaption) <= 4) then
// mMinWidth := (length(mCaption) + 2) * 12
// else if (length(mCaption) > 4) and (length(mCaption) <= 8) then
// mMinWidth := (length(mCaption) + 1) * 12
// else
// mMinWidth := (length(mCaption)) * 9;
// cxGrid.Columns[i].Width := mMinWidth;
// end;
// finally
// cxGrid.EndUpdate;
// end;
//end;
/// ////////////////////////////////////////
procedure TWindowFormDeSign.cxGridViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
mGridDBTableView: TcxGridDBTableView;
begin
if Key = vk_f12 then
begin
mGridDBTableView := TcxGridDBTableView(TcxGridSite(Sender).ViewInfo.GridView);
OpenGridDesignWin(mGridDBTableView);
end;
end;
/////////////////////////////////////////////
procedure TWindowFormDeSign.dxLayoutControl1DblClick(Sender: TObject);
begin
layoutDesign(TdxLayoutControl(Sender),ADOQueryCmd,PWideChar(dcode));
end;
/// ////////////////////////////////////////////////////////////////
// <20>򿪱<EFBFBD><F2BFAAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>
// 0: mGridType <20><>ѯ; 1:<3A><><EFBFBD><EFBFBD>
/// /////////////////////////////////////////////////////////////////
procedure TWindowFormDeSign.OpenGridDesignWin(mCxGridView: TcxGridDBTableView);
var
mGridType: integer;
mdesignCode: string;
mGridName: string;
k: integer;
client1:TClientDataSet;
begin
/// ////////////////////////////////////
// Ȩ<>޿<EFBFBD><DEBF><EFBFBD>
mGridName := TcxGrid(TcxGridLevel(mCxGridView.level).Control).name;
mdesignCode :=fDllFileName+'|'+ fFormName + '|' + intTostr(fFormId) + '|' + mGridName;
if not gIsCanDesign then
exit;
ShowCxGridDesign(application, mCxGridView, getColumnRelation(mCxGridView),AdOQueryCmd,PWideChar(fFormName) ,PWideChar(mGridName),PWideChar(fDllFileName),fformId,0,PWideChar(fProcedureName));
CreateCxGridColumn(application, mCxGridView,ADOQueryTmp,PWideChar(mdesignCode));
end;
/// ////////////////////////////////////////////////////////////////
// <20>򿪱<EFBFBD><F2BFAAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD> <20>µİ汾
/// /////////////////////////////////////////////////////////////////
procedure TWindowFormDeSign.OpenGridDesignWin10(mdesignCode:string;mGridName:string;mCxGridView: TcxGridDBTableView);
begin
ShowCxGridDesign(application, mCxGridView, getColumnRelation(mCxGridView),AdOQueryCmd,PWideChar(fFormName) ,PWideChar(mGridName),PWideChar(fDllFileName),fformId,0,PWideChar(fProcedureName));
CreateCxGridColumn(application, mCxGridView,ADOQueryTmp,PWideChar(mdesignCode));
end;
/// //////////////////////////////////////
//
/// ///////////////////////////////////////
function TWindowFormDeSign.GetMaxId(): integer;
begin
result := 0;
try
with ADOQueryTmp do
begin
close;
sql.Clear;
Filtered := false;
sql.Add('select max(id) as id');
sql.Add('from SD_FormGrid_Design A');
open;
result := fieldByName('id').AsInteger + 1;
end;
except
end;
end;
/// //////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD>toolbar<61><72>ťȨ<C5A5>޲<EFBFBD><DEB2><EFBFBD>
/// //////////////////////////////////////////////////////////////
//procedure TWindowFormDeSign.SetFormOperRight(mParent: TwinControl; mRightCaptions: string);
//var
// i: integer;
// mCaption: string;
// mOperRight: string;
//begin
// mOperRight := mRightCaptions;
//
// if mOperRight = '' then
// exit;
//
// try
// /// ////////////////////////////////////////////
// if mParent is TToolBar then
// begin
// for i := 0 to TToolBar(mParent).ButtonCount - 1 do
// begin
// mCaption := trim(TToolBar(mParent).Buttons[i].Caption);
// if (mCaption = '<27>ر<EFBFBD>') or (mCaption = '<27>˳<EFBFBD>') or (mCaption = '<27><><EFBFBD><EFBFBD>') then
// exit;
// /// //////////////////////////
// if trim(mOperRight) = '<27><>ѯ' then
// begin
// if pos(mCaption, '<27><>ѯ,ˢ<><CBA2>,<2C><><EFBFBD><EFBFBD>,<2C>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>,<2C>߼<EFBFBD><DFBC><EFBFBD>ѯ') > 0 then // ,<2C>鿴,<2C><>ϸ
// begin
// TToolBar(mParent).Buttons[i].Visible := true;
// end
// else
// begin
// TToolBar(mParent).Buttons[i].Visible := false;
// end;
// end
// else
// begin
// if (pos(mCaption, mOperRight) > 0) or (pos(mCaption, '<27><>ѯ,ˢ<><CBA2>,<2C><><EFBFBD><EFBFBD>,<2C>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>,<2C>߼<EFBFBD><DFBC><EFBFBD>ѯ') > 0) then // <20>鿴,
// begin
// TToolBar(mParent).Buttons[i].Visible := true;
// end
// else
// begin
// TToolBar(mParent).Buttons[i].Visible := false;
// end;
// end;
// end;
// exit;
// end;
// /// ////////////////////////////////////////////////
// if trim(mOperRight) = '<27><>ѯ' then
// exit;
// with mParent do
// begin
// for i := 0 to ControlCount - 1 do
// begin
// mCaption := '';
// if (Controls[i] is TBitBtn) then
// mCaption := trim(TBitBtn(Controls[i]).Caption)
// else if (Controls[i] is TButton) then
// mCaption := trim(TButton(Controls[i]).Caption)
// else if (Controls[i] is TSpeedButton) then
// mCaption := trim(TSpeedButton(Controls[i]).Caption)
// else
// continue;
// if (Controls[i] is TBitBtn) or (Controls[i] is TButton) or (Controls[i] is TSpeedButton) then
// begin
// if (pos(mCaption, mOperRight) > 0) or (mCaption = '<27><>ѯ') or (mCaption = '<27><><EFBFBD><EFBFBD>') or (mCaption = '<27>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>') then
// begin
// Controls[i].Visible := true;
// end
// else
// Controls[i].Visible := false;
// end;
// end;
// end;
//
// except
// application.MessageBox('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD>ťȨ<C5A5>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ', 0);
// end;
//end;
/// ////////////////////////////////////////////////////////////
//
/// ////////////////////////////////////////////////////////////
function TWindowFormDeSign.getChgDefaultValue(mValue: string): string;
begin
if '$$USERNAME' = mValue then
begin
result := DName;
end
else
result := mValue;
end;
/// ////////////////////////////////////////////////////
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ
/// /////////////////////////////////////////////////////
procedure TWindowFormDeSign.QueryDataPlus(ADOTmp: TADOQuery);
begin
end;
/////////////////////////////////////////////////////////
///
//////////////////////////////////////////////////////////
procedure TWindowFormDeSign.cxGridViewSelectionChanged(Sender: TcxCustomGridTableView);
var
i, J, idx: integer;
FocusedRowIndex: integer;
begin
if Sender.Tag = 888 then
exit;
try
Sender.BeginUpdate();
TcxGridDbTableView(Sender).BeginUpdate();
FocusedRowIndex := TcxGridDbTableView(Sender).Controller.FocusedRowIndex;
Sender.DataController.GotoFirst;
if TcxGridDbTableView(Sender).DataController.DataSet.FieldByName('ssel') = nil then
exit;
if TcxGridDbTableView(Sender).GetColumnByFieldName('ssel') = nil then
exit;
idx := TcxGridDbTableView(Sender).GetColumnByFieldName('ssel').Index;
for i := 0 to Sender.DataController.RecordCount - 1 do
begin
if TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue = true then
begin
TcxGridDbTableView(Sender).DataController.Edit;
TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue := false;
TcxGridDbTableView(Sender).DataController.Post();
end;
Sender.DataController.GotoNext;
end;
for i := 0 to Sender.DataController.GetSelectedCount - 1 do
begin
TcxGridDbTableView(Sender).Controller.FocusedRow := TcxGridDbTableView(Sender).Controller.SelectedRows[i];
if TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue = false then
begin
TcxGridDbTableView(Sender).DataController.Edit;
TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue := true;
TcxGridDbTableView(Sender).DataController.Post();
end;
end;
finally
TcxGridDbTableView(Sender).Controller.FocusedRowIndex := FocusedRowIndex;
TcxGridDbTableView(Sender).EndUpdate;
Sender.EndUpdate;
end;
end;
///////////////////////////////////////////////////////////////
///
///
procedure TWindowFormDeSign.cxGridViewCustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
ATextRect: TRect;
// AStyle: TcxStyle;
aCV: TcxCanvas;
begin
if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
Exit;
Sender.BeginUpdate() ;
aCV := ACanvas;
AViewInfo.GetBestFitWidth ;
ATextRect := AViewInfo.ContentBounds;
AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
InflateRect(ATextRect, -2, -1);
if AIndicatorViewInfo.GridRecord.Selected then //<2F><><EFBFBD><EFBFBD>if<69><66><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>кŴ<D0BA><C5B4>Ѱ<EFBFBD>ѡ<EFBFBD>е<EFBFBD><D0B5>кŸ<D0BA><C5B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>
begin
aCV.Font.Style := ACanvas.Font.Style + [fsBold];
aCV.Font.Color := clRed;
end
else
begin
aCV.Font.Style := ACanvas.Font.Style - [fsBold];
aCV.Font.Color := clblack;
end;
Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds, ATextRect, [], cxBordersAll, cxbsNormal, taCenter, vaCenter, False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
aCV.Font, aCV.font.Color, aCV.Brush.color);
Sender.EndUpdate;
ADone := True;
end;
/////////////////////////////////////////////////////////////////
///
function TWindowFormDeSign.getColumnRelation(tv1:TcxGridDBTableView):TclientDataSet;
var
i:Integer;
begin
if client1=nil then
begin
client1 := TClientDataSet.Create(nil);
client1.FieldDefs.Add('fieldName', ftString, 100);
client1.FieldDefs.Add('caption', ftString,100);
client1.FieldDefs.Add('ValueType', ftString,100);
client1.CreateDataSet;
end
else
client1.EmptyDataSet;
for i := 0 to tv1.ColumnCount - 1 do
begin
client1.Append;
client1.FieldByName('fieldName').Value:=tv1.Columns[i].DataBinding.FieldName;
client1.FieldByName('caption').Value:=tv1.Columns[i].Caption;
client1.FieldByName('ValueType').Value:=tv1.Columns[i].DataBinding.ValueType;
client1.Post;
end;
result:=client1;
end;
/////////////////////////////////////////////
procedure TWindowFormDeSign.setGridClick(Sender: TObject);
var
i:integer;
view:TcxGridDBTableView;
begin
view:=nil;
with TToolButton( Sender ).Parent.Parent do
begin
for i:=0 to ComponentCount-1 do
begin
if Components[i] is TcxGrid then
begin
if TcxGrid(Components[i]).IsFocused then
begin
view:= TcxGridDBTableView(TcxGrid(Components[i]).Views[0]);
end;
end;
end;
end;
//
if view<>nil then
begin
OpenGridDesignWin(view);
end
else
begin
showMessage('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>Ҫ<EFBFBD><D2AA><EFBFBD>Ƶı<C6B5><C4B1><EFBFBD>!');
end;
end;
end.