private void ChiTietPhieuMuon_Sach_PropertyChanging(Object sender, PropertyChangingEventArgs e) { if (e.PropertyName == nameof(Sach.pid)) { lb_ThongBaoLoiThemSach.Content = ""; PropertyChangingCancelEventArgs <string> cancelArgs = e as PropertyChangingCancelEventArgs <string>; if (BiTrungSach(cancelArgs.NewValue)) { lb_ThongBaoLoiThemSach.Content = "Sách đã được thêm"; datagrid_ChiTietPhieuMuon.CancelEdit(); cancelArgs.Cancel = true; return; } Sach sachTim = SachBUS.Instance.LaySach(cancelArgs.NewValue); if (sachTim == null) { lb_ThongBaoLoiThemSach.Content = "Không tìm thấy sách"; datagrid_ChiTietPhieuMuon.CancelEdit(); cancelArgs.Cancel = true; } } }
protected bool OnPropertyChanging <T>(string propertyName, T originalValue, T newValue) { var handler = this.PropertyChanging; if (handler != null) { var args = new PropertyChangingCancelEventArgs <T>(propertyName, originalValue, newValue); handler(this, args); return(!args.Cancel); } return(true); }