Example #1
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtMa.Text == "")
         {
             MessageBox.Show("Mã thể loại không được bỏ trống");
         }
         else if (txtTen.Text == "")
         {
             MessageBox.Show("Tên thể loại không được bỏ trống");
         }
         else
         {
             L.maThL  = txtMa.Text;
             L.tenThL = txtTen.Text;
             L.ghiChu = txtGhiChu.Text;
             int dem = 0;
             foreach (DataRow row in dtTheloai.Rows)
             {
                 foreach (DataColumn a in dtTheloai.Columns)
                 {
                     var check = row[a].ToString().Trim();
                     if (txtMa.Text.Trim() == check)
                     {
                         dem++;
                         break;
                     }
                 }
             }
             if (dem != 0)
             {
                 theloai.UpdateTheLoai(L.maThL, L.tenThL, L.ghiChu);
                 QuanLyTheLoai_GUI_Load(sender, e);
                 MessageBox.Show("Cập nhật thể loại thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("Mã thể loại không tồn tại, nhập lại", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("không cập nhật được thể loại, nhập lại", "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }