Bogart BogartPublic.vb
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的更多相关文章
- Bogart SysPwd.vb
Module syspwd Public Const STR_MASK = "MyFunction" '加密用字串 '預定義密碼長度 Public GintCheckPwd As ...
- Bogart gSub.vb
'--------------Job No 0900408 -------------- '--DIM PART ONE ONLINE Update Order Qty '''主要新加過程名 Refr ...
- Bogart gData.vb
Imports System Imports System.Data Imports System.Data.OleDb Imports Microsoft.VisualBasic Imports S ...
- Bogart BogartAutoCode.vb
Imports System.Data.SqlClient Imports System.Data Public Class BogartAutoCodeDataBase Private Conn A ...
- Bogart gFunction.vb
Module gFunction '其它不是常用的方法及函數 #Region " 將指定的數據格式轉換為英文格式" Public Function EnglishFormat(By ...
- Bogart gGrid.vb
Namespace BogartMis.Cls Public Class gGrid '設定表格控的列標題的別名 '說明:strItem字符串的格式為"01,02,03,04,05" ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- VB.NET设置控件和窗体的显示级别
前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...
- 用VB脚本批到导入字段到PowerDesigner
在PowerDesigner使用脚本批量导入excel中记录的表结构信息,由于需要通过powerdesigner逆向工程创建一些sybase IQ的表,由于是接口数据,只有excel表,手动导入太耗时 ...
随机推荐
- 粘包、拆包发生原因滑动窗口、MSS/MTU限制、Nagle算法
[TCP协议](3)---TCP粘包黏包 [TCP协议](3)---TCP粘包黏包 有关TCP协议之前写过两篇博客: 1.[TCP协议](1)---TCP协议详解 2.[TCP协议](2)---TCP ...
- (8)os和sys模块
import sysprint(sys.argv) #默认获取当前文件的路径 import os os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir(& ...
- 网络流--最大流ek模板
标准大白书式模板,代码简单但由于效率并不高,所以并不常用,就是这样 #include<stdio.h> #include<string.h> #include<queue ...
- day32 多进程
一 multiprocessing模块介绍 python中的多线程无法利用多核优势,如果想要充分地使用多核CPU的资源(os.cpu_count()查看),在python中大部分情况需要使用多进程. ...
- SQL Server获取指定行的数据
SQL Server获取指定行(如第二行)的数据 --SQL Server获取指定行(如第二行)的数据-- --法一(对象法)-- select * from ( select * , numbe ...
- Jmeter之JDBC
jdbc:mysql://ip:3306/test?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
- spark之 spark 2.2.0 Standalone安装、wordCount演示
说明:前提安装好hadoop集群,可参考 http://blog.csdn.net/zhang123456456/article/details/77621487 一. scala 安装 1.下载 s ...
- react-router4.0的使用
近来很忙,学了一波react,特来记一笔,分享下react-router的使用方式 第一步引入内部组件 import {Route,BrowserRouter as Router,Switch,Lin ...
- C# OracleBulkCopy 批量插入oracle数据库的方法
只有安装了oracle 11G客户端的机器上才可以用,要用到ODP.NET组件中的oracleDataAccess.DLL,命名空间引用为Oracle.DataAccess.Client; 引用:Or ...
- Linux内核深入研究之进程的线性地址空间-传统版
引言: 了解Linux环境下,进程的地址空间划分,对于我们理解Linux应用程序有很大的帮助,否则会被New与Malloc之类的指针操作弄的晕头转向,本文基于Linux内核讲述了Linux/Unix线 ...