Frmhocsinhmang
Imports BUSPublic Class frmHocSinh Dim bHocSinh As New BusHocSinh Dim dtHocSinh As New DataTable Dim mHocSinh(5) As Object Private Sub ChiTietHocSinh() mHocSinh(0) = txtMaHS.Text mHocSinh(1) = txtHoHS.Text mHocSinh(2) = txtTenHS.Text mHocSinh(3) = dtpNgaySinh.Value mHocSinh(4) = txtDienThoai.Text mHocSinh(5) = txtDiaChi.Text End Sub 'Xử lý các sự kiện người dùng tác động vào điều khiển trên form. Private Sub cmdThem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdThem.Click txtMaHS.Focus() For Each Ctr As Control In Me.gbThongTin.Controls If (TypeOf Ctr Is TextBox) Then Ctr.Text = "" End If Next End Sub Private Sub cmdLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLuu.Click Dim kt As String = "" 'kiểm tra lưu thành công hay không 'Kiểm tra rỗng For Each Ctr As Control In Me.gbThongTin.Controls If (TypeOf Ctr Is TextBox) And Ctr.Text = "" Then MsgBox("Bạn phải nhập dữ liệu") Exit Sub End If Next ChiTietHocSinh() kt = bHocSinh.Them(mHocSinh) If kt <> "" Then MsgBox(kt) 'Không lưu được thì thông báo End If End Sub Private Sub frmHocSinh_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End SubEnd Class
Bạn đang đọc truyện trên: TruyenHHH.com