Imports System.Data.SqlClient
Imports System.Data #Region "IBogartToolbar,請勿隨便更改" Interface IBogartToolbar
Sub j_menuPrint()
Sub j_LoadData()
'Sub j_setToolsBar()
Sub j_ChangeRecord()
Sub j_AddRow()
Sub j_EditRow()
Property EnabledPrint() As Boolean
Sub SetToolsControl(ByVal g As myDataGrid.myDatagrid)
Property CurrentGrid() As myDataGrid.myDatagrid
End Interface
#End Region Module DataAccess #Region "資料庫常用方法"
Public SystemBackColor As Color = Color.FromArgb(, , )
Public SystemBackColor2003 As Color = Color.FromArgb(, , )
Public SystemBackColorMenu As Color = Color.FromArgb(, , ) Public Function ExectueSQL(ByVal strSQL As String, ByVal objConn As OleDb.OleDbConnection) As DataSet
Dim ds As New DataSet
Dim dap As New OleDb.OleDbDataAdapter
Try
dap = New OleDb.OleDbDataAdapter(strSQL, objConn)
dap.Fill(ds)
Catch ex As Exception
MsgBox(ex.ToString())
Finally
dap.Dispose()
End Try
Return ds
End Function
Public Function ExectueSQL(ByVal strSQL As String, ByVal objConn As SqlClient.SqlConnection) As DataSet
Dim ds As New DataSet
Dim dap As New SqlClient.SqlDataAdapter
Try
dap = New SqlClient.SqlDataAdapter(strSQL, objConn)
dap.Fill(ds)
Catch ex As Exception
MsgBox(ex.ToString())
Finally
dap.Dispose()
End Try
Return ds
End Function
Public Function ExectueSQL(ByVal SqlCmd As SqlClient.SqlCommand) As DataSet
Dim ds As New DataSet
Dim dap As New SqlClient.SqlDataAdapter
Try
dap = New SqlClient.SqlDataAdapter(SqlCmd)
dap.Fill(ds)
Catch ex As Exception
MsgBox(ex.ToString())
Finally
dap.Dispose()
End Try
Return ds
End Function
Public Function ExectueSQL(ByVal SqlCmd As OleDb.OleDbCommand) As DataSet
Dim ds As New DataSet
Dim dap As New OleDb.OleDbDataAdapter
Try
dap = New OleDb.OleDbDataAdapter(SqlCmd)
dap.Fill(ds)
Catch ex As Exception
MsgBox(ex.ToString())
Finally
dap.Dispose()
End Try
Return ds
End Function Public Function ExectueCmdAS400(ByVal strSQL As String, ByVal objConn As OleDb.OleDbConnection) As Boolean
Dim ret As Boolean = False
Try
Dim retCount As Integer = ExectueCmd(strSQL, objConn)
ret = IIf(retCount >= , True, False)
Catch ex As Exception
MsgBox("ExectueCmd " & vbCrLf & ex.ToString())
ret = False
End Try
Return ret
End Function Public Function ExectueCmd(ByVal strSQL As String, ByVal objConn As OleDb.OleDbConnection) As Integer
Dim cmd As OleDb.OleDbCommand
Dim ret As Integer =
Try
cmd = New OleDb.OleDbCommand(strSQL, objConn)
cmd.CommandType = CommandType.Text
ret = cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("ExectueCmd:" & ex.ToString() & vbCrLf & strSQL)
ret = -
Finally
cmd.Dispose()
End Try
Return ret
End Function
Public Function ExectueCmd(ByVal strSQL As String, ByVal objConn As SqlClient.SqlConnection) As Integer
Dim cmd As SqlClient.SqlCommand
Dim ret As Integer
If objConn.State = ConnectionState.Closed Then
OpenConn(objConn)
End If
Try
cmd = New SqlClient.SqlCommand(strSQL, objConn)
ret = cmd.ExecuteNonQuery()
Catch ex As Exception
ret = -
Finally
cmd.Dispose()
End Try
Return ret
End Function
Public Function ExectueCmd(ByVal SqlCmd As SqlClient.SqlCommand) As Integer
Dim ret As Integer = -
Try
ret = SqlCmd.ExecuteNonQuery()
Catch ex As Exception
ret = -
Finally
SqlCmd.Dispose()
End Try
Return ret
End Function Public Function ExectueCmd(ByVal SqlCmd As OleDb.OleDbCommand) As Integer
Dim ret As Integer = -
Try
ret = SqlCmd.ExecuteNonQuery()
Catch ex As Exception
ret = -
Finally
SqlCmd.Dispose()
End Try
Return ret
End Function Public Function CDecs(ByVal strValue As String) As Decimal
If strValue.Trim() = "" Then
Return
Else
Return CDec(strValue)
End If
End Function Public Function IsALL(ByVal strValue As String) As String
strValue = strValue.Trim()
If strValue = "" Then
Return "All"
Else
Return strValue
End If
End Function
#End Region '請勿隨便更改 #Region "讀取Logo的方法" ''' <summary>
''' 添加公用報表Logo方法
''' </summary>
''' <param name="ds" type="Data.DataSet"> 包含 Logo(Table) 的DataSet </param>
''' <param name="AliasName" type="String">可選參數,資料庫字段的別名,默認:CompanyLogo,不區分大小寫.</param>
Public Sub GetLogo(ByRef ds As DataSet, Optional ByVal AliasName As String = "CompanyLogo")
Try
Dim dt As DataTable = GetLogo(AliasName)
ds.Tables.Add(dt)
ds.AcceptChanges()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub ''' <summary>
''' 添加公用報表Logo函數
''' </summary>
''' <param name="AliasName" type="String">可選參數,資料庫字段的別名,默認:CompanyLogo,不區分大小寫.</param>
''' <param name="tabName" type="String">可選參數,返回 Logo的表的名稱,默認:Logo,分大小寫.</param>
''' <returns> A System.Data.DataTable value </returns>
Public Function GetLogo(Optional ByVal AliasName As String = "CompanyLogo", Optional ByVal tabName As String = "Logo") As DataTable
Try
Dim strSQL As String = ""
Dim strCompanyCode As String = ""
If tabName.Trim = "" Then
tabName = "Logo"
End If If AliasName.Trim = "" Then
AliasName = "companylogo"
End If
Select Case g.gLocation
Case LocationType.CHINA_SHENZHEN
strCompanyCode = "SHS"
Case LocationType.THAILAND
strCompanyCode = "Thailand"
Case LocationType.HONGKONG
strCompanyCode = "AFT"
Case LocationType.BRUNE
strCompanyCode = "Brunet"
Case Else
strCompanyCode = "Bogart"
End Select
Dim dt As DataTable = GetLogo(strCompanyCode, AliasName, tabName)
Return dt.Copy
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
''' <summary>
''' 添加公用報表Logo函數
''' </summary>
''' <param name="strCompanyCode" type="String">公司編號,即:Logo的編號</param>
''' <param name="AliasName" type="String">資料庫字段的別名,不區分大小寫.</param>
''' <param name="tabName" type="String"> 返回 Logo的表的名稱,分大小寫.</param>
''' <returns> A System.Data.DataTable value </returns>
Public Function GetLogo(ByVal strCompanyCode As String, _
ByVal AliasName As String, _
ByVal tabName As String) As DataTable
Try
Dim strSQL As String = ""
Dim dt As DataTable = Nothing
If tabName.Trim = "" And AliasName.Trim = "" Then
Return dt
End If
If AliasName.ToLower = "companylogo" Then
strSQL = "select CompanyLogo from CompanyProfile where CompanyCode='" & strCompanyCode & "'"
Else
strSQL = "select CompanyLogo as " & AliasName & " from CompanyProfile where CompanyCode='" & strCompanyCode & "'"
End If
dt = DataAccess.ExectueSQL(strSQL, SqlConnect).Tables()
dt.TableName = tabName
Return dt.Copy
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
#End Region '請勿隨便更改 Public tmp_PHFRMT As DataTable Public Sub SetCheckBox(ByVal MyGrid As myDataGrid.myDatagrid, ByVal strColName As String)
strColName = strColName.Trim
If strColName = "" Then
Exit Sub
End If
Dim items As C1.Win.C1TrueDBGrid.ValueItems = MyGrid.Columns(strColName).ValueItems With items
' we're going to translate values - the datasource needs to hold at least 3 states
.Translate = True
' each click will cycle thru the various checkbox states
.CycleOnClick = True
.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
' now associate underlying db values with the checked state
.Values.Clear()
.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("", False)) ' unchecked
.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("", True)) ' checked
''.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("2", "INDETERMINATE")) ' indeterminate state
End With
End Sub ''' <summary>
''' 返回本地IP
''' </summary>
Public Function IPAdress() As String
Return System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList().ToString().Trim()
End Function Public Function ToDataTable(ByVal MyGrid As myDataGrid.myDatagrid) As DataTable
Dim ObjDataTable As DataTable
Try
If TypeOf (MyGrid.DataSource) Is DataView Then
Dim obDataView As DataView = CType(MyGrid.DataSource, DataView)
ObjDataTable = obDataView.Table.Clone()
Dim idx As Integer =
Dim strColNames(ObjDataTable.Columns.Count) As String
For Each col As DataColumn In ObjDataTable.Columns
strColNames(idx) = col.ColumnName
idx +=
Next
Dim IEnrator As IEnumerator = obDataView.GetEnumerator()
While IEnrator.MoveNext()
Dim drv As DataRowView = CType(IEnrator.Current, DataRowView)
Dim dr As DataRow = ObjDataTable.NewRow
Try
For Each strName As String In strColNames
dr(strName) = drv(strName)
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
ObjDataTable.Rows.Add(dr)
End While
ElseIf TypeOf (MyGrid.DataSource) Is DataTable Then
ObjDataTable = CType(MyGrid.DataSource, DataTable)
End If
Catch oE As System.Exception
ObjDataTable = Nothing
ErrorMsg.Show(oE)
End Try
Return ObjDataTable
End Function
''' <summary>
''' 返回一個字符串
''' </summary>
''' <param name="o" type="Object"> </param>
''' <returns> A System.String value </returns>
Public Function Trims(ByVal o As Object) As String
If TypeOf (o) Is DBNull Then
Return ""
Else
Return Convert.ToString(o).Trim()
End If
End Function End Module

Bogart BogartPublic.vb的更多相关文章

  1. Bogart SysPwd.vb

    Module syspwd Public Const STR_MASK = "MyFunction" '加密用字串 '預定義密碼長度 Public GintCheckPwd As ...

  2. Bogart gSub.vb

    '--------------Job No 0900408 -------------- '--DIM PART ONE ONLINE Update Order Qty '''主要新加過程名 Refr ...

  3. Bogart gData.vb

    Imports System Imports System.Data Imports System.Data.OleDb Imports Microsoft.VisualBasic Imports S ...

  4. Bogart BogartAutoCode.vb

    Imports System.Data.SqlClient Imports System.Data Public Class BogartAutoCodeDataBase Private Conn A ...

  5. Bogart gFunction.vb

    Module gFunction '其它不是常用的方法及函數 #Region " 將指定的數據格式轉換為英文格式" Public Function EnglishFormat(By ...

  6. Bogart gGrid.vb

    Namespace BogartMis.Cls Public Class gGrid '設定表格控的列標題的別名 '說明:strItem字符串的格式為"01,02,03,04,05" ...

  7. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  8. VB.NET设置控件和窗体的显示级别

    前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...

  9. 用VB脚本批到导入字段到PowerDesigner

    在PowerDesigner使用脚本批量导入excel中记录的表结构信息,由于需要通过powerdesigner逆向工程创建一些sybase IQ的表,由于是接口数据,只有excel表,手动导入太耗时 ...

