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

📄 clientissues.vb

📁 《VBA专业项目实例开发》源代码,学习vba必备
💻 VB
字号:
Imports System.Data.OleDb

Public Class ClientIssues
    Inherits System.Windows.Forms.Form
    
    Private varCompanyName As New StartApplication.ShareClass()
    Private ourConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\EasySelling\EasySelling.mdb;Persist Security Info=False"
    Private clientConnection As OleDbConnection = New OleDbConnection(ourConn)
    Private clientCommand As OleDbCommand
    Private clientDataReader As OleDbDataReader
    Friend WithEvents lstvIssues As System.Windows.Forms.ListView
    Private strSqlStatement As String
    Private varClientID As Long
    Declare Sub Sleep Lib "kernel32" (ByVal dwmilliseconds As Long)

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    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 lblLabelFormDes As System.Windows.Forms.Label
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents btnUpdate As System.Windows.Forms.Button
    Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    '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.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.lblLabelFormDes = New System.Windows.Forms.Label()
        Me.lstvIssues = New System.Windows.Forms.ListView()
        Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.btnUpdate = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'lblLabelFormDes
        '
        Me.lblLabelFormDes.Font = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblLabelFormDes.Location = New System.Drawing.Point(48, 16)
        Me.lblLabelFormDes.Name = "lblLabelFormDes"
        Me.lblLabelFormDes.Size = New System.Drawing.Size(456, 56)
        Me.lblLabelFormDes.TabIndex = 72
        Me.lblLabelFormDes.Text = "Customers might be facing some Issues while purchasing and using the Stationary P" & _
        "roducts. Select the Issues faced by current customer from the List below:"
        Me.lblLabelFormDes.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'lstvIssues
        '
        Me.lstvIssues.BackColor = System.Drawing.Color.PowderBlue
        Me.lstvIssues.CheckBoxes = True
        Me.lstvIssues.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1})
        Me.lstvIssues.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lstvIssues.GridLines = True
        Me.lstvIssues.Location = New System.Drawing.Point(49, 80)
        Me.lstvIssues.Name = "lstvIssues"
        Me.lstvIssues.Size = New System.Drawing.Size(456, 320)
        Me.lstvIssues.TabIndex = 73
        Me.lstvIssues.View = System.Windows.Forms.View.Details
        '
        'ColumnHeader1
        '
        Me.ColumnHeader1.Text = "Issues"
        Me.ColumnHeader1.Width = 452
        '
        'Button1
        '
        Me.Button1.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button1.Location = New System.Drawing.Point(416, 411)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(88, 24)
        Me.Button1.TabIndex = 76
        Me.Button1.Text = "&Close"
        '
        'btnUpdate
        '
        Me.btnUpdate.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnUpdate.Location = New System.Drawing.Point(320, 411)
        Me.btnUpdate.Name = "btnUpdate"
        Me.btnUpdate.Size = New System.Drawing.Size(88, 24)
        Me.btnUpdate.TabIndex = 75
        Me.btnUpdate.Text = "&Save"
        '
        'ClientIssues
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.PowderBlue
        Me.ClientSize = New System.Drawing.Size(565, 448)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.btnUpdate, Me.lstvIssues, Me.lblLabelFormDes})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Name = "ClientIssues"
        Me.Text = "ClientIssues"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim NewMDIParent As New MainMDI()
        NewMDIParent.Show()
        NewMDIParent.Hide()
        Me.Close()
    End Sub

    Private Sub ClientIssues_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim issueCount As Integer
        issueCount = 0
        Try
            clientConnection.Open()

            strSqlStatement = "SELECT Client_ID FROM tblClients WHERE Client_Name = '" & varCompanyName.SharedValue & "'"
            clientCommand = New OleDbCommand(strSqlStatement, clientConnection)
            clientDataReader = clientCommand.ExecuteReader()
            While clientDataReader.Read
                varClientID = clientDataReader.Item(0)
            End While
            clientDataReader.Close()


            strSqlStatement = "SELECT Expectation,selected FROM tblClientExpectations WHERE Client_ID = " & varClientID
            clientCommand = New OleDbCommand(strSqlStatement, clientConnection)
            clientDataReader = clientCommand.ExecuteReader()
            While clientDataReader.Read
                lstvIssues.Items().Add(clientDataReader.Item(0), issueCount)
                If clientDataReader.Item(1) = True Then
                    lstvIssues.Items(issueCount).Checked = True
                End If
                issueCount = issueCount + 1
            End While
            clientDataReader.Close()
            clientConnection.Close()
        Catch
            MsgBox(Err.Description())
        End Try

    End Sub


    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Dim varCollection As System.Windows.Forms.ListView.CheckedListViewItemCollection
        Dim varitem As ListViewItem
        Try
            varCollection = lstvIssues.CheckedItems()
            clientConnection.Open()
            For Each varitem In varCollection
                strSqlStatement = "UPDATE tblClientExpectations SET Selected = True WHERE Client_ID=" & varClientID & " AND Expectation = '" & varitem.Text & "'"
                clientCommand = New OleDbCommand(strSqlStatement, clientConnection)
                clientCommand.ExecuteNonQuery()
            Next
            clientConnection.Close()
            MsgBox("Record Saved Successfully.", MsgBoxStyle.Information, "Record Saved")

        Catch
            MsgBox(Err.Description())
        End Try


    End Sub
End Class

⌨️ 快捷键说明

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