1454 lines
49 KiB
ObjectPascal
1454 lines
49 KiB
ObjectPascal
![]() |
unit U_WindowFormdesign;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, SysUtils, Messages, Classes, Controls, StdCtrls, ComCtrls, Forms,
|
|||
|
ExtCtrls, ComObj, DXCORE, ActiveX, cxMemo, cxButtons, Graphics, IniFiles,
|
|||
|
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,
|
|||
|
cxLookAndFeelPainters, cxGridCustomView, Buttons, cxDropDownEdit;
|
|||
|
|
|||
|
type
|
|||
|
TWindowFormDeSign = class(TObject)
|
|||
|
private
|
|||
|
fFontSize: integer;
|
|||
|
fWhatDesign: string;
|
|||
|
fFormCaption: string;
|
|||
|
fDllName: string;
|
|||
|
fFormName: string;
|
|||
|
fFormId: integer;
|
|||
|
fIsShowColumnfilter: boolean;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryTmp: TADOQuery;
|
|||
|
function IsHasDesignRight(ADOTmp: TADOQuery): boolean;
|
|||
|
procedure SetCxGridColumnBestWidth(cxGrid: TcxGridDBTableView);
|
|||
|
function SaveFormGridInfo(mCxGridView: TcxGridDBTableView; ADOCmd: TADOQuery; mdesignCode: string; mGridName: string; mGridType: integer): boolean;
|
|||
|
function InitContainerControls(mdesignCode: string; containerCtrl: TwinControl): boolean;
|
|||
|
procedure SetFormOperRight(mParent: TwinControl; mRightCaptions: string);
|
|||
|
function GetMaxId(): integer;
|
|||
|
procedure onDesignDblClick(Sender: TObject);
|
|||
|
procedure cxGridViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|||
|
|
|||
|
procedure cxGridViewSelectionChanged(Sender: TcxCustomGridTableView);
|
|||
|
procedure CustomDrawcxGridHeader(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridColumnHeaderViewInfo; var ADone: boolean);
|
|||
|
procedure CreateCxGridColumn(tv1: TcxGridDBTableView; ADOQueryTmp: TADOQuery; mdesignCode, mGridName: string; HasFooter: boolean = true);
|
|||
|
function SaveContainerControInfo(mParentCtrl: TwinControl; ADOCmd: TADOQuery; mdesignCode: string; mDesigntype: integer): boolean;
|
|||
|
function InitCtrlData(mCtrl: TControl; mSql: string; mdefault: string): boolean;
|
|||
|
procedure OpenGridDesignWin(mCxGridView: TcxGridDBTableView);
|
|||
|
procedure OpenContainerDesign(containerCtrl: TwinControl);
|
|||
|
procedure ReadINIFileSetInfo(mfontSize: integer);
|
|||
|
function getChgDefaultValue(mValue: string): string;
|
|||
|
procedure cxGridViewCustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
|
|||
|
public
|
|||
|
function FormStyleInit(mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery; mStyleCode: string = '01'; mRightCaptions: string = ''): boolean;
|
|||
|
procedure QueryDataPlus(ADOTmp: TADOQuery);
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
/// //////////////////////////////////////////////////////
|
|||
|
// <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;
|
|||
|
begin
|
|||
|
ADOQueryCmd := ADOQCmd;
|
|||
|
ADOQueryTmp := ADOTmp;
|
|||
|
fDllName := gDllFileName;
|
|||
|
fFormName := Tform(mForm).name;
|
|||
|
fFormId := mFormId;
|
|||
|
if fFontSize < 9 then
|
|||
|
fFontSize := 9;
|
|||
|
if trim(mStyleCode) = '' then
|
|||
|
mStyleCode := '01';
|
|||
|
/// /////////////////////////////
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|||
|
with ADOTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from SD_ErpStyleParam');
|
|||
|
sql.Add('where StyleCode=' + quotedStr(mStyleCode));
|
|||
|
open;
|
|||
|
if RecordCount > 0 then
|
|||
|
begin
|
|||
|
fWhatDesign := trim(fieldByName('WhatDesign').AsString);
|
|||
|
mCtl3D := fieldByName('IsCtl3D').AsBoolean;
|
|||
|
mToolBarList := fieldByName('IsToolBarList').AsBoolean;
|
|||
|
mIsCustomBackColor := fieldByName('IsCustomBackColor').AsBoolean;
|
|||
|
mIsDrawGridHeader := fieldByName('IsDrawGridHeader').AsBoolean;
|
|||
|
fIsShowColumnfilter := fieldByName('IsShowColumnfilter').AsBoolean;
|
|||
|
if fieldByName('fontSize').AsInteger > 9 then
|
|||
|
begin
|
|||
|
fFontSize := fieldByName('fontSize').AsInteger;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
ReadINIFileSetInfo(fFontSize);
|
|||
|
//mForm.Font.name := '<27><><EFBFBD><EFBFBD>';
|
|||
|
mForm.Font.Size := fFontSize;
|
|||
|
// <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ɫ
|
|||
|
if mIsCustomBackColor then
|
|||
|
mForm.Color := clFormBack;
|
|||
|
|
|||
|
for i := 0 to mForm.ComponentCount - 1 do
|
|||
|
begin
|
|||
|
if (fFontSize > 9) then
|
|||
|
begin
|
|||
|
if mForm.Components[i] is Tlabel then
|
|||
|
begin
|
|||
|
if Tlabel(mForm.Components[i]).Left >= fFontSize then
|
|||
|
Tlabel(mForm.Components[i]).Left := Tlabel(mForm.Components[i]).Left - fFontSize;
|
|||
|
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;
|
|||
|
if mForm.Components[i] is TToolBar then
|
|||
|
begin
|
|||
|
TToolBar(mForm.Components[i]).AutoSize := true;
|
|||
|
TToolBar(mForm.Components[i]).Flat := true;
|
|||
|
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;
|
|||
|
SetFormOperRight(TToolBar(mForm.Components[i]), mRightCaptions);
|
|||
|
continue;
|
|||
|
end;
|
|||
|
if mForm.Components[i] is TcxTabControl then
|
|||
|
begin
|
|||
|
// TcxTabControl(mForm.Components[i]).Color := clToolBarBack ;
|
|||
|
continue;
|
|||
|
end;
|
|||
|
if mForm.Components[i] is TcomBoBox then
|
|||
|
begin
|
|||
|
// TcomBoBox(mForm.Components[i]).Color := clToolBarBack ;
|
|||
|
continue;
|
|||
|
end;
|
|||
|
// Tpanel
|
|||
|
if mForm.Components[i] is Tpanel then
|
|||
|
begin
|
|||
|
Tpanel(mForm.Components[i]).OnDblClick := onDesignDblClick;
|
|||
|
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;
|
|||
|
InitContainerControls(mdesignCode, Tpanel(mForm.Components[i]));
|
|||
|
|
|||
|
continue;
|
|||
|
end;
|
|||
|
// Tpanel
|
|||
|
if mForm.Components[i] is TScrollBox then
|
|||
|
begin
|
|||
|
TScrollBox(mForm.Components[i]).OnDblClick := onDesignDblClick;
|
|||
|
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;
|
|||
|
InitContainerControls(mdesignCode, TScrollBox(mForm.Components[i]));
|
|||
|
|
|||
|
continue;
|
|||
|
end;
|
|||
|
// Tcxgroup
|
|||
|
if mForm.Components[i] is TgroupBox then
|
|||
|
begin
|
|||
|
TgroupBox(mForm.Components[i]).OnDblClick := onDesignDblClick;
|
|||
|
if mIsCustomBackColor then
|
|||
|
TgroupBox(mForm.Components[i]).Color := clPanelBack;
|
|||
|
TgroupBox(mForm.Components[i]).Ctl3D := mCtl3D;
|
|||
|
mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + TgroupBox(mForm.Components[i]).name;
|
|||
|
InitContainerControls(mdesignCode, TgroupBox(mForm.Components[i]));
|
|||
|
|
|||
|
continue;
|
|||
|
end;
|
|||
|
// TcxPageControl
|
|||
|
if mForm.Components[i] is TcxPageControl then
|
|||
|
begin
|
|||
|
// TcxPageControl(mForm.Components[i]).OnDblClick:= onDesignDblClick ;
|
|||
|
if mIsCustomBackColor then
|
|||
|
TcxPageControl(mForm.Components[i]).Color := clPanelBack;
|
|||
|
// mDesignCode:=fFormName+'_'+intTostr(fFormid)+'_'+ TcxPageControl(mForm.Components[i]).Name ;
|
|||
|
// InitContainerControls(mDesignCode, TcxPageControl(mForm.Components[i]));
|
|||
|
continue;
|
|||
|
end;
|
|||
|
// Tcxgroup
|
|||
|
if mForm.Components[i] is TcxgroupBox then
|
|||
|
begin
|
|||
|
TcxgroupBox(mForm.Components[i]).OnDblClick := onDesignDblClick;
|
|||
|
if mIsCustomBackColor then
|
|||
|
TcxgroupBox(mForm.Components[i]).Color := clPanelBack;
|
|||
|
TcxgroupBox(mForm.Components[i]).Ctl3D := mCtl3D;
|
|||
|
mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + TcxgroupBox(mForm.Components[i]).name;
|
|||
|
InitContainerControls(mdesignCode, TcxgroupBox(mForm.Components[i]));
|
|||
|
continue;
|
|||
|
end;
|
|||
|
if mForm.Components[i] is Tcxtimeedit then
|
|||
|
begin
|
|||
|
Tcxtimeedit(mForm.Components[i]).Style.BorderStyle := ebsFlat;
|
|||
|
continue;
|
|||
|
end;
|
|||
|
// TcxGrid and gIsCustomDrawGridHeader
|
|||
|
if mForm.Components[i] is TcxGrid then
|
|||
|
begin
|
|||
|
TcxGrid(mForm.Components[i]).Font.Size := fFontsize;
|
|||
|
TcxGrid(mForm.Components[i]).LookAndFeel.ScrollbarMode := sbmClassic;
|
|||
|
|
|||
|
cxStyle_GridOddRow := TcxStyle.Create(mForm.Components[i]);
|
|||
|
cxStyle_GridEvenRow := TcxStyle.Create(mForm.Components[i]);
|
|||
|
cxStyle_active := TcxStyle.Create(mForm.Components[i]);
|
|||
|
cxStyle_selection := TcxStyle.Create(mForm.Components[i]);
|
|||
|
cxStyle_gridGroupBox := TcxStyle.Create(mForm.Components[i]);
|
|||
|
cxStyle_gridFoot := TcxStyle.Create(mForm.Components[i]);
|
|||
|
cxStyle_GridOddRow.Color := $00FDFAF9; // $00FBF6F2;
|
|||
|
cxStyle_GridEvenRow.Color := $20F3FBFB;
|
|||
|
cxStyle_active.Color := $0047D5FE; // $00C4EFFF; $00C6D9F9
|
|||
|
cxStyle_active.Font.Style := [];
|
|||
|
cxStyle_active.Font.name := '<27><><EFBFBD><EFBFBD>';
|
|||
|
|
|||
|
cxStyle_gridGroupBox.Color := $20F3FBFB;
|
|||
|
cxStyle_selection.Color := $0047D5FE;
|
|||
|
cxStyle_gridFoot.Color := clPanelBack;
|
|||
|
cxStyle_gridFoot.Font.Color := clBlack;
|
|||
|
//cxStyle_gridFoot.Font.name:='<27><><EFBFBD><EFBFBD>';
|
|||
|
cxStyle_selection.Font.Color := clBlack;
|
|||
|
cxStyle_selection.Font.Style := [];
|
|||
|
cxStyle_selection.Font.name := '<27><><EFBFBD><EFBFBD>';
|
|||
|
//cxStyle_active.Font.color := clBlack;
|
|||
|
|
|||
|
cxStyle_active.Font.Size := fFontsize;
|
|||
|
cxStyle_gridFoot.Font.Size := ffontsize;
|
|||
|
cxStyle_selection.Font.Size := ffontsize;
|
|||
|
//cxStyle_gridGroupBox.Font.Size:= ffontsize;
|
|||
|
// cxStyle_gridOddRow.font.Size:=ffontsize;
|
|||
|
// cxStyle_GridEvenRow.Font.Size:=ffontsize;
|
|||
|
|
|||
|
// cxStyle_gridFoot.font.Style:=[fsBold];
|
|||
|
if TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.Header <> nil then
|
|||
|
TcxStyle(TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.Header).Font.Size := ffontsize;
|
|||
|
|
|||
|
if TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.contentOdd = nil then
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.contentOdd := cxStyle_GridOddRow;
|
|||
|
if TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.contentEven = nil then
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.contentEven := cxStyle_GridEvenRow;
|
|||
|
if TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.inactive = nil then
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.inactive := cxStyle_active
|
|||
|
else
|
|||
|
TcxStyle(TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.inactive).Font.Size := ffontsize;
|
|||
|
|
|||
|
if TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.selection = nil then
|
|||
|
begin
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.selection := cxStyle_selection;
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.selection.AssignedValues := [];
|
|||
|
end
|
|||
|
else
|
|||
|
TcxStyle(TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.selection).Font.Size := ffontsize;
|
|||
|
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.groupByBox := cxStyle_gridGroupBox;
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).styles.Footer := cxStyle_gridFoot;
|
|||
|
|
|||
|
//TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0])
|
|||
|
// .styles.Header := nil;
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).optionsView.groupByBox := false;
|
|||
|
if mIsDrawGridHeader and (TcxGrid(mForm.Components[i]).Tag <> 1) then
|
|||
|
begin
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).optionsCustomize.columnfiltering := true;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
|
|||
|
TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).dataController.filter.AutoDataSetFilter := true;
|
|||
|
|
|||
|
if mForm.Components[i].Tag < 99 then
|
|||
|
SetCxGridColumnBestWidth(TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]));
|
|||
|
|
|||
|
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 := fFormName + '_' + intTostr(fFormId) + '_' + TcxGridDBTableView(TcxGrid(mForm.Components[i]).Views[0]).name;
|
|||
|
|
|||
|
// CreateCxGridColumn(TcxGridDBTableView(TcxGrid(mForm.Components[i])
|
|||
|
// .Views[0]), ADOQueryTmp, mdesignCode, '');
|
|||
|
|
|||
|
continue;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
/// ////////////////////////////////////////////////////////////////////
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ
|
|||
|
/// ///////////////////////////////////////////////////////////////////////
|
|||
|
function TWindowFormDeSign.SaveContainerControInfo(mParentCtrl: TwinControl; ADOCmd: TADOQuery; mdesignCode: string; mDesigntype: integer): boolean;
|
|||
|
var
|
|||
|
i: integer;
|
|||
|
begin
|
|||
|
result := false;
|
|||
|
try
|
|||
|
with ADOCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * ');
|
|||
|
sql.Add('from SD_FormControl_Design');
|
|||
|
sql.Add('where designCode=' + quotedStr(mdesignCode));
|
|||
|
open;
|
|||
|
|
|||
|
if RecordCount <= 0 then
|
|||
|
begin
|
|||
|
append;
|
|||
|
fieldByName('designCode').value := mdesignCode;
|
|||
|
fieldByName('InitType').value := 'systemset';
|
|||
|
fieldByName('Createman').value := DName;
|
|||
|
fieldByName('valid').value := 'Y';
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
edit;
|
|||
|
end;
|
|||
|
|
|||
|
fieldByName('Designtype').value := mDesigntype;
|
|||
|
fieldByName('ParentCtrlName').value := mParentCtrl.name;
|
|||
|
fieldByName('ParentCtrlType').value := mParentCtrl.ClassName;
|
|||
|
|
|||
|
fieldByName('ParentHeight').value := mParentCtrl.Height;
|
|||
|
fieldByName('DllFileName').value := fDllName;
|
|||
|
fieldByName('formId').value := fFormId;
|
|||
|
fieldByName('formName').value := fFormName;
|
|||
|
post;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
/// ////////////////
|
|||
|
// <20><><EFBFBD><EFBFBD>Ϣ
|
|||
|
with ADOCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * ');
|
|||
|
sql.Add('from SD_FormControl_Design_sub');
|
|||
|
sql.Add('where designCode=' + quotedStr(mdesignCode));
|
|||
|
open;
|
|||
|
|
|||
|
for i := mParentCtrl.ControlCount - 1 downto 0 do
|
|||
|
begin
|
|||
|
if not locate('ControlName', mParentCtrl.Controls[i].name, []) then
|
|||
|
begin
|
|||
|
append;
|
|||
|
fieldByName('designCode').value := trim(mdesignCode);
|
|||
|
fieldByName('ControlName').value := mParentCtrl.Controls[i].name;
|
|||
|
|
|||
|
if (mParentCtrl.Controls[i] is Tlabel) or (mParentCtrl.Controls[i] is Tcxlabel) then
|
|||
|
fieldByName('DefaultCaption').value := Tlabel(mParentCtrl.Controls[i]).Caption
|
|||
|
else if (mParentCtrl.Controls[i] is TButton) or (mParentCtrl.Controls[i] is TcxButtonEdit) then
|
|||
|
fieldByName('DefaultCaption').value := TButton(mParentCtrl.Controls[i]).Caption
|
|||
|
else if (mParentCtrl.Controls[i] is TRadioButton) then
|
|||
|
fieldByName('DefaultCaption').value := TRadioButton(mParentCtrl.Controls[i]).Caption;
|
|||
|
|
|||
|
fieldByName('ControlClass').value := mParentCtrl.Controls[i].ClassName;
|
|||
|
// fieldByName('DefLeftPos').Value :=TWinControl(mParentCtrl.Controls[i]).Left;
|
|||
|
// fieldByName('DefTopPos').Value :=TWinControl(mParentCtrl.Controls[i]).Top;
|
|||
|
// fieldByName('DefWidth').Value :=TWinControl(mParentCtrl.Controls[i]).Width;
|
|||
|
// fieldByName('DefHeight').Value :=TWinControl(mParentCtrl.Controls[i]).Height;
|
|||
|
fieldByName('TabOrder').value := TwinControl(mParentCtrl.Controls[i]).TabOrder;
|
|||
|
// fieldByName('defTabOrder').Value := TWinControl(mParentCtrl.Controls[i]).TabOrder ;
|
|||
|
fieldByName('Visible').value := TwinControl(mParentCtrl.Controls[i]).Visible;
|
|||
|
|
|||
|
fieldByName('creator').value := DName;
|
|||
|
fieldByName('Valid').value := 'Y';
|
|||
|
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
continue;
|
|||
|
// Edit;
|
|||
|
end;
|
|||
|
|
|||
|
fieldByName('ControlLeft').value := TwinControl(mParentCtrl.Controls[i]).Left;
|
|||
|
fieldByName('ControlTop').value := TwinControl(mParentCtrl.Controls[i]).Top;
|
|||
|
fieldByName('ControlWidth').value := TwinControl(mParentCtrl.Controls[i]).Width;
|
|||
|
fieldByName('ControlHeight').value := TwinControl(mParentCtrl.Controls[i]).Height;
|
|||
|
|
|||
|
if (mParentCtrl.Controls[i] is Tlabel) or (mParentCtrl.Controls[i] is Tcxlabel) then
|
|||
|
fieldByName('Caption').value := Tlabel(mParentCtrl.Controls[i]).Caption
|
|||
|
else if (mParentCtrl.Controls[i] is TButton) or (mParentCtrl.Controls[i] is TcxButtonEdit) then
|
|||
|
fieldByName('Caption').value := TButton(mParentCtrl.Controls[i]).Caption
|
|||
|
else if (mParentCtrl.Controls[i] is TcheckBox) then
|
|||
|
fieldByName('Caption').value := TcheckBox(mParentCtrl.Controls[i]).Caption
|
|||
|
else if (mParentCtrl.Controls[i] is TcxcheckBox) then
|
|||
|
fieldByName('Caption').value := TcxcheckBox(mParentCtrl.Controls[i]).Caption
|
|||
|
else if (mParentCtrl.Controls[i] is TRadioButton) then
|
|||
|
fieldByName('Caption').value := TRadioButton(mParentCtrl.Controls[i]).Caption;
|
|||
|
|
|||
|
if mParentCtrl.Controls[i] is Tlabel then
|
|||
|
begin
|
|||
|
fieldByName('fontSize').value := Tlabel(mParentCtrl.Controls[i]).Font.Size;
|
|||
|
fieldByName('fontColor').value := Tlabel(mParentCtrl.Controls[i]).Font.Color;
|
|||
|
end;
|
|||
|
|
|||
|
post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOCmd.close;
|
|||
|
result := true;
|
|||
|
except
|
|||
|
application.MessageBox('<27><><EFBFBD>游<EFBFBD><E6B8B8><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>Ϣʱ<CFA2><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
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;
|
|||
|
|
|||
|
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.onDesignDblClick(Sender: TObject);
|
|||
|
begin
|
|||
|
OpenContainerDesign(TwinControl(Sender));
|
|||
|
end;
|
|||
|
|
|||
|
/// ///////////////////////////////////////////////////////////////
|
|||
|
//
|
|||
|
/// ////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
procedure TWindowFormDeSign.CustomDrawcxGridHeader(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridColumnHeaderViewInfo; var ADone: boolean);
|
|||
|
var
|
|||
|
ARect: TRect;
|
|||
|
ATextToDraw: string;
|
|||
|
AIsVertical: boolean;
|
|||
|
FColorScheme: TColorSchemes;
|
|||
|
FCustomDrawingStyle: TCustomDrawingStyleArr;
|
|||
|
begin
|
|||
|
try
|
|||
|
ATextToDraw := ' ' + AViewInfo.Text;
|
|||
|
ARect := AViewInfo.Bounds;
|
|||
|
AIsVertical := true;
|
|||
|
DrawGradient(ACanvas.Canvas, ARect, ColorScheme[1, 0], ColorScheme[1, 1], 55, AIsVertical);
|
|||
|
ARect.Left := ARect.Right - 9;
|
|||
|
ARect.Right := ARect.Right - 1;
|
|||
|
InflateRect(ARect, -1, -3);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ
|
|||
|
if AViewInfo.Column.SortOrder = soAscending then
|
|||
|
AViewInfo.LookAndFeelPainter.DrawSortingMark(ACanvas, ARect, false)
|
|||
|
else if AViewInfo.Column.SortOrder = soDescending then
|
|||
|
AViewInfo.LookAndFeelPainter.DrawSortingMark(ACanvas, ARect, true);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
if fIsShowColumnfilter then
|
|||
|
begin
|
|||
|
if AViewInfo.Column.Options.Filtering then
|
|||
|
begin
|
|||
|
Sender.LookAndFeelPainter.DrawFilterDropDownButton(ACanvas, ARect, cxbsNormal, AViewInfo.Column.Filtered);
|
|||
|
OffsetRect(ARect, -16, 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>
|
|||
|
ARect := AViewInfo.Bounds;
|
|||
|
ACanvas.DrawEdge(ARect, false, false, [btop, bright, bBottom]); //
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ARect := AViewInfo.TextAreaBounds;
|
|||
|
SetBkMode(ACanvas.Canvas.Handle, TRANSPARENT);
|
|||
|
ACanvas.DrawText(ATextToDraw, ARect, 0);
|
|||
|
|
|||
|
ADone := true;
|
|||
|
// FCustomDrawingStyle[Integer(vtMaster), Integer(cdaColumnHeader)] <> cdsDefaultDrawing;
|
|||
|
|
|||
|
except
|
|||
|
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;
|
|||
|
|
|||
|
/// ////////////////////////////////////////////////////////////////
|
|||
|
// <20><EFBFBD><F2BFAAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>
|
|||
|
// 0: mGridType <20><>ѯ; 1:<3A><><EFBFBD><EFBFBD>
|
|||
|
/// /////////////////////////////////////////////////////////////////
|
|||
|
procedure TWindowFormDeSign.OpenGridDesignWin(mCxGridView: TcxGridDBTableView);
|
|||
|
type
|
|||
|
TMyFunc = function(App: Tapplication; FormH: hwnd; FormID: integer; UID: pchar; UName: pchar; dataBase: pchar; Title: pchar; Parameters1: pchar; Parameters2: pchar): hwnd; stdcall;
|
|||
|
var
|
|||
|
Tf: TMyFunc;
|
|||
|
Tp: TFarProc;
|
|||
|
Th: Thandle;
|
|||
|
newh: hwnd;
|
|||
|
mGridType: integer;
|
|||
|
mdesignCode: string;
|
|||
|
mGridName: string;
|
|||
|
k: integer;
|
|||
|
begin
|
|||
|
/// ////////////////////////////////////
|
|||
|
// Ȩ<><EFBFBD><DEBF><EFBFBD>
|
|||
|
mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + mCxGridView.name;
|
|||
|
mGridName := TcxGrid(TcxGridLevel(mCxGridView.level).Control).name;
|
|||
|
if not IsHasDesignRight(ADOQueryCmd) then
|
|||
|
exit;
|
|||
|
|
|||
|
/// ////////////////////////////////////////
|
|||
|
// <20><><EFBFBD>浱ǰ<E6B5B1>ؼ<EFBFBD><D8BC><EFBFBD>Ϣ
|
|||
|
if not SaveFormGridInfo(mCxGridView, ADOQueryCmd, mdesignCode, mGridName, mCxGridView.Tag) then
|
|||
|
begin
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
if trim(fWhatDesign) = '' then
|
|||
|
begin
|
|||
|
if FileExists(ExtractFilePath(application.ExeName) + 'GridDesign.EXE') then
|
|||
|
begin
|
|||
|
WinExec(PAnsiChar(ExtractFilePath(application.ExeName) + 'GridDesign.exe ' + mdesignCode + ' ' + DName), SW_SHOWNORMAL);
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
/// ////////////////////////////////////////
|
|||
|
//
|
|||
|
Th := LoadLibrary('RtDesign.dll');
|
|||
|
if Th > 0 then
|
|||
|
begin
|
|||
|
try
|
|||
|
Tp := GetProcAddress(Th, 'GetDllForm');
|
|||
|
if Tp <> nil then
|
|||
|
begin
|
|||
|
Tf := TMyFunc(Tp);
|
|||
|
newh := Tf(application, 0, 2, pchar(dcode), pchar(DName), pchar(ADOQueryCmd.ConnectionString), pchar(fFormCaption + mGridName + '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'), pchar(mdesignCode), pchar(''));
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
ShowMessage('<27><><EFBFBD><EFBFBD>RtDesign.dllʱ<6C><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!');
|
|||
|
end;
|
|||
|
finally
|
|||
|
// FreeLibrary(Th);
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
ShowMessage('<27>Ҳ<EFBFBD><D2B2><EFBFBD>RtDesign.dll');
|
|||
|
end;
|
|||
|
CreateCxGridColumn(mCxGridView, ADOQueryCmd, mdesignCode, mGridName);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
/// ////////////////////////////////////////////////////////
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>CxGrid<69><64>
|
|||
|
/// ////////////////////////////////////////////////////////
|
|||
|
procedure TWindowFormDeSign.CreateCxGridColumn(tv1: TcxGridDBTableView; ADOQueryTmp: TADOQuery; mdesignCode, mGridName: string; HasFooter: boolean = true);
|
|||
|
var
|
|||
|
ADBColumn: TcxGridDBColumn;
|
|||
|
strField, strCaption: string;
|
|||
|
mColumnName: string;
|
|||
|
mCalcWidth: integer;
|
|||
|
mWidth: integer;
|
|||
|
mAvgWidth, mGridWidth: integer;
|
|||
|
begin
|
|||
|
mWidth := 12;
|
|||
|
mGridWidth := TcxGrid(TcxGridLevel(tv1.level).Control).Width;
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from SD_ErpStyleParam');
|
|||
|
sql.Add('where StyleCode=''01''');
|
|||
|
open;
|
|||
|
if RecordCount > 0 then
|
|||
|
begin
|
|||
|
if fieldByName('headStyle').AsInteger = 0 then
|
|||
|
begin
|
|||
|
tv1.styles.Header := nil;
|
|||
|
end;
|
|||
|
end;
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
try
|
|||
|
|
|||
|
tv1.BeginUpdate;
|
|||
|
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select sum(width) as width ');
|
|||
|
sql.Add('from SD_FormGrid_Design A');
|
|||
|
sql.Add('where A.designCode=' + quotedStr(mdesignCode));
|
|||
|
sql.Add('and valid=1');
|
|||
|
open;
|
|||
|
|
|||
|
if mGridWidth > fieldByName('width').AsInteger then
|
|||
|
begin
|
|||
|
if tv1.ColumnCount > 0 then
|
|||
|
mAvgWidth := (mGridWidth - fieldByName('width').AsInteger) div tv1.ColumnCount - 5;
|
|||
|
end;
|
|||
|
|
|||
|
if mAvgWidth < 0 then
|
|||
|
mAvgWidth := 0;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select A.* ');
|
|||
|
sql.Add('from SD_FormGrid_Design A');
|
|||
|
sql.Add('where A.designCode=' + quotedStr(mdesignCode));
|
|||
|
// sql.Add('and A.formId='+intTostr(fFormId));
|
|||
|
// sql.Add('and A.formName='+QuotedStr(fFormName));
|
|||
|
sql.Add('order by A.columnOrder');
|
|||
|
open;
|
|||
|
if IsEmpty then
|
|||
|
begin
|
|||
|
// GetBeginColumnWidth(Tv1,mWidth);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
ADBColumn := tv1.GetColumnByFieldName(trim(fieldByName('fieldName').AsString));
|
|||
|
if ADBColumn <> nil then
|
|||
|
begin
|
|||
|
// <20><><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD>ʾ
|
|||
|
if not fieldByName('valid').AsBoolean then
|
|||
|
begin
|
|||
|
ADBColumn.Visible := false;
|
|||
|
ADBColumn.Hidden := true;
|
|||
|
Next;
|
|||
|
continue;
|
|||
|
end;
|
|||
|
ADBColumn.name := trim(tv1.name) + trim(fieldByName('fieldName').AsString);
|
|||
|
ADBColumn.Visible := fieldByName('Visible').AsBoolean;
|
|||
|
ADBColumn.Hidden := fieldByName('ColumnHide').AsBoolean;
|
|||
|
|
|||
|
ADBColumn.Caption := trim(fieldByName('caption').AsString);
|
|||
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
if tv1.optionsCustomize.columnfiltering and ADBColumn.Options.Filtering then
|
|||
|
mCalcWidth := length(trim(fieldByName('caption').AsString)) * mWidth + 10
|
|||
|
else
|
|||
|
mCalcWidth := length(trim(fieldByName('caption').AsString)) * mWidth;
|
|||
|
|
|||
|
// if fieldByName('width').AsInteger >mCalcWidth then
|
|||
|
ADBColumn.Width := fieldByName('width').AsInteger + mAvgWidth;
|
|||
|
// else
|
|||
|
// ADBColumn.Width :=mCalcWidth ;
|
|||
|
Next;
|
|||
|
continue;
|
|||
|
end;
|
|||
|
// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4><EFBFBD>
|
|||
|
mColumnName := trim(tv1.name) + trim(fieldByName('fieldName').AsString);
|
|||
|
if tv1.FindItemByName(mColumnName) <> nil then
|
|||
|
begin
|
|||
|
Next;
|
|||
|
continue;
|
|||
|
end;
|
|||
|
// <20>µ<EFBFBD><C2B5><EFBFBD>
|
|||
|
ADBColumn := tv1.CreateColumn;
|
|||
|
ADBColumn.DataBinding.FieldName := trim(fieldByName('fieldName').AsString);
|
|||
|
|
|||
|
ADBColumn.Caption := trim(fieldByName('Caption').AsString);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
if tv1.optionsCustomize.columnfiltering and ADBColumn.Options.Filtering then
|
|||
|
mCalcWidth := length(trim(fieldByName('caption').AsString)) * mWidth + 10
|
|||
|
else
|
|||
|
mCalcWidth := length(trim(fieldByName('caption').AsString)) * mWidth;
|
|||
|
if fieldByName('width').AsInteger > mCalcWidth then
|
|||
|
ADBColumn.Width := fieldByName('width').AsInteger
|
|||
|
else
|
|||
|
ADBColumn.Width := mCalcWidth;
|
|||
|
|
|||
|
ADBColumn.Visible := fieldByName('visible').AsBoolean;
|
|||
|
ADBColumn.Hidden := not fieldByName('visible').AsBoolean;
|
|||
|
ADBColumn.HeaderAlignmentHorz := taCenter;
|
|||
|
ADBColumn.MinWidth := 100;
|
|||
|
ADBColumn.name := mColumnName;
|
|||
|
|
|||
|
ADBColumn.Options.Editing := not fieldByName('ReadOnly').AsBoolean;
|
|||
|
ADBColumn.Options.Focusing := not fieldByName('ReadOnly').AsBoolean;
|
|||
|
/// /////////////
|
|||
|
// <20><><EFBFBD><EFBFBD>footer
|
|||
|
{
|
|||
|
if HasFooter then
|
|||
|
begin
|
|||
|
if fieldByName('FooterFlag').AsBoolean then
|
|||
|
begin
|
|||
|
CreateFooterCol(tv1,ADBColumn,ADBColumn.DataBinding.FieldName
|
|||
|
,trim(fieldByName('FooterType').AsString));
|
|||
|
end;
|
|||
|
end;
|
|||
|
}
|
|||
|
|
|||
|
Next;
|
|||
|
|
|||
|
end;
|
|||
|
tv1.optionsView.Footer := HasFooter;
|
|||
|
|
|||
|
close;
|
|||
|
end;
|
|||
|
finally
|
|||
|
tv1.EndUpdate;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
/// ///////////////////////////////////////////////////
|
|||
|
//
|
|||
|
/// ////////////////////////////////////////////////////
|
|||
|
function TWindowFormDeSign.IsHasDesignRight(ADOTmp: TADOQuery): boolean;
|
|||
|
begin
|
|||
|
result := false;
|
|||
|
try
|
|||
|
/// ////////////////////////////////////
|
|||
|
// Ȩ<><EFBFBD><DEBF><EFBFBD>
|
|||
|
with ADOTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
Filtered := false;
|
|||
|
sql.Add('select count(userid) as cnt');
|
|||
|
sql.Add('from sy_user A');
|
|||
|
sql.Add('where userid=' + quotedStr(dcode));
|
|||
|
sql.Add('and canDesign=1');
|
|||
|
sql.Add('and valid=''Y''');
|
|||
|
open;
|
|||
|
|
|||
|
if fieldByName('cnt').AsInteger > 0 then
|
|||
|
begin
|
|||
|
result := true;
|
|||
|
end;
|
|||
|
close;
|
|||
|
end;
|
|||
|
except
|
|||
|
application.MessageBox('<27><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ', 0);
|
|||
|
end;
|
|||
|
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><D8BC><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>
|
|||
|
// mWinType<70><65>0 <20><><EFBFBD><EFBFBD><EFBFBD>༭<EFBFBD><E0BCAD><EFBFBD>ڣ<EFBFBD>5:<3A><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// /////////////////////////////////////////////////////////////////
|
|||
|
procedure TWindowFormDeSign.OpenContainerDesign(containerCtrl: TwinControl);
|
|||
|
type
|
|||
|
TMyFunc = function(App: Tapplication; FormH: hwnd; FormID: integer; UID: pchar; UName: pchar; dataBase: pchar; Title: pchar; Parameters1: pchar; Parameters2: pchar): hwnd; stdcall;
|
|||
|
var
|
|||
|
Tf: TMyFunc;
|
|||
|
Tp: TFarProc;
|
|||
|
Th: Thandle;
|
|||
|
newh: hwnd;
|
|||
|
mdesignCode: string;
|
|||
|
begin
|
|||
|
mdesignCode := fFormName + '_' + intTostr(fFormId) + '_' + containerCtrl.name;
|
|||
|
if not IsHasDesignRight(ADOQueryTmp) then
|
|||
|
exit;
|
|||
|
|
|||
|
/// ////////////////////////////////////////
|
|||
|
// <20><><EFBFBD>浱ǰ<E6B5B1>ؼ<EFBFBD><D8BC><EFBFBD>Ϣ
|
|||
|
|
|||
|
if not SaveContainerControInfo(containerCtrl, ADOQueryCmd, mdesignCode, containerCtrl.Tag) then
|
|||
|
begin
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
if trim(fWhatDesign) = '' then
|
|||
|
begin
|
|||
|
if FileExists(ExtractFilePath(application.ExeName) + 'WinFormDesign.EXE') then
|
|||
|
begin
|
|||
|
WinExec(PAnsiChar(ExtractFilePath(application.ExeName) + 'WinFormDesign.exe ' + mdesignCode + ' ' + DName), SW_SHOWNORMAL);
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
|
|||
|
/// ////////////////////////////////////////
|
|||
|
//
|
|||
|
Th := LoadLibrary('RtDesign.dll');
|
|||
|
if Th > 0 then
|
|||
|
begin
|
|||
|
try
|
|||
|
Tp := GetProcAddress(Th, 'GetDllForm');
|
|||
|
if Tp <> nil then
|
|||
|
begin
|
|||
|
Tf := TMyFunc(Tp);
|
|||
|
newh := Tf(application, 0, 1, pchar(dcode), pchar(DName), pchar(DConString), pchar(fFormCaption + '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'), pchar(mdesignCode), pchar(''));
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
ShowMessage('<27><><EFBFBD><EFBFBD>RtDesign.dllʱ<6C><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!');
|
|||
|
end;
|
|||
|
finally
|
|||
|
// FreeLibrary(Th);
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
ShowMessage('<27>Ҳ<EFBFBD><D2B2><EFBFBD>RtDesign.dll');
|
|||
|
end;
|
|||
|
InitContainerControls(mdesignCode, containerCtrl);
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
/// /////////////////////////////////////////////////////////////////
|
|||
|
// <20><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ڿؼ<DABF><D8BC><EFBFBD>Ϣ
|
|||
|
/// /////////////////////////////////////////////////////////////////
|
|||
|
function TWindowFormDeSign.InitContainerControls(mdesignCode: string; containerCtrl: TwinControl): boolean;
|
|||
|
var
|
|||
|
mParentHeight: integer;
|
|||
|
mContrlName: string;
|
|||
|
i: integer;
|
|||
|
begin
|
|||
|
mParentHeight := 0;
|
|||
|
result := false;
|
|||
|
try
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from SD_FormControl_Design');
|
|||
|
sql.Add('where designCode=' + quotedStr(mdesignCode));
|
|||
|
open;
|
|||
|
|
|||
|
if RecordCount <= 0 then
|
|||
|
begin
|
|||
|
exit;
|
|||
|
end;
|
|||
|
mParentHeight := fieldByName('ParentHeight').AsInteger;
|
|||
|
containerCtrl.Height := mParentHeight;
|
|||
|
end;
|
|||
|
/// ///////////////////////////////
|
|||
|
// <20>ؼ<EFBFBD>
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from SD_FormControl_Design_sub');
|
|||
|
sql.Add('where designCode=' + quotedStr(mdesignCode));
|
|||
|
sql.Add('and isadd=0');
|
|||
|
|
|||
|
open;
|
|||
|
end;
|
|||
|
/// ///////////////////////////
|
|||
|
for i := containerCtrl.ControlCount - 1 downto 0 do
|
|||
|
begin
|
|||
|
mContrlName := containerCtrl.Controls[i].name;
|
|||
|
if ADOQueryTmp.locate('controlName', mContrlName, []) then
|
|||
|
begin
|
|||
|
TwinControl(containerCtrl.Controls[i]).Left := ADOQueryTmp.fieldByName('controlLeft').AsInteger;
|
|||
|
TwinControl(containerCtrl.Controls[i]).Top := ADOQueryTmp.fieldByName('controlTop').AsInteger;
|
|||
|
TwinControl(containerCtrl.Controls[i]).Width := ADOQueryTmp.fieldByName('controlWidth').AsInteger;
|
|||
|
TwinControl(containerCtrl.Controls[i]).Height := ADOQueryTmp.fieldByName('controlHeight').AsInteger;
|
|||
|
TwinControl(containerCtrl.Controls[i]).Visible := ADOQueryTmp.fieldByName('visible').AsBoolean;
|
|||
|
TwinControl(containerCtrl.Controls[i]).TabOrder := ADOQueryTmp.fieldByName('TabOrder').AsInteger;
|
|||
|
|
|||
|
if containerCtrl.Controls[i] is Tlabel then
|
|||
|
begin
|
|||
|
Tlabel(containerCtrl.Controls[i]).Caption := trim(ADOQueryTmp.fieldByName('Caption').AsString);
|
|||
|
continue;
|
|||
|
end
|
|||
|
else if containerCtrl.Controls[i] is TcxButton then
|
|||
|
begin
|
|||
|
TcxButton(containerCtrl.Controls[i]).Caption := trim(ADOQueryTmp.fieldByName('Caption').AsString);
|
|||
|
continue;
|
|||
|
end
|
|||
|
else if containerCtrl.Controls[i] is TButton then
|
|||
|
begin
|
|||
|
TButton(containerCtrl.Controls[i]).Caption := trim(ADOQueryTmp.fieldByName('Caption').AsString);
|
|||
|
continue;
|
|||
|
end
|
|||
|
else if containerCtrl.Controls[i] is TRadioButton then
|
|||
|
begin
|
|||
|
TRadioButton(containerCtrl.Controls[i]).Caption := trim(ADOQueryTmp.fieldByName('Caption').AsString);
|
|||
|
continue;
|
|||
|
end;
|
|||
|
|
|||
|
if trim(ADOQueryTmp.fieldByName('InitSql').AsString) <> '' then
|
|||
|
begin
|
|||
|
if (containerCtrl.Controls[i] is TcomBoBox) or (containerCtrl.Controls[i] is TcxComboBox) then
|
|||
|
begin
|
|||
|
InitCtrlData(containerCtrl.Controls[i], trim(ADOQueryTmp.fieldByName('InitSql').AsString), trim(ADOQueryTmp.fieldByName('DefaultValue').AsString));
|
|||
|
continue;
|
|||
|
end;
|
|||
|
if (containerCtrl.Controls[i] is Tdatetimepicker) then
|
|||
|
begin
|
|||
|
InitCtrlData(containerCtrl.Controls[i], trim(ADOQueryTmp.fieldByName('InitSql').AsString), '');
|
|||
|
continue;
|
|||
|
end;
|
|||
|
if (containerCtrl.Controls[i] is TcxDateEdit) then
|
|||
|
begin
|
|||
|
InitCtrlData(containerCtrl.Controls[i], trim(ADOQueryTmp.fieldByName('InitSql').AsString), '');
|
|||
|
continue;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
/// /////////////////////////////
|
|||
|
if trim(ADOQueryTmp.fieldByName('DefaultValue').AsString) <> '' then
|
|||
|
begin
|
|||
|
if (containerCtrl.Controls[i] is TEdit) then
|
|||
|
begin
|
|||
|
TEdit(containerCtrl.Controls[i]).Text := getChgDefaultValue(trim(ADOQueryTmp.fieldByName('DefaultValue').AsString));
|
|||
|
continue;
|
|||
|
end;
|
|||
|
if (containerCtrl.Controls[i] is TcxTextEdit) then
|
|||
|
begin
|
|||
|
TcxTextEdit(containerCtrl.Controls[i]).Text := getChgDefaultValue(trim(ADOQueryTmp.fieldByName('DefaultValue').AsString));
|
|||
|
continue;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
result := true;
|
|||
|
except
|
|||
|
application.MessageBox('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ڿؼ<DABF>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ', 0);
|
|||
|
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
|
|||
|
//J := TcxGridDbTableView( Sender).DataController.GetSelectedRowIndex(i);
|
|||
|
//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>еĵ<D0B5><C4B5>е<EFBFBD>ֵ
|
|||
|
// Sender.DataController.Edit;
|
|||
|
// Sender.DataController.Values[J, idx] := true;
|
|||
|
// Sender.Controller.EditingController.ShowEdit;
|
|||
|
// Sender.DataController.Edit;
|
|||
|
// TcxGridDbTableView( Sender).DataController.Values[J, idx] := true;
|
|||
|
// TcxGridDbTableView( Sender).DataController.PostEditingData;
|
|||
|
// Sender.DataController.SetValue(J, idx,true); ;
|
|||
|
// Sender.DataController.Post(false);
|
|||
|
// Sender.DataController.e
|
|||
|
// Sender.DataController.Post(true);
|
|||
|
// Sender.DataController.PostEditingData;
|
|||
|
|
|||
|
|
|||
|
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;
|
|||
|
aCV := ACanvas;
|
|||
|
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),
|
|||
|
// AStyle.Font, AStyle.TextColor, AStyle.Color);
|
|||
|
aCV.Font, aCV.font.Color, aCV.Brush.color);
|
|||
|
ADone := True;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TWindowFormDeSign.ReadINIFileSetInfo(mfontSize: integer);
|
|||
|
var
|
|||
|
programIni: Tinifile; //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
FileName: string;
|
|||
|
begin
|
|||
|
FileName := ExtractFilePath(Paramstr(0)) + 'SYSTEMSET.INI';
|
|||
|
if not FileExists(FileName) then
|
|||
|
exit;
|
|||
|
|
|||
|
try
|
|||
|
programIni := Tinifile.create(FileName);
|
|||
|
fFontSize := programIni.ReadInteger('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С', mfontSize);
|
|||
|
finally
|
|||
|
programIni.Free;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|