Thuât toán lập báo cáo:

Một phần của tài liệu Phần mềm Quản lí Khách hàng Thư viện . (Trang 58 - 90)

V: một số thuật toán của chơng trình:

3:Thuât toán lập báo cáo:

Có Có Không In báo cáo? Bắt đầu

Mở form lọc báo cáo

Tổng hợp số liệu Chọn tiêu thức cần báo cáo Tiếp không? Hiện ra màn hình thông tin cần báo cáo

VI.Một số form chính của chơng trình:

3: Form Nhập Phiếu yêu cầu:

5. Form Nhập tài liệu:

thực sự bổ ích cho bản thân. Tuy hiện nay kiến thức và kinh nghiệm còn hạn chế nhng em tin rằng qua quá trình thực tập và trong tơng lai em sẽ học hỏi và nâng cao kiến thức của mình nhằm có thể đáp ứng đợc yêu cầu thực sự cho công việc sau này. Bớc đầu là giai đoạn thực tập thực tế đầu tiên em đã đợc phép cùng các anh, các cô, các chú trong Trung tâm thực hiện nghiên cứu đề tài “Quản lý Khách hàng Th viện” là một may mắn cũng nh thách thức đầu tiên đối với bản thân em, cùng với sự giúp đỡ của cán bộ Trung tâm và nỗ lực của bản thân, em hy vọng rằng sẽ có một kết quả tốt trong kỳ thực tập thực tế này.

Với việc chọn xây dựng một modul nhỏ trong Trung tâm em hy vọng em sẽ tìm hiểu đợc sâu và kỹ hơn một hệ thống để phát triển.

Mặc dù đây là chơng trình nhỏ nhng cũng là sản phẩm nghiên cứu thực tế tại cơ sở, vì vậy nó có tính thực tiễn rất cao, em mong rằng nếu nh đợc phép, em sẽ hoàn thiện chơng trình để có thể đem vào ứng dụng trong công việc tại Th viện Trung tâm.

Trên đây là toàn chơng trình “Quản lý Khách hàng Th viện” tại Th viện Trung tâm Thông tin. Chơng trình đợc viêt bởi ngôn ngữ Visual Basic hỗ trợ việc quản lý khách hàng. Chơng trình này chủ yếu hoạt động chủ yếu dựa vào các giao tiếp giữa ngời sử dụng và máy tính ,vì vậy tác giả đã cố gắng đa ra một hệ thống giao diện cho chơng trình một cách gần gũi ,thân thiện với ngời sử dụng , hệ thống thông báo dễ hiểu dễ thực hiện

Chơng trình bớc đầu đã cho những kết quả tốt , thực hiện đúng theo các yêu cầucác nhiệm vụ chức năng đã đa ra.Tuy nhiên cũng nh bất kỳ một sản phẩm phần mềm nào khác chơng trình cần đợc bổ sung hoàn thiện không ngừng để phù hợp ,đáp ứng các yêu cầu mới về quản lý thông tin của ngời sử dụng.Các chức năng cần đợc cải tiến để thực hiện các yêu cầu nhanh chóng , hiệu quả hơn.

Chơng trình trên đây chắc chắn sẽ còn có rất nhiều các khiếm khuyết nhật định, tác giả sẽ cố gắng học hỏi , để luôn cải tiến hoàn thiện chơng trình đáp ứng các yêu cầu của ngời sử dụng trong những phiên bản mới nhất.

Phụ lục

Một số mã nguồn của chơng trình: Form Đăng nhập hệ thống:

Dim rs As New ADODB.Recordset Dim str, i

If txtuser.Text = "" Or txtpass.Text = "" Then

MsgBox "Bạn nên nhập đầy đủ tên và mật mã !!", vbOKOnly + vbInformation, "Thông báo"

txtuser.SetFocus Exit Sub

Else

If txtuser.Text = "Bùi gia Khơng" And txtpass.Text = "KhơngTB" Then frmchinh.Show

Unload Me Else

MsgBox "Ngời sử dụng không hợp lệ", vbOKOnly + vbQuestion, "Thông báo" Exit Sub

End If End If End Sub

Private Sub cmdthoat_Click() Unload Me

End Sub

Private Sub txtpass_GotFocus() txtpass.BackColor = &HC0E0FF End Sub

Private Sub txtpass_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

cmdconnect.SetFocus End Select

End Sub (adsbygoogle = window.adsbygoogle || []).push({});

Private Sub txtpass_LostFocus() txtpass.BackColor = &HFFFFFF End Sub

Private Sub txtuser_GotFocus() txtuser.BackColor = &HC0E0FF End Sub

Private Sub txtuser_KeyPress(KeyAscii As Integer) Select Case KeyAscii

End Select End Sub

Private Sub txtuser_LostFocus() txtuser.BackColor = &HFFFFFF

End Sub

2: Form Phiếu yêu cầu:

Private Sub MSFlexGrid1_Click() End Sub Option Explicit Dim c Dim CurrentRow Dim OldCol Dim oldrow

Dim cl, rw ' Bien chi cot va hang cua o se nhan du lieu tu Textbox Tex trong luoi Dim flag As String

Dim i, j

Private Sub Form_Load() open_mdb

grdchi_tiet_Init 'Khoi tao luoi va gan gia tri ban dau 'grdCHI_TIET2_Init

'grdCHI_TIET3_Init Lock_Text

Text.Visible = False 'An textbox nhap du lieu currentCol = 1

CurrentRow = 1 End Sub

'Private Sub Form_Activate() 'Display

'End Sub

Private Sub cmdNew_click() Un_Lock_Text

SET_NULL End Sub

Private Sub cmdUpdate_click() flag = "update"

Sua_Du_Lieu End Sub

Private Sub cmdSave_click()

If flag <> "update" Then 'neu form dang o che do them moi thi dat bien co ve che do luu flag = "save"

End If

Luu_Du_Lieu End Sub

Private Sub cmdSkip_click() SET_NULL

Lock_Text

cmdNew.SetFocus End Sub

Private Sub cmdClose_click() Unload Me

End Sub (adsbygoogle = window.adsbygoogle || []).push({});

Private Sub Sua_Du_Lieu() Un_Lock_Text

txtSop.Enabled = False txtNgay.SetFocus End Sub

Private Sub Xoa_Du_Lieu() Dim str Dim reponse Me.MousePointer = 11 If Trim(txtSP) = "" Then Me.MousePointer = 0 Exit Sub End If

MsgBox "Bạn có chắc chắn xoá phiếu này không?", vbYesNo + vbQuestion, "Thông báo"

If response = vbNo Then Exit Sub

Else

str = "delete from Phieu where So_Phieu = '" & Trim(txtSop) & "'" cn.Execute (str) End If SET_NULL Lock_Text Me.MousePointer = 0 End Sub

Private Sub Luu_Du_Lieu()

Dim rs As New ADODB.Recordset Dim rs1 As New ADODB.Recordset Dim str, lct

'MsgBox "Chú ý: Phải nhập số phiếu, ngày và Mã khách hàn trớc khi lu", vbOKOnly + vbExclamation, "Thông báo"

'Me.MousePointer = 0 'Exit Sub

'End If

' Tim co so phieu muon luu co trong table hay khong

str = "select * from Phieu where So_Phieu='" & Trim(txtSop) & "'" rs.Open str, adOpenKeyset, adLockOptimistic, adCmdText

If rs.EOF = True Then rs.AddNew rs!So_Phieu = txtSop rs!Ngay = txtNgay rs!Thang = txtThang rs!Nam = txtNam rs.Update rs.Close rs.Close Else

If flag = "save" Then

MsgBox "Số phiếu có mã [" & txtSop & "] đã tồn tại. Vui lòng kiểm tra lại", vbOKOnly + vbExclamation, "Thông báo"

Me.MousePointer = 0

str = "select * from KH where So_Phieu='" & Trim(txtSop) & "'" rs1.Open str, adOpenKeyset, adLockOptimistic, adCmdText If rs.EOF = True Then

rs1.AddNew rs1!So_Phieu = txtSop rs1!Ma_KH = txtMakh rs1!Tenkh = txtTenkh rs1!Dia_Chi = txtDC rs1!CQ_DVCT = txtCQ rs1!Email = txtDC rs1!LV_Quan_Tam = txtLV rs1!Fax = txtFax rs1!Yeu_Cau = txtYC rs1!Tong_Tien = txtTongt rs1!CT_No = txtNo rs1!Ngay_GTL = txtNgayg rs1!Ngay_TT = txtNgaytt rs1.Update Luu_Chi_Tiet End If rs1.Close

MsgBox "Số phiếu có mã [" & txtSop & "] đã tồn tại. Vui lòng kiểm tra lại", vbOKOnly + vbExclamation, "Thông báo"

Me.MousePointer = 0 End If Exit Sub End If End If Lock_Text cmdNew.SetFocus Me.MousePointer = 0 End Sub

Private Sub Luu_Chi_Tiet() Dim str, i

For i = 1 To grdchi_tiet.Row - 1

If grdchi_tiet.TextMatrix(i, 1) <> "" Then

str = "insert into TL_CD_ROM(Ma_TL,) value('" & txtMatl & "','" & grdchi_tiet.TextMatrix(i, 1) & "')"

cn.Execute (str) End If

Next i End Sub

Private Sub grdchi_tiet_KeyPress(KeyAscii As Integer) Dim ch As String

Dim oldrow (adsbygoogle = window.adsbygoogle || []).push({});

grdchi_tiet.SetFocus Dim str1 As String Dim i, c, r

Dim flag As Boolean flag = False

c = grdchi_tiet.Col r = grdchi_tiet.Row Select Case KeyAscii Case 27 Text.Text = grdchi_tiet.Text KeyAscii = 0 Text.Visible = False grdchi_tiet.SetFocus Case 13

'Kiem tra danh muc TL c = grdchi_tiet.Col grdchi_tiet.Col = 0

If grdchi_tiet.Text <> "" Then grdchi_tiet.Col = c

Text.Text = UCase(Trim(Text.Text)) ma_so = Text.Text Else grdchi_tiet.Text = UCase(Trim(grdchi_tiet.Text)) ma_so = grdchi_tiet.Text End If

str1 = "select * from TL_CD_ROM where Ma_TL='" & ma_so & "'" sr1.Open str1, cn

If sr1.EOF = True Then frmChontl.Show 1 If sosanh = True Then If ma_so <> "@" Then Text.Text = ma_so Else Text.Text = "" grdchi_tiet.Text = "" grdchi_tiet.Col = 2 grdchi_tiet.Text = "" grdchi_tiet.Col = 1 End If End If Else Dim X sr1.Close X = grdchi_tiet.Col grdchi_tiet.Col = 2 If grdchi_tiet.Text = "" Then

str1 = "select * from TL_CD_ROM where Ma_TL='" & ma_so & "'" sr1.Open str1, cn

If sr1.EOF = False Then ma_so = sr1!Ma_TL If sosanh = True Then Text.Text = ma_so grdchi_tiet.Col = 2 grdchi_tiet.Text = sr1!Ten_TL grdchi_tiet.Col = 1 End If End If End If grdchi_tiet.Col = X End If End If End If

If (Text.Text <> grdchi_tiet.Text) And (Text.Text <> "") Then grdchi_tiet.Text = Text.Text Text.Text = "" End If Else grdchi_tiet.Text = Text.Text Text.Text = "" End If Text.Visible = False grdchi_tiet.SetFocus tetx.Text = ""

If (ma_so <> "@") Then ' neu ma tl da nhap nhay sang o ke tiep MoveFirt End If grdchi_tiet.Refresh If grdchi_tiet.Text <> "" Then grdchi_tiet.Row = grdchi_tiet.Row + 1 End If MoveFirt 'Else

If (grdchi_tiet.Col = 1) Then Insert 'End If

Case Else

If grdchi_tiet.Col = 1 Then

' Nhan du lieu vao tb va hien thi no tren o tuong ung cua luoi ch = Chr$(KeyAscii) Text.SelStart = 1 Text.Visible = False Showtext End If End Select End Sub

Private Sub Text_LostFocus() currentCol = grdchi_tiet.Col curentRow = grdchi_tiet.Row grdchi_tiet.Row = oldrow grdchi_tiet.Col = oldrow

If (grdchi_tiet.Text = "") And (Text.Text <> "") Then grdchi_tiet.Text = Trim(Text.Text) End If grdchi_tiet.Col = currentCol grdchi_tiet.Row = CurrentRow Text.Text = "" Text.Visible = False End Sub

Dim c, r, i

r = grdchi_tiet.Row c = grdchi_tiet.Col Dim c1

'Vong duyet noi dung cot ma TL trong tat ca cac hang tren luoi For i = 1 To grdchi_tiet.Row - 1

grdchi_tiet.Row = i grdchi_tiet.Col = 1

c1 = Trim(grdchi_tiet.Text) If c1 = ma_so Then

MsgBox "Tài liệu này đã đợc chọn!", vbOKOnly + vbInformation, "Thông báo" ma_so = "@" grdchi_tiet.Col = c grdchi_tiet.Row = r Text.Text = "" grdchi_tiet.Col = 1 sosanh = False Exit Function End If Next i grdchi_tiet.Col = c grdchi_tiet.Row = r sosanh = True End Function

Public Sub Showtext() cl = grdchi_tiet.Col rw = grdchi_tiet.Row

Text.Top = (grdchi_tiet.RowPos(rw) + grdchi_tiet.Top) + 40

Text.Left = (grdchi_tiet.ColPos(cl) + grdchi_tiet.Left + grdchi_tiet.GridLineWidth * (grdchi_tiet.Col + 1)) + 40 Text.Width = grdchi_tiet.ColWidth(cl) - 10 Text.Height = grdchi_tiet.RowHeight(rw) - 10 Text.Visible = True Text.SetFocus End Sub

Public Sub MoveFirt() SendKeys "{left}" SendKeys "{left}" End Sub

txtSop.BackColor = &HFEF0B End Sub

Private Sub txtSop_KeyPress(KeyAscii As Integer) Select Case KeyAscii (adsbygoogle = window.adsbygoogle || []).push({});

Case 13

txtNgay.SetFocus End Select End Sub

Private Sub txtSop_Lostfocus() txtSop.BackColor = &HFFFFFF txtSop = UCase(Trim(txtSop)) End Sub

Private Sub txtNgay_Gotfocus() txtNgay.BackColor = &HFEF0B End Sub

Private Sub txtNgay_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

txtThang.SetFocus End Select

End Sub

Private Sub txtNgay_Lostfocus() txtNgay.BackColor = &HFFFFFF End Sub

Private Sub txtThang_Gotfocus() txtThang.BackColor = &HFEF0B End Sub

Private Sub txtThang_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

txtNam.SetFocus End Select End Sub

Private Sub txtThang_Lostfocus() txtThang.BackColor = &HFFFFFF End Sub

Private Sub txtNam_Gotfocus() txtNam.BackColor = &HFEF0B End Sub

Private Sub txtNam_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

txtMakh.SetFocus End Select

txtNam.BackColor = &HFFFFFF End Sub

Private Sub txtMakh_Gotfocus() txtMakh.BackColor = &HFEF0B End Sub

Private Sub txtMakh_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

txtTenkh.SetFocus End Select

End Sub

Private Sub txtMakh_Lostfocus() txtMakh.BackColor = &HFFFFFF End Sub

Private Sub txtTenkh_Gotfocus() txtTenkh.BackColor = &HFEF0B End Sub

Private Sub txtTenkh_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13 txtCQ.SetFocus End Select End Sub

Private Sub txtTenkh_Lostfocus() txtNam.BackColor = &HFFFFFF End Sub

Private Sub txtCQ_Gotfocus() txtCQ.BackColor = &HFEF0B End Sub (adsbygoogle = window.adsbygoogle || []).push({});

Private Sub txtCQ_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13 txtDC.SetFocus End Select End Sub

Private Sub txtCQ_Lostfocus() txtCQ.BackColor = &HFFFFFF End Sub

Private Sub txtDC_Gotfocus() txtDC.BackColor = &HFEF0B End Sub

