Private Sub DataGridView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick
Dim i As Integer
i = Me.DataGridView1.CurrentRow.Index
Me.txtNo.Text = Trim(DataGridView1.Item(0, i).Value)
Me.txtName.Text = Trim(DataGridView1.Item(1, i).Value)
Me.txtAge.Text = Trim(DataGridView1.Item(2, i).Value)
Me.txtSex.Text = Trim(DataGridView1.Item(3, i).Value)
Me.txtTel.Text = Trim(DataGridView1.Item(4, i).Value)
btnUpdata.Enabled = True
btndelete.Enabled = True
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
Dim dbobj As New ConnSqlServer.db
Dim strSql As String = "select * from Strbiogrophy"
Dim ds As New DataSet
dbobj.ReturnDataSet(strSql, ds)
Me.DataGridView1.DataSource = ds.Tables(0)
Me.txtName.Text = ""
Me.txtNo.Text = ""
Me.txtAge.Text = ""
Me.txtSex.Text = ""
Me.txtTel.Text = ""
End Sub
End Class
-------------------------------------------------------------------------------------------------------
代码5 FormTreatment.vb窗体代码
-------------------------------------------------------------------------------------------------------
Public Class FormTreatment
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strSql As String = "select * from viewillness where Strname like '%" & Me.txtName.Text & "%'"
Dim ds As New DataSet
Dim strSql1 As String = "select Strname from viewillness where Strname like '%" & Me.txtName.Text & "%'"
Dim dbobj As New ConnSqlServer.db
Dim dr As System.Data.SqlClient.SqlDataReader
dr = dbobj.DataReader(strSql1)
If dr.Read() And Me.txtName.Text <> "" Then
dbobj.ReturnDataSet(strSql, ds)
Me.DataGridView2.DataSource = ds.Tables(0)
Else
MessageBox.Show("无此姓名!")
End If
End Sub
Private Sub FormTreatment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strSql As String = "select * from VIEWchufang"
Dim ds As New DataSet
Dim ds2 As New DataSet
Dim strSql1 As String = "select * from viewillness"
Dim dbobj As New ConnSqlServer.db
Me.DataGridView1.DataSource = dbobj.ReturnDataSet(strSql, ds)
Me.DataGridView2.DataSource = dbobj.ReturnDataSet(strSql1, ds2)
Me.DataGridView1.DataSource = ds.Tables(0)
Me.DataGridView2.DataSource = ds2.Tables(0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strSql As String = "select * from viewchufang where Strname like '%" & Me.txtName1.Text & "%'"
Dim ds As New DataSet
Dim strSql1 As String = "select Strname from viewchufang where Strname like '%" & Me.txtName1.Text & "%'"
Dim dbobj As New ConnSqlServer.db
Dim dr As System.Data.SqlClient.SqlDataReader
dr = dbobj.DataReader(strSql1)
If dr.Read() And Me.txtName1.Text <> "" Then
dbobj.ReturnDataSet(strSql, ds)
Me.DataGridView1.DataSource = ds.Tables(0)
Else
MessageBox.Show("无此药品!")
End If
End Sub
Private Sub txtAge_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtAge.KeyPress
If e.KeyChar < Chr(49) Or e.KeyChar > Chr(58) Then
e.Handled = True
End If
End Sub
Private Sub DataGridView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick
Dim i As Integer
i = Me.DataGridView1.CurrentRow.Index
If Me.txtAllname.Text <> "" Then
If CInt(Trim(DataGridView1.Item(6, i).Value)) <= 100 Then
Windows.Forms.MessageBox.Show("库存数量小于100!" & Trim(DataGridView1.Item(3, i).Value) & " 价钱:" & Trim(DataGridView1.Item(7, i).Value), "提示", MessageBoxButtons.OK)
Else
Windows.Forms.MessageBox.Show(Trim(DataGridView1.Item(3, i).Value) & " 价钱:" & Trim(DataGridView1.Item(7, i).Value), "提示", MessageBoxButtons.OK)
End If
Else
If CInt(Trim(DataGridView1.Item(6, i).Value)) <= 100 Then
Windows.Forms.MessageBox.Show("库存数量小于100!" & Trim(DataGridView1.Item(3, i).Value) & " 价钱:" & Trim(DataGridView1.Item(7, i).Value), "提示", MessageBoxButtons.OK)
Else
Windows.Forms.MessageBox.Show(Trim(DataGridView1.Item(3, i).Value) & " 价钱:" & Trim(DataGridView1.Item(7, i).Value), "提示", MessageBoxButtons.OK)
End If
End If
End Sub
Private Sub DataGridView2_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView2.MouseClick
Dim i As Integer
i = Me.DataGridView2.CurrentRow.Index
Me.txtNo.Text = Trim(DataGridView2.Item(0, i).Value)
Me.txtName.Text = Trim(DataGridView2.Item(1, i).Value)
Me.txtAge.Text = Trim(DataGridView2.Item(4, i).Value)
Me.txtSex.Text = Trim(DataGridView2.Item(5, i).Value)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
FormPrint.Show()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim i As Integer
Try
i = Me.DataGridView1.CurrentRow.Index
Catch ex As Exception
MessageBox.Show("请先选中一个处方内容!")
Exit Sub
End Try
If Me.txtAllname.Text <> "" Then
Me.txtAllname.Text = txtAllname.Text & vbCrLf & Trim(DataGridView1.Item(1, i).Value) & ":" & Trim(DataGridView1.Item(8, i).Value)
Else
Me.txtAllname.Text = txtAllname.Text & Trim(DataGridView1.Item(1, i).Value) & ":" & Trim(DataGridView1.Item(8, i).Value)
End If
End Sub
End Class
-------------------------------------------------------------------------------------------------------
代码6 FormDrug.vb窗体代码
-------------------------------------------------------------------------------------------------------
Public Class FormDrug
Private Sub FormInster_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dbobj As New ConnSqlServer.db
Dim strSql As String = "select * from Strdrug"
Dim ds As New DataSet