示例#1
0
文件: ThemLop.cs 项目: ndhuy2711/QLHS
 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)
     {
     }
 }