public virtual void InvalidateAfterSearch(object sender, String strEventName) { Cursor.Current = Cursors.WaitCursor; Control searchResultControl = null; foreach (Control ctrl in Controls.Values) { if (ctrl.Tag == VinaScreen.SearchResultControl) { searchResultControl = ctrl; break; } } if (searchResultControl != null) { if (searchResultControl is GridControl) { VinaSearchResultsGridControl.BindingSearchResultGridControl((DevExpress.XtraGrid.GridControl)searchResultControl, Toolbar.ObjectCollection); } //if (Toolbar.ObjectCollectionLength > 0 && !Toolbar.IsNewAction()) // Invalidate(Toolbar.CurrentObjectID); } Cursor.Current = Cursors.Default; }
public virtual void InvalidateSearchResultsControl(object sender, String strEventName) { try { Cursor.Current = Cursors.WaitCursor; VinaDbUtil dbUtil = new VinaDbUtil(); String strMainTableName = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject); string mainTablePrimaryColumn = dbUtil.GetTablePrimaryColumn(strMainTableName); BaseBusinessController objMainObjectController = BusinessControllerFactory.GetBusinessController(strMainTableName + "Controller"); //Invalidate toolbar collection PropertyInfo[] properties; DataRow newRow; String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject); int iObjectID = Convert.ToInt32(dbUtil.GetPropertyValue(CurrentModuleEntity.MainObject, SqlDatabaseHelper.GetPrimaryKeyColumn(strMainObjectTableName))); if (Toolbar.ObjectCollection == null) { DataSet ds = objMainObjectController.GetDataSetByID(iObjectID); Toolbar.SetToolbar(ds); } else { //if Toolbar.ModusAction is new, add new object to object collection of toolbar if (Toolbar.ModuleAction == BaseToolbar.ModuleNew) { newRow = Toolbar.ObjectCollection.Tables[0].NewRow(); newRow = objMainObjectController.GetDataRowFromBusinessObject(newRow, CurrentModuleEntity.MainObject); Toolbar.ObjectCollection.Tables[0].Rows.Add(newRow); Toolbar.CurrentIndex = Toolbar.ObjectCollection.Tables[0].Rows.Count - 1; } else { //Update object in object collection of toolbar properties = CurrentModuleEntity.MainObject.GetType().GetProperties(); int iCurrIndex = Toolbar.CurrentIndex; for (int i = 0; i < properties.Length; i++) { if (Toolbar.ObjectCollection.Tables[0].Columns[properties[i].Name] != null) { Toolbar.ObjectCollection.Tables[0].Rows[iCurrIndex][properties[i].Name] = properties[i].GetValue(CurrentModuleEntity.MainObject, null); } } } } //Invalidate search result control Control searchResultControl = null; foreach (Control ctrl in Controls.Values) { if (ctrl.Tag == VinaScreen.SearchResultControl) { searchResultControl = ctrl; break; } } if (searchResultControl != null) { if (searchResultControl is GridControl) { VinaSearchResultsGridControl gridControl = searchResultControl as VinaSearchResultsGridControl; GridView gridView = gridControl.Views[0] as GridView; if (gridControl.DataSource == null) { VinaSearchResultsGridControl.BindingSearchResultGridControl(gridControl, Toolbar.ObjectCollection); } //gridControl.InvalidateLookupEditColumns(); gridView.RefreshData(); gridView.FocusedRowHandle = gridView.GetRowHandle(Toolbar.CurrentIndex); } } } catch (Exception) { } }