public static void AddOrUpdateRecord <TEntity>(RadDataForm form, ICUDOper <TEntity> dataContext, EditEndingEventArgs e) where TEntity : class { if (form.CanCommitEdit && e.EditAction == EditAction.Commit) { TEntity entity = (TEntity)form.CurrentItem; var result = dataContext.AddOrUpdate(entity); MessageBox.Show(result.Message); if (!result.IsSucceed) { e.Cancel = true; } } }
public static void AddOrUpdateRecord <TEntity>(RadDataForm form, ICUDOper <TEntity> dataContext, EditEndingEventArgs e) where TEntity : class { if (form.CanCommitEdit && e.EditAction == EditAction.Commit) { TEntity entity = (TEntity)form.CurrentItem; if (entity is IDEntity && ((IDEntity)entity).ID == default(int)) { CreatedData cd = entity as CreatedData; if (cd != null) { cd.CreatorID = VMGlobal.CurrentUser.ID; cd.CreateTime = DateTime.Now; } } var result = dataContext.AddOrUpdate(entity); MessageBox.Show(result.Message); if (!result.IsSucceed) { e.Cancel = true; } } }