Private Sub cmd_SuaCSDL_Click()
Dim curr_row As Long
If ListBox_CSDL.ListIndex = -1 Then Exit Sub
If Not ((txt_ID.Text <> "") And (txt_Name.Text <> "") And IsDate(txt_Date.Text) And (txt_Content.Text <> "") And (txt_HD.Text <> "") And IsNumeric(txt_Quantity.Value)) Then
MsgBox "Check Data Again! Please"
Exit Sub
End If
curr_row = ListBox_CSDL.ListIndex + 3
With Sheet1
.Range("B" & curr_row) = txt_ID.Text
.Range("C" & curr_row) = txt_Name.Text
.Range("D" & curr_row) = CDate(txt_Date.Text)
.Range("E" & curr_row) = txt_Content.Text
.Range("F" & curr_row) = txt_HD.Text
If Option_Import.Value Then
.Range("G" & curr_row) = txt_Quantity.Text
Else
.Range("H" & curr_row) = txt_Quantity.Text
End If
With ListBox_CSDL
.List(.ListIndex, 0) = txt_ID.Value
.List(.ListIndex, 1) = txt_Name.Value
.List(.ListIndex, 2) = txt_Date.Value
.List(.ListIndex, 3) = txt_Content.Value
.List(.ListIndex, 4) = txt_HD.Value
.List(.ListIndex, 5) = .Range("G" & curr_row)
.List(.ListIndex, 6) = .Range("H" & curr_row)
End With
ThisWorkbook.Save
MsgBox "Import Data Succesfull!"
If Not (Chechbox_Ngayhientai.Value Or CheckBox_ChuyenDS1.Value Or CheckBox_XuatLV.Value Or CheckBox_ChuyenNTL.Value) Then
txt_Date.Text = ""
txt_Content.Text = ""
End If
txt_ID.Text = ""
txt_Name.Text = ""
txt_HD.Text = ""
txt_Quantity.Text = ""
txt_ID.SetFocus
End With
End Sub
Private Sub ListBox_CSDL_Click()
With ListBox_CSDL
txt_ID.Value = .List(.ListIndex, 0)
txt_Name.Value = .List(.ListIndex, 1)
txt_Date.Value = .List(.ListIndex, 2)
txt_Content.Value = .List(.ListIndex, 3)
txt_HD.Value = .List(.ListIndex, 4)
End With
End Sub
Private Sub UserForm_Initialize()
Dim endR As Long
cmd_SuaCSDL.Enabled = False
cmd_XoaCSDL.Enabled = False
With ListBox_CSDL
.ColumnCount = 8
.ColumnWidths = "80,250,70,150,50,50,50,50"
' .BoundColumn = 1
' .TextColumn = 2
End With
load_listbox
End Sub