随机推荐

  1. paho.mqtt.embedded-c MQTTPacket pub0sub1.c hacking

    /******************************************************************************* * paho.mqtt.embedde ...

  2. 很全面的WinRAR实用技巧系列 - imsoft.cnblogs

    WinRAR也可以管理我的桌面时间长了,桌面上堆的东西实在太多,平时该如何管理呢?安装了WinRAR的朋友可以请它来帮忙,用它管理清除无用的桌面文件或图标. 以XP系统为例,系统所在目录是“c:\wi ...

  3. 51Nod 1090: 3个数和为0

    1090 3个数和为0  基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 给出一个长度为N的无序数组,数组中的元素为整数,有正有负包括0,并互不相等. ...

  4. 放苹果问题 DP计数 m个苹果放在n个盘子里,苹果,盘子相同,盘子可为空

    详细的解释放苹果问题的链接:苹果可相同可不同,盘子可相同可不同,盘子可空和不可空,都有详细的说明··· http://www.cnblogs.com/celia01/archive/2012/02/1 ...

  5. [转载]PHP 连接 Rabbitmq 实例代码

    转自 http://www.dahouduan.com/2017/11/23/php-rabbitmq-demo/ 接下来我们用 php 连接 rabbitmq 玩一玩.还没有安装 rabbitmq ...

  6. (转)C++ 容器及选用总结

    目录 ==================================================== 第一章 容器 第二章 Vector和string 第三章 关联容器 第四章 迭代器 第五 ...

  7. Git Authoritative Guide 学习

    一.git命令1.git add -u : 将工作区中所有改动的文件添加到暂存区(修改.删除),但是不提交未被git跟踪的文件 -i : 可以进入交互界面选择性提交 -A : 相对于-u,它还提交新建 ...

  8. TensorFlow学习线路

    如何高效的学习 TensorFlow 代码? 或者如何掌握TensorFlow,应用到任何领域? 作者:黄璞链接:https://www.zhihu.com/question/41667903/ans ...

  9. 【转】每天一个linux命令(7):mv命令

    原文网址:http://www.cnblogs.com/peida/archive/2012/10/27/2743022.html mv命令是move的缩写,可以用来移动文件或者将文件改名(move  ...

  10. php比较全的友好时间显示

    分享一个php友好的比较完成的时间格式化函数,包括‘刚刚’,'几秒之前',‘几分钟前’,'几小时前',几天前,几周前,几个月前等.调用方式很简单,是从ThinkSNS 里面拿出来的. /** * 友好 ...