以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  窗口工具条 代码优化指导!谢谢!  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=139544)

--  作者:chen_sheng
--  发布时间:2019/8/15 11:36:00
--  窗口工具条 代码优化指导!谢谢!
初学狐表  代码只是考虑实现功能  结果发现代码臃肿不堪
有些理念请教
1、自定义窗口按钮工具条和权限配合如何优化
2、每个窗口打开执行这个工具条的代码有没有好的方式  譬如自定义函数 或者变量什么的  咋样实现最优 效率更高

Dim gxz As Boolean \'工具 新增
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "S ELECT 新增  FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gxz =cmd.ExecuteScalar()
If gxz = True Then
        e.Form.Controls("GFxz").Enabled= True
Else
        e.Form.Controls("GFxz").Enabled= False
End If

Dim gxg As Boolean \'工具 修改
cmd.CommandText = "S ELECT 修改 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gxg =cmd.ExecuteScalar()
If gxg = True Then
       e.Form.Controls("GFxg").Enabled= True
Else
      e.Form.Controls("GFxg").Enabled= False
End If

Dim gbc As Boolean \'工具 保存
cmd.CommandText = "S ELECT 保存 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gbc =cmd.ExecuteScalar()
If gbc = True Then
       e.Form.Controls("GFbc").Enabled= True
Else
       e.Form.Controls("GFbc").Enabled= False
End If
Dim gsx As Boolean \'工具 刷新
cmd.CommandText = "S ELECT 刷新 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gsx =cmd.ExecuteScalar()
If gsx = True Then
       e.Form.Controls("GFsx").Enabled= True
Else
   e.Form.Controls("GFsx").Enabled= False
End If
Dim gsc As Boolean \'工具 删除
cmd.CommandText = "S ELECT 删除 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gsc =cmd.ExecuteScalar()
If gsc = True Then
       e.Form.Controls("GFsc").Enabled= True
Else
       e.Form.Controls("GFsc").Enabled= False
End If
Dim gyl As Boolean \'工具 预览
cmd.CommandText = "S ELECT 打印 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gyl =cmd.ExecuteScalar()
If gsc = True Then
       e.Form.Controls("GFyl").Enabled= True
Else
       e.Form.Controls("GFyl").Enabled= False
End If
Dim gdy As Boolean \'工具 打印
cmd.CommandText = "S ELECT 打印 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gdy =cmd.ExecuteScalar()
If gdy = True Then
     e.Form.Controls("GFdy").Enabled= True
Else
    e.Form.Controls("GFdy").Enabled= False
End If
Dim gdc As Boolean \'工具 导出
cmd.CommandText = "S ELECT 导出 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gdc =cmd.ExecuteScalar()
If gsc = True Then
       e.Form.Controls("GFdc").Enabled= True
Else
       e.Form.Controls("GFdc").Enabled= False
End If
Dim gtj As Boolean \'工具 提交
cmd.CommandText = "S ELECT 提交 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gtj =cmd.ExecuteScalar()
If gtj = True Then
     e.Form.Controls("GFtj").Enabled= True
Else
    e.Form.Controls("GFtj").Enabled= False
End If
Dim gsh As Boolean \'工具 审核
cmd.CommandText = "S ELECT 审核 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gsh =cmd.ExecuteScalar()
If gtj = True Then
     e.Form.Controls("GFsh").Enabled= True
Else
    e.Form.Controls("GFsh").Enabled= False
End If
Dim gja As Boolean \'工具 结案
cmd.CommandText = "S ELECT 结案 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gja =cmd.ExecuteScalar()
If gja = True Then
     e.Form.Controls("GFja").Enabled= True
Else
    e.Form.Controls("GFja").Enabled= False
End If
Dim gft As Boolean \'工具 反提
cmd.CommandText = "S ELECT 反提 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gft =cmd.ExecuteScalar()
If gft = True Then
     e.Form.Controls("GFft").Enabled= True
Else
    e.Form.Controls("GFft").Enabled= False
End If
Dim gfs As Boolean \'工具 反审
cmd.CommandText = "S ELECT 反审 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gfs =cmd.ExecuteScalar()
If gfs = True Then
     e.Form.Controls("GFfs").Enabled= True
Else
    e.Form.Controls("GFfs").Enabled= False
End If
Dim gcq As Boolean \'工具 重启
cmd.CommandText = "S ELECT 重启 FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
gcq =cmd.ExecuteScalar()
If gcq = True Then
     e.Form.Controls("GFcq").Enabled= True
Else
    e.Form.Controls("GFcq").Enabled= False
End If

--  作者:chen_sheng
--  发布时间:2019/8/15 11:46:00
--  
工具条样板请见下图
图片点击可在新窗口打开查看此主题相关图片如下:工具条窗口.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2019/8/15 11:58:00
--  
比如

cmd.CommandText = "SELECT 新增,修改  FROM [test].[dbo].[userqx] where [账号]= \'" & User.name & "\' and [窗体名称]= \'" & e.Form.Name & "\'  "
Dim dt As DataTable =cmd.ExecuteReader()
If dt.DataRows.Count > 0 Then
    Dim dr As DataRow = dt.DataRows(0)
    e.Form.Controls("GFxz").Enabled= dr("新增")
    e.Form.Controls("GFxg").Enabled= dr("修改")
    Return
End If
e.Form.Controls("GFxz").Enabled= False
e.Form.Controls("GFxg").Enabled= False


--  作者:有点蓝
--  发布时间:2019/8/15 12:00:00
--  
如果把控件名称设置的有规律一点,和列名对应起来,比如GFxz改为GF_新增,GFxg改为GF_修改

还可以

If dt.DataRows.Count > 0 Then
    Dim dr As DataRow = dt.DataRows(0)
    For Each dc As DataCol In dt.DataCols
        e.Form.Controls("GF_" & dc.Name).Enabled= dr(dc.Name)
    Next
    Return
End If

--  作者:chen_sheng
--  发布时间:2019/8/15 13:39:00
--  
非常感谢 

代码指导学会了  现在是每个窗口打开执行这个工具条的代码有没有好的方式  譬如自定义函数 或者变量什么的  咋样实现最优 效率更高

目前都是复杂臃肿的方式实现  渴望更加简洁的实现方式  谢谢!

狐表内如何实现类似下图  登录就获取了权限信息  打开窗口如何和窗体工具条按钮进行关联呢  这样是不是效率更高呢


图片点击可在新窗口打开查看此主题相关图片如下:权限设计.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2019/8/15 13:48:00
--  
没有办法使用这种用法
--  作者:chen_sheng
--  发布时间:2019/8/15 13:52:00
--  
如何把表标题颜色跟窗体颜色风格一样你   看起来感受差点

想改颜色部分具体见下图箭头指示

图片点击可在新窗口打开查看此主题相关图片如下:表颜色.png
图片点击可在新窗口打开查看


--  作者:chen_sheng
--  发布时间:2019/8/15 13:54:00
--  
或者就实现这个风格的界面

图片点击可在新窗口打开查看此主题相关图片如下:操作日志设计.png
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2019/8/15 13:55:00
--  
参考:http://www.foxtable.com/webhelp/topics/2065.htm


--  作者:chen_sheng
--  发布时间:2019/8/15 14:03:00
--  
假如想实现上图的配色  如何处理  开发的整个项目都想用这样类似的配色  感谢指导!