mycom2.ExecuteNonQuery()
MessageBox.Show("增加成功!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information)
mycon.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
5新增书籍窗口实现如下:
此窗口的功能就是录入新的图书信息,在录入图书信息时需要录入的信息有 :书籍名称,作者,出版社,书籍定价,出版日期
图6新增书籍窗口界面
在此窗口中可以进行新增书籍的操作
所有项必须全部添加
添加完成后通过点击“增加”按钮来完成新增书籍
“增加”按钮的事件代码
If CheckData() = False Then
Exit Sub
End If
Try
If mycon.State = ConnectionState.Closed Then
mycon.Open()
End If
Dim ID As Integer
ID = GetHeightID()
Dim ID1 As New SqlParameter("@ID1", SqlDbType.Int, 4)
ID1.Value = ID + 1
Dim sqlstr As String = "insert into Book values(@ID1,'" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "',1)"
Dim mycom As New SqlCommand(sqlstr, mycon)
mycom.Parameters.Add(ID1)
mycom.ExecuteNonQuery()
MessageBox.Show("恭喜你,保存成功!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information)
Call ClearData()
mycon.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
6图书信息维护实现如下