📄 ae.vb
字号:
Imports System.Data
Imports System.Data.OleDb
Public Class ae
Inherits System.Windows.Forms.Form
Dim MyConnectionstr As String = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Sellsystem.mdb"
Dim MySQL As String = "Select Products_ID as 主键,Products_Type as 产品型号,Products_typic as 产品类型,Products_produce as 产品厂家,Products_Quality as 产品质保,Products_OutPrice as 外部价格,Products_Price as 内部价格,Products_Quantity as 产品数量,Products_Prove as 产品说明,Products_img as 产品图片,Products_Ctypic as 所属类型 From Products_Table"
Dim MyConnection As New OleDbConnection(MyConnectionstr)
Dim MyCommand As New OleDbCommand(MySQL, MyConnection)
Dim Mydapater As New OleDbDataAdapter(MyCommand)
Dim MyDataset As New DataSet
Dim MyRow As DataRow
Dim MyTable As DataTable
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
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
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.DataGrid1 = New System.Windows.Forms.DataGrid
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button1.Location = New System.Drawing.Point(632, 356)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.TabIndex = 26
Me.Button1.Text = "删 除 "
'
'Button2
'
Me.Button2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Button2.Location = New System.Drawing.Point(727, 356)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(72, 24)
Me.Button2.TabIndex = 27
Me.Button2.Text = "退 出"
'
'DataGrid1
'
Me.DataGrid1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.DataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.DataGrid1.CaptionBackColor = System.Drawing.SystemColors.Control
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(-2, -14)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(805, 360)
Me.DataGrid1.TabIndex = 28
'
'ae
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(805, 383)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "ae"
Me.Text = "商品删除窗口"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If MyConnection.State = ConnectionState.Closed Then
MyConnection.Open()
End If
Mydapater.Fill(MyDataset, "MyProductsTable") '填充数据集
DataGrid1.DataSource = MyDataset.Tables("MyProductsTable") '把数据交给数据网格对象
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If MyConnection.State = ConnectionState.Closed Then
MyConnection.Open()
End If
MyDataset.Tables("MyProductsTable").Rows.RemoveAt(DataGrid1.CurrentRowIndex)
MsgBox(DataGrid1.CurrentRowIndex)
Dim Cmm As New OleDbCommandBuilder(Mydapater)
Mydapater.Update(MyDataset, "MyProductsTable")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -