private void btn_xoalop_Click(object sender, EventArgs e) { try { DialogResult DR = MessageBox.Show("Bạn có chắc chắn xoá lớp này!", "Thông báo", MessageBoxButtons.YesNo); if (DialogResult.Yes == DR) { QLHS_DTO hs = new QLHS_DTO(); hs.MaLop = txt_malop.Text; QLHS_BUS bus = new QLHS_BUS(); bus.XoaLop(hs); MessageBox.Show("Xoá thành công lớp " + txt_malop.Text + " !", "Thông báo"); LoadData(); txt_tenlop.DataBindings.Clear(); txt_tenlop.DataBindings.Add("Text", dtgv_themlop.DataSource, "TenLop"); txt_siso.DataBindings.Clear(); txt_siso.DataBindings.Add("Text", dtgv_themlop.DataSource, "SiSo"); txt_malop.DataBindings.Clear(); txt_malop.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaLop"); cb_Khoi_LopHoc.DataBindings.Clear(); cb_Khoi_LopHoc.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaKhoiLop"); } else { LoadData(); } } catch (Exception ex) { } }
private void btn_htcapnhat_Click(object sender, EventArgs e) { try { if ((txt_makhoilop.Text != "") && (txt_tenkhoilop.Text != "")) { QLHS_DTO hs = new QLHS_DTO(); hs.MaKhoiLop = txt_makhoilop.Text; hs.TenKhoiLop = txt_tenkhoilop.Text; QLHS_BUS bus = new QLHS_BUS(); bus.CapNhatKhoiLop(hs); MessageBox.Show("Cập nhật thành công khối lớp " + txt_makhoilop.Text + " !", "Thông báo"); LoadData(); btn_themkhoilop.Enabled = true; btn_xoakhoilop.Enabled = true; btn_capnhatkhoilop.Visible = true; btn_themlop.Enabled = true; btn_htthem.Visible = false; btn_htcapnhat.Visible = false; txt_makhoilop.Enabled = false; txt_tenkhoilop.Enabled = false; txt_makhoilop.DataBindings.Clear(); txt_makhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "MaKhoiLop"); txt_tenkhoilop.DataBindings.Clear(); txt_tenkhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "TenKhoiLop"); } else { MessageBox.Show("Cập nhật không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo"); } } catch (Exception ex) { } }
private void btn_luu_Click(object sender, EventArgs e) { try { if ((txt_mamonhoc.Text != "") && (txt_tenmonhoc.Text != "")) { QLHS_BUS bus = new QLHS_BUS(); bus.CapNhatMonHoc(txt_mamonhoc.Text, txt_tenmonhoc.Text); MessageBox.Show("Cập nhật thành công môn học " + txt_mamonhoc.Text + " !", "Thông báo"); LoadData(); btn_capnhatmon.Visible = true; btn_luu.Visible = false; txt_mamonhoc.Enabled = false; txt_tenmonhoc.Enabled = false; btn_themmon.Enabled = true; btn_xoa.Enabled = true; btn_nhapdiemmonhoc.Enabled = true; } else { MessageBox.Show("Cập nhật không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo"); } } catch (Exception ex) { } }
private void btn_luuss_Click(object sender, EventArgs e) { try { if ((txt_siso.Text != "")) { QLHS_BUS bus = new QLHS_BUS(); bus.CapNhatSiSo(Int32.Parse(txt_siso.Text)); MessageBox.Show("Cập nhật thành công sỉ số lớp", "Thông báo"); } else { MessageBox.Show("Cập nhật không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo"); } } catch (Exception ex) { MessageBox.Show("Mời nhập lại!"); } txt_diem.Enabled = false; txt_siso.Enabled = false; txt_tuoilon.Enabled = false; txt_tuoinho.Enabled = false; btn_tuoi.Enabled = true; btn_luuss.Visible = false; btn_siso.Visible = true; btn_diem.Enabled = true; txt_siso.Text = ""; }
public void LoadData() { try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.LayTatCaBangDiem(); DataTable dt_1 = bus.LayDSMonHoc(); cb_tenmh.DataSource = dt_1; cb_tenmh.DisplayMember = "TenMonHoc"; cb_tenmh.ValueMember = "TenMonHoc"; dtgv_danhsachbangdiem.DataSource = dt; if (dt.Rows.Count > 0) { dtgv_danhsachbangdiem.Rows[0].Selected = true; RowSelected = new QLHS_DTO(); RowSelected.MaBangDiem = dtgv_danhsachbangdiem.SelectedRows[0].Cells["MaBangDiem"].Value.ToString(); RowSelected.MaHocSinh = dtgv_danhsachbangdiem.SelectedRows[0].Cells["MaHocSinh"].Value.ToString(); RowSelected.MaMonHoc = dtgv_danhsachbangdiem.SelectedRows[0].Cells["MaMonHoc"].Value.ToString(); RowSelected.Diem15phut = dtgv_danhsachbangdiem.SelectedRows[0].Cells["Diem15phut"].Value.ToString(); RowSelected.Diem1tiet = dtgv_danhsachbangdiem.SelectedRows[0].Cells["Diem1tiet"].Value.ToString(); RowSelected.DiemCuoiKi = dtgv_danhsachbangdiem.SelectedRows[0].Cells["DiemCuoiKi"].Value.ToString(); } } catch (Exception ex) { } }
private void btn_XacNhan_Click(object sender, EventArgs e) { try { if (txt_mamonhoc.Text != "" && txt_tenmonhoc.Text != "") { QLHS_DTO hs = new QLHS_DTO(); hs.MaMonHoc = txt_mamonhoc.Text; hs.TenMonHoc = txt_tenmonhoc.Text; QLHS_BUS bus = new QLHS_BUS(); bus.ThemMonHoc(hs); MessageBox.Show("Thêm thành công môn học " + txt_tenmonhoc.Text + " !", "Thông báo"); LoadData(); btn_themmon.Visible = true; btn_XacNhan.Visible = false; txt_mamonhoc.Enabled = false; txt_tenmonhoc.Enabled = false; btn_capnhatmon.Enabled = true; btn_xoa.Enabled = true; btn_nhapdiemmonhoc.Enabled = true; } else { MessageBox.Show("Mời nhập đầy đủ thông tin Môn Học!"); } } catch { MessageBox.Show("Mã môn học này đã tồn tại!"); } }
public void LoadData() { try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.DSLop(); DataTable dt_1 = bus.LayKhoiLop(); dtgv_danhsachlop.DataSource = dt; cb_khoi.DataSource = dt_1; cb_khoi.DisplayMember = "MaKhoiLop"; cb_khoi.ValueMember = "MaKhoiLop"; if (dt.Rows.Count > 0) { dtgv_danhsachlop.Rows[0].Selected = true; RowSelected = new QLHS_DTO(); RowSelected.MaHocSinh = dtgv_danhsachlop.SelectedRows[0].Cells["MaHocSinh"].Value.ToString(); RowSelected.HoTen = dtgv_danhsachlop.SelectedRows[0].Cells["HoTen"].Value.ToString(); RowSelected.TenKhoiLop = dtgv_danhsachlop.SelectedRows[0].Cells["TenKhoiLop"].Value.ToString(); RowSelected.TenLop = dtgv_danhsachlop.SelectedRows[0].Cells["TenLop"].Value.ToString(); RowSelected.SiSo = dtgv_danhsachlop.SelectedRows[0].Cells["SiSo"].Value.ToString(); } } catch (Exception ex) { } }
private void btn_xoakhoilop_Click(object sender, EventArgs e) { try { DialogResult DR = MessageBox.Show("Bạn có chắc chắn xoá khối lớp này!", "Thông báo", MessageBoxButtons.YesNo); if (DialogResult.Yes == DR) { QLHS_BUS bus = new QLHS_BUS(); bus.XoaKhoiLop(txt_makhoilop.Text); MessageBox.Show("Xoá thành công khối lớp " + txt_makhoilop.Text + " !", "Thông báo"); LoadData(); txt_makhoilop.DataBindings.Clear(); txt_makhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "MaKhoiLop"); txt_tenkhoilop.DataBindings.Clear(); txt_tenkhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "TenKhoiLop"); } else { LoadData(); } } catch (Exception ex) { } }
private void btn_luu_Click(object sender, EventArgs e) { try { if ((txt_diem15phut.Text != "") && (txt_diem1tiet.Text != "") && (txt_diemck.Text != "") && (txt_mahocsinh.Text != "") && (txt_tenhs.Text != "")) { QLHS_DTO hs = new QLHS_DTO(); hs.MaHocSinh = txt_mahocsinh.Text; hs.MaMonHoc = lb_mamonhoc.Text; hs.Diem15phut = txt_diem15phut.Text; hs.Diem1tiet = txt_diem1tiet.Text; hs.DiemCuoiKi = txt_diemck.Text; QLHS_BUS bus = new QLHS_BUS(); bus.ThemBangDiem(hs); MessageBox.Show("Thêm thành công bảng điểm cho học sinh " + txt_mahocsinh.Text + " !", "Thông báo"); LoadData(); } else { MessageBox.Show("Thêm không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void LoadData() { try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.LayTatCaLop(); DataTable dt_1 = bus.LayKhoiLop(); dtgv_themlop.DataSource = dt; cb_Khoi_LopHoc.DataSource = dt_1; cb_Khoi_LopHoc.DisplayMember = "MaKhoiLop"; cb_Khoi_LopHoc.ValueMember = "MaKhoiLop "; if (dt.Rows.Count > 0) { dtgv_themlop.Rows[0].Selected = true; RowSelected = new QLHS_DTO(); RowSelected.MaLop = dtgv_themlop.SelectedRows[0].Cells["MaLop"].Value.ToString(); RowSelected.TenLop = dtgv_themlop.SelectedRows[0].Cells["TenLop"].Value.ToString(); RowSelected.SiSo = dtgv_themlop.SelectedRows[0].Cells["SiSo"].Value.ToString(); RowSelected.MaKhoiLop = dtgv_themlop.SelectedRows[0].Cells["MaKhoiLop"].Value.ToString(); } } catch (Exception ex) { } }
private void btn_htthem_Click(object sender, EventArgs e) { try { QLHS_DTO hs = new QLHS_DTO(); hs.MaKhoiLop = txt_makhoilop.Text; hs.TenKhoiLop = txt_tenkhoilop.Text; QLHS_BUS bus = new QLHS_BUS(); bus.ThemKhoiLop(hs); MessageBox.Show("Thêm thành công khối lớp " + txt_tenkhoilop.Text + " !", "Thông báo"); LoadData(); btn_themkhoilop.Visible = true; btn_capnhatkhoilop.Enabled = true; btn_xoakhoilop.Enabled = true; btn_htthem.Visible = false; btn_themlop.Enabled = true; btn_htcapnhat.Visible = false; btn_htthem.Visible = false; txt_makhoilop.Enabled = false; txt_tenkhoilop.Enabled = false; txt_makhoilop.DataBindings.Clear(); txt_makhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "MaKhoiLop"); txt_tenkhoilop.DataBindings.Clear(); txt_tenkhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "TenKhoiLop"); } catch { MessageBox.Show("Đã tồn tại mã Khối!"); } }
private void cb_khoi_SelectedIndexChanged(object sender, EventArgs e) { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.LayLopHoc(cb_khoi.Text); cb_lop.DataSource = dt; cb_lop.DisplayMember = "TenLop"; cb_lop.ValueMember = "TenLop"; }
private void cb_tenmh_SelectedIndexChanged(object sender, EventArgs e) { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.LayMaMH(cb_tenmh.Text); if (dt.Rows.Count > 0) { lb_mamonhoc.Text = dt.Rows[0]["MaMonHoc"].ToString(); } }
private void btn_themhocki_Click(object sender, EventArgs e) { QLHS_DTO hs = new QLHS_DTO(); hs.MaHocKi = txt_mahocki.Text; hs.TenHocKi = txt_tenhocki.Text; QLHS_BUS bus = new QLHS_BUS(); bus.ThemHocKi(hs); MessageBox.Show("Thêm thành công học kì " + txt_tenhocki.Text + " !", "Thông báo"); LoadData(); }
private void btn_Luu_HS_Click(object sender, EventArgs e) { try { if ((txt_hovaten.Text != "") && (dt_ngaysinh.Value.ToString() != "") && (cb_gioitinh.Text != "") && (txt_diachi.Text != "") && (txt_email.Text != "")) { QLHS_DTO hs = new QLHS_DTO(); hs.MaHocSinh = txt_mahocsinh.Text; hs.HoTen = txt_hovaten.Text; hs.NgaySinh = dt_ngaysinh.Value.ToString(); hs.GioiTinh = cb_gioitinh.Text; hs.DiaChi = txt_diachi.Text; hs.Email = txt_email.Text; QLHS_BUS bus = new QLHS_BUS(); bus.CapNhatHocSinh(hs); MessageBox.Show("Cập nhật thành công học sinh " + txt_mahocsinh.Text + " !", "Thông báo"); btn_capnhathocsinh.Visible = true; btn_ThemHS.Visible = true; btn_Luu_HS.Visible = false; txt_mahocsinh.Enabled = true; txt_mahocsinh.Enabled = false; txt_hovaten.Enabled = false; txt_email.Enabled = false; txt_diachi.Enabled = false; cb_gioitinh.Enabled = false; dt_ngaysinh.Enabled = false; LoadData(); txt_hovaten.DataBindings.Clear(); txt_hovaten.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "HoTen"); txt_mahocsinh.DataBindings.Clear(); txt_mahocsinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "MaHocSinh"); txt_email.DataBindings.Clear(); txt_email.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "Email"); txt_diachi.DataBindings.Clear(); txt_diachi.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "DiaChi"); cb_gioitinh.DataBindings.Clear(); cb_gioitinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "GioiTinh"); dt_ngaysinh.DataBindings.Clear(); dt_ngaysinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "NgaySinh"); } else { MessageBox.Show("Cập nhật không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void txt_mahocsinh_TextChanged(object sender, EventArgs e) { try { QLHS_BUS bus = new QLHS_BUS(); QLHS_DTO hs = new QLHS_DTO(); hs.MaHocSinh = txt_mahocsinh.Text; DataTable dt = bus.TIMHSBANGMA(hs.MaHocSinh); txt_tenhs.Text = dt.Rows[0]["HoTen"].ToString(); } catch (Exception ex) { txt_tenhs.Text = ""; } }
private void txt_mahocsinh_TextChanged(object sender, EventArgs e) { try { QLHS_BUS bus = new QLHS_BUS(); QLHS_DTO hs = new QLHS_DTO(); hs.MaHocSinh = txt_mahocsinh.Text; DataTable dt = bus.TIMHSBANGMA(hs.MaHocSinh); txt_tenhocsinh.Text = dt.Rows[0]["HoTen"].ToString(); dt_ngaysinh.Format = DateTimePickerFormat.Custom; dt_ngaysinh.CustomFormat = "dd/MM/yyyy"; dt_ngaysinh.Text = dt.Rows[0]["NgaySinh"].ToString(); } catch (Exception ex) { } }
private void btn_XacNhan_Click(object sender, EventArgs e) { btn_XacNhan.Visible = false; btn_them.Visible = true; try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.ThamSo(); string t = txt_siso.Text.ToString(); if ((0 < Int32.Parse(t) && Int32.Parse(t) < Int32.Parse(dt.Rows[0]["SiSo"].ToString()))) { QLHS_DTO hs = new QLHS_DTO(); hs.MaLop = txt_malop.Text; hs.TenLop = txt_tenlop.Text; hs.SiSo = txt_siso.Text; hs.MaKhoiLop = cb_Khoi_LopHoc.Text; bus.ThemLop(hs); MessageBox.Show("Thêm thành công lớp " + txt_malop.Text + " !", "Thông báo"); LoadData(); btn_capnhatlop.Enabled = true; btn_xoalop.Enabled = true; btn_xeplop.Enabled = true; txt_malop.Enabled = false; txt_siso.Enabled = false; txt_tenlop.Enabled = false; cb_Khoi_LopHoc.Enabled = false; txt_tenlop.DataBindings.Clear(); txt_tenlop.DataBindings.Add("Text", dtgv_themlop.DataSource, "TenLop"); txt_siso.DataBindings.Clear(); txt_siso.DataBindings.Add("Text", dtgv_themlop.DataSource, "SiSo"); txt_malop.DataBindings.Clear(); txt_malop.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaLop"); cb_Khoi_LopHoc.DataBindings.Clear(); cb_Khoi_LopHoc.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaKhoiLop"); } else { MessageBox.Show("Sỉ số lớp sai quy định"); } } catch { MessageBox.Show("Mời nhập lại đúng quy định!"); } }
public void LoadData() { try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.LayTatCaHocKi(); dtgv_danhsachhocki.DataSource = dt; if (dt.Rows.Count > 0) { dtgv_danhsachhocki.Rows[0].Selected = true; RowSelected = new QLHS_DTO(); RowSelected.MaHocKi = dtgv_danhsachhocki.SelectedRows[0].Cells["MaHocKi"].Value.ToString(); RowSelected.TenHocKi = dtgv_danhsachhocki.SelectedRows[0].Cells["TenHocKi"].Value.ToString(); } } catch (Exception ex) { } }
public void LoadData() { try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.LayTatCaKhoiLop(); dtgv_khoilop.DataSource = dt; if (dt.Rows.Count > 0) { dtgv_khoilop.Rows[0].Selected = true; RowSelected = new QLHS_DTO(); RowSelected.MaKhoiLop = dtgv_khoilop.SelectedRows[0].Cells["MaKhoiLop"].Value.ToString(); RowSelected.TenKhoiLop = dtgv_khoilop.SelectedRows[0].Cells["TenKhoiLop"].Value.ToString(); } } catch (Exception ex) { } }
public void LoadData() { try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.LayTatCaMonHoc(); dtgv_danhsachmonhoc.DataSource = dt; if (dt.Rows.Count > 0) { dtgv_danhsachmonhoc.Rows[0].Selected = true; RowSelected = new QLHS_DTO(); RowSelected.MaHocSinh = dtgv_danhsachmonhoc.SelectedRows[0].Cells["MaMonHoc"].Value.ToString(); RowSelected.HoTen = dtgv_danhsachmonhoc.SelectedRows[0].Cells["TenMonHoc"].Value.ToString(); } } catch (Exception ex) { } }
private void btn_Luu_Lai_Click(object sender, EventArgs e) { try { if ((txt_malop.Text != "") && (txt_tenlop.Text != "") && (txt_siso.Text != "") && (cb_Khoi_LopHoc.Text != "")) { QLHS_DTO hs = new QLHS_DTO(); hs.MaLop = txt_malop.Text; hs.TenLop = txt_tenlop.Text; hs.SiSo = txt_siso.Text; hs.MaKhoiLop = cb_Khoi_LopHoc.Text; QLHS_BUS bus = new QLHS_BUS(); bus.CapNhatLop(hs); MessageBox.Show("Cập nhật thành công lớp " + txt_malop.Text + " !", "Thông báo"); LoadData(); btn_capnhatlop.Visible = true; btn_Luu_Lai.Visible = false; btn_them.Enabled = true; btn_xoalop.Enabled = true; btn_xeplop.Enabled = true; txt_malop.Enabled = false; txt_siso.Enabled = false; txt_tenlop.Enabled = false; cb_Khoi_LopHoc.Enabled = false; txt_tenlop.DataBindings.Clear(); txt_tenlop.DataBindings.Add("Text", dtgv_themlop.DataSource, "TenLop"); txt_siso.DataBindings.Clear(); txt_siso.DataBindings.Add("Text", dtgv_themlop.DataSource, "SiSo"); txt_malop.DataBindings.Clear(); txt_malop.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaLop"); cb_Khoi_LopHoc.DataBindings.Clear(); cb_Khoi_LopHoc.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaKhoiLop"); } else { MessageBox.Show("Cập nhật không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo"); } } catch (Exception ex) { } }
public void LoadData() { try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.LayTatCaHocSinh(); dtgv_danhsachhocsinh.DataSource = dt; if (dt.Rows.Count > 0) { dtgv_danhsachhocsinh.Rows[0].Selected = true; RowSelected = new QLHS_DTO(); RowSelected.MaHocSinh = dtgv_danhsachhocsinh.SelectedRows[0].Cells["MaHocSinh"].Value.ToString(); RowSelected.HoTen = dtgv_danhsachhocsinh.SelectedRows[0].Cells["HoTen"].Value.ToString(); RowSelected.GioiTinh = dtgv_danhsachhocsinh.SelectedRows[0].Cells["GioiTinh"].Value.ToString(); RowSelected.NgaySinh = dtgv_danhsachhocsinh.SelectedRows[0].Cells["NgaySinh"].Value.ToString(); RowSelected.DiaChi = dtgv_danhsachhocsinh.SelectedRows[0].Cells["DiaChi"].Value.ToString(); RowSelected.Email = dtgv_danhsachhocsinh.SelectedRows[0].Cells["Email"].Value.ToString(); } } catch (Exception ex) { } }
private void btn_them_Click(object sender, EventArgs e) { try { QLHS_DTO hs = new QLHS_DTO(); hs.MaHocSinh = txt_mahocsinh.Text; hs.HoTen = txt_tenhocsinh.Text; hs.TenKhoiLop = cb_khoi.Text; hs.TenLop = cb_lop.Text; QLHS_BUS bus = new QLHS_BUS(); bus.ThemDSLop(cb_lop.Text, txt_mahocsinh.Text); MessageBox.Show("Thêm thành công học sinh vào lớp " + cb_lop.Text + " !", "Thông báo"); LoadData(); } catch { MessageBox.Show("Error: Lỗi Database !"); } }
private void btn_xoahocsinh_Click(object sender, EventArgs e) { try { DialogResult DR = MessageBox.Show("Bạn có chắc chắn xoá học sinh này!", "Thông báo", MessageBoxButtons.YesNo); if (DialogResult.Yes == DR) { QLHS_DTO hs = new QLHS_DTO(); QLHS_BUS bus = new QLHS_BUS(); bus.XoaHocSinh(txt_mahocsinh.Text); MessageBox.Show("Xoá thành công học sinh " + txt_mahocsinh.Text + " !", "Thông báo"); LoadData(); ClearText(); txt_hovaten.DataBindings.Clear(); txt_hovaten.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "HoTen"); txt_mahocsinh.DataBindings.Clear(); txt_mahocsinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "MaHocSinh"); txt_email.DataBindings.Clear(); txt_email.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "Email"); txt_diachi.DataBindings.Clear(); txt_diachi.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "DiaChi"); cb_gioitinh.DataBindings.Clear(); cb_gioitinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "GioiTinh"); dt_ngaysinh.DataBindings.Clear(); dt_ngaysinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "NgaySinh"); } else { LoadData(); } } catch (Exception ex) { } }
private void btn_timkiem_Click(object sender, EventArgs e) { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.TIMKIEMTHEOHOTEN(txt_timkiemtheoten.Text); if (dt.Rows.Count > 0) { dtgv_Timkiem.DataSource = dt; txt_mahocsinh.DataBindings.Clear(); txt_mahocsinh.DataBindings.Add("Text", dtgv_Timkiem.DataSource, "MaHocSinh"); txt_hoten.DataBindings.Clear(); txt_hoten.DataBindings.Add("Text", dtgv_Timkiem.DataSource, "HoTen"); txt_gioitinh.DataBindings.Clear(); txt_gioitinh.DataBindings.Add("Text", dtgv_Timkiem.DataSource, "GioiTinh"); txt_NgaySinh.DataBindings.Clear(); txt_NgaySinh.DataBindings.Add("Text", dtgv_Timkiem.DataSource, "NgaySinh"); txt_tenlop.DataBindings.Clear(); txt_tenlop.DataBindings.Add("Text", dtgv_Timkiem.DataSource, "TenLop"); txt_email.DataBindings.Clear(); txt_email.DataBindings.Add("Text", dtgv_Timkiem.DataSource, "Email"); txt_diachi.DataBindings.Clear(); txt_diachi.DataBindings.Add("Text", dtgv_Timkiem.DataSource, "DiaChi"); } }
public void LoadData() { try { QLHS_BUS bus = new QLHS_BUS(); DataTable dt = bus.TIMKIEMDSHS(); dtgv_Timkiem.DataSource = dt; if (dt.Rows.Count > 0) { dtgv_Timkiem.Rows[0].Selected = true; RowSelected = new QLHS_DTO(); RowSelected.MaHocSinh = dtgv_Timkiem.SelectedRows[0].Cells["MaHocSinh"].Value.ToString(); RowSelected.HoTen = dtgv_Timkiem.SelectedRows[0].Cells["HoTen"].Value.ToString(); RowSelected.TenLop = dtgv_Timkiem.SelectedRows[0].Cells["TenLop"].Value.ToString(); RowSelected.GioiTinh = dtgv_Timkiem.SelectedRows[0].Cells["GioiTinh"].Value.ToString(); RowSelected.NgaySinh = dtgv_Timkiem.SelectedRows[0].Cells["NgaySinh"].Value.ToString(); RowSelected.Email = dtgv_Timkiem.SelectedRows[0].Cells["Email"].Value.ToString(); RowSelected.DiaChi = dtgv_Timkiem.SelectedRows[0].Cells["DiaChi"].Value.ToString(); } } catch (Exception ex) { } }
private void btn_hoanthanh_Click(object sender, EventArgs e) { QLHS_BUS bus = new QLHS_BUS(); int nam = int.Parse(DateTime.Now.Year.ToString()); int dtp = int.Parse(dt_ngaysinh.Value.Year.ToString()); int t = nam - dtp; DataTable dt = bus.ThamSo(); //MessageBox.Show(dt.Rows[0]["TuoiToiThieu"].ToString()); //MessageBox.Show(dt.Rows[0]["TuoiToiDa"].ToString()); try { if (Int32.Parse(dt.Rows[0]["TuoiToiThieu"].ToString()) < t && t < Int32.Parse(dt.Rows[0]["TuoiToiDa"].ToString())) { if ((txt_hovaten.Text != "") && (dt_ngaysinh.Value.ToString() != "") && (cb_gioitinh.Text != "") && (txt_diachi.Text != "") && (txt_email.Text != "")) { QLHS_DTO hs = new QLHS_DTO(); hs.MaHocSinh = txt_mahocsinh.Text; hs.HoTen = txt_hovaten.Text; hs.NgaySinh = dt_ngaysinh.Value.ToString(); hs.GioiTinh = cb_gioitinh.Text; hs.DiaChi = txt_diachi.Text; hs.Email = txt_email.Text; bus.ThemHocSinh(hs); MessageBox.Show("Thêm thành công học sinh " + txt_hovaten.Text + " !", "Thông báo"); LoadData(); bus.ThemCTDSLOP(hs); btn_hoanthanh.Visible = false; btn_ThemHS.Visible = true; btn_capnhathocsinh.Visible = true; txt_mahocsinh.Enabled = false; txt_hovaten.Enabled = false; txt_email.Enabled = false; txt_diachi.Enabled = false; cb_gioitinh.Enabled = false; dt_ngaysinh.Enabled = false; txt_hovaten.DataBindings.Clear(); txt_hovaten.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "HoTen"); txt_mahocsinh.DataBindings.Clear(); txt_mahocsinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "MaHocSinh"); txt_email.DataBindings.Clear(); txt_email.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "Email"); txt_diachi.DataBindings.Clear(); txt_diachi.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "DiaChi"); cb_gioitinh.DataBindings.Clear(); cb_gioitinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "GioiTinh"); dt_ngaysinh.DataBindings.Clear(); dt_ngaysinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "NgaySinh"); } else { MessageBox.Show("Bạn chưa nhập đủ thông tin! Mời nhập lại!", "Cảnh báo"); } } else { MessageBox.Show("Tuổi của học sinh chưa đúng quy định! Không thêm thành công", "Cảnh báo"); } } catch (Exception ex) { MessageBox.Show("Mời nhập lại theo đúng quy định!"); } }