Code VB quản lý nhà sách, xem demo mà mình đưa lên để quyết định tải về làm đồ án nhé.
XEM THÊM ==> Hướng dẫn cài đặt chi tiết
Nguồn: Sharecode.vn
Dim cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub Combo1_Click()
Dim rs2 As New ADODB.Recordset
rs2.Open "SELECT tenhang,dongianhap,dongiaban FROM tblhang WHERE mahang = '" & Trim(Combo1.Text) & "'", cn, adOpenStatic, adLockOptimistic
Text2.Text = rs2![tenhang]
Text3.Text = rs2![dongianhap]
Text6.Text = rs2![dongiaban]
rs2.Close
End Sub
Private Sub Form_Load()
Dim rs1 As New ADODB.Recordset
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\DEMO\hang.mdb"
cn.CursorLocation = adUseClient
cn.Open
Rs.Open "SELECT * FROM tblhang", cn, adOpenStatic, adLockOptimistic
rs1.Open "SELECT mahang FROM tblhang", cn, adOpenStatic, adLockOptimistic
If (Not rs1.BOF) Then
rs1.MoveFirst
While (Not rs1.EOF)
Combo1.AddItem rs1![mahang]
rs1.MoveNext
Wend
End If
rs1.Close
End Sub
Private Sub Text3_Change()
Dim dgn, sl As Integer
dgn = Val(Text3.Text)
sl = Val(Text4.Text)
Text5.Text = dgn * sl
End Sub
Private Sub Text4_Change()
Dim dgn, sl As Integer
dgn = Val(Text3.Text)
sl = Val(Text4.Text)
Text5.Text = dgn * sl
End Sub
Dim cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub cbomaloai_Click()
Dim rs2 As New ADODB.Recordset
rs2.Open "SELECT tenloai FROM tblphanloaihang WHERE maloai = '" & Trim(cbomaloai.Text) & "'", cn, adOpenStatic, adLockOptimistic
Text3.Text = rs2![tenloai]
rs2.Close
End Sub
Private Sub Form_Load()
Dim rs1 As New ADODB.Recordset
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\DEMO\hang.mdb"
cn.CursorLocation = adUseClient
cn.Open
Rs.Open "SELECT * FROM tblhang", cn, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = Rs
rs1.Open "SELECT maloai FROM tblphanloaihang", cn, adOpenStatic, adLockOptimistic
If (Not rs1.BOF) Then
rs1.MoveFirst
While (Not rs1.EOF)
cbomaloai.AddItem rs1![maloai]
rs1.MoveNext
Wend
End If
rs1.Close
End Sub
Private Sub Text4_Change()
Dim dgn, dgb, pt As Integer
dgn = Val(Text4.Text)
dgb = Val(Text5.Text)
pt = ((dgb - dgn) * 100) / dgn
Text6.Text = pt
End Sub
Private Sub Text5_Change()
Dim dgn, dgb, pt As Integer
dgn = Val(Text4.Text)
dgb = Val(Text5.Text)
pt = ((dgb - dgn) * 100) / dgn
Text6.Text = pt
End Sub
Private Sub Text6_Change()
Dim dgn, dgb, pt As Integer
dgn = Val(Text4.Text)
pt = Val(Text6.Text)
dgb = dgn + (dgn * pt) / 100
Text5.Text = dgb
End Sub