protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects) OriginalList?.Clear(); OriginalList = null; DataPage?.Clear(); DataPage = null; FilteredList?.Clear(); FilteredList = null; ModelValueList?.Clear(); ModelValueList = null; SortDictionary?.Clear(); SortDictionary = null; FilterDictionary?.Clear(); FilterDictionary = null; } // TODO: free unmanaged resources (unmanaged objects) and override finalizer // TODO: set large fields to null disposedValue = true; } }
/// <summary> /// Invalidate based on a list /// </summary> /// <param name="lst">Object list</param> public virtual void Invalidate(IList <T> lst) { //Invalidate lookup edit columns to reflect all changes of lookup table //if (GridControl != null) // GridControl.InvalidateLookupEditColumns(); this.Clear(); foreach (T obj in lst) { this.Add((T)obj.Clone()); } //Invalidate original list same as itself OriginalList.Clear(); foreach (T obj in this) { OriginalList.Add((T)obj.Clone()); } if (GridControl != null) { GridControl.RefreshDataSource(); if (this.Count > 0) { if (CurrentIndex >= 0 && CurrentIndex < Count) { GridViewFocusRow(CurrentIndex); } else { GridViewFocusRow(0); } } } }
public virtual void Invalidate(DataTable table) { this.Clear(); OriginalList.Clear(); BaseBusinessController objItemController = BusinessControllerFactory.GetBusinessController(ItemTableName + "Controller"); //Invalidate lookup edit columns to reflect all changes of lookup table //if (GridControl != null) // GridControl.InvalidateLookupEditColumns(); foreach (DataRow row in table.Rows) { T objT = (T)objItemController.GetObjectFromDataRow(row); this.Add(objT); OriginalList.Add((T)objT.Clone()); } if (GridControl != null) { GridControl.RefreshDataSource(); if (this.Count > 0) { if (CurrentIndex >= 0 && CurrentIndex < Count) { GridViewFocusRow(CurrentIndex); } else { GridViewFocusRow(0); } } } }
public void Clear() { NewList.Clear(); OriginalList.Clear(); }
public virtual void SaveItemObjects() { try { EndCurrentEdit(); VinaDbUtil dbUtil = new VinaDbUtil(); String strItemTablePrimaryKey = dbUtil.GetTablePrimaryColumn(ItemTableName); BaseBusinessController objItemsController = BusinessControllerFactory.GetBusinessController(ItemTableName + "Controller"); int iParentObjectID = GetParentObjectID(); //Create or update foreach (T objT in this) { int iItemObjectID = (int)dbUtil.GetPropertyValue(objT, strItemTablePrimaryKey); if (iItemObjectID == 0 && Relation == cstRelationForeign) { if (iParentObjectID > 0) { if (dbUtil.GetPropertyValue(objT, ItemTableForeignKey) != null) { dbUtil.SetPropertyValue(objT, ItemTableForeignKey, iParentObjectID); } } } bool isUpdate = iItemObjectID > 0; if (isUpdate) { dbUtil.SetPropertyValue(objT, ERPModuleEntities.AAUpdatedUser, VinaApp.CurrentUserName); dbUtil.SetPropertyValue(objT, ERPModuleEntities.AAUpdatedDate, DateTime.Now); objItemsController.UpdateObject(objT); } else { dbUtil.SetPropertyValue(objT, ERPModuleEntities.AACreatedUser, VinaApp.CurrentUserName); dbUtil.SetPropertyValue(objT, ERPModuleEntities.AACreatedDate, DateTime.Now); iItemObjectID = objItemsController.CreateObject(objT); } } //Delete items foreach (T obj in OriginalList) { int iItemObjectID = (int)dbUtil.GetPropertyValue(obj, strItemTablePrimaryKey); if (iItemObjectID > 0 && !this.Exists(strItemTablePrimaryKey, iItemObjectID)) { objItemsController.DeleteObject(iItemObjectID); //Entity.DeleteObjectRelations(ItemTableName, iItemObjectID); } } //Invalidate original list OriginalList.Clear(); foreach (T obj in this) { OriginalList.Add((T)obj.Clone()); } } catch (Exception e) { // MessageBox.Show(e.ToString(), CommonLocalizedResources.MessageBoxDefaultCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }