private void ExecuteAdd(object obj) { try { Data d = new Data(); DataItemWindow window = new DataItemWindow { DataContext = d }; if (window.ShowDialog() == true) { if (string.IsNullOrWhiteSpace(d.Value1)) { return; } d.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); d.UpdateTime = d.AddTime; if (this._list == null) { this._list = new List <Data>(); } this._list.Add(d); DataCollection.Insert(0, d); Save(this._list); } } catch { } }
private void ExecuteEdit(object obj) { try { if (obj == null) { return; } Data s = (Data)obj; Data d = new Data { Index = s.Index, Value1 = s.Value1, Value2 = s.Value2, Value3 = s.Value3, Value4 = s.Value4, AddTime = s.AddTime, UpdateTime = s.UpdateTime }; DataItemWindow window = new DataItemWindow { DataContext = d }; if (window.ShowDialog() == true) { if (string.IsNullOrWhiteSpace(d.Value1)) { return; } s.UpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); s.Value1 = d.Value1; s.Value2 = d.Value2; s.Value3 = d.Value3; s.Value4 = d.Value4; Save(this._list); } } catch (Exception) { } }