bomnhauag > 16-06-13, 10:43 AM
bomnhauag > 16-06-13, 12:35 PM
Public chonTuNgay As Date
Public chonDenNgay As Date
Public daChonNgay As Boolean
Public Function layTuNgay() As Date
layTuNgay = chonTuNgay
End Function
Public Function layDenNgay() As Date
layDenNgay = chonDenNgay
End Function
Public Function DauThang(thang As Integer, nam As Integer) As Date
DauThang = DateSerial(nam, thang, 1)
End Function
Public Function CuoiThang(ByVal thang As Integer, ByVal nam As Integer) As Date
CuoiThang = DateAdd("m", 1, DauThang(thang, nam)) - 1
End Function
Public Function Qui(thang As Integer) As Integer
Qui = Int((thang - 1) / 3) + 1
End Function
Option Compare Database
Option Explicit
Private Sub cmdHuy_Click()
daChonNgay = False
DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdOK_Click()
daChonNgay = True
DoCmd.Close acForm, Me.Name
End Sub
Public Function DoiNgay()
Dim quy As Integer, thang1 As Integer, thang2 As Integer
Select Case frCHON
Case 1
chonTuNgay = DauThang(1, cmbNam)
chonDenNgay = CuoiThang(12, cmbNam)
Case 2
quy = cmbQuy
thang1 = quy * 3 - 2
thang2 = quy * 3
chonTuNgay = DauThang(thang1, cmbNam2)
chonDenNgay = CuoiThang(thang2, cmbNam2)
Case 3
thang1 = cmbThang
chonTuNgay = DauThang(thang1, cmbNam3)
chonDenNgay = CuoiThang(thang1, cmbNam3)
Case 4
thang1 = cmbThang1
thang2 = cmbThang2
chonTuNgay = DauThang(thang1, Year(Date))
chonDenNgay = CuoiThang(thang2, Year(Date))
End Select
txtTN = chonTuNgay
txtDN = chonDenNgay
End Function
Private Function DoiKieu(CHON As Byte)
frCHON = CHON
DoiNgay
End Function
Private Sub Form_Open(Cancel As Integer)
Dim i As Integer, nam As Integer
DoCmd.Restore
chonTuNgay = DauThang(Month(Date), Year(Date))
chonDenNgay = CuoiThang(Month(Date), Year(Date))
daChonNgay = False
nam = Year(Date)
For i = nam - 5 To nam + 5
cmbNam.AddItem i
cmbNam2.AddItem i
cmbNam3.AddItem i
Next i
End Sub
bomnhauag > 16-06-13, 01:00 PM
Public Function goiChonTG() As Boolean
DoCmd.OpenForm "FChonTG", acNormal, , , , acDialog
goiChonTG = daChonNgay
End Function
Thương Bụi > 16-06-13, 06:08 PM
bomnhauag > 16-06-13, 06:24 PM
bomnhauag > 17-06-13, 05:26 PM
Option Compare Database
Option Explicit 'kiem tra chat che cac bien da khai bao chua
Public chonNVSTT As Byte
Public daChonNV As Boolean
Public idPhongChon As Long
Public tenPhongChon As String
Public tenNVChon As String
Public phaiChon As Boolean
Public Function goiChonNV() As Boolean
DoCmd.OpenForm "FChonNV", acNormal, , , , acDialog
goiChonNV = daChonNV
End Function
Public Function laySTTChon() As Byte
laySTTChon = chonNVSTT
End Function
Public Function layTenPhongChon() As String
layTenPhongChon = tenPhongChon
End Function
Option Compare Database
Option Explicit
Dim tChon As Byte
Private Sub cmbPhai_AfterUpdate()
chonNV
End Sub
Private Sub cmbPhong_AfterUpdate()
chonNV
End Sub
Private Sub cmdHuy_Click()
daChonNV = False
DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdOK_Click()
daChonNV = True
DoCmd.Close acForm, Me.Name
End Sub
Private Sub Form_Load()
daChonNV = False
tChon = 1
chonNVSTT = 1
idPhongChon = 0
tenPhongChon = ""
tenNVChon = ""
phaiChon = False
CurrentDb.Execute "Update [T0 dsNhanVien] Set ChonIn=True"
End Sub
Private Sub chonNV()
CurrentDb.Execute "Update [T0 dsNhanVien] Set ChonIn=False"
Select Case tChon
Case 1
CurrentDb.Execute "Update [T0 dsNhanVien] Set ChonIn=True"
Case 2
idPhongChon = cmbPhong
tenPhongChon = cmbPhong.Column(1)
CurrentDb.Execute "Update [T0 dsNhanVien] Set ChonIn=True WHERE MaP=" & idPhongChon
Case 3
tenNVChon = Nz(txtTenNV, "")
CurrentDb.Execute "Update [T0 dsNhanVien] Set ChonIn=True WHERE TenNV Like '*" & txtTenNV & "*'"
Case 4
phaiChon = cmbPhai
CurrentDb.Execute "Update [T0 dsNhanVien] Set ChonIn=True WHERE Phai=" & phaiChon
Case 5
End Select
chonNVSTT = frCHON.Value
fSUB.Requery
End Sub
Private Sub frCHON_AfterUpdate()
If frCHON.Value <> tChon Then
cmbPhong.Enabled = frCHON.Value = 2
txtTenNV.Enabled = frCHON.Value = 3
cmbPhai.Enabled = frCHON.Value = 4
fSUB.Enabled = frCHON.Value = 5
tChon = frCHON.Value
chonNV
End If
End Sub
Private Sub txtTenNV_AfterUpdate()
chonNV
End Sub
bomnhauag > 17-06-13, 05:37 PM
SELECT [T0 dsNhanVien].ID, [T0 dsPhong].TenPhong, [T0 dsNhanVien].MaNV, [T0 dsNhanVien].TenNV, IIf([Phai],"Nữ","Nam") AS GioiTinh, [T0 dsNhanVien].ChucVu, [T0 dsNhanVien].NS, [T0 dsNhanVien].CMND, [T0 dsNhanVien].NgayBDLV, [T0 dsNhanVien].GhiChu
FROM [T0 dsPhong] INNER JOIN [T0 dsNhanVien] ON [T0 dsPhong].ID = [T0 dsNhanVien].MaP
WHERE ((([T0 dsNhanVien].ChonIn)=True));
Private Sub cmdNV_Click()
If goiChonNV Then
DoCmd.OpenReport "RDSNV", acViewPreview
End If
End Sub
bomnhauag > 03-07-13, 08:21 PM
bomnhauag > 03-07-13, 09:16 PM
Option Compare Database
Option Explicit
Public nhomBaoCao As Byte 'nhom Bao cao nao can hien cho nguoi dung chon
Public daChonBaoCao As Boolean 'kiem tra xem nguoi ta co hon ko hay la nhan Huy
Public giaTriChon As Long 'tra ve gia tri ma nguoi ta chon
Public Function layNhomBaoCao() As Byte
layNhomBaoCao = nhomBaoCao
End Function
Public Function goiChonIN() As Boolean
daChonBaoCao = False
DoCmd.OpenForm "FChonIn", acNormal, , , , acDialog
goiChonIN = daChonBaoCao
End Function
Option Compare Database
Option Explicit
Dim viTriChonCU As Byte, viTriMoi As Byte
Private Sub cmdHuy_Click()
daChonBaoCao = False
DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdIN_Click()
If lstBC.Column(2) = 0 Then Exit Sub 'truong hop nguoi dung chon ngay caai dong toan dau --------
viTriMoi = lstBC.Column(0)
'dua vao viTriChonCU ta bo chon trong table
CurrentDb.Execute "UPDATE TChonIn SET SD=False WHERE ID=" & viTriChonCU
'dat lai vi tri su dung sau cung dua vao viTriMoi
CurrentDb.Execute "UPDATE TChonIn SET SD=True WHERE ID=" & viTriMoi
daChonBaoCao = True
giaTriChon = lstBC.Column(2)
DoCmd.Close acForm, Me.Name
End Sub
Private Sub Form_Load()
viTriMoi = Nz(DLookup("ID", "TChonIn", "Nhom=layNhomBaoCao() AND SD=True"), 1)
viTriChonCU = viTriMoi
lstBC = viTriChonCU
End Sub
Private Sub lstBC_DblClick(Cancel As Integer)
Call cmdIN_Click
End Sub
Private Sub cmdNV_Click()
nhomBaoCao = 1
If goiChonIN Then
Select Case giaTriChon
Case 1 'in report danh sach nv rut gon
If goiChonNV Then
DoCmd.OpenReport "RDSNV", acViewPreview
End If
Case 2 'goi in report danh sach nv chi tiet
Case 3 'goi in report ds nv nam
Case 4 'goi in report ds nv nu
Case 5 'goi in report ds lanh dao
Case 6 'goi in report ds phong ke toan
End Select
End If
End Sub
Private Sub cmdDT_Click()
nhomBaoCao = 2
If goiChonIN Then
Select Case giaTriChon
Case 1 'in report bao cao doanh thu thang
Case 2 'in report bao cao doanh thu ca nhan
End Select
End If
End Sub
Private Sub cmdKHO_Click()
nhomBaoCao = 3
If goiChonIN Then
Select Case giaTriChon
Case 1 'in report bao cao ton kho
Case 2 'in report bao cao han SD
End Select
End If
End Sub
bomnhauag > 05-07-13, 03:45 PM