📄 market.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Public Class market
Inherits System.Windows.Forms.Form
Dim temprow As Integer
Dim tempname As String
Dim myconnection As SqlConnection = New _
SqlConnection("server=(local);database=footballplayer_change;" & _
"uid=sa;pwd=sa;")
Dim myadapter As SqlDataAdapter = New SqlDataAdapter()
Dim myds As DataSet
Dim mydv As DataView
Dim mycurrencymanager As CurrencyManager
Private Sub filldatasetandview()
myds = New DataSet()
Try
myadapter.Fill(myds, "willingtosell")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
mydv = New DataView(myds.Tables("willingtosell"))
mycurrencymanager = CType(Me.BindingContext(mydv), CurrencyManager)
End Sub
Private Sub bindfields()
playerlist.DataSource = myds
playerlist.DataMember = "willingtosell"
End Sub
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
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 GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents playerlist As System.Windows.Forms.DataGrid
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents price As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(market))
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.playerlist = New System.Windows.Forms.DataGrid
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.Button1 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.price = New System.Windows.Forms.TextBox
Me.GroupBox1.SuspendLayout()
CType(Me.playerlist, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox2.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.playerlist)
Me.GroupBox1.Location = New System.Drawing.Point(8, 40)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(208, 225)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
'
'playerlist
'
Me.playerlist.DataMember = ""
Me.playerlist.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.playerlist.Location = New System.Drawing.Point(8, 24)
Me.playerlist.Name = "playerlist"
Me.playerlist.Size = New System.Drawing.Size(192, 192)
Me.playerlist.TabIndex = 0
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.Button1)
Me.GroupBox2.Controls.Add(Me.Label1)
Me.GroupBox2.Controls.Add(Me.price)
Me.GroupBox2.Location = New System.Drawing.Point(272, 40)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(200, 225)
Me.GroupBox2.TabIndex = 1
Me.GroupBox2.TabStop = False
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(128, 128)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 24)
Me.Button1.TabIndex = 2
Me.Button1.Text = "确定"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(160, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "请输入您的标价:"
'
'price
'
Me.price.Location = New System.Drawing.Point(40, 72)
Me.price.Name = "price"
Me.price.Size = New System.Drawing.Size(152, 21)
Me.price.TabIndex = 0
Me.price.Text = ""
'
'market
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
Me.ClientSize = New System.Drawing.Size(512, 349)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "market"
Me.Text = "market"
Me.GroupBox1.ResumeLayout(False)
CType(Me.playerlist, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
Private Sub market_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myds = New DataSet()
myadapter.SelectCommand = New SqlCommand()
myadapter.SelectCommand.CommandText = "p_willingtosell"
myadapter.SelectCommand.CommandType = CommandType.StoredProcedure
' myadapter.SelectCommand.Parameters.Add()
myadapter.SelectCommand.Connection = myconnection
myconnection.Open()
Try
myadapter.SelectCommand.ExecuteNonQuery()
Catch ex As Exception
' MsgBox(main.tempuid)
MsgBox(ex.ToString)
End Try
myadapter.Fill(myds, "willingtosell")
myconnection.Close()
bindfields()
End Sub
Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles playerlist.Navigate
End Sub
Private Sub playerlist_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles playerlist.Click
temprow = playerlist.CurrentRowIndex()
MsgBox(temprow)
tempname = myds.Tables("willingtosell").Rows(temprow).Item(0)
MsgBox(tempname)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If tempname = "" Then
MsgBox("请选择球员")
Else
Dim cost As Double
cost = price.Text
'Dim myadapter As SqlDataAdapter = New SqlDataAdapter()
myadapter.SelectCommand = New SqlCommand()
myadapter.SelectCommand.CommandText = "p_buying"
myadapter.SelectCommand.CommandType = CommandType.StoredProcedure
myadapter.SelectCommand.Parameters.Add("@playername", tempname)
myadapter.SelectCommand.Parameters.Add("@uid", main.tempuid)
myadapter.SelectCommand.Parameters.Add("@value", cost)
myadapter.SelectCommand.Connection = myconnection
myconnection.Open()
Try
myadapter.SelectCommand.ExecuteNonQuery()
' myadapter.Fill(myds, "willingtosell")
Catch ex As Exception
' MsgBox(main.tempuid)
MsgBox(ex.ToString)
End Try
myconnection.Close()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -