private void btnCapNhat_Click(object sender, EventArgs e) { if (ctrl.KiemTra(txtMa, txtTen)) { btnThem.Enabled = true; btnXoa.Enabled = true; btnSua.Enabled = true; btnCapNhat.Enabled = false; btnBoQua.Visible = false; dataDSQuocTich.Enabled = false; QuocTichInfo qt = new QuocTichInfo(); qt.MaQuocTich = Convert.ToInt32(txtMa.Text); qt.TenQuocTich = txtTen.Text; if (Updating) { ctrl.Sua(qt); } else if (Adding) { ctrl.Them(qt); } ctrl.LayDSQuocTich(dataDSQuocTich); txtMa.Enabled = false; txtTen.Enabled = false; } }
private void btnThem_Click(object sender, EventArgs e) { //Kiem Tra tai day if (SVCtrl.KiemTra(txtHoTen, dateNgaySinh, txtDiaChi, txtMSSV, txtCMND, txtDienThoai, cmbQuocTich, cmbDanToc, cmbTonGiao)) { SinhVienInfo SV = new SinhVienInfo(); SV.CamTinhDang = chkCamTinhDang.Checked; SV.SoCMDN = txtCMND.Text; SV.DangVien = chkDangVien.Checked; DanTocInfo dantoc = new DanTocInfo(); dantoc.MaDanToc = (int)cmbDanToc.SelectedValue; dantoc.TenDanToc = cmbDanToc.Text; SV.DanToc = dantoc; SV.DiaChi = txtDiaChi.Text; SV.DienThoai = txtDienThoai.Text; SV.DoanVien = chkDoanVien.Checked; SV.GioiTinh = chkGioiTinh.Checked; SV.HoTen = txtHoTen.Text; SV.MaKTX = txtMaKTX.Text; SV.MSSV = txtMSSV.Text; SV.Namsinh = dateNgaySinh.Value; QuocTichInfo quoctich = new QuocTichInfo(); quoctich.MaQuocTich = (int)cmbQuocTich.SelectedValue; quoctich.TenQuocTich = cmbQuocTich.Text; SV.QuocTich = quoctich; TonGiaoInfo tongiao = new TonGiaoInfo(); tongiao.MaTonGiao = (int)cmbTonGiao.SelectedValue; tongiao.TenTonGiao = cmbTonGiao.Text; SV.TonGiao = tongiao; if (picHinh.ImageLocation == null) { SV.HinhAnh = ""; } else { SV.HinhAnh = picHinh.ImageLocation.ToString(); } IEnumerator ds = listDSThanNhan.Items.GetEnumerator(); while (ds.MoveNext()) { ListViewItem item = (ListViewItem)ds.Current; ThanNhanInfo tn = (ThanNhanInfo)item.Tag;// (ThanhNhanInfo)item.Tag; tn.SinhVien = SV; SV.DSThanNhan.Add(tn); } ListViewItem row = new ListViewItem(); row.Text = SV.HoTen; row.SubItems.Add(SV.GioiTinh == true?"Nam":"Nữ"); row.Tag = SV; listSinhVien.Items.Add(row); //Xoa Du Lieu tren Form txtCMND.Text = ""; txtDiaChi.Text = ""; txtDienThoai.Text = ""; txtHoTen.Text = ""; txtHoTen.Text = ""; txtMaKTX.Text = ""; txtMSSV.Text = ""; chkCamTinhDang.Checked = false; chkDangVien.Checked = false; chkDoanVien.Checked = false; chkGioiTinh.Checked = false; listDSThanNhan.Items.Clear();//Xóa ListView DS Thân nhân ///Lay MSSV tu dong txtMaKTX.Text = SVCtrl.LayMaKTXTuDanhSach(listSinhVien); picHinh.Image = null; } }