Đề tài Quản lý bệnh nhân tại bệnh viện mắt Nam Định
LỜI NÓI ĐẦU Ngày này cùng với sự phát triển vượt bậc của khoa học kỹ thuật thì công nghệ thông tin là một công cụ hỗ trợ rất đắc lực trong công tác quản lý. Chúng ta dễ dàng thấy được việc đưa tin học vào trong quản lý kinh doanh là một trong những ứng dụng quan trọng trong rất nhiều ứng dụng cơ sở dữ liệu. Nhờ vào công tác tin học hóa mà công việc quản lý và điều hành doanh nghiệp tỏ ra rất nhanh chóng và hiệu quả. Chính vì lẽ đó mà cơ sở dữ liệu như là một giải pháp hữu hiệu nhất cho các doanh nghiệp có thể tồn tại và phát triển một cách nhanh chóng.thông tin là một trong những lĩnh vực có nhiều đóng góp thiết thực nhất, công nghệ thông tin có mặt trong hầu hết các lĩnh vực của cuộc sống đặc biệt công nghệ
Bệnh viện Mắt tỉnh Nam Định là một trung tâm khám chữa các bệnh về Mắt lớn nhất tỉnh Nam Định. Do đó nhu cầu ứng dụng cơ sở dữ liệu trong việc quản lý bệnh nhân là hết sức thiết thực. Vì vậy nhóm em chọn đề tài phân tích và thiết kế hệ thống thông tin quản lý bệnh nhân tại bệnh viện Mắt tỉnh Nam Định làm đề tài thực tập môn PHÂN TÍCH THIẾT KẾ HỆ THỐNG.
Hệ thống được phân tích và thiết kế theo phương pháp có cấu trúc và được cài đặt trên môi trường Visual Basic 6.0.
Mặc dù có nhiều cố gắng nhưng vốn kiến thức chưa sâu, chưa có nhiều kinh nghiệm và hệ thống khá phức tạp nên không thể tránh khỏi nhữngthiếu sót. Rất mong được sự góp ý của quý thầy cô,anh chị cùng các bạn để báo cáo được hoàn thiện hơn.
Nam Định ngày Tháng năm 2010
125 trang |
Chia sẻ: lvcdongnoi | Lượt xem: 2786 | Lượt tải: 0
Bạn đang xem trước 20 trang tài liệu Đề tài Quản lý bệnh nhân tại bệnh viện mắt Nam Định, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
truoc(1).Enabled = True
Hienthi
End Sub
Private Sub cmdvedau_Click(Index As Integer)
cmdluu(1).Enabled = False
Adodcba.Recordset.MoveFirst
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Hienthi
End Sub
Private Sub cmdvesau_Click(Index As Integer)
cmdluu(1).Enabled = False
Adodcba.Recordset.MoveNext
grdbenhan.Refresh
If Adodcba.Recordset.EOF = True Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
Else
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
End If
Hienthi
End Sub
Private Sub cmdvetruoc_Click(Index As Integer)
cmdluu(1).Enabled = False
Adodcba.Recordset.MovePrevious
grdbenhan.Refresh
If Adodcba.Recordset.BOF = True Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Else
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End If
Hienthi
End Sub
Private Sub cmdxoa_Click(Index As Integer)
cmdluu(1).Enabled = True
Dim str As String
Dim response As VbMsgBoxResult
response = MsgBox(("B¹n cã muèn xoa b¶n ghi nµy kh«ng?"), vbYesNo + vbCritical, ("Thoong baso"))
If response = vbNo Then
Exit Sub
Else
Connection.OpenData ("benhan1")
str = "DELETE * FROM benhan1 where ((mabn = '" & (cbmabn.Text) & "') and (manv = '" & cbmanv.Text & "') and (sophong = '" & cbmap.Text & "')and (mabenh = '" & cbmabText & "'))"
cn.Execute (str)
End If
cbngayra.Enabled = False
cbthangra.Enabled = False
cbnamra.Enabled = False
Lammoi
Mo_khoa
End Sub
Private Sub setnull()
cmdluu(1).Enabled = True
cbmabn.Text = ""
cbmanv.Text = ""
cbmab.Text = ""
cbmap.Text = ""
txttt.Text = ""
cbngayvao.Text = "1"
cbthangvao.Text = "1"
cbnamvao.Text = "2009"
End Sub
Private Sub grdbenhan_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
cmdluu(1).Enabled = False
If (Adodcba.Recordset.BOF = False And Adodcba.Recordset.EOF = False) Then
cbmabn.Text = Adodcba.Recordset.Fields("mabn").Value
cbmanv.Text = Adodcba.Recordset.Fields("manv").Value
cbmab.Text = Adodcba.Recordset.Fields("mabenh").Value
cbmap.Text = Adodcba.Recordset.Fields("sophong").Value
txttt.Text = Adodcba.Recordset.Fields("ttbenh").Value
Call layngay(Adodcba.Recordset.Fields("ngayvao"), cbngayvao, cbthangvao, cbnamvao)
If Adodcba.Recordset.Fields("ngayra").Value "" Then
Call layngay(Adodcba.Recordset.Fields("ngayra"), cbngayra, cbthangra, cbnamra)
optcn.Visible = False
lbn.Visible = True
hienngay
cmdtra.Visible = False
Else
optcn.Visible = True
optcn.Value = False
lbn.Visible = False ' an di
anngay
End If
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
If Adodcba.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
End If
If Adodcba.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
End If
End If
End Sub
Private Sub Hienthi()
cmdluu(1).Enabled = False
If (Adodcba.Recordset.BOF = False And Adodcba.Recordset.EOF = False) Then
cbmabn.Text = Adodcba.Recordset.Fields("mabn").Value
cbmanv.Text = Adodcba.Recordset.Fields("manv").Value
cbmab.Text = Adodcba.Recordset.Fields("mabenh").Value
cbmap.Text = Adodcba.Recordset.Fields("sophong").Value
txttt.Text = Adodcba.Recordset.Fields("ttbenh").Value
Call layngay(Adodcba.Recordset.Fields("ngayvao"), cbngayvao, cbthangvao, cbnamvao)
If Adodcba.Recordset.Fields("ngayra").Value "" Then
Call layngay(Adodcba.Recordset.Fields("ngayra"), cbngayra, cbthangra, cbnamra)
optcn.Visible = False
lbn.Visible = True
hienngay
cmdtra.Visible = False
Else
optcn.Visible = True
optcn.Value = False
lbn.Visible = False
anngay
End If
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
If Adodcba.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
End If
If Adodcba.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
End If
End If
End Sub
Private Sub Lammoi()
Adodcba.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcba.RecordSource = "benhan1"
Connection.OpenData ("benhan1")
Adodcba.Refresh
End Sub
Private Sub khoa()
cbmabn.Locked = True
cbmanv.Locked = True
cbmab.Locked = True
cbmap.Locked = True
cbngayvao.Locked = True
cbthangvao.Locked = True
cbnamvao.Locked = True
cbngayra.Locked = True
cbthangra.Locked = True
cbnamra.Locked = True
txttt.Locked = True
End Sub
Private Sub Mo_khoa()
cbmabn.Locked = False
cbmanv.Locked = False
cbmab.Locked = False
cbmap.Locked = False
cbngayvao.Locked = False
cbthangvao.Locked = False
cbnamvao.Locked = False
cbngayra.Locked = False
cbthangra.Locked = False
cbnamra.Locked = False
txttt.Locked = False
End Sub
Private Sub anngay()
cbngayra.Visible = False
cbnamra.Visible = False
cbthangra.Visible = False
End Sub
Private Sub hienngay()
cbngayra.Visible = True
cbnamra.Visible = True
cbthangra.Visible = True
End Sub
Private Sub optcn_Click()
lbn.Visible = True
hienngay
If optcn.Visible = True Then
cmdtra.Visible = True
cbngayra.Locked = False
cbthangra.Locked = False
cbnamra.Locked = False
cbngayra.Enabled = True
cbthangra.Enabled = True
cbnamra.Enabled = True
End If
End Sub
* Tạo giao diện tìm kiếm, thống kê
- Tìm kiếm thông tin bệnh nhân
Cho phép tìm kiếm bệnh nhân theo các tiêu chí: Họ tên, Địa chỉ… Khi tìm thấy bệnh nhân ta có thể xem các thông tin chi tiết của bệnh nhân đó như: Thông tin khám bệnh, thông tin bệnh án, thông tin đơn thuốc, nằm giường, XN/CC…
Hình 4.6: Giao diện tìm kiếm thông tin bệnh nhân
Hình 4.7: Giao diện thống kê bệnh nhân
* Tạo giao diện lập phiếu xét nghiệm
Hình 4.8: Giao diện tạo phiếu xét nghiệm
Code của Form cập nhật và in phiếu xét nghiệm
Dim kt As Boolean
Dim nkd As Date
Dim ktin As Boolean
Private Sub cmdin_Click()
DREP.rsPhieuXN.Open
nxn = cbngayxn.Text & "/" & cbthangxn.Text & "/" & cbnamxn.Text
DREP.rsPhieuXN.Filter = "mabn = '" & dbmabn.Text & "' and madt='" & dbmaxn.Text & "' and manv ='" & dbmanv & "' and ketquaxn= '" & txtkq.Text & "'"
If DREP.rsPhieuXN.RecordCount = 0 Then
MsgBox (" Kh«ng t×m thÊy d÷ liÖu")
DREP.rsPhieuXN.Close
Else
rpkqxn.Show
End If
setnull
cmdin.Enabled = False
Mo_khoa
End Sub
Private Sub cmdsua_Click()
kt = True
cmdluu.Enabled = True
cmdin.Enabled = False
Mo_khoa
dbmabn.Enabled = False
End Sub
Private Sub Form_Load()
Call add_ngay(cbngayxn, cbthangxn, cbnamxn)
cbngayxn.Text = "1"
cbthangxn.Text = "1"
cbnamxn.Text = "2009"
kt = False
ktin = False
cmdin.Enabled = False
AdodcbaConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcxn.RecordSource = "xncc"
Connection.OpenData ("xncc")
Adodcxn.Refresh
grdxn.Refresh
setnull
Mo_khoa
cmdluu.Enabled = True
End Sub
Private Sub cmdluu_Click()
Dim str As String
nxn = cbngayxn.Text & "/" & cbthangxn.Text & "/" & cbnamxn.Text
Connection.OpenData ("xncc")
If (kt = True) Then
str = "update xncc set manv = '" & (dbmanv.Text) & "', madt= = '" & (dbmaxn.Text) & "', ngayXN = '" & nxn & "',ketquaXN = '" & (txtkq.Text) & "'where (mabn = '" & dbmabn.Text & "' and manv= '" & Adodcxn.Recordset.Fields("manv") & "' and madt = '" & Adodcxn.Recordset.Fields("madt") & "' and ketquaxn = '" & Adodcxn.Recordset.Fields("ketquaxn") & "')"
cn.Execute (str)
kt = False
cmdin.Enabled = True
Else
If dbmabn.Text = "" Then
MsgBox ("B¹n ph¶i nhËp m· bÖnh nh©n")
cmdin.Enabled = False
Else
str = "INSERT INTO xncc(mabn,manv,madt,ngayXN,ketquaXN) VALUES ('" _
& dbmabn.Text & "','" & dbmanv.Text & "','" & dbmaxn.Text & "','" & nxn & "','" & txtkq.Text & "')"
cn.Execute (str)
cmdin.Enabled = True
End If
End If
Connection.Closedata
grdxn.Refresh
'/////////////////////////////////////////////////
Lammoi
Mo_khoa
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
dbmabn.Enabled = True
End Sub
Private Sub cmdmoi_Click()
setnull
Mo_khoa
End Sub
Private Sub cmdvecuoi_Click(Index As Integer)
cmdluu.Enabled = False
Adodcxn.Recordset.MoveLast
cmdvecuoi(3).Enabled = False
cmdvesau(2).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvedau_Click(Index As Integer)
cmdluu.Enabled = False
Adodcxn.Recordset.MoveFirst
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvesau_Click(Index As Integer)
cmdluu.Enabled = False
Adodcxn.Recordset.MoveNext
grdxn.Refresh
If Adodcxn.Recordset.EOF = True Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
Else
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
End If
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvetruoc_Click(Index As Integer)
cmdluu.Enabled = False
Adodcxn.Recordset.MovePrevious
grdxn.Refresh
If Adodcxn.Recordset.BOF = True Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Else
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End If
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdxoa_Click()
Dim str As String
Dim response As VbMsgBoxResult
cmdluu.Enabled = True
nxn = cbngayxn.Text & "/" & cbthangxn.Text & "/" & cbnamxn.Text
response = MsgBox(("B¹n cã muèn xo¸ b¶n ghi nµy kh«ng?"), vbYesNo + vbCritical, ("Thoong baso"))
If response = vbNo Then
Exit Sub
Else
Connection.OpenData ("xncc")
str = "DELETE * FROM xncc WHERE mabn = '" & dbmabn.Text & "' and madt='" & dbmaxn.Text & "' and manv ='" & dbmanv & "' and ketquaxn= '" & txtkq.Text & "'" ' and ngayxn = '" & nxn & "' and day(ngayxn)='" & cbngayxn.Text & " and month(ngayxn)='" & cbthangxn.Text & "' and year(ngayxn)='" & cbnamxn.Text & "')"
cn.Execute (str)
End If
setnull
Lammoi
Mo_khoa
End Sub
Private Sub setnull()
cmdluu.Enabled = True
dbmabn.Text = ""
dbmanv.Text = ""
dbmaxn.Text = ""
txtkq.Text = ""
cbngayxn.Text = "1"
cbthangxn.Text = "1"
cbnamxn.Text = "2009"
End Sub
Private Sub grdxn_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdluu.Enabled = False
If (Adodcxn.Recordset.BOF = False And Adodcxn.Recordset.EOF = False) Then
dbmabn.Text = Adodcxn.Recordset.Fields("mabn").Value
dbmanv.Text = Adodcxn.Recordset.Fields("manv").Value
dbmaxn.Text = Adodcxn.Recordset.Fields("madt").Value
Call layngay(Adodcxn.Recordset.Fields("ngayXN"), cbngayxn, cbthangxn, cbnamxn)
txtkq.Text = Adodcxn.Recordset.Fields("ketquaXN").Value
khoa
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
If Adodcxn.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
End If
If Adodcxn.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
End If
cmdin.Enabled = True
End If
End Sub
Private Sub Hienthi()
cogt
cmdluu.Enabled = False
cmdsua.Enabled = True
If (Adodcxn.Recordset.BOF = False And Adodcxn.Recordset.EOF = False) Then
dbmabn.Text = Adodcxn.Recordset.Fields("mabn").Value
dbmanv.Text = Adodcxn.Recordset.Fields("manv").Value
dbmaxn.Text = Adodcxn.Recordset.Fields("madt").Value
Call layngay(Adodcxn.Recordset.Fields("ngayXN"), cbngayxn, cbthangxn, cbnamxn)
txtkq.Text = Adodcxn.Recordset.Fields("ketquaXN").Value
khoa
If Adodcxn.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
End If
If Adodcxn.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
End If
cmdin.Enabled = True
End If
End Sub
Private Sub Lammoi()
Adodcxn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcxn.RecordSource = "xncc"
Connection.OpenData ("xncc")
Adodcxn.Refresh
End Sub
Private Sub khoa()
dbmabn.Locked = True
dbmanv.Locked = True
dbmaxn.Locked = True
cbngayxn.Locked = True
cbthangxn.Locked = True
cbnamxn.Locked = True
txtkq.Locked = True
End Sub
Private Sub Mo_khoa()
dbmabn.Locked = False
dbmanv.Locked = False
dbmaxn.Locked = False
cbngayxn.Locked = False
cbthangxn.Locked = False
cbnamxn.Locked = False
txtkq.Locked = False
End Sub
Private Sub cogt()
dbmabn.Enabled = True
dbmanv.Enabled = True
dbmaxn.Enabled = True
txtkq.Enabled = True
cbngayxn.Enabled = True
cbthangxn.Enabled = True
cbnamxn.Enabled = True
End Sub
Private Sub txtmabn_Change()
Dim st As String
If Trim(txtmabn.Text = "") Then
Adodcxn.Refresh
grdxn.Refresh
Else
If Trim(txtmabn.Text) "" Then
If st "" Then
st = st + " and " + "mabn like '" + Trim(txtmabn.Text) + "*'"
Else
st = "mabn like '" + Trim(txtmabn.Text) + "*'"
End If
End If
Adodcxn.Recordset.Filter = st
grdxn.Refresh
End If
Hienthi
cmdin.Enabled = True
End Sub
Thiết kế giao diện cập nhật bệnh nhân nằm giường và in hóa đơn
Code
Dim kt As Boolean
Dim nn As Date
Dim nt As Date
Private Sub cmdin_Click()
DREP.rshoadongiuong.Open
nn = cbngaynhan.Text & "/" & cbthangnhan.Text & "/" & cbnamnhan.Text
nt = cbngaytra.Text & "/" & cbthangtra.Text & "/" & cbnamtra.Text
DREP.rshoadongiuong.Filter = "mabn = '" & dbmabn.Text & "'and sogiuong = '" & dbg.Text & "' and ngaynhan = '" & nn & "' and ngaytra = '" & nt & "'"
RPhoadongiuong.Show
setnull
cmdin.Enabled = False
Mo_khoa
cogt
anngay
cmdtra.Visible = False
lbtra.Visible = False
cmdin.Visible = False
End Sub
'/////CAP NHAT TRA GIUONG
Private Sub cmdtra_Click()
Dim str As String
Connection.OpenData ("BNG")
nt = cbngaytra.Text & "/" & cbthangtra.Text & "/" & cbnamtra.Text
str = "update BNG set ngaytra = '" & nt & "' where (mabn = '" & dbmabn.Text & "'and sogiuong = '" & dbg.Text & "' and day(ngaynhan)='" & cbngaynhan.Text & "' and month(ngaynhan)='" & cbthangnhan.Text & "' and year(ngaynhan)='" & cbnamnhan.Text & "')"
cn.Execute (str)
MsgBox (" CËp nhËt thµnh c«ng")
grdg.Refresh
Adodcg.Refresh
Connection.Closedata
Lammoi
cmdin.Enabled = True
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Mo_khoa
End Sub
Private Sub optcn_Click()
matgt
cbngaytra.Enabled = True
cbthangtra.Enabled = True
cbnamtra.Enabled = True
cbngaynhan.Enabled = False
cbthangnhan.Enabled = False
cbnamnhan.Enabled = False
cbngaytra.Locked = False
cbthangtra.Locked = False
cbnamtra.Locked = False
If optcn.Value = True Then
lbtra.Visible = True
hienngay
cmdtra.Visible = True
cmdin.Visible = True
cmdin.Enabled = False
End If
cbngaytra.Text = "1"
cbthangtra.Text = "1"
cbnamtra.Text = "2009"
End Sub
'//////// TIM KIEM THEO MA BENH NHAN
Private Sub txtmabn_Change()
Dim st As String
If Trim(txtmabn.Text = "") Then
Adodcg.Refresh
grdpg.Refresh
Else
If Trim(txtmabn.Text) "" Then
If st "" Then
st = st + " and " + "mabn like '" + Trim(txtmabn.Text) + "*'"
Else
st = "mabn like '" + Trim(txtmabn.Text) + "*'"
End If
End If
Adodcpg.Recordset.Filter = st
grdpg.Refresh
End If
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdsua_Click()
cmdtra.Visible = False
kt = True
cmdluu.Enabled = True
cmdin.Enabled = False
Mo_khoa
dbmabn.Enabled = False
End Sub
Private Sub Form_Load()
optcn.Visible = False
cmdtra.Visible = False
cmdsua.Enabled = False
cmdxoa.Enabled = False
lbtra.Visible = False
anngay
cmdin.Visible = False
Call add_ngay(cbngaynhan, cbthangnhan, cbnamnhan)
Call add_ngay(cbngaytra, cbthangtra, cbnamtra)
cbngaynhan.Text = "1"
cbthangnhan.Text = "1"
cbnamnhan.Text = "2009"
cbngaytra.Text = "1"
cbthangtra.Text = "1"
cbnamtra.Text = "2009"
'////////////
kt = False
cmdin.Enabled = False
Adodcg.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcg.RecordSource = "BNG"
Connection.OpenData ("BNG")
Adodcg.Refresh
grdg.Refresh
setnull
Mo_khoa
End Sub
'/////////////////////////
Private Sub cmdluu_Click()
Dim str As String
nn = cbngaynhan.Text & "/" & cbthangnhan.Text & "/" & cbnamnhan.Text
nt = cbngaytra.Text & "/" & cbthangtra.Text & "/" & cbnamtra.Text
Connection.OpenData ("BNG")
If (kt = True) Then
str = "update BNG set sogiuong = '" & (dbg.Text) & "', ngaynhan = '" & nn & "', ngaytra ='" & nt & "' where ( mabn = '" _
& dbmabn.Text & "' and sogiuong = '" & Adodcg.Recordset.Fields("sogiuong") & "')"
cn.Execute (str)
kt = False
Else
If dbmabn.Text = "" Then
MsgBox (" B¹n cha nhËp m· bÖnh nh©n. NhËp m·")
Else
str = "INSERT INTO BNG(mabn,sogiuong,ngaynhan) VALUES ('" _
& dbmabn.Text & "','" & dbg.Text & "','" & nn & "')"
cn.Execute (str)
MsgBox (" CËp nhËt thµnh c«ng")
End If
End If
Connection.Closedata
grdg.Refresh
'/////////////////////////////////////////////////
Lammoi
Mo_khoa
cmdtra.Visible = False
optcn.Visible = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
cmdin.Enabled = True
dbmabn.Enabled = True
End Sub
Private Sub cmdmoi_Click()
cmdtra.Visible = False
setnull
Mo_khoa
optcn.Value = False
optcn.Visible = False
lbtra.Visible = False
anngay
cmdsua.Enabled = False
cmdxoa.Enabled = False
cmdin.Visible = False
End Sub
Private Sub cmdvecuoi_Click(Index As Integer)
cmdluu.Enabled = False
Adodcg.Recordset.MoveLast
cmdvecuoi(3).Enabled = False
cmdvesau(2).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvedau_Click(Index As Integer)
cmdluu.Enabled = False
Adodcg.Recordset.MoveFirst
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvesau_Click(Index As Integer)
cmdluu.Enabled = False
Adodcg.Recordset.MoveNext
grdg.Refresh
If Adodcg.Recordset.EOF = True Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
Else
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
End If
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvetruoc_Click(Index As Integer)
cmdluu.Enabled = False
Adodcg.Recordset.MovePrevious
grdg.Refresh
If Adodcg.Recordset.BOF = True Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Else
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End If
Hienthi
cmdin.Enabled = True
End Sub
'///////////XOA THONG TIN
Private Sub cmdxoa_Click()
Dim str As String
Dim response As VbMsgBoxResult
cmdtra.Visible = False
cmdluu.Enabled = True
nn = cbngaynhan.Text & "/" & cbthangnhan.Text & "/" & cbnamnhan.Text
nt = cbngaytra.Text & "/" & cbthangtra.Text & "/" & cbnamtra.Text
response = MsgBox(("B¹n cã muèn xo¸ b¶n ghi nµy kh«ng?"), vbYesNo + vbCritical, ("Thoong baso"))
If response = vbNo Then
Exit Sub
Else
'//// Xoa du lieu o bang BNG
Connection.OpenData ("BNG")
str = "DELETE * FROM BNG WHERE (mabn = '" & dbmabn.Text & "'and sogiuong = '" & dbg.Text & "' and day(ngaynhan)= '" & cbngaynhan.Text & "' and month(ngaynhan) ='" & cbthangnhan.Text & "' and year(ngaynhan) = '" & cbnamnhan.Text & "' and day(ngaytra)= '" & cbngaytra.Text & "' and month(ngaytra) ='" & cbthangtra.Text & "' and year(ngaytra) = '" & cbnamtra.Text & "')"
cn.Execute (str)
End If
setnull
'//////////////////////////////////////////////
Lammoi
Mo_khoa
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End Sub
Private Sub setnull()
cmdluu.Enabled = True
dbmabn.Text = ""
dbg.Text = ""
cbngaynhan.Text = "1"
cbthangnhan.Text = "1"
cbnamnhan.Text = "2009"
cbngaytra.Text = "1"
cbthangtra.Text = "1"
cbnamtra.Text = "2009"
End Sub
Private Sub grdg_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
cmdtra.Visible = False
cmdsua.Enabled = True
cmdxoa.Enabled = True
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdluu.Enabled = False
If (Adodcg.Recordset.BOF = False And Adodcg.Recordset.EOF = False) Then
'--------------------------------------------------
'// Ket xuat thong tin tu luoi ra dieu khien
dbmabn.Text = Adodcg.Recordset.Fields("mabn").Value
dbg.Text = Adodcg.Recordset.Fields("sogiuong").Value
Call layngay(Adodcg.Recordset.Fields("ngaynhan"), cbngaynhan, cbthangnhan, cbnamnhan)
If Adodcg.Recordset.Fields("ngaytra").Value "" Then
Call layngay(Adodcg.Recordset.Fields("ngaytra"), cbngaytra, cbthangtra, cbnamtra)
optcn.Visible = False ' an di
lbtra.Visible = True ' hien len
hienngay
cmdin.Visible = True
Else
optcn.Visible = True
optcn.Value = False
lbtra.Visible = False ' an di
anngay
cmdin.Visible = False
End If
cogt
khoa
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
If Adodcg.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
End If
If Adodcg.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
End If
cmdin.Enabled = True
End If
End Sub
Private Sub Hienthi()
cogt
cmdtra.Visible = False
cmdluu.Enabled = False
cmdsua.Enabled = True
If (Adodcg.Recordset.BOF = False And Adodcg.Recordset.EOF = False) Then
'--------------------------------------------------
'// Ket xuat thong tin tu luoi ra dieu khien
cmdsua.Enabled = True
cmdxoa.Enabled = True
dbmabn.Text = Adodcg.Recordset.Fields("mabn").Value
dbg.Text = Adodcg.Recordset.Fields("sogiuong").Value
Call layngay(Adodcg.Recordset.Fields("ngaynhan"), cbngaynhan, cbthangnhan, cbnamnhan)
If Adodcg.Recordset.Fields("ngaytra").Value "" Then
Call layngay(Adodcg.Recordset.Fields("ngaytra"), cbngaytra, cbthangtra, cbnamtra)
optcn.Visible = False ' an di
lbtra.Visible = True ' hien len
hienngay
cmdin.Visible = True
Else
optcn.Visible = True
optcn.Value = False
lbtra.Visible = False ' an di
anngay
End If
cogt
khoa
If Adodcg.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
End If
If Adodcg.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
End If
cmdin.Enabled = True
End If
End Sub
Private Sub Lammoi()
Adodcg.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcg.RecordSource = "BNG"
Connection.OpenData ("BNG")
Adodcg.Refresh
End Sub
Private Sub khoa()
dbmabn.Locked = True
dbg.Locked = True
cbngaynhan.Locked = True
cbthangnhan.Locked = True
cbnamnhan.Locked = True
cbngaytra.Locked = True
cbthangtra.Locked = True
cbnamtra.Locked = True
End Sub
Private Sub Mo_khoa()
dbmabn.Locked = False
dbg.Locked = False
cbngaynhan.Locked = False
cbthangnhan.Locked = False
cbnamnhan.Locked = False
cbngaytra.Locked = False
cbthangtra.Locked = False
cbnamtra.Locked = False
End Sub
Private Sub matgt()
dbmabn.Enabled = False
dbg.Enabled = False
cbngaynhan.Enabled = True
cbthangnhan.Enabled = True
cbnamnhan.Enabled = True
End Sub
Private Sub cogt()
dbmabn.Enabled = True
dbg.Enabled = True
cbngaynhan.Enabled = True
cbthangnhan.Enabled = True
cbnamnhan.Enabled = True
End Sub
Private Sub anngay()
cbngaytra.Visible = False
cbnamtra.Visible = False
cbthangtra.Visible = False
End Sub
Private Sub hienngay()
cbngaytra.Visible = True
cbnamtra.Visible = True
cbthangtra.Visible = True
End Sub
Thiết kế giao diện cập nhật đơn thuốc
Đoạn code của Form cập nhật đơn thuốc
Dim ktsua As Boolean
Dim ktnhap As Boolean
Dim ktt As Boolean
Dim nkd As Date
Private Sub cmdin_Click()
DREP.rsdonthuocrp.Open
nkd = cbngaykd.Text & "/" & cbthangkd.Text & "/" & cbnamkd.Text
DREP.rsdonthuocrp.Filter = "mabn = '" & dbmabn.Text & "' and manv='" & dbmanv.Text & "' and ngaykedon = '" & nkd & "'"
rpdonthuoc.Show
End Sub
Private Sub cmdsuath_Click()
ktsua = True
ktnhap = False
ktt = False
Mo_khoa
cmdluu(1).Enabled = True
dbmabn.Enabled = False
dbmanv.Enabled = False
cbngaykd.Enabled = False
cbthangkd.Enabled = False
cbnamkd.Enabled = False
dbmath.Enabled = False
End Sub
'/////////Them thuoc
Private Sub cmdthem_Click(Index As Integer)
cmdluu(1).Enabled = False
cmdsuath.Enabled = False
dbmath.Text = ""
txtsl.Text = ""
txtcd.Text = ""
cmdluu(1).Enabled = True
ktsua = False
ktnhap = False
dbmath.Locked = False
txtsl.Locked = False
txtcd.Locked = False
ktt = True
End Sub
'///////////Xoa thuoc
Private Sub cmdxoath_Click()
Dim str As String
cmdluu(1).Enabled = True
Dim response As VbMsgBoxResult
response = MsgBox(("B¹n cã muèn xoa thuèc nµy kh«ng?"), vbYesNo + vbCritical, ("Thoong baso"))
If response = vbNo Then
Exit Sub
Else
'//// Xoa du lieu o bang thuoc
Connection.OpenData ("donthuoc")
str = "DELETE * FROM donthuoc WHERE mabn = '" & dbmabn.Text & "'and manv= '" & dbmanv.Text & "'and mathuoc = '" & dbmath.Text & "'"
cn.Execute (str)
End If
'//////////////////////////////////////////////
Lammoi
Mo_khoa
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End Sub
Private Sub Form_Load()
Call add_ngay(cbngaykd, cbthangkd, cbnamkd)
cbngaykd.Text = "1"
cbthangkd.Text = "1"
cbnamkd.Text = "2009"
cmdthem(0).Enabled = False
cmdsuath.Enabled = False
cmdxoath.Enabled = False
ktnhap = True
ktsua = False
ktt = False
AdodcbaConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcdt.RecordSource = "donthuoc"
Connection.OpenData ("donthuoc")
Adodcdt.Refresh
grddt.Refresh
setnull
Mo_khoa
End Sub
Private Sub cmdluu_Click(Index As Integer)
Dim str As String
nkd = cbngaykd.Text & "/" & cbthangkd.Text & "/" & cbnamkd.Text
Connection.OpenData ("donthuoc")
If (ktsua = True) Then
If IsNumeric(txtsl.Text) = False Then
MsgBox ("NhËp l¹i sè lîng kiªu sè")
Else
str = "update donthuoc set soluong = '" & (txtsl.Text) & "',cachdung = '" & txtcd.Text & "' where (mabn = '" & dbmabn.Text & "' and manv= '" & dbmanv.Text & "'and mathuoc= '" & dbmath.Text & "')"
cn.Execute (str)
End If
End If
If ktnhap = True Then
If (dbmabn.Text = "") Or (dbmanv.Text = "") Or (dbmath.Text = "") Then
MsgBox ("NhËp thiÕu th«ng tin. NhËp l¹i.")
Else
If IsNumeric(txtsl.Text) = False Then
MsgBox ("NhËp l¹i sè lîng kiªu sè")
Else
sql = "INSERT INTO donthuoc(mabn,manv,mathuoc,soluong,cachdung,ngaykedon) VALUES ('" _
& (dbmabn.Text) & "','" & (dbmanv.Text) & "','" & (dbmath.Text) & "','" & (txtsl.Text) & "', '" & (txtcd.Text) & "','" & nkd & "')"
cn.Execute (sql)
cmdthem(0).Enabled = True
cmdsuath.Enabled = True
cmdxoath.Enabled = True
cmdluu(1).Enabled = False
End If
End If
End If
If ktt = True Then
If IsNumeric(txtsl.Text) = False Then
MsgBox ("NhËp l¹i sè lîng kiªu sè")
Else
str = "INSERT INTO donthuoc(mabn,manv,mathuoc,soluong,cachdung,ngaykedon) VALUES ('" _
& (dbmabn.Text) & "','" & (dbmanv.Text) & "','" & (dbmath.Text) & "','" & (txtsl.Text) & "', '" & (txtcd.Text) & "','" & nkd & "')"
cn.Execute (str)
ktt = False
dbmath.Text = ""
txtsl.Text = ""
txtcd.Text = ""
cmdluu(1).Enabled = False
End If
End If
grddt.Refresh
Adodcdt.Refresh
Connection.Closedata
'/////////////////////////////////////////////////
Lammoi
Mo_khoa
dbmabn.Enabled = True
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End Sub
Private Sub cmdmoi_Click(Index As Integer)
setnull
Mo_khoa
cmdluu(1).Enabled = True
dbmabn.Enabled = True
cmdthem(0).Enabled = False
cmdsuath.Enabled = False
cmdxoath.Enabled = False
ktnhap = True
End Sub
Private Sub cmdvecuoi_Click(Index As Integer)
cmdluu(1).Enabled = False
Adodcdt.Recordset.MoveLast
cmdvecuoi(3).Enabled = False
cmdvesau(2).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
Hienthi
End Sub
Private Sub cmdvedau_Click(Index As Integer)
cmdluu(1).Enabled = False
Adodcdt.Recordset.MoveFirst
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Hienthi
End Sub
Private Sub cmdvesau_Click(Index As Integer)
cmdluu(1).Enabled = False
Adodcdt.Recordset.MoveNext
grddt.Refresh
If Adodcdt.Recordset.EOF = True Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
Else
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
End If
Hienthi
End Sub
Private Sub cmdvetruoc_Click(Index As Integer)
cmdluu(1).Enabled = False
Adodcdt.Recordset.MovePrevious
grddt.Refresh
If Adodcdt.Recordset.BOF = True Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Else
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End If
Hienthi
End Sub
'///////////Xoa ca don thuoc
Private Sub cmdxoa_Click(Index As Integer)
Dim str As String
Dim response As VbMsgBoxResult
cmdluu(1).Enabled = True
nkd = cbngaykd.Text & "/" & cbthangkd.Text & "/" & cbnamkd.Text
response = MsgBox(("B¹n cã muèn d¬n thuèc nµy kh«ng?"), vbYesNo + vbCritical, ("Thoong baso"))
If response = vbNo Then
Exit Sub
Else
Connection.OpenData ("donthuoc")
str = "DELETE * FROM donthuoc WHERE (mabn = '" & dbmabn.Text & "' and manv= '" & dbmanv.Text & "')" ' day(ngaykedon)='" & cbngaykd.Text & "' and month(ngaykedon)='" & cbthangkd.Text & "' and year(ngaykedon)='" & cbnamkd.Text & "')" ' and ngaykedon =nkd )"
cn.Execute (str)
End If
Lammoi
Mo_khoa
setnull
End Sub
Private Sub setnull()
cmdluu(1).Enabled = True
dbmabn.Text = ""
dbmanv.Text = ""
dbmath.Text = ""
txtsl.Text = "0"
txtcd.Text = ""
cbngaykd.Text = "1"
cbthangkd.Text = "1"
cbnamkd.Text = "2009"
End Sub
Private Sub grddt_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
cogt
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdluu(1).Enabled = False
cmdsuath.Enabled = True
cmdxoath.Enabled = True
cmdthem(0).Enabled = True
If (Adodcdt.Recordset.BOF = False And Adodcdt.Recordset.EOF = False) Then
'--------------------------------------------------
'// Ket xuat thong tin tu luoi ra dieu khien
dbmabn.Text = Adodcdt.Recordset.Fields("mabn").Value
dbmanv.Text = Adodcdt.Recordset.Fields("manv").Value
dbmath.Text = Adodcdt.Recordset.Fields("mathuoc").Value
Call layngay(Adodcdt.Recordset.Fields("ngaykedon"), cbngaykd, cbthangkd, cbnamkd)
txtsl.Text = Adodcdt.Recordset.Fields("soluong").Value
txtcd.Text = Adodcdt.Recordset.Fields("cachdung").Value
khoa
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
If Adodcdt.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
End If
If Adodcdt.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
End If
End If
End Sub
Private Sub Hienthi()
cogt
cmdluu(1).Enabled = False
cmdsuath.Enabled = True
cmdxoath.Enabled = True
cmdthem(0).Enabled = True
If (Adodcdt.Recordset.BOF = False And Adodcdt.Recordset.EOF = False) Then
'--------------------------------------------------
'// Ket xuat thong tin tu luoi ra dieu khien
dbmabn.Text = Adodcdt.Recordset.Fields("mabn").Value
dbmanv.Text = Adodcdt.Recordset.Fields("manv").Value
dbmath.Text = Adodcdt.Recordset.Fields("mathuoc").Value
Call layngay(Adodcdt.Recordset.Fields("ngaykedon"), cbngaykd, cbthangkd, cbnamkd)
txtsl.Text = Adodcdt.Recordset.Fields("soluong").Value
txtcd.Text = Adodcdt.Recordset.Fields("cachdung").Value
khoa
If Adodcdt.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
End If
If Adodcdt.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
End If
End If
End Sub
Private Sub Lammoi()
Adodcdt.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcdt.RecordSource = "donthuoc"
Connection.OpenData ("donthuoc")
Adodcdt.Refresh
End Sub
Private Sub khoa()
dbmabn.Locked = True
dbmanv.Locked = True
dbmath.Locked = True
cbngaykd.Locked = True
cbthangkd.Locked = True
cbnamkd.Locked = True
txtcd.Locked = True
txtsl.Locked = True
End Sub
Private Sub Mo_khoa()
dbmabn.Locked = False
dbmanv.Locked = False
dbmath.Locked = False
cbngaykd.Locked = False
cbthangkd.Locked = False
cbnamkd.Locked = False
txtcd.Locked = False
txtsl.Locked = False
End Sub
Private Sub cogt()
dbmabn.Enabled = True
dbmanv.Enabled = True
dbmath.Enabled = True
txtsl.Enabled = True
txtcd.Enabled = True
cbngaykd.Enabled = True
cbthangkd.Enabled = True
cbnamkd.Enabled = True
End Sub
Thiết kế giao diện cập nhật và in phiếu khám bệnh
Code của Form cập nhật và in phiếu khám bệnh
Dim kt As Boolean
Dim nkb As Date
'///////////// In Phieu kham benh
Private Sub cmdin_Click()
DREP.rsphieuKB.Open
nkb = cbngaykb.Text & "/" & cbthangkb.Text & "/" & cbnamkb.Text
DREP.rsphieuKB.Filter = "mabn = '" & dbmabn.Text & "' and manv='" & dbmanv.Text & "' and sophong ='" & dbp.Text & "' and yckham = '" & txtyckb.Text & "' and ngaykham = '" & nkb & "'"
RPPhieuKB.Show
setnull
cmdin.Enabled = False
Mo_khoa
End Sub
'///////////// Cap nhat ket qua kham benh
Private Sub cmdkq_Click()
Dim str As String
nkb = cbngaykb.Text & "/" & cbthangkb.Text & "/" & cbnamkb.Text
str = "update dongkb1 set kqkham = '" & (txtkqkb.Text) & "'where (mabn = '" & dbmabn.Text & "'and manv = '" & dbmanv.Text & "' and sophong = '" & dbp.Text & "' and yckham = '" & txtyckb.Text & "' and day(ngaykham)= '" & cbngaykb.Text & "' and month(ngaykham) ='" & cbthangkb.Text & "' and year(ngaykham) = '" & cbnamkb.Text & "')"
cn.Execute (str)
MsgBox (" CËp nhËt thµnh c«ng")
Lammoi
setnull
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
optcn.Value = False
optcn.Visible = False
lbk.Visible = False
txtkqkb.Visible = False
cmdkq.Visible = False
Mo_khoa
End Sub
Private Sub optcn_Click()
matgt
txtkqkb.Enabled = True
txtkqkb.Locked = False
If optcn.Value = True Then
lbk.Visible = True
txtkqkb.Visible = True
txtkqkb.Text = ""
cmdkq.Visible = True
End If
End Sub
Private Sub txtmabn_Change()
Dim st As String
If Trim(txtmabn.Text = "") Then
Adodcpkb.Refresh
grdpkb.Refresh
Else
If Trim(txtmabn.Text) "" Then
If st "" Then
st = st + " and " + "mabn like '" + Trim(txtmabn.Text) + "*'"
Else
st = "mabn like '" + Trim(txtmabn.Text) + "*'"
End If
End If
Adodcpkb.Recordset.Filter = st
grdpkb.Refresh
End If
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdsua_Click()
cmdkq.Visible = False
kt = True
cmdluu.Enabled = True
cmdin.Enabled = False
Mo_khoa
dbmabn.Enabled = False
End Sub
Private Sub Form_Load()
optcn.Visible = False
cmdkq.Visible = False
cmdsua.Enabled = False
cmdxoa.Enabled = False
lbk.Visible = False
txtkqkb.Visible = False
Call add_ngay(cbngaykb, cbthangkb, cbnamkb)
cbngaykb.Text = "1"
cbthangkb.Text = "1"
cbnamkb.Text = "2009"
'////////////
kt = False
cmdin.Enabled = False
Adodcpkb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcpkb.RecordSource = "dongKB1"
Connection.OpenData ("dongkb1")
Adodcpkb.Refresh
grdpkb.Refresh
setnull
Mo_khoa
End Sub
'/////////////////////////
'////////////CAP NHAT THONG TIN KHAM BENH
Private Sub cmdluu_Click()
Dim str As String
cmdkq.Visible = False
nkb = cbngaykb.Text & "/" & cbthangkb.Text & "/" & cbnamkb.Text
Connection.OpenData ("dongkb1")
If (kt = True) Then
str = "update dongkb1 set manv = '" & (dbmanv.Text) & "', sophong= = '" & (dbp.Text) & "', ngaykham = '" & nkb & "',yckham = '" & (txtyckb.Text) & "', kqkham = '" & (txtkqkb.Text) & "'where ( mabn = '" _
& dbmabn.Text & "' and manv = '" & Adodcpkb.Recordset.Fields("manv") & "' and sophong = '" & Adodcpkb.Recordset.Fields("sophong") & "' and yckham = '" & Adodcpkb.Recordset.Fields("yckham") & "' and kqkham = '" & Adodcpkb.Recordset.Fields("kqkham") & "')"
cn.Execute (str)
kt = False
Else
If dbmabn.Text = "" Then
MsgBox (" B¹n cha nhËp m· bÖnh nh©n. NhËp m·")
Else
str = "INSERT INTO dongkb1(mabn,manv,sophong,ngaykham,yckham) VALUES ('" _
& dbmabn.Text & "','" & dbmanv.Text & "','" & dbp.Text & "','" & nkb & "','" & txtyckb.Text & "')"
cn.Execute (str)
End If
End If
Connection.Closedata
grdpkb.Refresh
'/////////////////////////////////////////////////
Lammoi
Mo_khoa
'optcn.Visible = True
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
cmdin.Enabled = True
dbmabn.Enabled = True
End Sub
Private Sub cmdmoi_Click()
cmdkq.Visible = False
setnull
Mo_khoa
optcn.Value = False
optcn.Visible = False
lbk.Visible = False
txtkqkb.Visible = False
cmdsua.Enabled = False
cmdxoa.Enabled = False
End Sub
Private Sub cmdvecuoi_Click(Index As Integer)
cmdluu.Enabled = False
Adodcpkb.Recordset.MoveLast
cmdvecuoi(3).Enabled = False
cmdvesau(2).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvedau_Click(Index As Integer)
cmdluu.Enabled = False
Adodcpkb.Recordset.MoveFirst
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvesau_Click(Index As Integer)
cmdluu.Enabled = False
Adodcpkb.Recordset.MoveNext
grdpkb.Refresh
If Adodcpkb.Recordset.EOF = True Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
Else
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvedau(0).Enabled = True
End If
Hienthi
cmdin.Enabled = True
End Sub
Private Sub cmdvetruoc_Click(Index As Integer)
cmdluu.Enabled = False
Adodcpkb.Recordset.MovePrevious
grdpkb.Refresh
If Adodcpkb.Recordset.BOF = True Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
Else
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End If
Hienthi
cmdin.Enabled = True
End Sub
'////////////XOA THONG TIN
Private Sub cmdxoa_Click()
cmdkq.Visible = False
cmdluu.Enabled = True
Dim str As String
nkb = cbngaykb.Text & "/" & cbthangkb.Text & "/" & cbnamkb.Text
Dim response As VbMsgBoxResult
response = MsgBox(("B¹n cã muèn xo¸ b¶n ghi nµy kh«ng?"), vbYesNo + vbCritical, ("Thoong baso"))
If response = vbNo Then
Exit Sub
Else
'//// Xoa du lieu o bang XNCC
Connection.OpenData ("dongkb1")
str = "DELETE * FROM dongkb1 WHERE (mabn = '" & dbmabn.Text & "' and manv = '" & dbmanv.Text & "' and sophong = '" & dbp.Text & "' and yckham = '" & txtyckb.Text & "' and day(ngaykham)= '" & cbngaykb.Text & "' and month(ngaykham) ='" & cbthangkb.Text & "' and year(ngaykham) = '" & cbnamkb.Text & "')"
cn.Execute (str)
End If
setnull
'//////////////////////////////////////////////
Lammoi
Mo_khoa
cmdvecuoi(3).Enabled = True
cmdvesau(2).Enabled = True
End Sub
Private Sub setnull()
cmdluu.Enabled = True
dbmabn.Text = ""
dbmanv.Text = ""
dbp.Text = ""
txtyckb.Text = ""
cbngaykb.Text = "1"
cbthangkb.Text = "1"
cbnamkb.Text = "2009"
End Sub
Private Sub grdpkb_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
cmdkq.Visible = False
cmdsua.Enabled = True
cmdxoa.Enabled = True
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdluu.Enabled = False
If (Adodcpkb.Recordset.BOF = False And Adodcpkb.Recordset.EOF = False) Then
'--------------------------------------------------
'// Ket xuat thong tin tu luoi ra dieu khien
dbmabn.Text = Adodcpkb.Recordset.Fields("mabn").Value
dbmanv.Text = Adodcpkb.Recordset.Fields("manv").Value
dbp.Text = Adodcpkb.Recordset.Fields("sophong").Value
Call layngay(Adodcpkb.Recordset.Fields("ngaykham"), cbngaykb, cbthangkb, cbnamkb)
txtyckb.Text = Adodcpkb.Recordset.Fields("yckham").Value
If Adodcpkb.Recordset.Fields("kqkham").Value "" Then
txtkqkb.Text = Adodcpkb.Recordset.Fields("kqkham").Value
optcn.Visible = False ' an di
lbk.Visible = True ' hien len
txtkqkb.Visible = True
Else
optcn.Visible = True
optcn.Value = False
lbk.Visible = False ' an di
txtkqkb.Visible = False
End If
cogt
khoa
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
If Adodcpkb.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
cmdvesau(2).Enabled = True
cmdvecuoi(3).Enabled = True
End If
If Adodcpkb.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
cmdvedau(0).Enabled = True
cmdvetruoc(1).Enabled = True
End If
cmdin.Enabled = True
End If
End Sub
Private Sub Hienthi()
cogt
cmdkq.Visible = False
cmdluu.Enabled = False
cmdsua.Enabled = True
If (Adodcpkb.Recordset.BOF = False And Adodcpkb.Recordset.EOF = False) Then
'--------------------------------------------------
'// Ket xuat thong tin tu luoi ra dieu khien
cmdsua.Enabled = True
cmdxoa.Enabled = True
dbmabn.Text = Adodcpkb.Recordset.Fields("mabn").Value
dbmanv.Text = Adodcpkb.Recordset.Fields("manv").Value
dbp.Text = Adodcpkb.Recordset.Fields("sophong").Value
Call layngay(Adodcpkb.Recordset.Fields("ngaykham"), cbngaykb, cbthangkb, cbnamkb)
txtyckb.Text = Adodcpkb.Recordset.Fields("yckham").Value
If Adodcpkb.Recordset.Fields("kqkham").Value "" Then
txtkqkb.Text = Adodcpkb.Recordset.Fields("kqkham").Value
optcn.Visible = False ' an di
lbk.Visible = True ' hien len
txtkqkb.Visible = True
Else
optcn.Visible = True
optcn.Value = False
lbk.Visible = False ' an di
txtkqkb.Visible = False
End If
khoa
If Adodcpkb.Recordset.BOF Then
cmdvedau(0).Enabled = False
cmdvetruoc(1).Enabled = False
End If
If Adodcpkb.Recordset.EOF Then
cmdvesau(2).Enabled = False
cmdvecuoi(3).Enabled = False
End If
cmdin.Enabled = True
End If
End Sub
Private Sub Lammoi()
Adodcpkb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodcpkb.RecordSource = "dongkb1"
Connection.OpenData ("dongkb1")
Adodcpkb.Refresh
'Setnull
End Sub
Private Sub khoa()
dbmabn.Locked = True
dbmanv.Locked = True
dbp.Locked = True
cbngaykb.Locked = True
cbthangkb.Locked = True
cbnamkb.Locked = True
txtkqkb.Locked = True
txtyckb.Locked = True
End Sub
Private Sub Mo_khoa()
dbmabn.Locked = False
dbmanv.Locked = False
dbp.Locked = False
cbngaykb.Locked = False
cbthangkb.Locked = False
cbnamkb.Locked = False
txtkqkb.Locked = False
txtyckb.Locked = False
End Sub
Private Sub matgt()
dbmabn.Enabled = False
dbmanv.Enabled = False
dbp.Enabled = False
txtyckb.Enabled = False
txtkqkb.Enabled = False
cbngaykb.Enabled = False
cbthangkb.Enabled = False
cbnamkb.Enabled = False
End Sub
Private Sub cogt()
dbmabn.Enabled = True
dbmanv.Enabled = True
dbp.Enabled = True
txtyckb.Enabled = True
txtkqkb.Enabled = True
cbngaykb.Enabled = True
cbthangkb.Enabled = True
cbnamkb.Enabled = True
End Sub
Thiết kế giao diện cập nhật thông tin thành viên
Code:
Dim kt As Boolean
Private Sub cmdluu_Click(Index As Integer)
Dim str As String
Connection.OpenData ("Quantri")
If (kt = True) Then
str = "update Quantri set use = '" & (txt1.Text) & "', quyen = '" & quyen & "',pass = '" & txt2.Text & "'"
cn.Execute (str)
kt = False
Else
str = "INSERT INTO Quantri (use,pass,) VALUES ('" & txt1.Text & "','" & txt2.Text & "','" & quyen & "')"
cn.Execute (str)
setnull
End If
Connection.Closedata
DataGrid1.Refresh
Adodc1.Refresh
Lammoi
Mo_khoa
cmdsua.Enabled = False
End Sub
Private Sub cmdthem_Click(Index As Integer)
kt = False
Adodc1.RecordSource = "Quantri"
setnull
Mo_khoa
cmdluu.Enabled = True
cmdsua.Enabled = False
End Sub
Private Sub cmdxoa_Click(Index As Integer)
cmdluu.Enabled = True
Dim str As String
Dim response As VbMsgBoxResult
response = MsgBox(("B¹n cã muèn xoa b¶n ghi nµy kh«ng?"), vbYesNo + vbCritical, ("Thoong baso"))
If response = vbNo Then
Exit Sub
Else
Connection.OpenData ("thuoc")
str = "DELETE * FROM Quantri "
cn.Execute (str)
End If
Lammoi
Mo_khoa
cmdsua.Enabled = False
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
cmdluu.Enabled = False
If (Adodc1.Recordset.BOF = False And Adodc1.Recordset.EOF = False) Then
txt1.Text = Adodc1.Recordset.Fields("use").Value
txt2.Text = Adodc1.Recordset.Fields("pass").Value
If Adodc1.Recordset.Fields("quyen").Value = "op2" Then
op1.Value = False
op2.Value = True
Else
op2.Value = False
op1.Value = True
End If
End If
End Sub
Private Sub Form_Load()
DataGrid1.Refresh
kt = False
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodc1.RecordSource = "Quantri"
Connection.OpenData ("Quantri")
Adodc1.Refresh
DataGrid1.Refresh
setnull
Mo_khoa
End Sub
Private Sub cmdsua_Click(Index As Integer)
cmdluu.Enabled = True
kt = True
Mo_khoa
cmdsua.Enabled = False
End Sub
Private Sub setnull()
txt1.Text = ""
txt2.Text = ""
op1.Value = True
End Sub
Private Sub cmdthoat_Click(Index As Integer)
Unload Me
End Sub
Private Sub khoa()
txt1.Locked = True
txt2.Locked = True
End Sub
Private Sub Mo_khoa()
txt1.Locked = False
txt2.Locked = False
End Sub
Private Sub Lammoi()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:\nhom3\quanlybenhnhan.mdb;Persist Security Info=False"
Adodc1.RecordSource = "Quantri"
Connection.OpenData ("Quantri")
Adodc1.Refresh
End Sub
Private Sub Hienthi()
If (Adodc1.Recordset.BOF = False And Adodc1.Recordset.EOF = False) Then
'--------------------------------------------------
'// Ket xuat thong tin tu luoi ra dieu khien
txt1.Text = Adodc1.Recordset.Fields("use").Value
txt2.Text = Adodc2.Recordset.Fields("pass").Value
End If
End Sub
Private Sub nam_Click()
op1.Value = True
op2.Value = False
End Sub
Private Sub nu_Click()
op2.Value = True
op1.Value = False
End Sub
Giao diện phần đăng nhập
Code
Private Sub cmdcancel_Click()
'
Unload Me
End
End Sub
Private Sub cmdok_Click()
Dim st As String
st = "use like '" + txtten.Text + "' and pass like '" + txtmk.Text + "'"
Adodc1.Recordset.Filter = st
If Adodc1.Recordset.RecordCount > 0 Then
If Adodc1.Recordset.Fields("quyen") = True Then
Dangnhap.Hide
FrmChinh.cn.Enabled = True
FrmChinh.lp.Enabled = True
FrmChinh.TK.Enabled = True
FrmChinh.admin.Enabled = False
Else
Dangnhap.Hide
FrmChinh.cn.Enabled = True
FrmChinh.lp.Enabled = True
FrmChinh.TK.Enabled = True
FrmChinh.admin.Enabled = True
End If
Else
MsgBox ("B¹n nhËp sai tªn hoÆc mËt khÈu!")
txtmk.Text = ""
End If
End Sub
Private Sub Form_Load()
txtten.Text = ""
txtmk.Text = ""
End Sub
Giao diện chính của chương trình
Code
Private Sub b_Click()
CNBenh.Show
End Sub
Private Sub benhan_Click()
CNbenhan.Show
End Sub
Private Sub bn_Click()
CapnhatBN.Show
End Sub
Private Sub cnthuoc_Click()
capnhatthuoc.Show
End Sub
Private Sub cntv_Click()
Frmadmin.Show
End Sub
Private Sub cv_Click()
cnchuyenvien.Show
End Sub
Private Sub dn_Click()
Dangnhap.Show
End Sub
Private Sub donthuoc_Click()
CNdonthuoc1.Show
End Sub
Private Sub pkb_Click()
khambenh.Show
End Sub
Private Sub pxn_Click()
Phieuxn.Show
End Sub
Private Sub saoluu_Click()
End Sub
Private Sub slph_Click()
saoluu.Show
End Sub
Private Sub TKKB_Click()
TKe.Show
End Sub
Private Sub TKTT_Click()
TKK.Show
End Sub
Private Sub tragiuong_Click()
hoadongiuong.Show
End Sub
Các file đính kèm theo tài liệu này:
- Bao cao nhom3.doc
- nhom3.rar