Chuyên đề Xây dựng và phát triển hệ thông thông tin quản lý tiền gửi và tiền vay của khách hàng tại Ngân hàng Nông nghiệp và Phát triển Nông thôn – Chi nhánh Láng Hạ

 Nắm bắt được rõ hơn quá trình xây dựng một hệ thống thông tin và được áp dụng giải quyết trong một bài toán cụ thể là “Quản lý tiền gửi và tiền vay của khách hàng”.  Xây dựng được một phần mềm quản lý bằng MS Access và Visual Basic 6.0. Từ đó, giúp em nắm bắt được ngôn ngữ lập trình của MS Acces, Visual Basic 6.0 và những điểm yếu và mạnh của nó.  Tự mình tìm hiểu, nghiên cứu và kết hợp với kiến thức đã có khai thác, phát triển để giải quyết bài toán thực tế.

doc124 trang | Chia sẻ: aloso | Lượt xem: 1537 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Chuyên đề Xây dựng và phát triển hệ thông thông tin quản lý tiền gửi và tiền vay của khách hàng tại Ngân hàng Nông nghiệp và Phát triển Nông thôn – Chi nhánh Láng Hạ, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
End Sub Private Sub CmdCuoiCT_Click() On Error GoTo Err_Cuoi_Click If AdoKHGuiTienCT.Recordset.EOF Then MsgBox "Ban dang o ban ghi cuoi", vbOKOnly, "Thong bao" Else AdoKHGuiTienCT.Recordset.MoveLast End If Exit_Cuoi_Click: Exit Sub Err_Cuoi_Click: MsgBox Err.Description Resume Exit_Cuoi_Click End Sub Private Sub CmdDau_Click() On Error GoTo Err_Dau_Click If AdoKHGuiTien.Recordset.BOF Then MsgBox "Ban dang o ban ghi dau tien", vbOKOnly, "Thong bao" Else AdoKHGuiTien.Recordset.MoveFirst End If Exit_Dau_Click: Exit Sub Err_Dau_Click: MsgBox Err.Description Resume Exit_Dau_Click End Sub Private Sub CmdDauCT_Click() On Error GoTo Err_Dau_Click If AdoKHGuiTienCT.Recordset.BOF Then MsgBox "Ban dang o ban ghi dau tien", vbOKOnly, "Thong bao" Else AdoKHGuiTienCT.Recordset.MoveFirst End If Exit_Dau_Click: Exit Sub Err_Dau_Click: MsgBox Err.Description Resume Exit_Dau_Click End Sub Private Sub CmdFrCT1_Click() If xThem Then AdoKHGuiTienCT.Recordset.Delete AdoKHGuiTienCT.Recordset.MoveNext If AdoKHGuiTienCT.Recordset.EOF Then AdoKHGuiTienCT.Recordset.MoveLast End If End If AdoKHGuiTienCT.Refresh Lock_textCT End Sub Private Sub CmdGhi_Click() On Error GoTo Err_ghi_click CmdThem.Visible = True CmdSua.Visible = True CmdXoa.Enabled = True CmdGhi.Visible = False CmdKhong.Visible = False CmdThoat.Enabled = True AdoKHGuiTien.Recordset.UpdateBatch adAffectAll CmdSua.Visible = True CmdKhong.Visible = False CmdGhi.Visible = False CmdXoa.Visible = True CmdThem.Visible = True ' cmdThemTG.SetFocus Lock_text Cmdclick.Enabled = False CmdTienGocLS.Enabled = False xThem = False DGridGui.Refresh CmdRf.Enabled = False Command1.Enabled = False AdoKHGuiTien.Recordset.Filter = "SoGui = '" & TxtSoGui & "'" AdoKHGuiTien.Recordset.Requery Exit_ghi_click: DGridGui.SetFocus Exit Sub Err_ghi_click: MsgBox "Data is invalid." Resume Exit_ghi_click End Sub Private Sub CmdGhiTG_Click() On Error GoTo Err_ghi_click cmdThemTG.Visible = True CmdSuaTG.Visible = True CmdXoaTG.Enabled = True CmdGhiTG.Visible = False CmdKhongTG.Visible = False CmdThoat.Enabled = True AdoKHGuiTienCT.Recordset.UpdateBatch adAffectAll 'CmdThem.SetFocus Lock_textCT Cmdclick.Enabled = False CmdTienGocLS.Enabled = False xThem = False DGridGuiCT.Refresh CmdRf.Enabled = True Command1.Enabled = True AdoKHGuiTienCT.Recordset.Filter = "SoGui = '" & Text1 & "'" AdoKHGuiTienCT.Recordset.Requery Exit_ghi_click: DGridGui.SetFocus Exit Sub Err_ghi_click: MsgBox "Data is invalid." Resume Exit_ghi_click End Sub Private Sub Unlock_text() CmbMaKH.locked = False CmbMaNV.locked = False TxtSoGui.locked = False TxtNgayBDGui.locked = False DGridGui.AllowUpdate = False DGridGui.AllowDelete = False DGridGui.AllowAddNew = False End Sub Private Sub Lock_text() CmbMaKH.locked = True TxtTenKH.locked = True txtTel.locked = True txtEmail.locked = True txtDiaChi.locked = True CmbMaNV.locked = True TxtTenNV.locked = True TxtSoGui.locked = True TxtNgayBDGui.locked = True DGridGui.AllowUpdate = False DGridGui.AllowDelete = False DGridGui.AllowAddNew = False End Sub Private Sub Lock_textCT() CmbMaKHCT.locked = True TxtTenKHCT.locked = True TxtSoTienGui.locked = True TxtLaiSuat.locked = True TxtSoKHGT.locked = True TxtNgayRutLS.locked = True Text1.locked = True TxtSoTienLS.locked = True CmbHTGT.locked = True TxttrangthaiGT.locked = True TxtTienGocLS.locked = True DGridGuiCT.AllowUpdate = False DGridGuiCT.AllowAddNew = False DGridGuiCT.AllowDelete = False End Sub Private Sub CmdKhongTG_Click() cmdThemTG.Visible = True CmdSuaTG.Visible = True CmdXoaTG.Enabled = True CmdGhiTG.Visible = False CmdKhongTG.Visible = False CmdThoat.Enabled = True AdoKHGuiTienCT.Refresh AdoKHGuiTienCT.Recordset.Clone AdoKHGuiTienCT.Recordset.MoveLast CmdSuaTG.Visible = True CmdKhongTG.Visible = False CmdGhiTG.Visible = False CmdXoaTG.Visible = True cmdThemTG.Visible = True cmdThemTG.SetFocus xThem = False Lock_textCT Cmdclick.Enabled = False CmdTienGocLS.Enabled = False Exit_Khong_Click: DGridGuiCT.SetFocus Exit Sub Err_Khong_Click: MsgBox "Data is invalid!" Resume Exit_Khong_Click End Sub Private Sub CmdNgayCT_Click() CalPhearum.Visible = True CalPhearum.SetFocus If Not IsNull(TxtNgayBDGui.Text) Then CalPhearum.Visible = TxtNgayBDGui.Text Else CalPhearum.Visible = Date End If End Sub Private Sub CmdNapRutLS_Click() On Error GoTo Err_Sua_click recnum = AdoKHGuiTienCT.Recordset.Bookmark CmdSuaTG.Visible = False CmdKhongTG.Visible = True CmdGhiTG.Visible = True CmdXoaTG.Enabled = False cmdThemTG.Visible = False CmdThoat.Enabled = False Text1.locked = True TxtNgayRutLS.locked = True CmbMaKHCT.locked = True TxtTenKHCT.locked = True CmbHTGT.locked = True TxtLaiSuat.locked = True TxtSoTienGui.locked = False TxtSoKHGT.locked = True Cmdclick.Enabled = True TxtSoTienLS.locked = True CmdTienGocLS.Enabled = False TxtTienGocLS.locked = True TxttrangthaiGT.locked = True DGridGuiCT.AllowUpdate = False DGridGuiCT.AllowAddNew = False DGridGuiCT.AllowDelete = False TxtTienGocLS.Text = "" TxttrangthaiGT.Text = "DaRutLS" Optdrt(0).SetFocus xThem = False Set_timeCT Exit_Sua_click: Exit Sub Err_Sua_click: MsgBox Err.Description Resume Exit_Sua_click End Sub Private Sub CmdNapTLH_Click() On Error GoTo Err_Sua_click recnum = AdoKHGuiTienCT.Recordset.Bookmark CmdSuaTG.Visible = False CmdKhongTG.Visible = True CmdGhiTG.Visible = True CmdXoaTG.Enabled = False cmdThemTG.Visible = False CmdThoat.Enabled = False Text1.locked = True TxtNgayRutLS.locked = True CmbMaKHCT.locked = True TxtTenKHCT.locked = True CmbHTGT.locked = True TxtLaiSuat.locked = True TxtSoTienGui.locked = False TxtSoKHGT.locked = True Cmdclick.Enabled = True TxtSoTienLS.locked = True CmdTienGocLS.Enabled = True TxtTienGocLS.locked = True TxttrangthaiGT.locked = True DGridGuiCT.AllowUpdate = False DGridGuiCT.AllowAddNew = False DGridGuiCT.AllowDelete = False xThem = False TxttrangthaiGT.Text = "DaLinhHet" Optdrtgls(1).SetFocus Set_timeCT Exit_Sua_click: Exit Sub Err_Sua_click: MsgBox Err.Description Resume Exit_Sua_click End Sub Private Sub CmdRf_Click() If xThem Then AdoKHGuiTien.Recordset.Delete AdoKHGuiTien.Recordset.MoveNext If AdoKHGuiTien.Recordset.EOF Then AdoKHGuiTien.Recordset.MoveLast End If End If AdoKHGuiTien.Refresh Lock_text End Sub Private Sub CmdRf1_Click() If xThem Then AdoKHGuiTien.Recordset.Delete AdoKHGuiTien.Recordset.MoveNext If AdoKHGuiTien.Recordset.EOF Then AdoKHGuiTien.Recordset.MoveLast End If End If AdoKHGuiTien.Refresh Lock_text End Sub Private Sub CmdSau_Click() If AdoKHGuiTien.Recordset.EOF Then MsgBox "ban dang o ban ghi cuoi", vbOKOnly, "Thong bao" Else AdoKHGuiTien.Recordset.MoveNext End If End Sub Private Sub CmdSauCT_Click() If AdoKHGuiTienCT.Recordset.EOF Then MsgBox "ban dang o ban ghi cuoi", vbOKOnly, "Thong bao" Else AdoKHGuiTienCT.Recordset.MoveNext End If End Sub Private Sub CmdSearch_Click() CmdGhiTG.Visible = True CmdSuaTG.Visible = True CmdXoaTG.Visible = True cmdThemTG.Visible = False CmdSearch.Visible = False CmdStop.Visible = True CmdThoat.Enabled = False lblTruong.Enabled = True lblTimKiem.Enabled = True CmbField.Enabled = True txtFind.Enabled = True AddItem CmbField.SetFocus End Sub Private Sub CmdStop_Click() cmdThemTG.Visible = True CmdXoaTG.Visible = True CmdSuaTG.Visible = True CmdSearch.Visible = True CmdStop.Visible = False CmdThoat.Enabled = True CmbField.Clear txtFind.Text = "" lblTruong.Enabled = False lblTimKiem.Enabled = False CmbField.Enabled = False txtFind.Enabled = False CmdRf.Enabled = True Command1.Enabled = True End Sub Private Sub CmdSuaTG_Click() On Error GoTo Err_Sua_click recnum = AdoKHGuiTienCT.Recordset.Bookmark cmdThemTG.Visible = False CmdSuaTG.Visible = False CmdXoaTG.Enabled = False CmdGhiTG.Visible = True CmdKhongTG.Visible = True CmdThoat.Enabled = False Text1.locked = True TxtNgayRutLS.locked = True CmbMaKHCT.locked = False TxtTenKHCT.locked = True CmbHTGT.locked = False TxtLaiSuat.locked = True TxtSoTienGui.locked = True TxtSoKHGT.locked = True Cmdclick.Enabled = False TxtSoTienLS.locked = True CmdTienGocLS.Enabled = False TxtTienGocLS.locked = True TxttrangthaiGT.locked = True DGridGuiCT.AllowUpdate = False DGridGuiCT.AllowAddNew = False DGridGuiCT.AllowDelete = False xThem = False Exit_Sua_click: Exit Sub Err_Sua_click: MsgBox Err.Description Resume Exit_Sua_click End Sub Private Sub CmdThoat_Click() Unload Me End Sub Private Sub CmdTienGocLS_Click() Me.TxtTienGocLS.Text = CDbl(Me.TxtSoTienGui) + CDbl(Me.TxtSoTienLS) TxtTienGocLS.Refresh End Sub Private Sub cmdTK_Click() CmdGhi.Visible = True CmdSua.Visible = True CmdXoa.Visible = True CmdThem.Visible = False cmdTK.Visible = False CmdTTK.Visible = True CmdThoat.Enabled = False lblTruong.Enabled = True lblTimKiem.Enabled = True CmbTimKH.Enabled = True TxtTimKiem.Enabled = True CmdTTK.Visible = True AddItem1 CmbTimKH.SetFocus End Sub Private Sub CmdTruoc_Click() If AdoKHGuiTien.Recordset.BOF Then MsgBox "Ban dang o ban ghi dau tien", vbOKOnly, "Thong bao" Else AdoKHGuiTien.Recordset.MovePrevious End If End Sub Private Sub CmdTruocCT_Click() If AdoKHGuiTienCT.Recordset.BOF Then MsgBox "Ban dang o ban ghi dau tien", vbOKOnly, "Thong bao" Else AdoKHGuiTienCT.Recordset.MovePrevious End If End Sub Private Sub CmdTTK_Click() CmbTimKH.Clear TxtTimKiem.Text = "" CmdThem.Visible = True CmdXoa.Visible = True CmdSua.Visible = True cmdTK.Visible = True CmdTTK.Visible = False CmdThoat.Enabled = True lblTruong.Enabled = False lblTimKiem.Enabled = False CmbTimKH.Enabled = False TxtTimKiem.Enabled = False CmdRf.Enabled = True Command1.Enabled = True End Sub Private Sub CmdXemTruoc_Click() FrmBCTTKHGT.Show End Sub Private Sub CmdXoaTG_Click() On Error GoTo Err_Xoa_click cmdThemTG.Visible = True CmdSuaTG.Visible = True CmdXoaTG.Enabled = True CmdGhiTG.Visible = False CmdKhongTG.Visible = False CmdThoat.Enabled = True Dim TraLoi Dim KRY As Variant TraLoi = MsgBox("Ban muon xoa Ma nha cung cap " & CmbMaKHCT.Text & _ " (cung voi cac thong tin lien quan)?", 48 + 4, "Thong bao") KRY = Text1.Text If TraLoi = 6 Then Set Conn = New ADODB.Connection Set rs = New ADODB.Recordset Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" Conn.Open KRY = Text1.Text strSQL = "DELETE * FROM TblKhGuiTien WHERE SoGui ='" & KRY & "';" Conn.Execute strSQL Conn.Close AdoKHGuiTienCT.Recordset.Delete AdoKHGuiTienCT.Recordset.Clone AdoKHGuiTienCT.Recordset.MoveNext 'If AdoKHGuiTienCT.Recordset.EOF Then ' AdoKHGuiTienCT.Recordset.MoveLast ' End If AdoKHGuiTien.Recordset.Filter = "SoGui = '" & Text1 & "'" AdoKHGuiTien.Recordset.Requery End If Lock_textCT Exit_Xoa_click: Exit Sub Err_Xoa_click: MsgBox Err.Description Resume Exit_Xoa_click End Sub Private Sub CmdKhong_Click() AdoKHGuiTien.Refresh AdoKHGuiTien.Recordset.Clone AdoKHGuiTien.Recordset.MoveLast CmdThem.Visible = True CmdSua.Visible = True CmdXoa.Enabled = True CmdGhi.Visible = False CmdKhong.Visible = False CmdThoat.Enabled = True 'CmdThem.SetFocus xThem = False Lock_text Exit_Khong_Click: DGridGui.SetFocus Exit Sub Err_Khong_Click: MsgBox "Data is invalid!" Resume Exit_Khong_Click End Sub Private Sub CmdSua_Click() On Error GoTo Err_Sua_click CmdThem.Visible = False CmdSua.Visible = False CmdXoa.Enabled = False CmdGhi.Visible = True CmdKhong.Visible = True CmdThoat.Enabled = False recnum = AdoKHGuiTien.Recordset.Bookmark xThem = False Unlock_text Exit_Sua_click: Exit Sub Err_Sua_click: MsgBox Err.Description Resume Exit_Sua_click End Sub Private Sub CmdThem_Click() AdoKHGuiTien.Recordset.AddNew CmdThem.Visible = False CmdSua.Visible = False CmdXoa.Enabled = False CmdGhi.Visible = True CmdKhong.Visible = True CmdThoat.Enabled = False TxtTenKH.Text = "" TxtTenNV.Text = "" TxtSoGui.Text = "" TxtNgayBDGui.Text = "" Set_time Unlock_text AdoKHGuiTienCT.Recordset.Filter = "SoGui = '" & TxtSoGui & "'" AdoKHGuiTienCT.Recordset.Requery TxtSoGui.SetFocus End Sub Private Sub cmdThemTG_Click() On Error GoTo Err_Them_click cmdThemTG.Visible = False CmdSuaTG.Visible = False CmdXoaTG.Enabled = False CmdGhiTG.Visible = True CmdKhongTG.Visible = True CmdThoat.Enabled = False xThemCT = True mKhong = False mLoad = False mChange = False mGhi = False AdoKHGuiTienCT.Recordset.AddNew Text1.locked = True TxtNgayRutLS.locked = True CmbMaKHCT.locked = False TxtTenKHCT.locked = True CmbHTGT.locked = False TxtLaiSuat.locked = True TxtSoTienGui.locked = False TxtSoKHGT.locked = True Cmdclick.Enabled = False TxtSoTienLS.locked = False CmdTienGocLS.Enabled = False TxtTienGocLS.locked = True TxttrangthaiGT.locked = True DGridGuiCT.AllowUpdate = True DGridGuiCT.AllowAddNew = True DGridGuiCT.AllowDelete = True TxtSoTienLS.Text = "" TxtTienGocLS.Text = "" TxttrangthaiGT.Text = "Dang Gui" optdgt(1).SetFocus AdoKHGuiTienCT.Recordset.Fields("SoGui") = Trim(TxtSoGui.Text) 'TinhTongCong ' TxtTenHH.Text = "" Exit_Them_click: Exit Sub Err_Them_click: MsgBox Err.Description Resume Exit_Them_click End Sub Private Sub CmdXoa_Click() On Error GoTo Err_Xoa_click CmdThem.Visible = True CmdSua.Visible = True CmdXoa.Enabled = True CmdGhi.Visible = False CmdKhong.Visible = False CmdThoat.Enabled = True Dim TraLoi Dim KRY As Variant TraLoi = MsgBox("Ban muon xoa Ma Khach hang " & CmbMaKH.Text & _ " (cung voi cac thong tin lien quan)?", 48 + 4, "Thong bao") KRY = TxtSoGui.Text If TraLoi = 6 Then Set Conn = New ADODB.Connection Set rs = New ADODB.Recordset Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" Conn.Open KRY = TxtSoGui.Text strSQL = "DELETE * FROM TblKhGuiTienCT WHERE SoGui ='" & KRY & "';" Conn.Execute strSQL Conn.Close AdoKHGuiTien.Recordset.Delete AdoKHGuiTien.Recordset.Clone AdoKHGuiTien.Recordset.MoveNext 'If AdoKHGuiTien.Recordset.EOF Then ' AdoKHGuiTien.Recordset.MoveLast 'End If AdoKHGuiTienCT.Recordset.Filter = "SoGui = '" & TxtSoGui & "'" AdoKHGuiTienCT.Recordset.Requery End If Lock_text Exit_Xoa_click: Exit Sub Err_Xoa_click: MsgBox Err.Description Resume Exit_Xoa_click End Sub Private Sub Command1_Click() If xThem Then AdoKHGuiTienCT.Recordset.Delete AdoKHGuiTienCT.Recordset.MoveNext If AdoKHGuiTienCT.Recordset.EOF Then AdoKHGuiTienCT.Recordset.MoveLast End If End If AdoKHGuiTienCT.Refresh Lock_textCT End Sub Private Sub Form_Load() Dim so As Integer, ngay, thang, nam thang = Month(Now()) ngay = Day(Now()) nam = Year(Now()) Me.LblThang = thang Me.LblNgay = ngay Me.LblNam = nam CmdSua.Visible = True CmdKhong.Visible = False CmdGhi.Visible = False CmdXoa.Visible = True CmdThem.Visible = True AdoKHGuiTien.Visible = False AdoKHGuiTien.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" AdoKHGuiTienCT.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" 'Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" Lock_text Lock_textCT Cmdclick.Enabled = False CmdTienGocLS.Enabled = False NapAdoKHGuiTien NapAdoKHGuiTienCT NapCmbMaKH NapCmbMaNV NapCmbMaKHCT NapCmbHTGT NapCmbTongCong End Sub Private Sub Set_time() If Month(Now()) = Me.LblThang Then Me.TxtNgayBDGui.Text = Format(Now(), "dd//mm//yy") End If End Sub Private Sub Set_timeCT() If Month(Now()) = Me.LblThang Then Me.TxtNgayRutLS.Text = Format(Now(), "dd//mm//yy") End If End Sub Private Sub TinhThanhTien() Dim ThanhTien As New ADODB.Recordset Dim Str As String If CmbMaKHCT.Text "" Then Str = "SELECT SUM(SoTienCOLS) AS Tong From TblKHGuiTienCT GROUP BY MaKH AND MaKH='" & CmbMaKHCT.Text & "'" ThanhTien.Open Str, Conn TxtTongCongRT.Text = ThanhTien!Tong ThanhTien.Close End If End Sub Private Sub AddItem() CmbField.AddItem ("SoGui") CmbField.AddItem ("MaKH") CmbField.AddItem ("TenKH") CmbField.AddItem ("TrangThaiGT") End Sub Private Sub AddItem1() CmbTimKH.AddItem ("SoGui") CmbTimKH.AddItem ("MaKH") End Sub Private Sub NapAdoKHGuiTien() AdoKHGuiTien.CommandType = adCmdText AdoKHGuiTien.RecordSource = "SELECT * from TblKHGuiTien order by SoGui" AdoKHGuiTien.Refresh End Sub Private Sub NapAdoKHGuiTienCT() AdoKHGuiTienCT.CommandType = adCmdText AdoKHGuiTienCT.RecordSource = "SELECT * from TblKHGuiTienCT order by SoGui" AdoKHGuiTienCT.Refresh End Sub Private Sub NapCmbMaKHCT() Dim SQL As String SQL = " Select MaKH From TblDMKH Order by MaKH" RsMaKHCT.Open SQL, Conn CmbMaKHCT.Clear Do While Not RsMaKHCT.EOF CmbMaKHCT.AddItem RsMaKHCT!MaKH RsMaKHCT.MoveNext Loop RsMaKHCT.Close End Sub Private Sub NapCmbHTGT() Dim SQL As String SQL = " Select LoaiHTGT From TblLoaiLS Order by LoaiHTGT" RsHTGT.Open SQL, Conn CmbHTGT.Clear Do While Not RsHTGT.EOF CmbHTGT.AddItem RsHTGT!LoaiHTGT RsHTGT.MoveNext Loop RsHTGT.Close End Sub Private Sub NapCmbTongCong() Dim SQL As String SQL = " Select MaKH From TblDMKH Order by MaKH" RsTongCong.Open SQL, Conn CmbTongCong.Clear Do While Not RsTongCong.EOF CmbTongCong.AddItem RsTongCong!MaKH RsTongCong.MoveNext Loop RsTongCong.Close End Sub Private Sub NapCmbMaKH() Dim SQL As String SQL = " Select MaKH From TblDMKH Order by MaKH" RsMaKH.Open SQL, Conn CmbMaKH.Clear Do While Not RsMaKH.EOF CmbMaKH.AddItem RsMaKH!MaKH RsMaKH.MoveNext Loop RsMaKH.Close End Sub Private Sub NapCmbMaNV() Dim SQL As String SQL = " Select MaNV From TblDMNV Order by MaNV" RsMaNV.Open SQL, Conn CmbMaNV.Clear Do While Not RsMaNV.EOF CmbMaNV.AddItem RsMaNV!MaNV RsMaNV.MoveNext Loop RsMaNV.Close End Sub Private Sub optdgt_Click(Index As Integer) optdgt(1).Value = True Optdrt(0).Value = False Optdrtgls(1).Value = False Cmdclick.Enabled = False CmdTienGocLS.Enabled = False TxttrangthaiGT.Text = "Dang Gui" End Sub Private Sub Optdrt_Click(Index As Integer) optdgt(1).Value = False Optdrt(0).Value = True Optdrtgls(1).Value = False Cmdclick.Enabled = False CmdTienGocLS.Enabled = False TxttrangthaiGT.Text = "DaRutLS" End Sub Private Sub Optdrtgls_Click(Index As Integer) optdgt(1).Value = False Optdrt(0).Value = False Optdrtgls(1).Value = True Cmdclick.Enabled = False CmdTienGocLS.Enabled = False TxttrangthaiGT.Text = "DaLinhHet" End Sub Private Sub txtFind_Change() If CmbField.Text = "" Or txtFind = "" Then AdoKHGuiTienCT.Recordset.Filter = "" AdoKHGuiTienCT.Refresh Exit Sub End If AdoKHGuiTienCT.Recordset.Filter = CmbField & " LIKE '*" & txtFind & "*'" End Sub Private Sub TxtTimKiem_Change() If CmbTimKH.Text = "" Or TxtTimKiem = "" Then AdoKHGuiTien.Recordset.Filter = "" AdoKHGuiTien.Refresh Exit Sub End If AdoKHGuiTien.Recordset.Filter = CmbTimKH & " LIKE '*" & TxtTimKiem & "*'" End Sub Form Phiếu khách hàng đến vay tiền 'Dim Conn As New ADODB.Connection 'Dim NapTudong As New ADODB.Recordset Dim RsMaNV As New ADODB.Recordset Dim RsMaKH As New ADODB.Recordset Dim RsMaKHCT As New ADODB.Recordset Dim RsHTVT As New ADODB.Recordset Dim RsTongCong As New ADODB.Recordset Dim xThem, xsua, recnum Private Sub AdoKHVayTien_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) lblResult.Caption = "Khách hàng hiện tại có" & AdoKHVayTien.Recordset.RecordCount txtSoKH1.Text = "Khách hàng " & AdoKHVayTien.Recordset.AbsolutePosition & _ " trong " & AdoKHVayTien.Recordset.RecordCount End Sub Private Sub AdoKHVayTienCT_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) lblResult.Caption = "Khách hàng hiện tại có" AdoKHVayTienCT.Recordset.RecordCount txtSoKH.Text = "Khách hàng " & AdoKHVayTienCT.Recordset.AbsolutePosition & _ " trong " & AdoKHVayTienCT.Recordset.RecordCount End Sub Private Sub CmbHTVT_Click() Set Conn = New ADODB.Connection Set NapTuDong = New ADODB.Recordset Dim Str As String Str = "SELECT * FROM TblLoaiLSVay WHERE TblLoaiLSVay.LoaiHTVT='" & CmbHTVT.Text & "'" Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanLyNH.mdb;Persist Security Info=False" Conn.Open NapTuDong.Open Str, Conn CmbHTVT.Text = NapTuDong!LoaiHTVT TxtLaiSuat.Text = NapTuDong!TLLaisuat TxtSoTienVay.SetFocus End Sub Private Sub CmbMaKH_Click() Set Conn = New ADODB.Connection Set NapTuDong = New ADODB.Recordset Dim Str As String Str = "SELECT * FROM TblDMKHVay WHERE TblDMKHVay.MaKH='" & CmbMaKH.Text & "'" Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanLyNH.mdb;Persist Security Info=False" Conn.Open NapTuDong.Open Str, Conn TxtTenKH.Text = NapTuDong!TenKH txtTel.Text = NapTuDong!Tel txtEmail.Text = NapTuDong!Email txtDiaChi.Text = NapTuDong!DiaChi NapTuDong.Close End Sub Private Sub CmbMaKHCT_Click() Set Conn = New ADODB.Connection Set NapTuDong = New ADODB.Recordset Dim Str As String Str = "SELECT * FROM TblDMKHVay WHERE TblDMKHVay.MaKH='" & CmbMaKHCT.Text & "'" Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanLyNH.mdb;Persist Security Info=False" Conn.Open NapTuDong.Open Str, Conn TxtTenKHCT.Text = NapTuDong!TenKH NapTuDong.Close End Sub Private Sub CmbMaNV_Click() Set Conn = New ADODB.Connection Set NapTuDong = New ADODB.Recordset Dim Str As String Str = "SELECT * FROM TblDMNV WHERE TblDMNV.MaNV='" & CmbMaNV.Text & "'" Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanLyNH.mdb;Persist Security Info=False" Conn.Open NapTuDong.Open Str, Conn TxtTenNV.Text = NapTuDong!TenNV NapTuDong.Close End Sub Private Sub CmbTongCong_Click() Dim ThanhTien As New ADODB.Recordset Dim Str As String If CmbTongCong.Text "" Then Str = "SELECT SUM(SoTienLS) AS Tong From TblKHVayTienCT GROUP BY MaKH AND MaKH='" & CmbTongCong.Text & "'" ThanhTien.Open Str, Conn TxtTongCongRT.Text = ThanhTien!Tong ThanhTien.Close End If End Sub Private Sub Cmdclick_Click() Dim P1, T1, N1 P1 = Me.TxtSoTienVay T1 = Me.TxtLaiSuat N1 = Me.TxtSoKHVT Me.TxtSoTienLS.Text = (P1 * (T1 ^ N1)) - P1 End Sub Private Sub CmdCuoi_Click() On Error GoTo Err_Cuoi_Click If AdoKHVayTien.Recordset.EOF Then MsgBox "Ban dang o ban ghi cuoi", vbOKOnly, "Thong bao" Else AdoKHVayTien.Recordset.MoveLast End If Exit_Cuoi_Click: Exit Sub Err_Cuoi_Click: MsgBox Err.Description Resume Exit_Cuoi_Click End Sub Private Sub CmdCuoiCT_Click() On Error GoTo Err_Cuoi_Click If AdoKHVayTienCT.Recordset.EOF Then MsgBox "Ban dang o ban ghi cuoi", vbOKOnly, "Thong bao" Else AdoKHVayTienCT.Recordset.MoveLast End If Exit_Cuoi_Click: Exit Sub Err_Cuoi_Click: MsgBox Err.Description Resume Exit_Cuoi_Click End Sub Private Sub CmdDau_Click() On Error GoTo Err_Dau_Click If AdoKHVayTien.Recordset.BOF Then MsgBox "Ban dang o ban ghi dau tien", vbOKOnly, "Thong bao" Else AdoKHVayTien.Recordset.MoveFirst End If Exit_Dau_Click: Exit Sub Err_Dau_Click: MsgBox Err.Description Resume Exit_Dau_Click End Sub Private Sub CmdDauCT_Click() On Error GoTo Err_Dau_Click If AdoKHVayTienCT.Recordset.BOF Then MsgBox "Ban dang o ban ghi dau tien", vbOKOnly, "Thong bao" Else AdoKHVayTienCT.Recordset.MoveFirst End If Exit_Dau_Click: Exit Sub Err_Dau_Click: MsgBox Err.Description Resume Exit_Dau_Click End Sub Private Sub CmdGhi_Click() On Error GoTo Err_ghi_click AdoKHVayTien.Recordset.UpdateBatch adAffectAll CmdThem.Visible = True CmdSua.Visible = True CmdXoa.Enabled = True CmdGhi.Visible = False CmdKhong.Visible = False CmdThoat.Enabled = True 'CmdThem.SetFocus Lock_text CmdRf.Enabled = False Command1.Enabled = True xThem = False DGridVay.Refresh AdoKHVayTien.Recordset.Filter = "SoVay = '" & TxtSoVay & "'" AdoKHVayTien.Recordset.Requery Exit_ghi_click: DGridVayCT.SetFocus Exit Sub Err_ghi_click: MsgBox "Data is invalid." Resume Exit_ghi_click End Sub Private Sub CmdGhiVay_Click() On Error GoTo Err_ghi_click AdoKHVayTienCT.Recordset.UpdateBatch adAffectAll cmdThemVay.Visible = True CmdSuaVay.Visible = True CmdXoaVay.Enabled = True CmdGhiVay.Visible = False CmdKhongVay.Visible = False CmdThoat.Enabled = True 'cmdThemVay.SetFocus Lock_textCT TxtSoKHVT.locked = True CmdRf.Enabled = True Command1.Enabled = True xThem = False DGridVayCT.Refresh AdoKHVayTienCT.Recordset.Filter = "SoVay = '" & Text1 & "'" AdoKHVayTienCT.Recordset.Requery Exit_ghi_click: DGridVay.SetFocus Exit Sub Err_ghi_click: MsgBox "Data is invalid." Resume Exit_ghi_click End Sub Private Sub Lock_textCT() CmbMaKHCT.locked = True TxtTenKHCT.locked = True TxtSoTienVay.locked = True TxtLaiSuat.locked = True CmbHTVT.locked = True TxtNgayTraTien.locked = True Text1.locked = True TxtSoTienLS.locked = True TxtTienGocLS.locked = False TxttrangthaiVT.locked = True DGridVayCT.AllowUpdate = False DGridVayCT.AllowAddNew = False DGridVayCT.AllowDelete = False End Sub Private Sub CmdKhong_Click() AdoKHVayTien.Refresh AdoKHVayTien.Recordset.Clone AdoKHVayTien.Recordset.MoveLast CmdThem.Visible = True CmdSua.Visible = True CmdXoa.Enabled = True CmdGhi.Visible = False CmdKhong.Visible = False CmdThoat.Enabled = True CmdThem.SetFocus xThem = False Lock_text Exit_Khong_Click: DGridVay.SetFocus Exit Sub Err_Khong_Click: MsgBox "Data is invalid!" Resume Exit_Khong_Click End Sub Private Sub CmdKhongVay_Click() AdoKHVayTienCT.Refresh AdoKHVayTienCT.Recordset.Clone AdoKHVayTienCT.Recordset.MoveLast cmdThemVay.Visible = True CmdSuaVay.Visible = True CmdXoaVay.Enabled = True CmdGhiVay.Visible = False CmdKhongVay.Visible = False CmdThoat.Enabled = True TxtSoKHVT.locked = True Cmdclick.Enabled = False CmdTienGocLS.Enabled = False ' cmdThemVay.SetFocus xThem = False Lock_textCT Exit_Khong_Click: DGridVayCT.SetFocus Exit Sub Err_Khong_Click: MsgBox "Data is invalid!" Resume Exit_Khong_Click End Sub Private Sub CmdNapRutLS_Click() On Error GoTo Err_Sua_click recnum = AdoKHVayTienCT.Recordset.Bookmark CmdSuaVay.Visible = False CmdKhongVay.Visible = True CmdGhiVay.Visible = True CmdXoaVay.Enabled = False cmdThemVay.Visible = False CmdThoat.Enabled = False Text1.locked = True TxtNgayTraTien.locked = True CmbMaKHCT.locked = True TxtTenKHCT.locked = True CmbHTVT.locked = True TxtLaiSuat.locked = True TxtSoTienVay.locked = False TxtSoKHVT.locked = False Cmdclick.Enabled = True TxtSoTienLS.locked = True CmdTienGocLS.Enabled = False TxtTienGocLS.locked = True TxttrangthaiVT.locked = True DGridVayCT.AllowUpdate = False DGridVayCT.AllowAddNew = False DGridVayCT.AllowDelete = False TxtTienGocLS.Text = "" TxttrangthaiVT.Text = "DaTraLS" Optdrt(0).SetFocus xThem = False Set_timeCT Exit_Sua_click: Exit Sub Err_Sua_click: MsgBox Err.Description Resume Exit_Sua_click End Sub Private Sub CmdNapTDtraHet_Click() On Error GoTo Err_Sua_click recnum = AdoKHVayTienCT.Recordset.Bookmark CmdSuaVay.Visible = False CmdKhongVay.Visible = True CmdGhiVay.Visible = True CmdXoaVay.Enabled = False cmdThemVay.Visible = False CmdThoat.Enabled = False Text1.locked = True TxtNgayTraTien.locked = True CmbMaKHCT.locked = True TxtTenKHCT.locked = True CmbHTVT.locked = True TxtLaiSuat.locked = True TxtSoTienVay.locked = False TxtSoKHVT.locked = False Cmdclick.Enabled = True TxtSoTienLS.locked = True CmdTienGocLS.Enabled = True TxtTienGocLS.locked = True TxttrangthaiVT.locked = True DGridVayCT.AllowUpdate = False DGridVayCT.AllowAddNew = False DGridVayCT.AllowDelete = False xThem = False Set_timeCT TxttrangthaiVT.Text = "DaTraHet" OptDTH(1).SetFocus Exit_Sua_click: Exit Sub Err_Sua_click: MsgBox Err.Description Resume Exit_Sua_click End Sub Private Sub CmdRf_Click() If xThem Then AdoKHVayTien.Recordset.Delete AdoKHVayTien.Recordset.MoveNext If AdoKHVayTien.Recordset.EOF Then AdoKHVayTien.Recordset.MoveLast End If End If AdoKHVayTien.Refresh Lock_text End Sub Private Sub CmdSau_Click() If AdoKHVayTien.Recordset.EOF Then MsgBox "ban dang o ban ghi cuoi", vbOKOnly, "Thong bao" Else AdoKHVayTien.Recordset.MoveNext End If End Sub Private Sub CmdSauCT_Click() If AdoKHVayTienCT.Recordset.EOF Then MsgBox "ban dang o ban ghi cuoi", vbOKOnly, "Thong bao" Else AdoKHVayTienCT.Recordset.MoveNext End If End Sub Private Sub CmdSearch_Click() CmdGhiVay.Visible = True CmdSuaVay.Visible = True CmdXoaVay.Visible = True cmdThemVay.Visible = False CmdSearch.Visible = False CmdStop.Visible = True CmdThoat.Enabled = False lblTruong.Enabled = True lblTimKiem.Enabled = True CmbField.Enabled = True txtFind.Enabled = True AddItem CmbField.SetFocus End Sub Private Sub AddItem() CmbField.AddItem ("SoVay") CmbField.AddItem ("MaKH") CmbField.AddItem ("TenKH") CmbField.AddItem ("TrangThaiVT") End Sub Private Sub CmdStop_Click() CmbField.Clear txtFind.Text = "" cmdThemVay.Visible = True CmdXoaVay.Visible = True CmdSuaVay.Visible = True CmdSearch.Visible = True CmdStop.Visible = False CmdThoat.Enabled = True lblTruong.Enabled = False lblTimKiem.Enabled = False CmbField.Enabled = False txtFind.Enabled = False End Sub Private Sub CmdSua_Click() On Error GoTo Err_Sua_click CmdThem.Visible = False CmdSua.Visible = False CmdXoa.Enabled = False CmdGhi.Visible = True CmdKhong.Visible = True CmdThoat.Enabled = False recnum = AdoKHVayTien.Recordset.Bookmark xThem = False Unlock_text Exit_Sua_click: Exit Sub Err_Sua_click: MsgBox Err.Description Resume Exit_Sua_click End Sub Private Sub CmdSuaVay_Click() On Error GoTo Err_Sua_click recnum = AdoKHVayTienCT.Recordset.Bookmark cmdThemVay.Visible = False CmdSuaVay.Visible = False CmdXoaVay.Enabled = False CmdGhiVay.Visible = True CmdKhongVay.Visible = True CmdThoat.Enabled = False Text1.locked = True TxtNgayTraTien.locked = True CmbMaKHCT.locked = False TxtTenKHCT.locked = True CmbHTVT.locked = False TxtLaiSuat.locked = True TxtSoTienVay.locked = True TxtSoKHVT.locked = True Cmdclick.Enabled = False TxtSoTienLS.locked = True CmdTienGocLS.Enabled = False TxtTienGocLS.locked = True TxttrangthaiVT.locked = True DGridVayCT.AllowUpdate = False DGridVayCT.AllowAddNew = False DGridVayCT.AllowDelete = False xThem = False Exit_Sua_click: Exit Sub Err_Sua_click: MsgBox Err.Description Resume Exit_Sua_click End Sub Private Sub CmdThem_Click() CmdThem.Visible = False CmdSua.Visible = False CmdXoa.Enabled = False CmdGhi.Visible = True CmdKhong.Visible = True CmdThoat.Enabled = False AdoKHVayTien.Recordset.AddNew TxtTenKH.Text = "" TxtTenNV.Text = "" TxtSoVay.Text = "" TxtNgayBDVay.Text = "" Set_time Unlock_text AdoKHVayTienCT.Recordset.Filter = "SoVay = '" & TxtSoVay & "'" AdoKHVayTienCT.Recordset.Requery TxtSoVay.SetFocus End Sub Private Sub cmdThemVay_Click() On Error GoTo Err_Them_click xThemCT = True mKhong = False mLoad = False mChange = False mGhi = False cmdThemVay.Visible = False CmdSuaVay.Visible = False CmdXoaVay.Enabled = False CmdGhiVay.Visible = True CmdKhongVay.Visible = True CmdThoat.Enabled = False AdoKHVayTienCT.Recordset.AddNew Text1.locked = True TxtNgayTraTien.locked = True CmbMaKHCT.locked = False TxtTenKHCT.locked = True CmbHTVT.locked = False TxtLaiSuat.locked = True TxtSoTienVay.locked = False TxtSoKHVT.locked = True Cmdclick.Enabled = False TxtSoTienLS.locked = True CmdTienGocLS.Enabled = False TxtTienGocLS.locked = True TxttrangthaiVT.locked = True DGridVayCT.AllowUpdate = True DGridVayCT.AllowAddNew = True DGridVayCT.AllowDelete = True TxtSoTienLS.Text = "" TxtTienGocLS.Text = "” TxttrangthaiVT.Text = "DangVay" optdgt(1).SetFocus AdoKHVayTienCT.Recordset.Fields("SoVay") = Trim(TxtSoVay.Text) 'TinhTongCong ' TxtTenHH.Text = "" Exit_Them_click: Exit Sub Err_Them_click: MsgBox Err.Description Resume Exit_Them_click End Sub Private Sub CmdThoat_Click() Unload Me End Sub Private Sub CmdTienGocLS_Click() Me.TxtTienGocLS.Text = CDbl(Me.TxtSoTienVay) + CDbl(Me.TxtSoTienLS) TxtTienGocLS.Refresh End Sub Private Sub cmdTK_Click() CmdGhi.Visible = True CmdSua.Visible = True CmdXoa.Visible = True CmdThem.Visible = False cmdTK.Visible = False CmdTTK.Visible = True CmdThoat.Enabled = False lblTruong.Enabled = True lblTimKiem.Enabled = True CmbTimKH.Enabled = True TxtTimKiem.Enabled = True CmdTTK.Visible = True AddItem1 CmbTimKH.SetFocus End Sub Private Sub AddItem1() CmbTimKH.AddItem ("SoVay") CmbTimKH.AddItem ("MaKH") End Sub Private Sub CmdTruoc_Click() If AdoKHVayTien.Recordset.BOF Then MsgBox "Ban dang o ban ghi dau tien", vbOKOnly, "Thong bao" Else AdoKHVayTien.Recordset.MovePrevious End If End Sub Private Sub CmdTruocCT_Click() If AdoKHVayTienCT.Recordset.BOF Then MsgBox "Ban dang o ban ghi dau tien", vbOKOnly, "Thong bao" Else AdoKHVayTienCT.Recordset.MovePrevious End If End Sub Private Sub CmdTTK_Click() CmbTimKH.Clear TxtTimKiem.Text = "" CmdThem.Visible = True CmdXoa.Visible = True CmdSua.Visible = True cmdTK.Visible = True CmdTTK.Visible = False CmdThoat.Enabled = True lblTruong.Enabled = False lblTimKiem.Enabled = False CmbTimKH.Enabled = False TxtTimKiem.Enabled = False End Sub Private Sub CmdXemTruoc_Click() FrmBCTTKHVayTien.Show End Sub Private Sub CmdXoa_Click() On Error GoTo Err_Xoa_click CmdThem.Visible = True CmdSua.Visible = True CmdXoa.Enabled = True CmdGhi.Visible = False CmdKhong.Visible = False CmdThoat.Enabled = True Dim TraLoi Dim KRY As Variant TraLoi = MsgBox("Ban muon xoa Ma nha cung cap " & CmbMaKH.Text & _ " (cung voi cac thong tin lien quan)?", 48 + 4, "Thong bao") KRY = TxtSoVay.Text If TraLoi = 6 Then Set Conn = New ADODB.Connection Set rs = New ADODB.Recordset Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" Conn.Open KRY = TxtSoVay.Text strSQL = "DELETE * FROM TblKhVayTienCT WHERE SoVay ='" & KRY & "';" Conn.Execute strSQL Conn.Close AdoKHVayTien.Recordset.Delete AdoKHVayTien.Recordset.Clone AdoKHVayTien.Recordset.MoveNext If AdoKHVayTien.Recordset.EOF Then AdoKHVayTien.Recordset.MoveLast End If AdoKHVayTienCT.Recordset.Filter = "SoVay = '" & TxtSoVay & "'" AdoKHVayTienCT.Recordset.Requery End If Lock_text Exit_Xoa_click: Exit Sub Err_Xoa_click: MsgBox Err.Description Resume Exit_Xoa_click End Sub Private Sub CmdXoaVay_Click() On Error GoTo Err_Xoa_click cmdThemVay.Visible = True CmdSuaVay.Visible = True CmdXoaVay.Enabled = True CmdGhiVay.Visible = False CmdKhongVay.Visible = False CmdThoat.Enabled = True Dim TraLoi Dim KRY As Variant TraLoi = MsgBox("Ban muon xoa Ma nha cung cap " & CmbMaKHCT.Text & _ " (cung voi cac thong tin lien quan)?", 48 + 4, "Thong bao") KRY = Text1.Text If TraLoi = 6 Then Set Conn = New ADODB.Connection Set rs = New ADODB.Recordset Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" Conn.Open KRY = Text1.Text strSQL = "DELETE * FROM TblKhVayTien WHERE SoVay ='" & KRY & "';" Conn.Execute strSQL Conn.Close AdoKHVayTienCT.Recordset.Delete AdoKHVayTienCT.Recordset.Clone AdoKHVayTienCT.Recordset.MoveNext If AdoKHVayTienCT.Recordset.EOF Then AdoKHVayTienCT.Recordset.MoveLast End If AdoKHVayTien.Recordset.Filter = "SoVay = '" & TxtSoVay & "'" AdoKHVayTien.Recordset.Requery End If Lock_textCT Exit_Xoa_click: Exit Sub Err_Xoa_click: MsgBox "Khong the xoa ban ghi nay !" Resume Exit_Xoa_click End Sub Private Sub Command1_Click() If xThem Then AdoKHVayTienCT.Recordset.Delete AdoKHVayTienCT.Recordset.MoveNext If AdoKHVayTienCT.Recordset.EOF Then AdoKHVayTienCT.Recordset.MoveLast End If End If AdoKHVayTienCT.Refresh Lock_textCT End Sub Private Sub Form_Load() Dim so As Integer, ngay, thang, nam thang = Month(Now()) ngay = Day(Now()) nam = Year(Now()) Me.LblThang = thang Me.LblNgay = ngay Me.LblNam = nam CmdSua.Visible = True CmdKhong.Visible = False CmdGhi.Visible = False CmdXoa.Visible = True CmdThem.Visible = True AdoKHVayTien.Visible = False AdoKHVayTien.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" AdoKHVayTienCT.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" 'Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" Lock_text Lock_textCT TxtSoKHVT.locked = True Cmdclick.Enabled = False CmdTienGocLS.Enabled = False NapAdoKHVayTien NapAdoKHVayTienCT NapCmbMaKH NapCmbMaNV NapCmbMaKHCT NapCmbHTVT NapCmbTongCong End Sub Private Sub Set_time() If Month(Now()) = Me.LblThang Then Me.TxtNgayBDVay.Text = Format(Now(), "dd//mm//yy") End If End Sub Private Sub Set_timeCT() If Month(Now()) = Me.LblThang Then Me.TxtNgayTraTien.Text = Format(Now(), "dd//mm//yy") End If End Sub Private Sub TinhThanhTien() Dim ThanhTien As New ADODB.Recordset Dim Str As String If CmbMaKHCT.Text "" Then Str = "SELECT SUM(SoTienKHTra) AS Tong From TblKHVayTienCT GROUP BY MaKH AND MaKH='" & CmbMaKHCT.Text & "'" ThanhTien.Open Str, Conn TxtTongCongRT.Text = ThanhTien!Tong ThanhTien.Close End If End Sub Private Sub Unlock_text() CmbMaKH.locked = False CmbMaNV.locked = False TxtSoVay.locked = False TxtNgayBDVay.locked = False DGridVay.AllowUpdate = False DGridVay.AllowDelete = False DGridVay.AllowAddNew = False End Sub Private Sub Lock_text() CmbMaKH.locked = True TxtTenKH.locked = True txtTel.locked = True txtEmail.locked = True txtDiaChi.locked = True CmbMaNV.locked = True TxtTenNV.locked = True TxtSoVay.locked = True TxtNgayBDVay.locked = True CmbHTVT.locked = True DGridVay.AllowUpdate = False DGridVay.AllowDelete = False DGridVay.AllowAddNew = False End Sub Private Sub NapAdoKHVayTien() AdoKHVayTien.CommandType = adCmdText AdoKHVayTien.RecordSource = "SELECT * from TblKHVayTien order by SoVay" AdoKHVayTien.Refresh End Sub Private Sub NapAdoKHVayTienCT() AdoKHVayTienCT.CommandType = adCmdText AdoKHVayTienCT.RecordSource = "SELECT * from TblKHVayTienCT order by SoVay" AdoKHVayTienCT.Refresh End Sub Private Sub NapCmbMaKH() Dim SQL As String SQL = " Select MaKH From TblDMKHVay Order by MaKH" RsMaKH.Open SQL, Conn CmbMaKH.Clear Do While Not RsMaKH.EOF CmbMaKH.AddItem RsMaKH!MaKH RsMaKH.MoveNext Loop RsMaKH.Close End Sub Private Sub NapCmbHTVT() Dim SQL As String SQL = " Select LoaiHTVT From TblLoaiLSVay Order by LoaiHTVT" RsHTVT.Open SQL, Conn CmbHTVT.Clear Do While Not RsHTVT.EOF CmbHTVT.AddItem RsHTVT!LoaiHTVT RsHTVT.MoveNext Loop RsHTVT.Close End Sub Private Sub NapCmbMaNV() Dim SQL As String SQL = " Select MaNV From TblDMNV Order by MaNV" RsMaNV.Open SQL, Conn CmbMaNV.Clear Do While Not RsMaNV.EOF CmbMaNV.AddItem RsMaNV!MaNV RsMaNV.MoveNext Loop RsMaNV.Close End Sub Private Sub NapCmbMaKHCT() Dim SQL As String SQL = " Select MaKH From TblDMKHVay Order by MaKH" RsMaKHCT.Open SQL, Conn CmbMaKHCT.Clear Do While Not RsMaKHCT.EOF CmbMaKHCT.AddItem RsMaKHCT!MaKH RsMaKHCT.MoveNext Loop RsMaKHCT.Close End Sub Private Sub NapCmbTongCong() Dim SQL As String SQL = " Select MaKH From TblDMKHVay Order by MaKH" RsTongCong.Open SQL, Conn CmbTongCong.Clear Do While Not RsTongCong.EOF CmbTongCong.AddItem RsTongCong!MaKH RsTongCong.MoveNext Loop RsTongCong.Close End Sub Private Sub optdgt_Click(Index As Integer) optdgt(1).Value = True Optdrt(0).Value = False OptDTH(1).Value = False 'Cmdclick.Enabled = False 'CmdTienGocLS.Enabled = False TxttrangthaiVT.Text = "DangVay" End Sub Private Sub Optdrt_Click(Index As Integer) optdgt(1).Value = False Optdrt(0).Value = True OptDTH(1).Value = False 'Cmdclick.Enabled = False 'CmdTienGocLS.Enabled = False TxttrangthaiVT.Text = "DaTraLS" End Sub Private Sub OptDTH_Click(Index As Integer) optdgt(1).Value = False Optdrt(0).Value = False OptDTH(1).Value = True 'Cmdclick.Enabled = False 'CmdTienGocLS.Enabled = False TxttrangthaiVT.Text = "DaTraHet" End Sub Private Sub txtFind_Change() If CmbField.Text = "" Or txtFind = "" Then AdoKHVayTienCT.Recordset.Filter = "" AdoKHVayTienCT.Refresh Exit Sub End If AdoKHVayTienCT.Recordset.Filter = CmbField & " LIKE '*" & txtFind & "*'" End Sub Private Sub TxtTimKiem_Change() If CmbTimKH.Text = "" Or TxtTimKiem = "" Then AdoKHVayTien.Recordset.Filter = "" AdoKHVayTien.Refresh Exit Sub End If AdoKHVayTien.Recordset.Filter = CmbTimKH & " LIKE '*" & TxtTimKiem & "*'" End Sub Form Báo cáo trạng thái gửi tiền của khách hàng Dim RsMaKH As New ADODB.Recordset Private Sub CmbMaKH_Click() Set Conn = New ADODB.Connection Set NapTuDong = New ADODB.Recordset Dim Str As String Str = "SELECT * FROM TblDMKH WHERE TblDMKH.MaKH='" & CmbMaKH.Text & "'" Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanLyNH.mdb;Persist Security Info=False" Conn.Open NapTuDong.Open Str, Conn TxtTenKH.Text = NapTuDong!TenKH NapTuDong.Close End Sub Private Sub CmdRutLS_Click() DataEnvironment3.rsCommand1.Open"SELECT TblKHGuiTienCT.SoGui, TblKHGuiTien.NgayBDGui,TblKHGuiTienCT.NgayRutLS, TblKHGuiTienCT.TenKH,TblKHGuiTienCT.HinhThucGT, TblKHGuiTienCT.SoTienGui, TblKHGuiTienCT.SoTienLS, TblKHGuiTienCT.SoTienLinhHet,TblKHGuiTienCT.TrangThaiGT FROM TblKHGuiTienCT INNER JOIN TblKHGuiTien ON TblKHGuiTienCT.SoGui = TblKHGuiTien.SoGui WHERE (((TblKHGuiTienCT.TenKH) = '" & TxtTenKH & " ') AND((TblKHGuiTienCT.TrangThaiGT) = '" & TxttrangthaiGT & " '));" If DataEnvironment3.rsCommand1.BOF = True Then MsgBox " Hello ", vbInformation Else RptBCTienLSKHGT.Show vbModal DataEnvironment3.rsCommand1.Close End If End Sub Private Sub cmdTGDLH_Click() DataEnvironment3.rsCommand1.Open "SELECT TblKHGuiTienCT.SoGui, TblKHGuiTien.NgayBDGui, TblKHGuiTienCT.NgayRutLS, TblKHGuiTienCT.TenKH,TblKHGuiTienCT.HinhThucGT, TblKHGuiTienCT.SoTienGui, TblKHGuiTienCT.SoTienLS, TblKHGuiTienCT.SoTienLinhHet,TblKHGuiTienCT.TrangThaiGT FROM TblKHGuiTienCT INNER JOIN TblKHGuiTien ON TblKHGuiTienCT.SoGui = TblKHGuiTien.SoGui WHERE (((TblKHGuiTienCT.TenKH) = '" & TxtTenKH & " ') AND((TblKHGuiTienCT.TrangThaiGT) = '" & TxttrangthaiGT & " '));" If DataEnvironment3.rsCommand1.BOF = True Then MsgBox " Hello ", vbInformation Else RptBCTienLinhHetKHGT.Show vbModal DataEnvironment3.rsCommand1.Close End If End Sub Private Sub CmdTienGui_Click() DataEnvironment3.rsCommand1.Open "SELECT TblKHGuiTienCT.SoGui, TblKHGuiTien.NgayBDGui, TblKHGuiTienCT.NgayRutLS, TblKHGuiTienCT.TenKH,TblKHGuiTienCT.HinhThucGT, TblKHGuiTienCT.SoTienGui, TblKHGuiTienCT.SoTienLS, TblKHGuiTienCT.SoTienLinhHet,TblKHGuiTienCT.TrangThaiGT FROM TblKHGuiTienCT INNER JOIN TblKHGuiTien ON TblKHGuiTienCT.SoGui = TblKHGuiTien.SoGui WHERE (((TblKHGuiTienCT.TenKH) = '" & TxtTenKH & " ') AND((TblKHGuiTienCT.TrangThaiGT) = '" & TxttrangthaiGT & " '));" If DataEnvironment3.rsCommand1.BOF = True Then MsgBox " Hello ", vbInformation Else RptBCTienGuiKHGT.Show vbModal DataEnvironment3.rsCommand1.Close End If End Sub Private Sub Command1_Click() Unload Me End Sub Private Sub Form_Load() Dim so As Integer, ngay, thang, nam thang = Month(Now()) ngay = Day(Now()) nam = Year(Now()) Me.LblThang = thang Me.LblNgay = ngay Me.LblNam = nam AdoDMKH.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" NapCmbMaKH End Sub Private Sub NapCmbMaKH() Dim SQL As String SQL = " Select MaKH From TblDMKH Order by MaKH" RsMaKH.Open SQL, Conn CmbMaKH.Clear Do While Not RsMaKH.EOF CmbMaKH.AddItem RsMaKH!MaKH RsMaKH.MoveNext Loop RsMaKH.Close End Sub Private Sub optdgt_Click(Index As Integer) optdgt(1).Value = True Optdrt(0).Value = False Optdrtgls(1).Value = False CmdTienGui.Enabled = True cmdTGDLH.Enabled = False CmdRutLS.Enabled = False TxttrangthaiGT.Text = "Dang Gui" End Sub Private Sub Optdrt_Click(Index As Integer) optdgt(1).Value = False Optdrt(0).Value = True Optdrtgls(1).Value = False CmdTienGui.Enabled = False cmdTGDLH.Enabled = False CmdRutLS.Enabled = True TxttrangthaiGT.Text = "DaRutLS" End Sub Private Sub Optdrtgls_Click(Index As Integer) optdgt(1).Value = False Optdrt(0).Value = False Optdrtgls(1).Value = True CmdTienGui.Enabled = False cmdTGDLH.Enabled = True CmdRutLS.Enabled = False TxttrangthaiGT.Text = "DaLinhHet" End Sub Form Báo cáo trạng thái vay tiền của khách hàng Dim RsMaKH As New ADODB.Recordset Private Sub CmbMaKH_Click() Set Conn = New ADODB.Connection Set NapTuDong = New ADODB.Recordset Dim Str As String Str = "SELECT * FROM TblDMKHVay WHERE TblDMKHVay.MaKH='" & CmbMaKH.Text & "'" Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanLyNH.mdb;Persist Security Info=False" Conn.Open NapTuDong.Open Str, Conn TxtTenKH.Text = NapTuDong!TenKH NapTuDong.Close End Sub Private Sub CmdTienVay_Click() DataEnvironment4.rsCommand1.Open "SELECT TblKHVayTienCT.SoVay, TblKHVayTien.NgayBDVay, TblKHVayTienCT.NgayTraTV, TblKHVayTienCT.MaKH, TblKHVayTienCT.TenKH, TblKHVayTienCT.HinhThucVT, TblKHVayTienCT.SoTienVay, TblKHVayTienCT.SoTienLS, TblKHVayTienCT.SoTienTraHet, TblKHVayTienCT.TrangThaiVT FROM TblKHVayTien INNER JOIN TblKHVayTienCT ON TblKHVayTien.SoVay = TblKHVayTienCT.SoVay WHERE (((TblKHVayTienCT.MaKH)='" & CmbMaKH & " ') AND ((TblKHVayTienCT.TrangThaiVT)='" & TxttrangthaiVT & "'));" If DataEnvironment4.rsCommand1.BOF = True Then MsgBox " Hello ", vbInformation Else RptBCTienVayKHVT.Show vbModal DataEnvironment4.rsCommand1.Close End If End Sub Private Sub CmdTraLS_Click() DataEnvironment4.rsCommand1.Open "SELECT TblKHVayTienCT.SoVay, TblKHVayTien.NgayBDVay, TblKHVayTienCT.NgayTraTV, TblKHVayTienCT.MaKH, TblKHVayTienCT.TenKH, TblKHVayTienCT.HinhThucVT, TblKHVayTienCT.SoTienVay, TblKHVayTienCT.SoTienLS, TblKHVayTienCT.SoTienTraHet, TblKHVayTienCT.TrangThaiVT FROM TblKHVayTien INNER JOIN TblKHVayTienCT ON TblKHVayTien.SoVay = TblKHVayTienCT.SoVay WHERE (((TblKHVayTienCT.MaKH)='" & CmbMaKH & " ') AND ((TblKHVayTienCT.TrangThaiVT)='" & TxttrangthaiVT & "'));" If DataEnvironment4.rsCommand1.BOF = True Then MsgBox " Hello ", vbInformation Else RptBCTienLSKHVT.Show vbModal DataEnvironment4.rsCommand1.Close End If End Sub Private Sub cmdTTraHet_Click() DataEnvironment4.rsCommand1.Open "SELECT TblKHVayTienCT.SoVay, TblKHVayTien.NgayBDVay, TblKHVayTienCT.NgayTraTV, TblKHVayTienCT.MaKH, TblKHVayTienCT.TenKH, TblKHVayTienCT.HinhThucVT, TblKHVayTienCT.SoTienVay, TblKHVayTienCT.SoTienLS, TblKHVayTienCT.SoTienTraHet, TblKHVayTienCT.TrangThaiVT FROM TblKHVayTien INNER JOIN TblKHVayTienCT ON TblKHVayTien.SoVay = TblKHVayTienCT.SoVay WHERE (((TblKHVayTienCT.MaKH)='" & CmbMaKH & " ') AND ((TblKHVayTienCT.TrangThaiVT)='" & TxttrangthaiVT & "'));" If DataEnvironment4.rsCommand1.BOF = True Then MsgBox " Hello ", vbInformation Else RptBCTienTraHetKHVT.Show vbModal DataEnvironment4.rsCommand1.Close End If End Sub Private Sub Form_Load() Dim so As Integer, ngay, thang, nam thang = Month(Now()) ngay = Day(Now()) nam = Year(Now()) Me.LblThang = thang Me.LblNgay = ngay Me.LblNam = nam AdoDMKHVay.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\QuanlyNH.mdb;Persist Security Info=False" NapCmbMaKH End Sub Private Sub NapCmbMaKH() Dim SQL As String SQL = " Select MaKH From TblDMKHVAY Order by MaKH" RsMaKH.Open SQL, Conn CmbMaKH.Clear Do While Not RsMaKH.EOF CmbMaKH.AddItem RsMaKH!MaKH RsMaKH.MoveNext Loop RsMaKH.Close End Sub Private Sub optdgt_Click(Index As Integer) optdgt(1).Value = True Optdrt(0).Value = False OptDTH(1).Value = False CmdTienVay.Enabled = True CmdTraLS.Enabled = False cmdTTraHet.Enabled = False TxttrangthaiVT.Text = "DangVay" End Sub Private Sub Optdrt_Click(Index As Integer) optdgt(1).Value = False Optdrt(0).Value = True OptDTH(1).Value = False CmdTienVay.Enabled = False CmdTraLS.Enabled = True cmdTTraHet.Enabled = False TxttrangthaiVT.Text = "DaTraLS" End Sub Private Sub OptDTH_Click(Index As Integer) optdgt(1).Value = False Optdrt(0).Value = False OptDTH(1).Value = True CmdTienVay.Enabled = False CmdTraLS.Enabled = False cmdTTraHet.Enabled = True TxttrangthaiVT.Text = "DaTraHet" End Sub

Các file đính kèm theo tài liệu này:

  • doc33029.doc
Tài liệu liên quan