Exemplo n.º 1
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnSua.Text == "Sửa")
         {
             txtTen.ReadOnly = false; cbKhoa.Enabled = true;
             txtTen.Focus();
             btnSua.Text     = "Lưu";
             btnThem.Enabled = btnXoa.Enabled = false;
         }
         else
         {
             Lop lop = new Lop();
             lop.IDLop  = Int32.Parse(txtMa.Text);
             lop.IDKhoa = (int)cbKhoa.SelectedValue;
             lop.TenLop = txtTen.Text;
             if (Lop.CapNhat(lop))
             {
                 MessageBox.Show("Sửa thành công!!!");
                 LoadDSLop();
                 dghienthi.Refresh();
                 btnSua.Text     = "Sửa";
                 btnThem.Enabled = btnXoa.Enabled = true;
                 txtTen.ReadOnly = true;
             }
             else
             {
                 MessageBox.Show("Sửa thất bại!!!");
                 txtTen.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }