private void btnCapNhat_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtLaiSuat.Text.Trim())) { LOAITK loaitk = busLoaiTK.timLoaiTK(cbxTenLoai.Text.Trim()); loaitk.LAISUAT = double.Parse(txtLaiSuat.Text.Trim()); switch (cbxTenLoai.Text) { case "Tiet kiem co ky han 3 thang": busLoaiTK.suaLoaiTK("LTK01"); break; case "Tiet kiem co ky han 6 thang": busLoaiTK.suaLoaiTK("LTK02"); break; case "Tiet kiem co ky han 12 thang": busLoaiTK.suaLoaiTK("LTK03"); break; case "Tiet kiem khong ky han": busLoaiTK.suaLoaiTK("LTK04"); break; } MessageBox.Show("Cập nhật lãi suất thành công"); dgvLoaiTK.DataSource = busLoaiTK.layLoaiTK(); } else { lblLoi.Visible = true; } }
public void suaLoaiTK(string MaLoai) { try { LOAITK loaitk = db.LOAITKs.SingleOrDefault(x => x.MALOAITK.Equals(MaLoai)); db.Entry(loaitk).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } catch (Exception e) { throw e; } }