private void OnAddSubmit <T>(T newobj, Label errorlabel, Action[] callback) where T : class { try { var wcfconfigdatacontext = new WcfConfigDataContext(); wcfconfigdatacontext.GetTable <T>().InsertOnSubmit(newobj); wcfconfigdatacontext.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict); wcfconfigdatacontext.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues); errorlabel.Text = "添加成功"; } catch (Exception ex) { errorlabel.Text = ex.Message; } finally { foreach (Action act in callback) { act(); } } }
private void OnDeleteSubmit <T>(WcfConfigDataContext wcfconfigdatacontext, T entity, Label errorlabel, Action[] callback) where T : class { try { var query = (from e in wcfconfigdatacontext.GetTable <T>() where e == entity select e); wcfconfigdatacontext.GetTable <T>().DeleteOnSubmit(entity); wcfconfigdatacontext.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict); wcfconfigdatacontext.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues); } catch (Exception ex) { errorlabel.Text = ex.Message; } finally { foreach (Action act in callback) { act(); } } }