766 lines
23 KiB
ObjectPascal
766 lines
23 KiB
ObjectPascal
unit U_cxGridCustomSet;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, SysUtils, Messages, Classes, Controls, StdCtrls, ComCtrls, Forms,
|
||
ExtCtrls, ComObj, DXCORE, ActiveX, cxMemo, cxButtons, Graphics, IniFiles,
|
||
Variants, 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,
|
||
dxLayoutContainer,
|
||
cxCustomData, cxClasses, cxTimeEdit, cxEdit, cxLookAndFeels, dxLayoutControl,
|
||
cxLookAndFeelPainters, cxGridCustomView, Buttons, cxDropDownEdit;
|
||
|
||
// procedure createFindLayout(dxLayoutControl1: TdxLayoutControl; ADOTmp: TADOQuery; mdesignCode: string);
|
||
procedure CreateCxGridColumn(tv1: TcxGridDBTableView;
|
||
ADOQueryTmp: TADOQuery; pdesignCode: PWideChar);
|
||
// stdcall;external 'rtCommon.dll' Name 'CreateCxGridColumn_A';
|
||
//procedure CreateCxGridColumn_A(application: TApplication;
|
||
// tv1: TcxGridDBTableView; ADOQueryTmp: TADOQuery; mdesignCode: string);
|
||
// stdcall; external 'rtCommon.dll';
|
||
procedure ShowCxGridDesign(application: TApplication;
|
||
mCxGridView: TcxGridDBTableView; client1: TClientDataSet; ADOCmd: TADOQuery;
|
||
mFormName: string; mGridName: string; mDllName: string;mFormId: integer; mGridType: integer = 0;mProcedureName: string='');
|
||
//function SaveGridSetInfoToBase(mCxGridView: TcxGridDBTableView;
|
||
// ADOCmd: TADOQuery; designCode: PWideChar): Boolean; stdcall;
|
||
// external 'rtCommon.dll' Name 'SaveGridSetInfoToBase_A';
|
||
//
|
||
function checkColumnMustIn(app: TApplication; tv1: TcxGridDBTableView;
|
||
mFlag: integer): Boolean;
|
||
// stdcall;external 'rtCommon.dll' Name 'checkColumnMustIn_A';
|
||
function checkColumnMustIn_A(app: TApplication; tv1: TcxGridDBTableView;
|
||
client1: TClientDataSet; mFlag: integer): Boolean;
|
||
procedure getColumnRelation(tv1: TcxGridDBTableView; client1: TClientDataSet);
|
||
function SaveGridSetInfoToBase(mCxGridView: TcxGridDBTableView; client1:TClientDataSet;
|
||
ADOCmd: TADOQuery; designCode: string): Boolean;
|
||
implementation
|
||
|
||
uses
|
||
U_globalVar;
|
||
|
||
/// ////////////////////////////////////////////////////////////////
|
||
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>
|
||
// 0: mGridType <20><>ѯ; 1:<3A><><EFBFBD><EFBFBD>
|
||
/// /////////////////////////////////////////////////////////////////
|
||
// procedure ShowCxGridDesign(mCxGridView: TcxGridDBTableView; ADOCmd: TADOQuery;
|
||
// mFormName: string; mGridName: string; mDllName: string; mFormId: integer;
|
||
// mGridType: integer = 0);
|
||
// type
|
||
// TMyFunc = function(App: Tapplication; FormH: hwnd; FormID: integer;
|
||
// UID: String; UName: String; dataBase: string; Title: string; Def1: string;
|
||
// Def2: string): hwnd; stdcall;
|
||
// var
|
||
// Tf: TMyFunc;
|
||
// Tp: TFarProc;
|
||
// Th: Thandle;
|
||
// newh: hwnd;
|
||
// mdesignCode: string;
|
||
// begin
|
||
//
|
||
// /// ////////////////////////////////////
|
||
// // Ȩ<><EFBFBD><DEBF><EFBFBD>
|
||
// with ADOCmd do
|
||
// begin
|
||
// close;
|
||
// sql.Clear;
|
||
// filtered := false;
|
||
// sql.Add('select count(*) as cnt');
|
||
// sql.Add('from sy_user A');
|
||
// sql.Add('where userid=' + quotedStr(gUserId));
|
||
// sql.Add('and valid=''Y''');
|
||
// sql.Add('and candesign=1');
|
||
// open;
|
||
// if fieldByName('cnt').AsInteger <= 0 then
|
||
// begin
|
||
// close;
|
||
// // exit;
|
||
// end;
|
||
// close;
|
||
//
|
||
// mdesignCode := mDllName +mFormName+ '|' + intTostr(mFormId) + '|' + mGridName;
|
||
//
|
||
// /// ////////////////////////////////////////
|
||
// // <20><><EFBFBD>浱ǰ<E6B5B1>ؼ<EFBFBD><D8BC><EFBFBD>Ϣ
|
||
// if not SaveGridSetInfoToBase(mCxGridView, ADOCmd, mdesignCode) then
|
||
// begin
|
||
// exit;
|
||
// end;
|
||
// end;
|
||
//
|
||
// /// ////////////////////////////////////////
|
||
// //
|
||
// 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(gUserId), PChar(gUserName),
|
||
// PChar(DConString), PChar('<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();
|
||
// end;
|
||
// end
|
||
// else
|
||
// begin
|
||
// ShowMessage('<27>Ҳ<EFBFBD><D2B2><EFBFBD>rtDesign.dll');
|
||
// end;
|
||
// // CreateCxGridColumn(mCxGridView,ADOCmd,mwinCode,mFormName,mGridName);
|
||
//
|
||
// CreateCxGridColumn(mCxGridView, ADOCmd, mdesignCode);
|
||
//
|
||
// end;
|
||
|
||
/// ////////////////////////////////////////////////////////////////////
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||
/// ///////////////////////////////////////////////////////////////////////
|
||
// function SaveGridSetInfoToBase(mCxGridView: TcxGridDBTableView;
|
||
// ADOCmd: TADOQuery; designCode: string): Boolean;
|
||
// var
|
||
// i: integer;
|
||
// mfieldName: string;
|
||
// begin
|
||
// result := false;
|
||
//
|
||
// try
|
||
// with ADOCmd do
|
||
// begin
|
||
// close;
|
||
// sql.Clear;
|
||
// sql.Add('select * from SD_FormGrid_Design');
|
||
// sql.Add('where designCode=' + quotedStr(designCode));
|
||
// open;
|
||
//
|
||
// for i := mCxGridView.ColumnCount - 1 downto 0 do
|
||
// begin
|
||
// mfieldName := TcxGridDBColumn(mCxGridView.Columns[i])
|
||
// .DataBinding.FieldName;
|
||
//
|
||
// if locate('fieldName', mfieldName, []) then
|
||
// begin
|
||
// // Edit ;
|
||
// continue;
|
||
// end
|
||
// else
|
||
// begin
|
||
//
|
||
// Append;
|
||
// fieldByName('designCode').value := designCode;
|
||
//
|
||
// fieldByName('ColumnName').value := mCxGridView.Columns[i].Name;
|
||
// fieldByName('oldCaption').value := mCxGridView.Columns[i].Caption;
|
||
// fieldByName('ColumnLock').value := 0;
|
||
// fieldByName('ColumnHide').value := mCxGridView.Columns[i].Hidden;
|
||
// fieldByName('ColumnOrder').value := mCxGridView.Columns[i].SortOrder;
|
||
// fieldByName('Visible').value := mCxGridView.Columns[i].Visible;
|
||
//
|
||
// fieldByName('Valid').value := 1;
|
||
// end;
|
||
//
|
||
// 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);
|
||
//
|
||
// if mCxGridView.Columns[i].FixedKind = fkLeftDynamic then
|
||
// begin
|
||
// fieldByName('fixColumn').value := True;
|
||
// end
|
||
// else
|
||
// begin
|
||
// fieldByName('fixColumn').value := false;
|
||
// end;
|
||
//
|
||
// fieldByName('Width').value := mCxGridView.Columns[i].Width;
|
||
//
|
||
// if mCxGridView.Columns[i].Tag=9 then
|
||
// begin
|
||
// fieldByName('mustIn').value := true;
|
||
// end
|
||
// else
|
||
// begin
|
||
// fieldByName('mustIn').value := false;
|
||
// end;
|
||
// fieldByName('IsOrder').value := 1;
|
||
//
|
||
// Post;
|
||
// end;
|
||
//
|
||
// 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(designCode));
|
||
// sql.Add('and fieldName=' + quotedStr(mfieldName));
|
||
// open;
|
||
// if RecordCount <= 0 then
|
||
// begin
|
||
// Append;
|
||
// fieldByName('designcode').value := designCode;
|
||
// fieldByName('fieldName').value := mfieldName;
|
||
// 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;
|
||
// end;
|
||
// end;
|
||
// result := True;
|
||
// except
|
||
// Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʱ<CFA2><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
// end;
|
||
// end;
|
||
|
||
//
|
||
/// ////////////////////////////////////////////////////////
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>CxGrid<69><64>
|
||
/// ////////////////////////////////////////////////////////
|
||
procedure CreateCxGridColumn( tv1: TcxGridDBTableView;
|
||
ADOQueryTmp: TADOQuery; pdesignCode: PWideChar);
|
||
var
|
||
ADBColumn: TcxGridDBColumn;
|
||
strField, strCaption: string;
|
||
mColumnName: string;
|
||
mCalcWidth: integer;
|
||
mWidth: integer;
|
||
mAvgWidth, mGridWidth: integer;
|
||
HeaderStyle: TcxStyle;
|
||
footsumitem:tcxdatasummaryitem;
|
||
mdesignCode:string;
|
||
begin mWidth := 12;
|
||
mGridWidth := TcxGrid(TcxGridLevel(tv1.level).Control).Width;
|
||
mdesignCode:=pdesignCode ;
|
||
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));
|
||
open;
|
||
if IsEmpty then
|
||
exit;
|
||
end;
|
||
try
|
||
|
||
HeaderStyle := TcxStyle.Create(nil);
|
||
// HeaderStyle.Font := TcxGrid(TcxGridLevel(tv1.level).Control).Font;
|
||
HeaderStyle.TextColor := clBlue;
|
||
tv1.BeginUpdate;
|
||
|
||
// CreateCxGridColumn_A(application,tv1,ADOQueryTmp,mdesignCode);
|
||
|
||
with ADOQueryTmp do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if trim(fieldByName('fieldName').AsString)='' then
|
||
begin
|
||
Next;
|
||
continue;
|
||
end;
|
||
ADBColumn := tv1.GetColumnByFieldName
|
||
(trim(ADOQueryTmp.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(ADOQueryTmp.fieldByName('fieldName').AsString);
|
||
|
||
if fieldByName('fixColumn').AsBoolean then
|
||
begin
|
||
ADBColumn.FixedKind := fkLeftDynamic;
|
||
end
|
||
else begin ADBColumn.FixedKind := fkNone;
|
||
end;
|
||
if fieldByName('mustIn').AsBoolean then
|
||
begin
|
||
ADBColumn.Tag := 9;
|
||
end;
|
||
if ADBColumn.Tag = 9 then
|
||
ADBColumn.Styles.Header := HeaderStyle;
|
||
ADBColumn.Hidden := fieldByName('ColumnHide').AsBoolean;
|
||
if ADBColumn.Hidden then begin ADBColumn.Visible := false;
|
||
end
|
||
else begin ADBColumn.Visible := fieldByName('Visible').AsBoolean;
|
||
end;
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
///
|
||
if (trim(ADOQueryTmp.fieldByName('FooterType').AsString)<>'') and (ADBColumn.Summary.FooterKind=skNone) then
|
||
begin
|
||
footsumitem:=tv1.DataController.Summary.FooterSummaryItems.Add;
|
||
footsumitem.ItemLink:= ADBColumn ;
|
||
if (trim(fieldByName('FooterType').AsString)='sum') or (trim(fieldByName('FooterType').AsString)='<27>ϼ<EFBFBD>') then
|
||
begin
|
||
footsumitem.Kind:=skSum;
|
||
end;
|
||
if (trim(fieldByName('FooterType').AsString)='count')or (trim(fieldByName('FooterType').AsString)='С<><D0A1>') then
|
||
begin
|
||
footsumitem.Kind:=skCount;
|
||
end;
|
||
// footsumitem.Format:='#';
|
||
footsumitem.Position:=spFooter;
|
||
end
|
||
else
|
||
begin
|
||
// ADBColumn.Summary.FooterKind:=skNone ;
|
||
end;
|
||
ADBColumn.Caption := trim(fieldByName('caption').AsString);
|
||
|
||
Next;
|
||
continue;
|
||
end;
|
||
//
|
||
if not fieldByName('valid').AsBoolean then
|
||
begin
|
||
ADOQueryTmp.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
|
||
ADOQueryTmp.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>
|
||
|
||
ADBColumn.Width := fieldByName('width').AsInteger;
|
||
if fieldByName('fixColumn').AsBoolean then
|
||
begin
|
||
ADBColumn.FixedKind := fkLeftDynamic;
|
||
end;
|
||
//
|
||
if fieldByName('mustIn').AsBoolean then
|
||
begin
|
||
ADBColumn.Tag := 9;
|
||
end;
|
||
ADBColumn.Visible := fieldByName('visible').AsBoolean;
|
||
// ADBColumn.Hidden := fieldByName('ColumnHide').AsBoolean;
|
||
ADBColumn.HeaderAlignmentHorz := taCenter;
|
||
// ADBColumn.MinWidth := 50;
|
||
ADBColumn.Name := mColumnName;
|
||
|
||
ADBColumn.Options.Editing := not fieldByName('ReadOnly').AsBoolean;
|
||
ADBColumn.Options.Focusing := not fieldByName('ReadOnly').AsBoolean;
|
||
/// /////////////
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
///
|
||
if (trim(ADOQueryTmp.fieldByName('FooterType').AsString)<>'') then
|
||
begin
|
||
footsumitem:=tv1.DataController.Summary.FooterSummaryItems.Add;
|
||
footsumitem.ItemLink:= ADBColumn ;
|
||
if (trim(fieldByName('FooterType').AsString)='sum') or (trim(fieldByName('FooterType').AsString)='<27>ϼ<EFBFBD>') then
|
||
begin
|
||
footsumitem.Kind:=skSum;
|
||
end;
|
||
if (trim(fieldByName('FooterType').AsString)='count') or (trim(fieldByName('FooterType').AsString)='С<><D0A1>') then
|
||
begin
|
||
footsumitem.Kind:=skCount;
|
||
end;
|
||
// footsumitem.Format:='#';
|
||
footsumitem.Position:=spFooter;
|
||
|
||
end;
|
||
|
||
|
||
ADOQueryTmp.Next;
|
||
|
||
end;
|
||
|
||
close;
|
||
end;
|
||
finally
|
||
|
||
tv1.EndUpdate;
|
||
end;
|
||
end;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯloyout
|
||
// procedure createFindLayout(dxLayoutControl1: TdxLayoutControl;
|
||
// ADOTmp: TADOQuery; mdesignCode: string);
|
||
// var
|
||
// LayoutItem: TdxLayoutItem;
|
||
// cxTextEdit: TcxTextEdit;
|
||
// i: integer;
|
||
// begin
|
||
// with ADOTmp 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.columnQuery=1 or A.ColumnFilter=1)');
|
||
// sql.Add('and A.valid=1');
|
||
// open;
|
||
//
|
||
// while not Eof do
|
||
// begin
|
||
// cxTextEdit := TcxTextEdit.Create(nil);
|
||
// cxTextEdit.Name := trim(fieldByName('fieldName').AsString);
|
||
// cxTextEdit.Text := '';
|
||
// cxTextEdit.Tag := 2;
|
||
//
|
||
// if (dxLayoutControl1.FindComponent('layitem' +
|
||
// trim(fieldByName('fieldName').AsString)) = nil) and
|
||
// (dxLayoutControl1.FindItem(cxTextEdit) = nil) then
|
||
// begin
|
||
// LayoutItem := dxLayoutControl1.CreateItemForControl(cxTextEdit, nil);
|
||
// LayoutItem.Name := 'layitem' + trim(fieldByName('fieldName').AsString);
|
||
// LayoutItem.CaptionOptions.Text := trim(fieldByName('caption').AsString);
|
||
// LayoutItem.Control := cxTextEdit;
|
||
//
|
||
// LayoutItem.SizeOptions.SizableHorz := True;
|
||
// LayoutItem.SizeOptions.SizableVert := True;
|
||
// end;
|
||
// Next;
|
||
// end;
|
||
//
|
||
// end;
|
||
// end;
|
||
|
||
//
|
||
function checkColumnMustIn(app: TApplication; tv1: TcxGridDBTableView;
|
||
mFlag: integer): Boolean;
|
||
var
|
||
i: integer;
|
||
client1: TClientDataSet;
|
||
begin client1 := TClientDataSet.Create(nil);
|
||
try
|
||
client1.FieldDefs.Add('fieldName', ftString, 100);
|
||
client1.FieldDefs.Add('caption', ftString, 100);
|
||
client1.FieldDefs.Add('ValueType', ftString, 100);
|
||
client1.FieldDefs.Add('fieldValue', ftString, 100);
|
||
client1.CreateDataSet;
|
||
getColumnRelation(tv1, client1);
|
||
Result := checkColumnMustIn_A(app, tv1, client1, mFlag);
|
||
|
||
finally
|
||
client1.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
/// //////////////////////////////////////////////////////////////
|
||
///
|
||
procedure getColumnRelation(tv1: TcxGridDBTableView; client1: TClientDataSet);
|
||
var
|
||
i: integer;
|
||
begin
|
||
|
||
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;
|
||
end;
|
||
|
||
end;
|
||
//////////////////////////////////////////////////
|
||
/// //
|
||
function checkColumnMustIn_A(app:TApplication;tv1: TcxGridDBTableView;client1:TClientDataSet; mFlag: integer): Boolean;
|
||
var
|
||
i: integer;
|
||
mfieldName:string;
|
||
begin
|
||
result:=false;
|
||
for i := 0 to tv1.ColumnCount-1 do
|
||
begin
|
||
// ADBColumn :=TcxGridDBColumn( tv1.Columns[i] );
|
||
if tv1.Columns[i].Tag = mFlag then
|
||
begin
|
||
with tv1.DataController.DataSet do //
|
||
begin
|
||
if not client1.Locate('caption',tv1.Columns[i].Caption,[]) then Continue;
|
||
mfieldName :=trim( client1.FieldByName('fieldName').AsString);
|
||
if locate( mfieldName, null, []) or locate( mfieldName, '', []) then
|
||
begin
|
||
Application.MessageBox(PChar(tv1.Columns[i].Caption + '<27><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!'), '<27><>ʾ', 0);
|
||
exit;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
result:=true;
|
||
end;
|
||
|
||
///////////////////////////////////
|
||
|
||
|
||
|
||
//////////////////////////////////////////////////
|
||
/// /// ////////////////////////////////////////////////////////////////////
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||
/// ///////////////////////////////////////////////////////////////////////
|
||
function SaveGridSetInfoToBase(mCxGridView: TcxGridDBTableView; client1:TClientDataSet;
|
||
ADOCmd: TADOQuery; designCode: string): Boolean;
|
||
var
|
||
i: integer;
|
||
mfieldName: string;
|
||
begin
|
||
result := false;
|
||
|
||
try
|
||
|
||
ADOCmd.close;
|
||
// ADOCmd.LockType := ltBatchOptimistic;
|
||
with ADOCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from SD_FormGrid_Design');
|
||
sql.Add('where designCode=' + quotedStr(designCode));
|
||
open;
|
||
|
||
for i := mCxGridView.ColumnCount - 1 downto 0 do
|
||
begin
|
||
if not client1.Locate('caption',mCxGridView.Columns[i].Caption,[]) then Continue;
|
||
mfieldName :=trim( client1.FieldByName('fieldName').AsString);
|
||
|
||
if locate('fieldName', mfieldName, []) then
|
||
begin
|
||
continue;
|
||
end
|
||
else
|
||
begin
|
||
|
||
Append;
|
||
fieldByName('designCode').value := designCode;
|
||
|
||
fieldByName('ColumnName').value := mCxGridView.Columns[i].Name;
|
||
fieldByName('oldCaption').value := mCxGridView.Columns[i].Caption;
|
||
fieldByName('ColumnLock').value := 0;
|
||
fieldByName('ColumnHide').value := mCxGridView.Columns[i].Hidden;
|
||
fieldByName('ColumnOrder').value := mCxGridView.Columns[i].SortOrder;
|
||
fieldByName('Visible').value := mCxGridView.Columns[i].Visible;
|
||
|
||
fieldByName('Valid').value := 1;
|
||
end;
|
||
|
||
fieldByName('FieldName').value :=mfieldName;
|
||
fieldByName('Caption').value := mCxGridView.Columns[i].Caption;
|
||
fieldByName('ColumnType').value :=trim( client1.FieldByName('valueType').AsString);
|
||
|
||
if mCxGridView.Columns[i].FixedKind = fkLeftDynamic then
|
||
begin
|
||
fieldByName('fixColumn').value := True;
|
||
end
|
||
else
|
||
begin
|
||
fieldByName('fixColumn').value := false;
|
||
end;
|
||
|
||
fieldByName('Width').value := mCxGridView.Columns[i].Width;
|
||
|
||
if mCxGridView.Columns[i].Tag=9 then
|
||
begin
|
||
fieldByName('mustIn').value := true;
|
||
end
|
||
else
|
||
begin
|
||
fieldByName('mustIn').value := false;
|
||
end;
|
||
fieldByName('IsOrder').value := 1;
|
||
|
||
|
||
Post;
|
||
end;
|
||
|
||
end;
|
||
ADOCmd.UpdateBatch();
|
||
/// /////////////////////////////////////////////
|
||
//
|
||
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(designCode));
|
||
sql.Add('and fieldName=' + quotedStr(mfieldName));
|
||
open;
|
||
if RecordCount <= 0 then
|
||
begin
|
||
Append;
|
||
fieldByName('designcode').value := designCode;
|
||
fieldByName('fieldName').value := mfieldName;
|
||
fieldByName('Caption').value := 'δ<><CEB4><EFBFBD><EFBFBD>';
|
||
fieldByName('ColumnName').value := mCxGridView.Name + mfieldName;
|
||
if (mCxGridView.DataController.DataSet.Fields[i].DataType=ftString) or (mCxGridView.DataController.DataSet.Fields[i].DataType=ftWideString) then
|
||
fieldByName('ColumnType').value :='String'
|
||
else if (mCxGridView.DataController.DataSet.Fields[i].DataType=ftInteger) or (mCxGridView.DataController.DataSet.Fields[i].DataType=ftSmallInt) then
|
||
fieldByName('ColumnType').value :='Integer'
|
||
else if (mCxGridView.DataController.DataSet.Fields[i].DataType=ftFloat) or (mCxGridView.DataController.DataSet.Fields[i].DataType=ftBcd) then
|
||
fieldByName('ColumnType').value :='Float'
|
||
else if mCxGridView.DataController.DataSet.Fields[i].DataType=ftDateTime then
|
||
fieldByName('ColumnType').value :='DateTime'
|
||
else if mCxGridView.DataController.DataSet.Fields[i].DataType=ftBoolean then
|
||
fieldByName('ColumnType').value :='Boolean'
|
||
else
|
||
fieldByName('ColumnType').value :=TFieldType( mCxGridView.DataController.DataSet.Fields[i].DataType);
|
||
|
||
if fields.FindField('fieldValue')<>nil then
|
||
fieldByName('fieldValue').value :=mCxGridView.DataController.DataSet.Fields[i].Value;
|
||
fieldByName('Visible').value := false;
|
||
fieldByName('AddFlag').value := True;
|
||
fieldByName('Width').value := 60;
|
||
fieldByName('ColumnOrder').value := 99;
|
||
fieldByName('Valid').value := 0;
|
||
Post;
|
||
|
||
end
|
||
else
|
||
begin
|
||
edit;
|
||
if fields.FindField('fieldValue')<>nil then
|
||
fieldByName('fieldValue').value :=mCxGridView.DataController.DataSet.Fields[i].Value;
|
||
post;
|
||
end;
|
||
end;
|
||
end;
|
||
ADOCmd.UpdateBatch();
|
||
|
||
////////////////////////////////////////////
|
||
///<2F><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ
|
||
|
||
ADOCmd.close;
|
||
ADOCmd.LockType:=ltOptimistic ;
|
||
result := True;
|
||
except
|
||
ADOCmd.close;
|
||
ADOCmd.LockType:=ltOptimistic ;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʱ<CFA2><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
///////////////////////////
|
||
|
||
procedure ShowCxGridDesign(application: TApplication;
|
||
mCxGridView: TcxGridDBTableView; client1: TClientDataSet; ADOCmd: TADOQuery;
|
||
mFormName: string; mGridName: string; mDllName: string;mFormId: integer; mGridType: integer = 0;mProcedureName: string='');
|
||
type
|
||
TMyFunc = function(App: Tapplication; FormH: hwnd; FormID: integer;
|
||
UID: String; UName: String; dataBase: string; Title: string; Def1: string;
|
||
Def2: string): hwnd; stdcall;
|
||
var
|
||
Tf: TMyFunc;
|
||
Tp: TFarProc;
|
||
Th: Thandle;
|
||
newh: hwnd;
|
||
mdesignCode: string;
|
||
begin
|
||
|
||
mdesignCode := mDllName +'|'+mFormName+ '|' + intTostr(mFormId) + '|' + mGridName;
|
||
///////////////////
|
||
if mProcedureName<>'' then
|
||
begin
|
||
with ADOCmd 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('gridName').Value :=mGridName;
|
||
fieldByName('ProcedureParam').Value :='';
|
||
end
|
||
else
|
||
edit;
|
||
|
||
|
||
fieldByName('newProcedureName').Value :=trim(mProcedureName);
|
||
post;
|
||
|
||
end;
|
||
end;
|
||
/// ////////////////////////////////////////
|
||
// <20><><EFBFBD>浱ǰ<E6B5B1>ؼ<EFBFBD><D8BC><EFBFBD>Ϣ
|
||
if not SaveGridSetInfoToBase(mCxGridView,client1, ADOCmd, mdesignCode) then
|
||
begin
|
||
exit;
|
||
end;
|
||
|
||
|
||
/// ////////////////////////////////////////
|
||
//
|
||
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(gUserId), PChar(gUserName),
|
||
PChar(ADOCmd.Connection.ConnectionString), PChar('<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();
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
ShowMessage('<27>Ҳ<EFBFBD><D2B2><EFBFBD>rtDesign.dll');
|
||
end;
|
||
|
||
end;
|
||
end.
|