Delphi实现ERP单据列表栏目设置
什么都不用说了,ERP你懂的。一张报表,不同的客户都可以调死你。直接上图
通过这个设置界面,直接生成参数调整报表所用的DBGridEh。对,是DBGridEh,不是DBGrid,也不是CXGrid。
然后再将这些参数生成一个JSON,保存到数据库。下次打开,直接取这个JSON就可以了。这样,客户可以根据自己的需要调整自己的报表。
unit uGridDes; interface uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,DbGridEh, DBGridEhGrouping, ToolCtrlsEh,
DBGridEhToolCtrls, DynVarsEh, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf,
FireDAC.DApt.Intf, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client,
EhLibVCL, GridsEh, DBAxisGridsEh,QJson, Vcl.ComCtrls, Vcl.ToolWin; type
RGridIndex=record
cFileName:String;
cTitle:String;
cDefTitle:String;
iWidth:Integer;
bVisible:Boolean;
end;
TFrmGridDes = class(TForm)
FDMem: TFDMemTable;
DataSource1: TDataSource;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
StatusBar1: TStatusBar;
DBGridEh1: TDBGridEh;
procedure FormShow(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure DBGridEh1CellClick(Column: TColumnEh);
procedure ToolButton4Click(Sender: TObject);
private
// function JsonLoadGrid: TQJson;
{ Private declarations }
public
FDBGridEh:TDBGridEh;
FJson:TQJson;
function UPDateJson:TQJson;
function GetJsonFromGrid:TQJson;
function UPDateGrid:Boolean;
Function TryParsetojson(Text:String):Boolean;
class Function SetGridasJson(FDBGrid:TDBGridEh;Ajson:TQjson):TQJson;
{ Public declarations }
end; var
FrmGridDes: TFrmGridDes; implementation {$R *.dfm} procedure TFrmGridDes.DBGridEh1CellClick(Column: TColumnEh);
begin
// if then
if DBGridEh1.ReadOnly=False And (Column.FieldName<>'cFieldName') then
DBGridEh1.EditorMode:=True; end; procedure TFrmGridDes.FormCreate(Sender: TObject);
begin
FJson:=TQJson.Create;
FDMem.CreateDataSet;
end; procedure TFrmGridDes.FormShow(Sender: TObject);
var
I:integer;
begin Self.Left:=(Screen.Width-Self.Width) div 2;
Self.Top:=(Screen.Height-Self.Height)div 2;
DBGridEh1.ReadOnly:=True;
DBGridEh1.Options:=DBGridEh1.Options-[dgEditing]+[dgRowSelect];
FDMem.Close;
FDMem.CreateDataSet;
// if FJson.Count=0 then for I := 0 to FDBGridEh.Columns.Count-1 do
FDMem.AppendRecord([I,FDBGridEh.Columns[i].FieldName,FDBGridEh.Columns[i].Title.Caption,
FDBGridEh.Columns[i].Title.Caption,FDBGridEh.Columns[i].Width,FDBGridEh.Columns[i].Visible]); FDMem.First; end; function TFrmGridDes.GetJsonFromGrid: TQJson;
Var
I:integer;
begin
Result:=nil;
FDMem.DisableControls;
FDMem.Table.Clear;
for I := 0 to FDBGridEh.Columns.Count-1 do
FDMem.AppendRecord([I,FDBGridEh.Columns[i].FieldName,FDBGridEh.Columns[i].Title.Caption,
FDBGridEh.Columns[i].Title.Caption,FDBGridEh.Columns[i].Width,FDBGridEh.Columns[i].Visible]);
UPDateJson;
FDMem.First;
FDMem.EnableControls;
Result:=Fjson;
end; function TFrmGridDes.UPDateGrid:Boolean;
Var
ItemJson:TQJson;
I:integer;
begin
Result:=False;
if Fjson.Count=0 then Exit; Try for I := 0 to FJson.Count-1 do
begin
ItemJson:=FJson.ItemByName(IntToStr(I));
With FDBGridEh.Columns[i] do// else
begin
if FieldName<>ItemJson.ValueByName('cFieldName','') then
FieldName:=ItemJson.ValueByName('cFieldName','');
if Width<>StrTOInt(ItemJson.ValueByName('iWidth','64')) then
Width:=StrTOInt(ItemJson.ValueByName('iWidth','64'));
if Title.Caption<>ItemJson.ValueByName('cDefTitle','1') then
Title.Caption:=ItemJson.ValueByName('cDefTitle','1');
if Visible<>StrToBool(ItemJson.ValueByName('bVisible','2')) then
Visible:=StrToBool(ItemJson.ValueByName('bVisible','2'));
end;
// ItemJson.Free;
end;
except
Exit(False);
End; Result:=True; end; function TFrmGridDes.UPDateJson: TQJson;
Var
ItemJson:TQJson;
str:string;
begin
FJson.Clear;
FDMem.DisableControls;
FDMem.First;
while Not FDMem.Eof do
begin
ItemJson:=TQJson.Create;
for Str in FDMem.FieldList do
ItemJson.Add(Str,FDMem.FieldByName(Str).AsString);
FJson.Add(IntToStr(FDMem.FieldByName('iRow').AsInteger),ItemJson);
FDMem.Next;
end;
FDMem.First;
FDMem.EnableControls;
Result:=FJson;
end; class function TFrmGridDes.SetGridasJson(FDBGrid: TDBGridEh;
Ajson: TQjson): TQJson;
begin
if FrmGridDes=nil then
FrmGridDes:=TFrmGridDes.Create(nil);
FrmGridDes.FDBGridEh:=FDBGrid; FrmGridDes.UPDateGrid;
FrmGridDes.ShowModal;
FrmGridDes.UPDateGrid;
Result:=TQJson.Create;
Result.Assign(FrmGridDes.fJson); end; procedure TFrmGridDes.ToolButton1Click(Sender: TObject);
begin DBGridEh1.ReadOnly:=False;
DBGridEh1.Options:=DBGridEh1.Options+[dgediting]-[dgRowSelect];
ToolButton2.Enabled:=True;
ToolButton1.Enabled:=False;
ToolButton5.Enabled:=True;
ToolButton6.Enabled:=True;
ToolButton4.Enabled:=True;
end; procedure TFrmGridDes.ToolButton2Click(Sender: TObject);
begin
FDMem.Edit;
FDMem.Post;
DBGridEh1.ReadOnly:=True;
UPDateJson;
DBGridEh1.Options:=DBGridEh1.Options-[dgediting]+[dgRowSelect];
ToolButton1.Enabled:=True;
ToolButton2.Enabled:=False;
ToolButton4.Enabled:=False;
ToolButton5.Enabled:=False;
ToolButton6.Enabled:=False;
end; procedure TFrmGridDes.ToolButton3Click(Sender: TObject);
begin
if ToolButton2.Enabled then
begin
ShowMessage('栏目设置未保存,不能退出');
Exit;
end; Close;
end; procedure TFrmGridDes.ToolButton4Click(Sender: TObject);
begin
FDMem.Edit;
FDMem.Post;
DBGridEh1.ReadOnly:=True;
GetJsonFromGrid;
DBGridEh1.Options:=DBGridEh1.Options-[dgediting]+[dgRowSelect];
ToolButton1.Enabled:=True;
ToolButton2.Enabled:=False;
ToolButton4.Enabled:=False;
ToolButton5.Enabled:=False;
ToolButton6.Enabled:=False;
end; procedure TFrmGridDes.ToolButton5Click(Sender: TObject); Var
R1,R2:RGridIndex;
begin
if FDMem.Bof then exit; FDMem.DisableControls;
R1.cFileName:=FDMem.FieldByName('cFieldName').AsString;
R1.cTitle:=FDMem.FieldByName('cTitle').AsString;
R1.cDefTitle:=FDMem.FieldByName('cDefTitle').AsString;
R1.iWidth:=FDMem.FieldByName('iWidth').AsInteger;
R1.bVisible:=FDMem.FieldByName('bVisible').AsBoolean; FDMem.Prior; R2.cFileName:=FDMem.FieldByName('cFieldName').AsString;
R2.cTitle:=FDMem.FieldByName('cTitle').AsString;
R2.cDefTitle:=FDMem.FieldByName('cDefTitle').AsString;
R2.iWidth:=FDMem.FieldByName('iWidth').AsInteger;
R2.bVisible:=FDMem.FieldByName('bVisible').AsBoolean;
FDMem.Edit;
FDMem.FieldByName('cFieldName').AsString:=R1.cFileName;
FDMem.FieldByName('ctitle').AsString:=R1.cTitle;
FDMem.FieldByName('cDeftitle').AsString:=R1.cDefTitle;
FDMem.FieldByName('iWidth').AsInteger:=r1.iWidth;
FDMem.FieldByName('bVisible').AsBoolean:=R1.bVisible;
FDMem.Next;
FDMem.Edit;
FDMem.FieldByName('cFieldName').AsString:=R2.cFileName;
FDMem.FieldByName('ctitle').AsString:=R2.cTitle;
FDMem.FieldByName('cDeftitle').AsString:=R2.cDefTitle;
FDMem.FieldByName('iWidth').AsInteger:=r2.iWidth;
FDMem.FieldByName('bVisible').AsBoolean:=R2.bVisible;
FDMem.Prior;
FDMem.EnableControls; end; procedure TFrmGridDes.ToolButton6Click(Sender: TObject);
Var
R1,R2:RGridIndex;
begin
if FDMem.Eof then Exit; FDMem.DisableControls;
R1.cFileName:=FDMem.FieldByName('cFieldName').AsString;
R1.cTitle:=FDMem.FieldByName('cTitle').AsString;
R1.cDefTitle:=FDMem.FieldByName('cDefTitle').AsString;
R1.iWidth:=FDMem.FieldByName('iWidth').AsInteger;
R1.bVisible:=FDMem.FieldByName('bVisible').AsBoolean; FDMem.Next; R2.cFileName:=FDMem.FieldByName('cFieldName').AsString;
R2.cTitle:=FDMem.FieldByName('cTitle').AsString;
R2.cDefTitle:=FDMem.FieldByName('cDefTitle').AsString;
R2.iWidth:=FDMem.FieldByName('iWidth').AsInteger;
R2.bVisible:=FDMem.FieldByName('bVisible').AsBoolean;
FDMem.Edit;
FDMem.FieldByName('cFieldName').AsString:=R1.cFileName;
FDMem.FieldByName('ctitle').AsString:=R1.cTitle;
FDMem.FieldByName('cDeftitle').AsString:=R1.cDefTitle;
FDMem.FieldByName('iWidth').AsInteger:=r1.iWidth;
FDMem.FieldByName('bVisible').AsBoolean:=R1.bVisible;
FDMem.Prior;
FDMem.Edit;
FDMem.FieldByName('cFieldName').AsString:=R2.cFileName;
FDMem.FieldByName('ctitle').AsString:=R2.cTitle;
FDMem.FieldByName('cDeftitle').AsString:=R2.cDefTitle;
FDMem.FieldByName('iWidth').AsInteger:=r2.iWidth;
FDMem.FieldByName('bVisible').AsBoolean:=R2.bVisible;
FDMem.Next;
FDMem.EnableControls; end; function TFrmGridDes.TryParsetojson(Text: String): Boolean;
begin
Result:=FJson.TryParse(Text);
end; end.
object FrmGridDes: TFrmGridDes
Left = 0
Top = 0
BorderIcons = []
BorderStyle = bsDialog
Caption = #35774#32622
ClientHeight = 416
ClientWidth = 425
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object ToolBar1: TToolBar
Left = 0
Top = 0
Width = 425
Height = 26
ButtonWidth = 31
Caption = 'ToolBar1'
DrawingStyle = dsGradient
EdgeBorders = [ebLeft, ebTop, ebRight]
EdgeInner = esNone
EdgeOuter = esNone
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
ShowCaptions = True
TabOrder = 0
object ToolButton1: TToolButton
Left = 0
Top = 0
Caption = #20462#25913
ImageIndex = 0
OnClick = ToolButton1Click
end
object ToolButton5: TToolButton
Left = 31
Top = 0
Caption = #21521#19978
Enabled = False
ImageIndex = 3
OnClick = ToolButton5Click
end
object ToolButton6: TToolButton
Left = 62
Top = 0
Caption = #21521#19979
Enabled = False
ImageIndex = 3
OnClick = ToolButton6Click
end
object ToolButton2: TToolButton
Left = 93
Top = 0
Caption = #20445#23384
Enabled = False
ImageIndex = 1
OnClick = ToolButton2Click
end
object ToolButton4: TToolButton
Left = 124
Top = 0
Caption = #25918#24323
Enabled = False
ImageIndex = 3
OnClick = ToolButton4Click
end
object ToolButton3: TToolButton
Left = 155
Top = 0
Caption = #36864#20986
ImageIndex = 2
OnClick = ToolButton3Click
end
end
object StatusBar1: TStatusBar
Left = 0
Top = 397
Width = 425
Height = 19
Panels = <
item
Text = #26639#30446#33258#23450#20041#35774#32622
Width = 50
end>
end
object DBGridEh1: TDBGridEh
Left = 0
Top = 26
Width = 425
Height = 371
Align = alClient
Color = 13816530
ColumnDefValues.Title.Alignment = taCenter
ColumnDefValues.Title.Color = clBtnShadow
DataGrouping.Color = clWindow
DataGrouping.ParentColor = False
DataSource = DataSource1
DynProps = <>
EvenRowColor = clScrollBar
GridLineParams.DataHorzLines = True
GridLineParams.DataVertLines = False
IndicatorOptions = [gioShowRowIndicatorEh]
BackgroundData.Visible = True
OddRowColor = clGradientActiveCaption
RowHeight = 23
RowPanel.Active = True
STFilter.Color = clActiveBorder
TabOrder = 2
TitleParams.Font.Charset = DEFAULT_CHARSET
TitleParams.Font.Color = clWindowText
TitleParams.Font.Height = 15
TitleParams.Font.Name = 'Tahoma'
TitleParams.Font.Style = [fsBold]
TitleParams.ParentFont = False
OnCellClick = DBGridEh1CellClick
Columns = <
item
Color = 11776947
DynProps = <>
EditButtons = <>
FieldName = 'cFieldName'
Footers = <>
ReadOnly = True
TextEditing = False
Title.Caption = #23383#27573
Title.Color = clGradientInactiveCaption
Width = 113
end
item
DynProps = <>
EditButtons = <>
FieldName = 'cTitle'
Footers = <>
ReadOnly = True
Title.Caption = #26631#39064
Visible = False
Width = 126
end
item
DynProps = <>
EditButtons = <>
FieldName = 'cDefTitle'
Footers = <>
Title.Caption = #33258#23450#20041#26631#39064
Width = 143
end
item
DynProps = <>
EditButtons = <>
FieldName = 'iWidth'
Footers = <>
Title.Caption = #23485#24230
end
item
DynProps = <>
EditButtons = <>
FieldName = 'bVisible'
Footers = <>
Title.Caption = #26174#31034
Width = 53
end
item
DynProps = <>
EditButtons = <>
FieldName = 'iRow'
Footers = <>
Visible = False
end>
object RowDetailData: TRowDetailPanelControlEh
end
end
object FDMem: TFDMemTable
FieldDefs = <
item
Name = 'iRow'
DataType = ftInteger
end
item
Name = 'cFieldName'
DataType = ftString
Size = 20
end
item
Name = 'cTitle'
DataType = ftString
Size = 50
end
item
Name = 'cDefTitle'
DataType = ftString
Size = 50
end
item
Name = 'iWidth'
DataType = ftFloat
end
item
Name = 'bVisible'
DataType = ftBoolean
end>
IndexDefs = <>
FetchOptions.AssignedValues = [evMode]
FetchOptions.Mode = fmAll
ResourceOptions.AssignedValues = [rvSilentMode]
ResourceOptions.SilentMode = True
UpdateOptions.AssignedValues = [uvCheckRequired, uvAutoCommitUpdates]
UpdateOptions.CheckRequired = False
UpdateOptions.AutoCommitUpdates = True
StoreDefs = True
Left = 152
Top = 144
end
object DataSource1: TDataSource
DataSet = FDMem
Left = 288
Top = 176
end
end
Delphi实现ERP单据列表栏目设置的更多相关文章
- 单据列表里无法找到ERP系统开发需求单,但是业务对象里可以找到
当从测试库迁移正式库时,如果新增了子系统,那么两边的子系统ID是不一样的 在BOS里修改单据的子系统只能修改业务对象列表里的子系统ID,单据列表里没有跟着一起修改 所以单据列表里的子系统ID需要手工去 ...
- 如何在dede栏目设置中添加自定义字段(dede二次开发-纯抄贴)
如何在dede栏目设置中添加自定义字段 这个说法以前没有见到到,很少有客户会提出这样的二次要求,今天织梦者在网上转了一下看到了这样的一篇文章转过来与大家分享 鉴于这个教程没人发过,网上搜索的人也比较多 ...
- Delphi XE7 Update1修正列表
Delphi XE7 Update1修正列表 官方下载地址:http://altd.embarcadero.com/download/radstudio/xe7/delphicbuilder_xe7_ ...
- delphi开发实例:保存字体设置的方法
http://blog.csdn.net/delphi308/article/details/9906147 delphi开发实例:保存字体设置的方法 2013-08-11 22:37 446人阅读 ...
- Delphi 常用API 函数列表
Delphi 常用API 函数 AdjustWindowRect 给定一种窗口样式,计算获得目标客户区矩形所需的窗口大小AnyPopup 判断屏幕上是否存在任何弹出式窗口ArrangeIconicWi ...
- 获取URL列表,设置代理请求URL,https的加密方式处理
做了一个测试的一个小工具,需求如下: 1.有一批URL列表,需要知道哪个URL请求响应内容中包含http:关键字的. 2.url请求包括http和https 2种协议 3.要部署在linux服务器上, ...
- WordPress默认栏目设置
WordPress是一个注重美学.易用性和网络标准的个人信息发布平台,是全球使用最多的博客系统,只需要在系统后台做一些简单的设计,基本就能实现我们日常个性化发布个人信息的需求,而博客后台的使用其实很简 ...
- IOS 特定于设备的开发:Info.plist属性列表的设置
应用程序的Info.plist属性列表使你能够在向iTunes提交应用程序时指定应用程序的要求.这些限制允许告诉iTunes应用程序需要哪些设备特性. 每个IOS单元都会提供一个独特的特性集.一些设备 ...
- delphi中获得进程列表或想要的进程(枚举进程、遍历进程)
一个常见的编程任务是枚举所有运行的"应用程序".Windows 任务管理器就是一个很好的例子.它用两种方式列出"应用程序".任务管理器的第一个选项卡列出桌面上的 ...
随机推荐
- 20155217 2016-2017-2 《Java程序设计》第10周学习总结
20155217 2016-2017-2 <Java程序设计>第10周学习总结 教材学习内容总结 网络编程 网络编程就是在两个或两个以上的设备(例如计算机)之间传输数据. 程序员所作的事情 ...
- 加分项——C语言实现Linux的pwd命令
加分项--C语言实现Linux的pwd命令 实现要求 1 学习pwd命令 2 研究pwd实现需要的系统调用(man -k; grep),写出伪代码 3 实现mypwd 4 测试mypwd pwd pw ...
- !important用法:
如果不加important特性,则超链接的颜色为蓝色,但是加上important之后优先级提高了,显示颜色为绿色 <style type="text/css"> a{ ...
- SIM_AT_Command
下面是GET请求 AT+HTTPPARA? 查询设置的Para命令 AT+SAPBR=1,1 (模块启动后设置一次即可)OK AT+HTTPINIT (初始化)OK AT+HTTPPARA=CONTE ...
- 使用idea写ssm的时候提示源文件夹中的文件找不到
<context:property-placeholder location="classpath:db.properties"/>这一行idea提示找不到db.pro ...
- 跟浩哥学自动化测试Selenium -- Selenium简介 (1)
Selenium 简介 Selenium 是一款开源的web自动化测试工具,用来模拟对浏览器的操作(主要是对页面元素的操作),简单来讲,其实就是一个jar包.Selenium早期的版本比如1.0市场占 ...
- Windows10 Oracle ODBC安装配置
项目紧迫,需在短时间内交付成果,新团队成员,吐嘈之前数据库设计太low,很难看懂数据库表结构间的关系,为了使新同事更好的了解数据库表结构,特意使用powerDesigner对oracle.mysql数 ...
- realstudio 粒子特效问题总结
ParticleEmitter._inner_material.flags.depth_write = true;ParticleEmitter._inner_material.flags.depth ...
- Python基础灬函数(定义,参数)
函数 函数定义 # 定义一个计算绝对值的函数 def cal_abs(x): if x >= 0: return x else: return -x # 调用函数 print('-1的绝对值是: ...
- Windows下使用WinRAR命令自动备份文件
最近有一个需求:为了防止数据丢失,每天对固定文件夹下的文件进行打包压缩备份. 解决办法:使用Windows的任务计划程序,每天执行一下压缩命令: Windows任务计划程序在这里就不再介绍了,网上有很 ...