private void btSua_Click(object sender, EventArgs e) { HocSinh hs = new HocSinh(); hs.MaHocSinh = Convert.ToInt32(tbMaHs.Text); HocSinhDAL hsDAL = new HocSinhDAL(); if (tbMaHs.Text != hs.MaHocSinh.ToString()) { MessageBox.Show("Khong duoc sua ma hoc sinh", " loi "); } else { if (tbHoTen.TextLength == 0) { MessageBox.Show("Chua nhap ho ten hoc sinh", " loi "); } else { hs.HoTen = tbHoTen.Text; if (rbNam.Checked == false && rbNu.Checked == false) { MessageBox.Show("Chua chon gioi tinh", " loi "); } else { if (rbNam.Checked == true) { hs.GioiTinh = "Nam"; } else if (rbNu.Checked == true) { hs.GioiTinh = "Nữ"; } if (tbNgaySinh.Text == "dd-mm-yyyy" || tbNgaySinh.TextLength == 0) { MessageBox.Show("Chua nhap ngay sinh", " loi "); } else { hs.NgaySinh = Convert.ToDateTime(tbNgaySinh.Text); if (tbNoiSinh.TextLength == 0) { MessageBox.Show("Chua nhap noi sinh ", " loi "); } else { hs.NoiSinh = tbNoiSinh.Text; if (tbDanToc.TextLength == 0) { MessageBox.Show("Chua nhap dan toc", " loi "); } else { hs.DanToc = tbDanToc.Text; if (tbTonGiao.TextLength == 0) { MessageBox.Show("Chua nhap ton giao", " loi "); } else { hs.TonGiao = tbTonGiao.Text; hsDAL.SuaHocSinh(hs); dgvHocSinh.DataSource = hsDAL.LoadDS(); } } } } } } } }