⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 在本实例中
💻 VB
📖 第 1 页 / 共 3 页
字号:
Imports System
Imports System.IO
Imports System.Data
'引入数据库操作类命名空间
Imports System.Data.OleDb
'引入ADO.NET操作命名空间
Imports Microsoft.VisualBasic


Public Class Form1
    Inherits System.Windows.Forms.Form

    '标志是否进行更该
    Dim flag As Integer = 0
    Dim flag1 As Integer = 0
    Public flag2 As Integer = 0
    Dim eid As String
    Dim ADOcmd As OleDbDataAdapter
    '建立ADODataSetCommand对象   
    Dim ds As DataSet = New DataSet()
    '建立DataSet对象 
    Dim mytable As Data.DataTable
    '建立表单对象
    Dim myrow As Data.DataRow
    '建立数据行对象
    Dim nrow As Integer
    '定义一个整型变量来存放当前行数
    Public Function OpenDb() As Short
        Dim SQLstr As String
        '定义SQL查询字符串
        SQLstr = "select * from employees"
        '建立SQL查询语句
        ADOcmd = New OleDbDataAdapter(SQLstr, "Provider=SQLOLEDB;Data Source=qianzh;" & _
                                                               "Integrated Security=SSPI;Initial Catalog=employ")
        '建立ADODataSetCommand对象

        ADOcmd.Fill(ds, "employees")
        '取得表单
        mytable = ds.Tables.Item(0)
        '取得employees表
        nrow = 0
        '设置为起始行
        myrow = mytable.Rows.Item(nrow)
        '取得第1行数据
    End Function

    Private Sub LoadPict()
        Dim mstream As ADODB.Stream
        mstream = New ADODB.Stream()
        mstream.Type = ADODB.StreamTypeEnum.adTypeBinary
        mstream.Open()
        '读取图片,并再当前目录存为一个临时文件temp.gif
        mstream.Write(myrow.Item(9))
        mstream.SaveToFile("temp.gif", ADODB.SaveOptionsEnum.adSaveCreateOverWrite)
        mstream.Close()
        Dim path As String = "temp.gif"
        PiBox.SizeMode = PictureBoxSizeMode.StretchImage
        PiBox.Image = Image.FromFile(path)
    End Sub

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()
        InitializeComponent()
        OpenDb()
        If Not myrow.Item(9) Is Nothing Then
            LoadPict()

        End If


    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
    Friend WithEvents TBfirst As System.Windows.Forms.ToolBarButton
    Friend WithEvents TBpre As System.Windows.Forms.ToolBarButton
    Friend WithEvents TBNext As System.Windows.Forms.ToolBarButton
    Friend WithEvents TBlast As System.Windows.Forms.ToolBarButton
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents BtAdd As System.Windows.Forms.Button
    Friend WithEvents BtDel As System.Windows.Forms.Button
    Friend WithEvents BtEdit As System.Windows.Forms.Button
    Friend WithEvents BtSave As System.Windows.Forms.Button
    Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
    Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox
    Friend WithEvents Cmbtype As System.Windows.Forms.ComboBox
    Friend WithEvents txtSearch As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents GroupBox5 As System.Windows.Forms.GroupBox
    Friend WithEvents GroupBox6 As System.Windows.Forms.GroupBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Private components As System.ComponentModel.IContainer

    'Required by the Windows Form Designer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents PiBox As System.Windows.Forms.PictureBox
    Friend WithEvents TxtemployeeID As System.Windows.Forms.TextBox
    Friend WithEvents Txttitle As System.Windows.Forms.TextBox
    Friend WithEvents TxteName As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Txtdeptno As System.Windows.Forms.TextBox
    Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
    Friend WithEvents Gdresult As System.Windows.Forms.DataGrid
    Friend WithEvents BtSearch1 As System.Windows.Forms.Button
    Friend WithEvents BtSearch2 As System.Windows.Forms.Button
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Cmbdno As System.Windows.Forms.ComboBox
    Friend WithEvents Iml As System.Windows.Forms.ImageList
    Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
    Friend WithEvents Btsearch3 As System.Windows.Forms.Button
    Friend WithEvents Cmbtitle As System.Windows.Forms.ComboBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.TBfirst = New System.Windows.Forms.ToolBarButton
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.BtEdit = New System.Windows.Forms.Button
        Me.BtDel = New System.Windows.Forms.Button
        Me.BtAdd = New System.Windows.Forms.Button
        Me.BtSave = New System.Windows.Forms.Button
        Me.GroupBox4 = New System.Windows.Forms.GroupBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.BtSearch1 = New System.Windows.Forms.Button
        Me.txtSearch = New System.Windows.Forms.TextBox
        Me.Cmbtype = New System.Windows.Forms.ComboBox
        Me.GroupBox5 = New System.Windows.Forms.GroupBox
        Me.GroupBox6 = New System.Windows.Forms.GroupBox
        Me.Btsearch3 = New System.Windows.Forms.Button
        Me.Cmbtitle = New System.Windows.Forms.ComboBox
        Me.Cmbdno = New System.Windows.Forms.ComboBox
        Me.Label9 = New System.Windows.Forms.Label
        Me.BtSearch2 = New System.Windows.Forms.Button
        Me.Label6 = New System.Windows.Forms.Label
        Me.Gdresult = New System.Windows.Forms.DataGrid
        Me.TxtemployeeID = New System.Windows.Forms.TextBox
        Me.TBpre = New System.Windows.Forms.ToolBarButton
        Me.TBNext = New System.Windows.Forms.ToolBarButton
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Txttitle = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.ToolBar1 = New System.Windows.Forms.ToolBar
        Me.TBlast = New System.Windows.Forms.ToolBarButton
        Me.Iml = New System.Windows.Forms.ImageList(Me.components)
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.RichTextBox1 = New System.Windows.Forms.RichTextBox
        Me.Label8 = New System.Windows.Forms.Label
        Me.Txtdeptno = New System.Windows.Forms.TextBox
        Me.Label7 = New System.Windows.Forms.Label
        Me.TxteName = New System.Windows.Forms.TextBox
        Me.PiBox = New System.Windows.Forms.PictureBox
        Me.GroupBox3 = New System.Windows.Forms.GroupBox
        Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
        Me.GroupBox2.SuspendLayout()
        Me.GroupBox4.SuspendLayout()
        Me.GroupBox5.SuspendLayout()
        Me.GroupBox6.SuspendLayout()
        CType(Me.Gdresult, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox3.SuspendLayout()
        Me.SuspendLayout()
        '
        'TBfirst
        '
        Me.TBfirst.ImageIndex = 0
        Me.TBfirst.ToolTipText = "显示第一条"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.BtEdit)
        Me.GroupBox2.Controls.Add(Me.BtDel)
        Me.GroupBox2.Controls.Add(Me.BtAdd)
        Me.GroupBox2.Controls.Add(Me.BtSave)
        Me.GroupBox2.Location = New System.Drawing.Point(0, 368)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(240, 48)
        Me.GroupBox2.TabIndex = 2
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "操作"
        '
        'BtEdit
        '
        Me.BtEdit.Location = New System.Drawing.Point(116, 16)
        Me.BtEdit.Name = "BtEdit"
        Me.BtEdit.Size = New System.Drawing.Size(48, 23)
        Me.BtEdit.TabIndex = 0
        Me.BtEdit.Text = "编辑"
        '
        'BtDel
        '
        Me.BtDel.Location = New System.Drawing.Point(66, 16)
        Me.BtDel.Name = "BtDel"
        Me.BtDel.Size = New System.Drawing.Size(48, 23)
        Me.BtDel.TabIndex = 0
        Me.BtDel.Text = "删除"
        '
        'BtAdd
        '
        Me.BtAdd.Location = New System.Drawing.Point(16, 16)
        Me.BtAdd.Name = "BtAdd"
        Me.BtAdd.Size = New System.Drawing.Size(48, 23)
        Me.BtAdd.TabIndex = 0
        Me.BtAdd.Text = "添加"
        '
        'BtSave
        '
        Me.BtSave.Location = New System.Drawing.Point(166, 16)
        Me.BtSave.Name = "BtSave"
        Me.BtSave.Size = New System.Drawing.Size(56, 23)
        Me.BtSave.TabIndex = 0
        Me.BtSave.Text = "保存"
        '
        'GroupBox4
        '
        Me.GroupBox4.Controls.Add(Me.Label5)
        Me.GroupBox4.Controls.Add(Me.Label4)
        Me.GroupBox4.Controls.Add(Me.BtSearch1)
        Me.GroupBox4.Controls.Add(Me.txtSearch)
        Me.GroupBox4.Controls.Add(Me.Cmbtype)
        Me.GroupBox4.Location = New System.Drawing.Point(8, 8)
        Me.GroupBox4.Name = "GroupBox4"
        Me.GroupBox4.Size = New System.Drawing.Size(256, 64)
        Me.GroupBox4.TabIndex = 0
        Me.GroupBox4.TabStop = False
        Me.GroupBox4.Text = "单查询"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(112, 16)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(56, 16)
        Me.Label5.TabIndex = 3
        Me.Label5.Text = "查询条件"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(8, 17)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(56, 16)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "查询类型"
        '
        'BtSearch1
        '
        Me.BtSearch1.Location = New System.Drawing.Point(192, 24)
        Me.BtSearch1.Name = "BtSearch1"
        Me.BtSearch1.Size = New System.Drawing.Size(48, 24)
        Me.BtSearch1.TabIndex = 2
        Me.BtSearch1.Text = "查询"
        '
        'txtSearch
        '
        Me.txtSearch.Location = New System.Drawing.Point(112, 32)
        Me.txtSearch.Name = "txtSearch"
        Me.txtSearch.Size = New System.Drawing.Size(72, 21)
        Me.txtSearch.TabIndex = 1
        Me.txtSearch.Text = ""
        '
        'Cmbtype
        '
        Me.Cmbtype.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.Cmbtype.DropDownWidth = 64
        Me.Cmbtype.Items.AddRange(New Object() {"雇员编号", "雇员名称", "家庭电话"})
        Me.Cmbtype.Location = New System.Drawing.Point(8, 32)
        Me.Cmbtype.Name = "Cmbtype"
        Me.Cmbtype.Size = New System.Drawing.Size(88, 20)
        Me.Cmbtype.TabIndex = 0
        '
        'GroupBox5
        '
        Me.GroupBox5.Controls.Add(Me.GroupBox6)
        Me.GroupBox5.Controls.Add(Me.Gdresult)
        Me.GroupBox5.Location = New System.Drawing.Point(8, 80)
        Me.GroupBox5.Name = "GroupBox5"
        Me.GroupBox5.Size = New System.Drawing.Size(256, 288)
        Me.GroupBox5.TabIndex = 1
        Me.GroupBox5.TabStop = False
        '
        'GroupBox6
        '
        Me.GroupBox6.Controls.Add(Me.Btsearch3)
        Me.GroupBox6.Controls.Add(Me.Cmbtitle)
        Me.GroupBox6.Controls.Add(Me.Cmbdno)
        Me.GroupBox6.Controls.Add(Me.Label9)
        Me.GroupBox6.Controls.Add(Me.BtSearch2)
        Me.GroupBox6.Controls.Add(Me.Label6)
        Me.GroupBox6.Location = New System.Drawing.Point(8, 8)
        Me.GroupBox6.Name = "GroupBox6"
        Me.GroupBox6.Size = New System.Drawing.Size(240, 88)
        Me.GroupBox6.TabIndex = 0
        Me.GroupBox6.TabStop = False
        Me.GroupBox6.Text = "多查询"
        '
        'Btsearch3
        '
        Me.Btsearch3.Location = New System.Drawing.Point(176, 56)
        Me.Btsearch3.Name = "Btsearch3"
        Me.Btsearch3.Size = New System.Drawing.Size(48, 24)
        Me.Btsearch3.TabIndex = 6
        Me.Btsearch3.Text = "查询"
        '
        'Cmbtitle
        '
        Me.Cmbtitle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.Cmbtitle.DropDownWidth = 64
        Me.Cmbtitle.Location = New System.Drawing.Point(80, 56)
        Me.Cmbtitle.Name = "Cmbtitle"
        Me.Cmbtitle.Size = New System.Drawing.Size(72, 20)
        Me.Cmbtitle.TabIndex = 5
        '
        'Cmbdno
        '

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -