📄 frmstockbook.vb
字号:
Me.TextBox4.Location = New System.Drawing.Point(96, 88)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(296, 21)
Me.TextBox4.TabIndex = 23
Me.TextBox4.Text = ""
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 88)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(72, 21)
Me.Label4.TabIndex = 22
Me.Label4.Text = "图书名称"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(96, 24)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(296, 21)
Me.TextBox3.TabIndex = 21
Me.TextBox3.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 56)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(80, 21)
Me.Label3.TabIndex = 20
Me.Label3.Text = "图书 ISBN"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(96, 56)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(296, 21)
Me.TextBox2.TabIndex = 19
Me.TextBox2.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 24)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 21)
Me.Label2.TabIndex = 18
Me.Label2.Text = "订单序号"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.ForeColor = System.Drawing.Color.Navy
Me.Button1.Location = New System.Drawing.Point(360, 21)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 24)
Me.Button1.TabIndex = 18
Me.Button1.Text = "购买"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(104, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(248, 21)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(96, 21)
Me.Label1.TabIndex = 0
Me.Label1.Text = "订单编码"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'frmStockBook
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(432, 389)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Name = "frmStockBook"
Me.Text = "图书采购管理"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Public order As String
Public id As String
Public sqlstr As String
Public count As Integer
Public cur As Integer
Private Sub TextBox1_KeyPress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
ShowData(GetStkInfo(0))
Me.Label10.Text = " 1 Of " & count
End If
End Sub
Public Function GetStkInfo(ByVal index As Integer) As StockInfo
order = Trim(Me.TextBox1.Text)
Dim ds As New DataSet()
ds.Clear()
sqlstr = "SELECT * FROM StockOrder WHERE Orderid='" & order & "'"
ds = GetDataFromDB(sqlstr)
Dim stkinfo As New StockInfo()
If ds.Tables(0).Rows.Count > 0 Then
stkinfo.Name = ds.Tables(0).Rows(index)("Name")
stkinfo.ID = ds.Tables(0).Rows(index)("ID")
stkinfo.ISBN = ds.Tables(0).Rows(index)("ISBN")
stkinfo.Numbers = ds.Tables(0).Rows(index)("Numbers")
stkinfo.Price = ds.Tables(0).Rows(index)("Price")
stkinfo.Authors = ds.Tables(0).Rows(index)("Authors")
stkinfo.PublishAddress = ds.Tables(0).Rows(index)("PublishAddress")
stkinfo.Publishers = ds.Tables(0).Rows(index)("Publisher")
count = ds.Tables(0).Rows.Count
Return stkinfo
End If
End Function
Public Sub ShowData(ByVal stkinfo As StockInfo)
Me.TextBox2.Text = stkinfo.ISBN
Me.TextBox3.Text = stkinfo.ID
Me.TextBox4.Text = stkinfo.Name
Me.TextBox5.Text = stkinfo.Price
Me.TextBox6.Text = stkinfo.Numbers
Me.TextBox7.Text = stkinfo.Authors
Me.TextBox8.Text = stkinfo.PublishAddress
Me.ComboBox1.Text = stkinfo.Publishers
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
If count > 0 Then
cur += 1
If cur <= count - 1 Then
ShowData(GetStkInfo(cur))
Me.Label10.Text = cur + 1 & " Of " & count
Else
cur = count - 1
End If
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
If count > 0 Then
cur -= 1
If cur >= 0 Then
ShowData(GetStkInfo(cur))
Me.Label10.Text = cur + 1 & " Of " & count
Else
cur = 0
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim isbn As String = Trim(Me.TextBox2.Text)
Dim num As Integer = Val(Me.TextBox6.Text)
Dim num1 As Integer
If isbn = "" Then
Exit Sub
End If
Dim bkInfo As New BookInfo()
bkInfo = AddBookInfo()
If IsAdded(isbn) = False Then
sqlstr = "INSERT INTO BookInfo (ISBN,Name,Authors,Price,Numbers," & _
"Publisher,PublishAddress) VALUES ('" & bkInfo.ISBN & "'," & _
"'" & bkInfo.Name & "','" & bkInfo.Authors & "'," & _
"'" & bkInfo.Price & "','" & bkInfo.Numbers & "'," & _
"'" & bkInfo.Publishers & "','" & bkInfo.Publishers & "') "
Else
sqlstr = "SELECT Numbers FROM BookInfo WHERE ISBN='" & isbn & "'"
Dim ds As New DataSet()
ds.Clear()
ds = GetDataFromDB(sqlstr)
If ds.Tables(0).Rows.Count > 0 Then
num1 = ds.Tables(0).Rows(0)("Numbers")
End If
num = num1 + num
sqlstr = "UPDATE BookInfo SET Numbers='" & num & _
"' WHERE ISBN='" & isbn & "'"
End If
If UpdateDataBase(sqlstr) = True Then
MsgBox("祝贺你,图书采购成功。", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Information, "采购成功")
End If
End Sub
Public Function IsAdded(ByVal isbn As String) As Boolean
sqlstr = "SELECT * FROM BookInfo WHERE ISBN='" & isbn & "'"
Dim ds As New DataSet()
ds.Clear()
ds = GetDataFromDB(sqlstr)
If Not ds Is Nothing Then
Return True
Else
Return False
End If
End Function
Public Function AddBookInfo() As BookInfo
Dim bookInfo As New BookInfo()
bookInfo.ISBN = Trim(Me.TextBox2.Text)
bookInfo.Name = Trim(Me.TextBox4.Text)
bookInfo.Price = Val(Me.TextBox5.Text)
bookInfo.Numbers = Val(Me.TextBox6.Text)
bookInfo.Publishers = Trim(Me.ComboBox1.Text)
bookInfo.PublishAddress = Trim(Me.TextBox8.Text)
bookInfo.Authors = Trim(Me.TextBox7.Text)
Return bookInfo
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -