菜单栏自定义按钮执行SQL脚本
功能说明:
在填报、修改、查阅模板时,顶部的菜单栏添加一个自定义按钮并在点击按钮时执行SQL语言脚本。
支持版本:
企业版7.0以上
效果:
- Imports SpreadsheetGear
- Imports C1.Silverlight
- Imports C1.Silverlight.C1MessageBoxButton
- Imports C1.Silverlight.C1MessageBoxIcon
- Imports Newtonsoft.Json
- Imports Newtonsoft.Json.Linq
- Imports System.Windows.forms
- Namespace ExcelViewVBDotnet
- Public Class StandardInterface
- '预留位置1
- '预留位置2
- Dim EV As SpreadsheetGear.Windows.Co**ols.WorkbookView,AW As SpreadsheetGear.IWorkbook,Range As SpreadsheetGear.IRange
- Dim CF As TextBox,VW As Object
- Dim TS As StackPanel
- Public Sub Workbook_Open(OldRoot As Object,NewRoot As Object,Excel As SpreadsheetGear.Windows.Co**ols.WorkbookView)
- EV = Excel
- Excel.GetLock()
- AW = Excel.ActiveWorkbook
- Range = AW.ActiveWorksheet.Range
- Excel.ReleaseLock()
- CF = CType(OldRoot.Children(1),TextBox)
- TS = CType(OldRoot.Children(5),StackPanel)
-
-
- Dim BT1 As New Button
- BT1.Name = "BT_RZ"
- BT1.Content = "写入日志"
- BT1.Margin= New Thickness(0, 2, 0, 2)
- BT1.Padding= New Thickness(13, 3, 13, 3)
- BT1.Style=CType(Application.Current.Resources("ButtonStyle3"),style)
- BT1.Foreground = CType(Application.Current.Resources("Foreground1"),System.Windows.Media.Brush)
- AddHandler BT1.Click, Sub()
- CF.Tag="INSERT INTO SYS_LOG (LID,COMPUTERNAME,USERNAME,LOGTYPE,LOGDATE,LOGDETAIL) VALUES(NEWID(),'192.168.0.100','超级管理员','执行SQL',GETDATE(),NEWID())|执行完毕! " '执行的SQL语句,语句后竖线分隔符及后面显示的文字为在语句执行完成后弹出提示内容。
- CF.Text="#执行SQL"
- End Sub
- TS.Children.Insert(16, BT1)
- End Sub'打开时执行事件
- Public Sub RangeSelection(sender As Object,e As SpreadsheetGear.Windows.Co**ols.RangeSelectionChangedEventArgs)
- End Sub'单元格选择后执行的事件
- Public Sub RangeChanged(sender As Object,e As SpreadsheetGear.Windows.Co**ols.RangeChangedEventArgs)
- End Sub'单元格编辑完成后执行事件
- Public Sub ButtunClick(sender As Object,e As SpreadsheetGear.Windows.Co**ols.ShapeActionEventArgs)
- End Sub'按钮/标签点击事件
- Public Sub FollowHyperlink(sender As Object)
- End Sub '暂不支持
- End Class
- ' 注:除事件字眼下可以自定义代码外的所有代码不允许改动,否则编译将有可能失败。
- End Namespace
复制代码
|
hessen