Private Sub txtDC_KeyPress(KeyAscii As Integer) Select Case KeyAscii

End Sub

Private Sub txtDC_Lostfocus() txtDC.BackColor = &HFFFFFF End Sub

Private Sub txtDT_Gotfocus() txtDT.BackColor = &HFEF0B End Sub

Private Sub txtDT_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13 txtFax.SetFocus End Select End Sub

Private Sub txtDT_Lostfocus() txtDT.BackColor = &HFFFFFF End Sub

Private Sub txtFax_Gotfocus() txtFax.BackColor = &HFEF0B End Sub

Private Sub txtFax_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

txtEmail.SetFocus End Select

End Sub

Private Sub txtFax_Lostfocus() txtFax.BackColor = &HFFFFFF End Sub

Private Sub txtEmail_Gotfocus() txtEmail.BackColor = &HFEF0B End Sub

Private Sub txtEmail_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13 txtLV.SetFocus End Select End Sub

Private Sub txtEmail_Lostfocus() txtLV.BackColor = &HFFFFFF End Sub

Private Sub txtLV_Gotfocus() txtLV.BackColor = &HFEF0B End Sub

Case 13

cmbYC.SetFocus End Select End Sub

Private Sub txtLV_Lostfocus() txtLV.BackColor = &HFFFFFF End Sub

Private Sub cmbYC_Gotfocus() cmbYC.BackColor = &HFEF0B End Sub

Private Sub cmbYC_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

txtTongt.SetFocus End Select

End Sub (adsbygoogle = window.adsbygoogle || []).push({});

Private Sub cmbYC_Lostfocus() cmbYC.BackColor = &HFFFFF End Sub

Private Sub txtTongt_Gotfocus() txtTongt.BackColor = &HFEF0B End Sub

Private Sub txtTongt_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13 txtNo.SetFocus End Select End Sub

Private Sub txtTongt_Lostfocus() txtTongt.BackColor = &HFFFFFF End Sub

Private Sub txtNo_Gotfocus() txtLV.BackColor = &HFEF0B End Sub

Private Sub txtNo_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13 txtNg.SetFocus End Select End Sub

Private Sub txtNo_Lostfocus() txtNo.BackColor = &HFFFFFF End Sub

End Sub

Private Sub txtNg_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

cmbPTG.SetFocus End Select

End Sub

Private Sub txtNg_Lostfocus() txtNg.BackColor = &HFFFFFF 'If CheckDate(txtNg) = "1" Then

'Mgsbox "Chú ý:Dữ liệu kiểu ngày tháng. Vui lòng nhập lại", vbOKOnly + vbExclamation, "Thông báo"

'txtNg.SetFocus 'Exit Sub 'End If End Sub

Private Sub cmbPTG_Gotfocus() cmbPTG.BackColor = &HFEF0B End Sub

Private Sub cmbPTG_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13 txtNtt.SetFocus End Select End Sub

Private Sub cmbPTG_Lostfocus() cmbPTG.BackColor = &HFFFFF End Sub

Private Sub txtNtt_Gotfocus() txtNg.BackColor = &HFEF0B End Sub

Private Sub txtNtt_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

cmbPTTT.SetFocus End Select

End Sub

Private Sub txtNtt_Lostfocus() txtNtt.BackColor = &HFFFFFF End Sub

Private Sub cmbPTTT_Gotfocus() cmbPTTT.BackColor = &HFEF0B End Sub

Case 13 grdchi_tiet.Row = 1 grdchi_tiet.Col = 1 grdchi_tiet.SetFocus End Select End Sub

Private Sub cmbPTTT_Lostfocus() cmbPTTT.BackColor = &HFFFFF End Sub (adsbygoogle = window.adsbygoogle || []).push({});

Private Sub SET_NULL() txtSop = "" txtNgay = "" txtThang = "" txtNam = "" txtMakh = "" txtTenkh = "" txtDC = "" txtCQ_DVCT = "" txtDT = "" txtphai = "" txtNg = "__/__/____" txtNtt = "__/__/____" txtEmail = "" txtFax = "" txtTongt = "" txtNo = "" grdchi_tiet_clear End Sub

