NộI dung Trang
Phần I GiớI thiệu về ngôn ngữ Visual Basic
Lập trình vớI ngôn ngữ Visual Basic
Cấu trúc của một chương trình viết bằng ngôn ngữ Visual Basic
Phần II Giới thiệu phần mềm quản lý thu chi phòng khám
A Mổ tả các chức năng của phần mềm
B Cơ sở dữ liệu
Phần III Mã nguồn
86 trang |
Chia sẻ: huong.duong | Lượt xem: 1497 | Lượt tải: 2
Bạn đang xem trước 20 trang tài liệu Lập trình vớI ngôn ngữ Visual Basic, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
dnew.hwnd
Else
cmdedit.Enabled = True
cmddelete.Enabled = True
TreeView1.Enabled = True
Saved = True
Skin.RemoveSkin cmdnew.hwnd
cmdnew.Caption = "T¹o míi"
Skin.ApplySkin cmdnew.hwnd
ClearText
cmdsave.Enabled = False
DisableText
End If
End Sub
1.6 Mã nguồn thủ tục CmdSave_Click()
Private Sub CmdSave_Click()
Dim sql As String
If txtMa.Text = "" Then
cmdsave.Enabled = False
DisableText
cmdedit.Enabled = False
cmddelete.Enabled = True
cmdexit.Enabled = True
cmdnew.Enabled = True
Exit Sub
End If
vbExclamation, "Chú ý"
If logic = True Then
rsNhanvien.AddNew
rsNhanvien!manhanvien = txtMa.Text
rsNhanvien!tennhanvien = txtHoten.Text
If txtDiachi.Text "" Then
rsNhanvien!diachi = txtDiachi.Text
End If
If txtDTnharieng.Text "" Then
rsNhanvien!dtnr = txtDTnharieng.Text
End If
If txtDTcoquan.Text "" Then
rsNhanvien!dtcq = txtDTcoquan.Text
End If
If txtDTdidong.Text "" Then
rsNhanvien!didong = txtDTdidong.Text
End If
If txtDonvi.Text "" Then
rsNhanvien!donvi = txtDonvi.Text
End If
If txtCapbac.Text "" Then
rsNhanvien!capbac = txtCapbac.Text
End If
If txtChuyenkhoa.Text "" Then
rsNhanvien!chuyenkhoa = txtChuyenkhoa.Text
End If
If txtNgayluong.Text "" Then
rsNhanvien!ngayluong = txtNgayluong.Text
End If
rsNhanvien.Update
TreeView1.Nodes.Add "parent", tvwChild, , txtMa.Text, "co"
If TreeView1.Nodes("parent").Expanded = False Then
TreeView1.Nodes("parent").Expanded = True
End If
Skin.RemoveSkin cmdnew.hwnd
cmdnew.Caption = "T¹o míi"
Skin.ApplySkin cmdnew.hwnd
ClearText
cmdsave.Enabled = False
DisableText
ElseIf logic = False Then
sql = "update tblnhanvien set [tennhanvien] =" & _
"'" & txtHoten.Text & "',[diachi]=" & _
"'" & txtDiachi.Text & "', [capbac]=" & _
"'" & txtCapbac.Text & "',[chuyenkhoa]=" & _
"'" & txtChuyenkhoa.Text & "',[dtnr]=" & _
"'" & txtDTnharieng.Text & "',[dtcq]=" & _
"'" & txtDTcoquan.Text & "',[didong]=" & _
"'" & txtDTdidong.Text & "',[ngayluong]=" & _
"'" & txtNgayluong.Text & "',[donvi]=" & _
"'" & txtDonvi.Text & "'" & _
" where manhanvien = '" & txtMa.Text & "'"
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = cnn1
.CommandText = sql
.Execute
End With
End If
TreeView1.Sorted = True
cmddelete.Enabled = True
TreeView1.Enabled = True
DisableText
If cmdedit.Caption = "Huû" Then
Skin.RemoveSkin cmdedit.hwnd
cmdedit.Caption = "Söa"
Skin.ApplySkin cmdedit.hwnd
End If
cmdedit.Enabled = True
cmdsave.Enabled = False
Saved = True
cmdexit.Enabled = True
cmdnew.Enabled = True
logic = False
End Sub
1.7 Mã nguồn Form_load
Private Sub Form_Load()
Saved = True
'Load skin cho form
Dim SkinPath As String
SkinPath = App.Path & "\skin\web_ii.skn"
Skin.LoadSkin SkinPath
Skin.ApplySkin Me.hwnd
'Xac dinh khung cua form
frm_nhanvien.Height = 5900
frm_nhanvien.Width = 10250
'Nap co so du lieu len form
Set cnn1 = New ADODB.Connection
cnn1.Provider = "Microsoft.Jet.OLEDB.3.51"
cnn1.Open App.Path & "\qltc.mdb"
Set rsNhanvien = New ADODB.Recordset
rsNhanvien.Open "tblNhanvien", cnn1, adOpenKeyset, adLockOptimistic, adCmdTable
'Tao cac Node len treeview theo co so du lieu
Call Create_Node
'Khoi tao Panel
Dim mypanel As Panel
StatusBar1.Panels.Clear
Set mypanel = StatusBar1.Panels.Add(1, , , sbrDate)
mypanel.AutoSize = sbrNoAutoSize
mypanel.Bevel = sbrInset
Set mypanel = StatusBar1.Panels.Add(2, , , sbrTime)
mypanel.AutoSize = sbrNoAutoSize
mypanel.Bevel = sbrInset
mypanel.Alignment = sbrLeft
Set mypanel = StatusBar1.Panels.Add(3)
StatusBar1.Panels(3).Text = "Thanh tr¹ng th¸i"
StatusBar1.Panels(3).AutoSize = sbrSpring
'Tao kieu cho label Nhan vien
Lbldanhsach.FontBold = True
cmdsave.Enabled = False
If CallMaNV = "" Then
'Disable Text khi load form
Else
If rsNhanvien.RecordCount <= 0 Then
Exit Sub
End If
rsNhanvien.MoveFirst
Do While Not rsNhanvien.EOF
If rsNhanvien!manhanvien = CallMaNV Then
Call ClearText
Call Dis
DisableText
Exit Sub
End If
rsNhanvien.MoveNext
Loop
End If
DisableText
End Sub
1.8 Priviate sub Dis
Private Sub Dis()
txtMa.Text = rsNhanvien!manhanvien
If IsNull(rsNhanvien!tennhanvien) = False Then
txtHoten.Text = rsNhanvien!tennhanvien
End If
If IsNull(rsNhanvien!diachi) = False Then
txtDiachi.Text = rsNhanvien!diachi
End If
If IsNull(rsNhanvien!dtnr) = False Then
txtDTnharieng = rsNhanvien!dtnr
End If
If IsNull(rsNhanvien!dtcq) = False Then
txtDTcoquan = rsNhanvien!dtcq
End If
If IsNull(rsNhanvien!didong) = False Then
txtDTdidong = rsNhanvien!didong
End If
If IsNull(rsNhanvien!capbac) = False Then
txtCapbac = rsNhanvien!capbac
End If
If IsNull(rsNhanvien!chuyenkhoa) = False Then
txtChuyenkhoa = rsNhanvien!chuyenkhoa
End If
If IsNull(rsNhanvien!donvi) = False Then
txtDonvi = rsNhanvien!donvi
End If
If IsNull(rsNhanvien!ngayluong) = False Then
txtNgayluong = rsNhanvien!ngayluong
End If
End Sub
1.9 Mã nguồn thủ tục Create_Node
Private Sub Create_Node()
Dim ChildID As Integer
TreeView1.Refresh
TreeView1.Nodes.Clear
TreeView1.Nodes.Add , , "parent", "Nh©n viªn", "star"
ChildID = 0
If rsNhanvien.RecordCount <= 0 Then
Exit Sub
End If
rsNhanvien.MoveFirst
Do Until rsNhanvien.EOF = True
TreeView1.Nodes.Add "parent", tvwChild, "C" & ChildID & "", rsNhanvien!manhanvien, "co"
ChildID = ChildID + 1
rsNhanvien.MoveNext
Loop
TreeView1.Nodes("parent").Expanded = True
End Sub
Mã nguồn thủ tục Check()
Private Sub check()
Dim i As Integer
Dim thi As String
rsNhanvien.MoveFirst
Do While Not rsNhanvien.EOF
If rsNhanvien.EOF Then rsNhanvien.MoveLast
For i = 1 To Len(rsNhanvien!manhanvien)
thi = Mid(rsNhanvien!manhanvien, i, 1)
If IsNumeric(thi) Then
t(i) = thi
chu = t(i - 4) & t(i - 3) & t(i - 2) & t(i - 1) & t(i)
l = CInt(chu)
End If
If l > temp Then temp = l
Next i
rsNhanvien.MoveNext
Loop
End Sub
Form Frm_benhnhan
Mã nguồn thủ tuc Cmbmadichvu_click
Private Sub Cmbmadichvu_click()
rst2.MoveFirst
While Not rst2.EOF
If rst2!madv = Me.cmbmadichvu.Text Then
If IsNull(rst2!tendv) Then
Me.txttendichvu = ""
Else
Me.txttendichvu = rst2!tendv
End If
If IsNull(rst2!giadv) Then
Me.txtdongia = ""
Else
Me.txtdongia = rst2!giadv
End If
End If
rst2.MoveNext
Wend
If b = True Then
Me.cmbmanhanvien.Clear
rst1.MoveFirst
While Not rst1.EOF
If rst1!mabenhnhan = Me.txtmabenhnhan.Text And rst1!madichvu = Me.cmbmadichvu.Text Then
Me.cmbmanhanvien.AddItem rst1!manhanvien
End If
rst1.MoveNext
Wend
End If
End Sub
Mã nguồnthủ tục CmbManhanvien_Click
Private Sub CmbManhanvien_Click()
rst3.MoveFirst
While Not rst3.EOF
If rst3!manhanvien = Me.cmbmanhanvien.Text Then
If IsNull(rst3!tennhanvien) Then
Me.txttennhanvien = ""
Else
Me.txttennhanvien = rst3!tennhanvien
End If
If IsNull(rst3!chuyenkhoa) Then
Me.txtchuyenkhoa = ""
Else
Me.txtchuyenkhoa = rst3!chuyenkhoa
End If
End If
rst3.MoveNext
Wend
End Sub
Mã nguồn thủ tục CmdAdd_Click()
Private Sub CmdAdd_Click()
If CmdAdd.Caption = "T¹o míi" Then
flag = True
'Me.cmbmadichvu.Enabled = False
'Me.cmbmanhanvien.Enabled = False
Me.txttendichvu.Enabled = False
Me.txtchuyenkhoa.Enabled = False
Me.txttendichvu.Enabled = False
Me.txtdongia.Enabled = False
Me.lst1.ListItems.Clear
Me.lst2.ListItems.Clear
cmdxoa.Enabled = False
cmdsua.Enabled = False
cmdnewdv.Enabled = False
cmdsavedv.Enabled = False
cmddeletedv.Enabled = False
Me.cmdluu.Enabled = True
Me.cmdAddlist.Visible = False
Me.cmdaddlist1.Visible = False
Me.cmddeletelist.Visible = False
Me.cmddeletelist1.Visible = False
Me.txtmabenhnhan.Text = ""
Me.txthoten.Text = ""
Me.txttuoi.Text = ""
Me.txtdiachi.Text = ""
Me.txtdienthoai.Text = ""
Me.cmbmadichvu.Clear
Me.cmbmanhanvien.Clear
Skin.RemoveSkin CmdAdd.hwnd
CmdAdd.Caption = "Huû"
Skin.LoadSkin App.Path & "\_temp.skn"
Skin.ApplySkin CmdAdd.hwnd
rst2.MoveFirst
While Not rst2.EOF
Me.cmbmadichvu.AddItem rst2.Fields(0).Value
rst2.MoveNext
Wend
rst4.MoveFirst
While Not rst4.EOF
If rst4!ngaylamviec = Date Then
Me.cmbmanhanvien.AddItem rst4.Fields(0).Value
End If
rst4.MoveNext
Wend
b = False
ElseIf CmdAdd.Caption = "Huû" Then
flag = False
Me.cmbmadichvu.Enabled = True
Me.cmbmanhanvien.Enabled = True
cmdxoa.Enabled = True
cmdsua.Enabled = True
cmdnewdv.Enabled = True
cmdsavedv.Enabled = False
cmddeletedv.Enabled = True
cmdluu.Enabled = False
Me.txttendichvu.Enabled = True
Me.txtchuyenkhoa.Enabled = True
Me.txttendichvu.Enabled = True
Me.txtdongia.Enabled = True
Me.lst1.Enabled = True
Me.lst2.Enabled = True
Me.txtmabenhnhan.Text = ""
Me.txthoten.Text = ""
Me.txttuoi.Text = ""
Me.txtdiachi.Text = ""
Me.txtdienthoai.Text = ""
Me.cmbmadichvu.Clear
Me.cmbmanhanvien.Clear
Skin.RemoveSkin CmdAdd.hwnd
CmdAdd.Caption = "T¹o míi"
Skin.LoadSkin App.Path & "\_temp.skn"
Skin.ApplySkin CmdAdd.hwnd
b = True
End If
lst1.ListItems.Clear
lst2.ListItems.Clear
'lst1.Refresh
'lst2.Refresh
End Sub
Mã nguồn thủ tục cmdAddlist_Click()
Private Sub cmdAddlist_Click()
If Me.cmbmadichvu.Text = "" Then
Exit Sub
Else
Set l = Me.lst1.ListItems.Add(, , Me.cmbmadichvu.Text)
l.SubItems(1) = Me.txttendichvu.Text
l.SubItems(2) = Me.txtdongia.Text
Me.cmdaddlist1.Visible = True
Me.cmddeletelist.Visible = True
End If
End Sub
Mã nguồn thủ tục cmddeletedv_Click()
Private Sub cmddeletedv_Click()
Dim i, j As Integer
If Me.cmbmadichvu.Text = "" Then
MsgBox "chua chon dich vu can xoa"
Me.cmbmadichvu.SetFocus
Exit Sub
ElseIf Me.cmbmanhanvien.Text = "" Then
MsgBox "chua chon nhan vien can xoa"
Me.cmbmadichvu.SetFocus
Exit Sub
Else
rst1.MoveFirst
While Not rst1.EOF
If rst1!mabenhnhan = Me.txtmabenhnhan And rst1!manhanvien = Me.cmbmanhanvien.Text And rst1!madichvu = Me.cmbmadichvu.Text Then
rst1.Delete
End If
rst1.MoveNext
Wend
End If
i = Me.lst1.ListItems.Count
j = 0
While i > 0 And j 1
If Me.lst1.ListItems(i).Text = Me.cmbmadichvu.Text Then
Me.lst1.ListItems.Remove i
i = i - 1
j = 1
Else
i = i - 1
End If
Wend
i = Me.lst2.ListItems.Count
j = 0
While i > 0 And j 1
If Me.lst2.ListItems(i).Text = Me.cmbmanhanvien.Text Then
Me.lst2.ListItems.Remove i
i = i - 1
j = 1
Else
i = i - 1
End If
Wend
End Sub
Mã nguồn thủ tục cmdin_Click()
Private Sub cmdin_Click()
Dim sql As String
Dim rst10 As ADODB.Recordset
sql = "SELECT tblDV.MaBenhNhan, tblBenhnhan.Hoten, tblDichvu.TenDV, tblDichvu.Giadv, tblDV.NgaylamDV" & _
" FROM tblNhanVien INNER JOIN (tblBenhnhan INNER JOIN (tblDichvu INNER JOIN tblDV ON tblDichvu.MaDV = tblDV.MaDichVu) ON tblBenhnhan.MaBenhNhan = tblDV.MaBenhNhan) ON tblNhanVien.MaNhanVien = tblDV.MaNhanVien" & _
" WHERE tblDV.Mabenhnhan ='" & Me.txtmabenhnhan.Text & "'"
Set rst10 = New ADODB.Recordset
With rst10
.ActiveConnection = cnnData
.Source = sql
.Open
End With
Set rpt_Hoadon.DataSource = rst10
rpt_Hoadon.Show
End Sub
Mã nguồn thủ tục cmdluu_Click()
Private Sub cmdluu_Click()
Dim sql As String
If Me.CmdAdd.Caption = "Huû" Then
Skin.RemoveSkin CmdAdd.hwnd
CmdAdd.Caption = "T¹o míi"
Skin.LoadSkin App.Path & "\_temp.skn"
Skin.ApplySkin CmdAdd.hwnd
End If
If flag = True Then
If Me.txtmabenhnhan = "" Then
Me.txtmabenhnhan.SetFocus
cmdluu.Enabled = False
Exit Sub
Else
If Me.cmbmadichvu.Text = "" Then
MsgBox "cha nhËp dÞch vô"
Me.cmbmadichvu.SetFocus
Exit Sub
End If
If Me.cmbmanhanvien.Text = "" Then
MsgBox "cha nhËp nh©n viªn"
Me.cmbmanhanvien.SetFocus
Exit Sub
End If
With rst
.AddNew
.Fields(0).Value = Me.txtmabenhnhan.Text
.Fields(1).Value = Me.txthoten.Text
.Fields(2).Value = Me.txttuoi.Text
.Fields(3).Value = Me.txtdiachi.Text
.Fields(4).Value = Me.txtdienthoai.Text
.Update
End With
With rst1
.AddNew
.Fields(0).Value = Me.txtmabenhnhan.Text
.Fields(1).Value = Me.cmbmanhanvien.Text
.Fields(2).Value = Me.cmbmadichvu.Text
.Fields(3).Value = Date
.Update
End With
TreeView1.Nodes.Add "parent", tvwChild, , Me.txtmabenhnhan.Text, "tron"
Me.lst1.Enabled = True
Me.lst2.Enabled = True
Set l = Me.lst1.ListItems.Add(, , Me.cmbmadichvu.Text)
l.SubItems(1) = Me.txttendichvu.Text
l.SubItems(2) = Me.txtdongia.Text
Set s = Me.lst2.ListItems.Add(, , Me.cmbmanhanvien.Text)
s.SubItems(1) = Me.txttennhanvien
s.SubItems(2) = Me.txtchuyenkhoa
'If Me.CmdAdd.Caption = "Huû" Then
Me.cmdnewdv.Enabled = True
Skin.RemoveSkin Me.CmdAdd.hwnd
Me.CmdAdd.Caption = "T¹o míi"
Skin.LoadSkin App.Path & "\_temp.skn"
Skin.ApplySkin Me.CmdAdd.hwnd
'End If
End If
ElseIf flag = False Then
sql = "update tblbenhnhan set [hoten] ='" & Me.txthoten.Text & "'," & "[tuoi] ='" & Me.txttuoi.Text & "'," & "[diachi] ='" & Me.txtdiachi.Text & "'," & "[dienthoai] ='" & Me.txtdienthoai.Text & "'" & _
" where tblbenhnhan.mabenhnhan ='" & Me.txtmabenhnhan.Text & "'"
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = cn
.CommandText = sql
.Execute
End With
End If
flag = False
b = True
Me.txtchuyenkhoa = ""
Me.txtdiachi = ""
Me.txtdienthoai = ""
Me.txtdongia = ""
Me.txthoten = ""
Me.txtmabenhnhan = ""
Me.txttendichvu = ""
Me.txttennhanvien = ""
Me.txttuoi = ""
Me.cmbmadichvu.Clear
Me.cmbmanhanvien.Clear
cmdluu.Enabled = False
cmdxoa.Enabled = True
cmdsua.Enabled = True
End Sub
Mã nguồn thủ tục cmdnewdv_Click()
Private Sub cmdnewdv_Click()
If Me.cmdnewdv.Caption = "Thªm dÞch vô" Then
flag1 = True
Me.cmbmadichvu.Clear
rst2.MoveFirst
While Not rst2.EOF
Me.cmbmadichvu.AddItem rst2.Fields(0).Value
rst2.MoveNext
Wend
Me.cmbmanhanvien.Clear
rst4.MoveFirst
While Not rst4.EOF
If rst4!ngaylamviec = Date Then
Me.cmbmanhanvien.AddItem rst4!manhanvien
End If
rst4.MoveNext
Wend
Skin.RemoveSkin Me.cmdnewdv.hwnd
Me.cmdnewdv.Caption = "Huû"
Skin.LoadSkin App.Path & "\_temp.skn"
Skin.ApplySkin Me.cmdnewdv.hwnd
Me.cmddeletedv.Enabled = False
Me.cmdsavedv.Enabled = True
b = False
Me.txttendichvu = ""
Me.txtdongia = ""
Me.txttennhanvien = ""
Me.txtchuyenkhoa = ""
Me.cmdAddlist.Visible = True
' Me.cmddeletelist.Visible = True
ok = Me.lst1.ListItems.Count
ElseIf Me.cmdnewdv.Caption = "Huû" Then
flag1 = False
rst1.MoveFirst
lst1.ListItems.Clear
Me.cmbmadichvu.Clear
While Not rst1.EOF
If rst1!mabenhnhan = Me.txtmabenhnhan.Text Then
Me.cmbmadichvu.AddItem rst1!madichvu
rst2.MoveFirst
While Not rst2.EOF
If rst2!madv = rst1!madichvu Then
Set l = lst1.ListItems.Add(, , rst2!madv)
l.SubItems(1) = rst2!tendv
l.SubItems(2) = rst2!giadv
End If
rst2.MoveNext
Wend
End If
rst1.MoveNext
Wend
'MsgBox Me.cmbmadichvu.ListCount
' For i = Me.cmbmadichvu.ListCount - 1 To 2 Step -1
' For j = Me.cmbmadichvu.ListCount - 2 To 1 Step -1
' If Me.cmbmadichvu.List(i) = Me.cmbmadichvu.List(j) Then
' Me.cmbmadichvu.RemoveItem j
' End If
' Next j
' Next i
rst1.MoveFirst
lst2.ListItems.Clear
While Not rst1.EOF
If rst1!mabenhnhan = Me.txtmabenhnhan.Text Then
rst3.MoveFirst
While Not rst3.EOF
If rst3!manhanvien = rst1!manhanvien Then
Set s = lst2.ListItems.Add(, , rst3!manhanvien)
If IsNull(rst3!tennhanvien) Then
s.SubItems(1) = ""
Else
s.SubItems(1) = rst3!tennhanvien
End If
If IsNull(rst3!capbac) Then
s.SubItems(2) = ""
Else
s.SubItems(2) = rst3!capbac
End If
If IsNull(rst3!chuyenkhoa) Then
s.SubItems(3) = ""
Else
s.SubItems(3) = rst3!chuyenkhoa
End If
End If
rst3.MoveNext
Wend
End If
rst1.MoveNext
Wend
Me.CmdAdd.Enabled = True
Me.cmdluu.Enabled = True
Me.cmdxoa.Enabled = True
'Me.cmdnewdv.Enabled = True
'Me.cmdsavedv.Enabled = True
'Me.cmddeletedv.Enabled = True
Skin.RemoveSkin Me.cmdnewdv.hwnd
Me.cmdnewdv.Caption = "Thªm dÞch vô"
Skin.LoadSkin App.Path & "\_temp.skn"
Skin.ApplySkin Me.cmdnewdv.hwnd
Me.cmbmanhanvien.Clear
Me.txttendichvu = ""
Me.txtdongia = ""
Me.txttennhanvien = ""
Me.txtchuyenkhoa = ""
b = True
Me.cmdAddlist.Visible = False
Me.cmddeletelist.Visible = False
End If
End Sub
Mã nguồn thủ tục cmdsavedv_Click()
Private Sub cmdsavedv_Click()
Dim i, j As Integer
If cmdnewdv.Caption = "Huû" Then
Skin.RemoveSkin cmdnewdv.hwnd
cmdnewdv.Caption = "Thªm dÞch vô"
Skin.LoadSkin App.Path & "\_temp.skn"
Skin.ApplySkin cmdnewdv.hwnd
End If
If flag1 = True Then
If Me.lst1.ListItems.Count < Me.lst2.ListItems.Count Then
MsgBox "Cha nhËp d÷ liÖu vÒ phÇn dÞch vô!", , "Th«ng b¸o!"
Me.cmdAddlist.SetFocus
Exit Sub
ElseIf Me.lst1.ListItems.Count > Me.lst2.ListItems.Count Then
MsgBox "Cha nhËp d÷ liÖu vÒ phÇn nh©n viªn!", , "Th«ng b¸o!"
Me.cmdaddlist1.SetFocus
Exit Sub
ElseIf Me.lst1.ListItems.Count = Me.lst2.ListItems.Count = ok Then
Exit Sub
Else
j = ok + 1
For i = j To Me.lst1.ListItems.Count
With rst1
.AddNew
.Fields(0).Value = Me.txtmabenhnhan.Text
.Fields(1).Value = Me.lst2.ListItems(i).Text
.Fields(2).Value = Me.lst1.ListItems(i).Text
.Fields(3).Value = Date
.Update
End With
Next i
End If
End If
b = True
Me.cmdsavedv.Enabled = False
Me.cmddeletedv.Enabled = True
Me.cmdsavedv.Enabled = False
Me.cmdAddlist.Visible = False
Me.cmddeletelist.Visible = False
Me.cmdaddlist1.Visible = False
Me.cmddeletelist1.Visible = False
End Sub
Mã nguồn thủ tục cmdxoa_Click()
Private Sub cmdxoa_Click()
Dim i As Integer
Dim ctr As Control
rst.MoveFirst
While Not rst.EOF
If rst.Fields(0).Value = Me.txtmabenhnhan.Text Then
rst.Delete
For i = TreeView1.Nodes.Count - 1 To 1 Step -1
If TreeView1.Nodes.Item(i).Text = Me.txtmabenhnhan.Text Then
TreeView1.Nodes.Remove i
End If
Next i
End If
rst.MoveNext
Wend
For Each ctr In Me.Controls
If TypeOf ctr Is TextBox Then
ctr.Text = ""
End If
If TypeOf ctr Is ComboBox Then
ctr.Text = ""
End If
If TypeOf ctr Is ListItem Then
ctr.ListItems.Clear
End If
Next
Me.lst1.ListItems.Clear
Me.lst2.ListItems.Clear
Me.cmbmadichvu.Enabled = True
Me.cmbmanhanvien.Enabled = True
Me.txttendichvu.Enabled = True
Me.txtchuyenkhoa.Enabled = True
Me.txttendichvu.Enabled = True
Me.txtdongia.Enabled = True
Me.lst1.Enabled = True
Me.lst2.Enabled = True
End Sub
Mã nguồn thủ tục Form_load
Private Sub Form_Load()
Me.Height = 8200
Me.Width = 11200
CmdAdd.Enabled = False
Me.cmdAddlist.Visible = False
Me.cmdaddlist1.Visible = False
Me.cmddeletedv.Enabled = False
Me.cmddeletelist.Visible = False
Me.cmddeletelist1.Visible = False
Me.cmdexit.Enabled = True
Me.cmdnewdv.Enabled = False
Me.cmdin.Enabled = False
Me.CmdAdd.Enabled = True
Me.cmdluu.Enabled = False
Me.cmdsavedv.Enabled = False
Me.cmdsua.Enabled = False
Me.cmdxoa.Enabled = False
Skin.LoadSkin App.Path & "\_temp.skn"
Skin.ApplySkin Me.hwnd
b = True
Set cn = New ADODB.Connection
With cn
.Provider = "microsoft.jet.oledb.3.51"
.ConnectionString = App.Path & "\qltc.mdb"
.Open
End With
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = cn
.Source = "select * from tblbenhnhan"
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open
End With
Set rst1 = New ADODB.Recordset
With rst1
.ActiveConnection = cn
.Source = "select * from tbldv"
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open
End With
Set rst2 = New ADODB.Recordset
With rst2
.ActiveConnection = cn
.Source = "select * from tbldichvu"
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open
End With
Set rst3 = New ADODB.Recordset
With rst3
.ActiveConnection = cn
.Source = "select * from tblnhanvien"
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open
End With
Set rst4 = New ADODB.Recordset
With rst4
.ActiveConnection = cn
.Source = "select * from tbllichkham"
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Open
End With
TreeView1.Nodes.Add , , "parent", "Danh sach benh nhan ngay :" & Date, "star"
rst.MoveFirst
While Not rst.EOF
TreeView1.Nodes.Add "parent", tvwChild, , rst.Fields(0).Value, "tron"
rst.MoveNext
Wend
TreeView1.Nodes("parent").Expanded = True
lst1.ColumnHeaders.Add 1, , "Ma Dich Vu"
lst1.ColumnHeaders.Add 2, , "Ten Dich Vu"
lst1.ColumnHeaders.Add 3, , "Don Gia"
lst2.ColumnHeaders.Add 1, , "Ma Nhan Vien"
lst2.ColumnHeaders.Add 2, , "Ten Nhan Vien"
lst2.ColumnHeaders.Add 3, , "Cap Bac"
lst2.ColumnHeaders.Add 4, , "Chuyen Khoa"
lst2.View = lvwReport
flag = False
flag1 = False
lst1.Enabled = False
lst2.Enabled = False
End Sub
Form Frm_ khachhang
Mã nguồn thủ tục cmd_add_Click()
Private Sub cmd_add_Click()
Dim tho As Control
vAdd = True
If cmd_add.Caption = "Thªm" Then
Skin.RemoveSkin cmd_add.hwnd
cmd_add.Caption = "Huû"
Skin.ApplySkin cmd_add.hwnd
For Each tho In Controls
If TypeOf tho Is CommandButton Then
tho.Enabled = False
End If
Next tho
cmd_add.Enabled = True
cmd_save.Enabled = True
cmd_close.Enabled = True
TreeView1.Enabled = False
Check100
Luong = CInt(chu)
la = "MDD" & (temp + 1)
rsdd.AddNew
Me.txtdiachidd.Text = ""
Me.txtdtdd.Text = ""
Me.txtdd.Text = ""
Me.txthotendd.Text = ""
Me.txtmdd.Text = ""
txtmdd = la
Else
bandau
Skin.RemoveSkin cmd_add.hwnd
cmd_add.Caption = "Thªm"
Skin.ApplySkin cmd_add.hwnd
cmd_save.Enabled = False
ClearText
rsdd.CancelUpdate
TreeView1.Enabled = True
End If
End Sub
Mã nguồn thủ tục cmd_Close_Click()
Private Sub cmd_Close_Click()
Unload Me
End Sub
Private Sub cmd_del_Click()
'Dim cmd As ADODB.Command
'Dim sql As String
'sql = "Delete from tbldaidien" & _
' " where madaidien='" & txtmdd.Text & "'"
'Set cmd = New ADODB.Command
'With cmd
' .ActiveConnection = cnn
' .CommandText = sql
' .Execute
'End With
Dim tho As Integer
tho = MsgBox("B¹n cã muèn xo¸ b¶n ghi nµy kh«ng ?", vbInformation + vbYesNo, "Chó ý !")
If tho = vbYes Then
If rsdd.RecordCount <= 0 Then
Exit Sub
End If
bandau
If txtMadv.Text = "" Then
Exit Sub
End If
rsdd.MoveFirst
While Not rsdd.EOF
If rsdd!madaidien = txtmdd.Text Then
rsdd.Delete
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes(i).Text = txtMadv.Text Then
TreeView1.Nodes.Remove i
Exit For
End If
Next i
End If
rsdd.MoveNext
Wend
ClearText
rsdd.MovePrevious
If rsdd.BOF = True Then rsdd.MoveFirst
rsDv.MovePrevious
If rsDv.BOF = True Then rsDv.MoveFirst
Else
Exit Sub
End If
End Sub
Mã nguồn thủ tục cmd_edit_Click()
Private Sub cmd_edit_Click()
Dim bo As Control
For Each bo In Controls
If TypeOf bo Is CommandButton Then
bo.Enabled = False
End If
Next bo
cmd_save.Enabled = True
cmd_close.Enabled = True
TreeView1.Enabled = False
logic = True
End Sub
Mã nguồn thủ tục cmd_new_Click()
Private Sub cmd_new_Click()
If cmd_new.Caption = "T¹o míi" Then
Skin.RemoveSkin cmd_new.hwnd
cmd_new.Caption = "Huû"
cmd_save.Enabled = True
Skin.ApplySkin cmd_new.hwnd
check
Luong = CInt(chu)
ha = "M§V" & (temp + 1)
rsDv.AddNew
Check100
Luong = CInt(chu)
la = "M§D" & (temp + 1)
rsdd.AddNew
ClearText
txtmdd = la
txtMadv = ha
Dim bo As Control
For Each bo In Controls
If TypeOf bo Is CommandButton Then
bo.Enabled = False
End If
Next bo
cmd_save.Enabled = True
cmd_close.Enabled = True
cmd_new.Enabled = True
TreeView1.Enabled = False
Else
bandau
rsDv.CancelUpdate
rsdd.CancelUpdate
cmd_save.Enabled = False
Skin.RemoveSkin cmd_new.hwnd
cmd_new.Caption = "T¹o míi"
Skin.ApplySkin cmd_new.hwnd
TreeView1.Enabled = True
ClearText
End If
End Sub
mã nguồn thủ tục cmd_save_Click()
Private Sub cmd_save_Click()
If cmd_add.Caption = "Huû" Then
Skin.RemoveSkin cmd_add.hwnd
cmd_add.Caption = "Thªm"
Skin.ApplySkin cmd_add.hwnd
End If
If cmd_new.Caption = "Huû" Then
Skin.RemoveSkin cmd_new.hwnd
cmd_new.Caption = "T¹o míi"
Skin.ApplySkin cmd_new.hwnd
End If
If logic = True Then
'********************EDIT CLICK*****************
Dim cmd As ADODB.Command
Dim cmddv As ADODB.Command
Dim sqledit As String
Dim sqleditdv As String
sqledit = "update tbldaidien set [tennguoidaidien] =" & _
"'" & txthotendd.Text & "',[diachi]=" & _
"'" & txtdiachidd.Text & "', [dienthoai]=" & _
"'" & txtdtdd.Text & "',[DiDong]=" & _
"'" & txtdd.Text & "'" & _
" where madaidien = '" & txtmdd.Text & "'"
sqleditdv = "update tbldonvilamhd set [tendonvi]=" & _
"'" & txttendv.Text & "',[diachi]='" & txtdiachidv.Text & "',[dienthoai]=" & _
"'" & txtDTdv.Text & "',[FAX]='" & txtFaxdv.Text & "',[MAVUNG]=" & _
"'" & cmbMaVungDv.Text & "'" & _
" where MADAIDIEN='" & txtmdd.Text & "' and MADONVI='" & txtMadv.Text & "'"
Set cmd = New ADODB.Command
Set cmddv = New ADODB.Command
With cmd
.ActiveConnection = cnn
.CommandText = sqledit
.Execute
End With
With cmddv
.ActiveConnection = cnn
.CommandText = sqleditdv
.E
Các file đính kèm theo tài liệu này:
- P0075.doc