Private Sub Lock_Text() txtSop.Enabled = True txtNgay.Enabled = False txtThang.Enabled = False txtNam.Enabled = False txtMakh.Enabled = False txtTenkh.Enabled = False txtDC.Enabled = False txtLV.Enabled = False txtCQ.Enabled = False txtEmail.Enabled = False txtFax.Enabled = False cmbYC.Enabled = False txtTongt.Enabled = False txtNo.Enabled = False txtNg.Enabled = False

cmbPTTT.Enabled = False grdchi_tiet.Enabled = False cmdSave.Enabled = False cmdSkip.Enabled = False cmdClose.Enabled = False cmdDel.Enabled = True cmdUpdate.Enabled = True cmdNew.Enabled = True flag = "" End Sub

Private Sub Un_Lock_Text() txtSop.Enabled = True txtNgay.Enabled = True txtThang.Enabled = True txtNam.Enabled = True txtMakh.Enabled = True txtTenkh.Enabled = True txtDC.Enabled = True txtLV.Enabled = True txtDT.Enabled = True txtEmail.Enabled = True txtFax.Enabled = True txtTongt.Enabled = True txtNo.Enabled = True txtNg.Enabled = True txtNtt.Enabled = True txtCQ.Enabled = True cmbYC.Enabled = True cmbPTG.Enabled = True cmbPTTT.Enabled = True grdchi_tiet.Enabled = True txtSop.SetFocus cmdSave.Enabled = True cmdSkip.Enabled = True cmdNew.Enabled = False cmdUpdate.Enabled = False cmdDel.Enabled = False End Sub

'Private Sub Display()

'Dim rs As ADODB.Recordset 'Dim rs1 As ADODB.Recordset 'Dim rs2 As ADODB.Recordset 'Dim rs3 As ADODB.Recordset 'Dim str, i

'str = "select * from KH where So_Phieu='1'" 'rs.Open str, cn

'If rs.EOF = False Then ' txtMakh = rs!Ma_KH ' txtTenkh = rs!Ten_KH ' txtDC = rs!Dia_Chi ' txtCQ = rs!CQ_DVCT ' txtEmail = rs!Email ' txtFax = rs!Fax ' txtDT = rs!DT ' txtTongt = rs!Tong_Tien ' txtNo = rs!CT_No ' cmbYC = rs!Yeu_Cau ' txtNg = rs!Ng ' txtNtt = rs!Ntt ' txtNgay = rs!Ngay ' cmbPTG = rs!Gui 'cmbPTTT = rs!TT

'str = "select * from Phieu where Sop='" & Phieuhh & "'" 'rs1.Open str, cn

'If rs1.EOF = False Then ' txtSop = rs1!So_Phieu ' txtNgay = rs1!Ngay ' txtThang = rs1!Thang ' txtNam = rs1!Nam 'i = 0

' While Not rs1.EOF ' i = i + 1 ' If i >= grdchi_tiet.Row - 1 Then ' grdchi_tiet.Row = grdchi_tiet.Row + 1 ' grdchi_tiet.TextMatrix(i, 0) = i ' End If ' grdchi_tiet.TextMatrix(i, 1) = rs1!Ma_TL

' str = " select Ten_TL from TL_CD_ROM where Ma_TL = '" & rs1!Ma_TL & "'" ' rs2.Open str, cn

' If rs2.EOF = False Then

' grdchi_tiet.TextMatrix(i, 2) = rs2!Ten_TL ' End If ' rs2.Close ' rs1.MoveNext ' Wend ' End If ' End If 'Phieuhh = "1"

Dim i, j For i = 1 To grdchi_tiet.Row - 1 For j = 1 To grdchi_tiet.Cols - 1 grdchi_tiet.TextMatrix(i, j) = "" Next j Next i End Sub

Private Sub Insert() Dim c, r

c = grdchi_tiet.Col r = grdchi_tiet.Row

If grdchi_tiet.Row >= grdchi_tiet.Rows - 1 Then grdchi_tiet.Rows = grdchi_tiet.Rows + 1 grdchi_tiet.Row = grdchi_tiet.Rows - 1 grdchi_tiet.Col = 0 grdchi_tiet.Text = Format$(grdchi_tiet.Rows - 1) End If grdchi_tiet.Col = c grdchi_tiet.Row = r grdchi_tiet.SetFocus End Sub

Private Sub grdchi_tiet_Init() Dim i grdchi_tiet.Cols = 3 grdchi_tiet.Rows = 20 grdchi_tiet.Font.Name = ".VnTime" grdchi_tiet.FontSize = 10 grdchi_tiet.Row = 0 '1 Cot hien thi grdchi_tiet.Col = 0 grdchi_tiet.ColWidth(0) = 700 grdchi_tiet.CellAlignment = 4 grdchi_tiet.ColAlignment(0) = 4 grdchi_tiet.Text = "STT" ' 2 grdchi_tiet.Col = 1 grdchi_tiet.ColWidth(1) = 1200 grdchi_tiet.CellAlignment = 4 grdchi_tiet.ColAlignment(1) = 4 grdchi_tiet.Text = "Mã TL" '3 grdchi_tiet.Col = 2 grdchi_tiet.ColWidth(2) = 3000 grdchi_tiet.CellAlignment = 4

grdchi_tiet.Text = " Tên tài liệu" ' danh so cho STT Dim STT grdchi_tiet.Col = 0 For STT = 1 To grdchi_tiet.Rows - 1 grdchi_tiet.Row = STT grdchi_tiet.Text = STT Next STT End Sub

3: Form Nhập tài liệu: Option Explicit

Private flag As String

Private Sub cmdClose_click() Unload Me

End Sub

Private Sub cmdDel_click() Xoa_Du_Lieu

End Sub

Private Sub cmdNew_click() Un_Lock_Text

SET_NULL End Sub

Private Sub cmdSave_click() If flag <> "update" Then flag = "save"

End If (adsbygoogle = window.adsbygoogle || []).push({});

Luu_Du_Lieu End Sub

Private Sub cmdSkip_click() SET_NULL

Lock_Text End Sub

Private Sub cmdUpdate_click() flag = "update"

Private Sub Form_Load() open_mdb

Lock_Text Display_Listview End Sub

Private Sub Lvltem_ItemClick(ByVal Item As MSComctlLib.ListItem) txtMatl = Item.Text

txtTentl = Item.SubItems(1) End Sub

Private Sub txtMatl_GotFocus() txtMatl.BackColor = &HFEF0B End Sub

Private Sub txtMatl_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

txtTentl.SetFocus End Select End Sub

Private Sub txtMatl_LostFocus() txtMatl.BackColor = 12640511 txtMatl = Trim(txtMatl)

End Sub

Private Sub txtTentl_GotFocus() txtTentl.BackColor = &HFEF0B '12640511

End Sub

Private Sub txtTentl_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

txtSot.SetFocus End Select End Sub

Private Sub txtTentl_LostFocus() txtTentl.BackColor = 12640511

End Sub

Private Sub txtSot_GotFocus() txtSot.BackColor = &HFEF0B End Sub

Private Sub txtSot_KeyPress(KeyAscii As Integer) Select Case KeyAscii

Case 13

cmdSave.SetFocus End Select

End Sub

Private Sub txtSot_LostFocus() txtSot.BackColor = 12640511 End Sub

Private Sub Xoa_Du_Lieu() Dim str

Dim response

If Trim(txtMatl) = "" Then Exit Sub (adsbygoogle = window.adsbygoogle || []).push({});

End If

If MsgBox("Bạn có chắc chắn xoá phòng ban này không?", vbYesNo + vbQuestion, "Thông báo") = vbNo Then

Exit Sub Else

str = "delete from TL_CD_ROM where Ma_TL='" & Trim(txtMatl) & "'" cn.Execute (str) End If SET_NULL Lock_Text Display_Listview End Sub

Private Sub Luu_Du_Lieu()

Dim rs As New ADODB.Recordset Dim str

If Trim(txtMatl) = "" Or Trim(txtTentl) = "" Then

Một phần của tài liệu Phần mềm Quản lí Khách hàng Thư viện . (Trang 58 - 90)