public virtual void ActionInvalidate(int objectID) { VinaDbUtil dbUtil = new VinaDbUtil(); string tableName = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject); string primaryKey = dbUtil.GetTablePrimaryColumn(tableName); if (Toolbar.ObjectCollection != null) { for (int i = 0; i < Toolbar.ObjectCollection.Tables[0].Rows.Count; i++) { if (objectID == Convert.ToInt32(Toolbar.ObjectCollection.Tables[0].Rows[i][primaryKey])) { Toolbar.CurrentIndex = i; //FocusRowOfGridSearchResultByToolbarCurrentIndex(); return; } } } //If can't find the object in toolbar's collection BaseBusinessController controller = BusinessControllerFactory.GetBusinessController(tableName + "Controller"); if (controller != null) { DataSet ds = controller.GetDataSetByID(objectID); Toolbar.SetToolbar(ds); //InvalidateAfterSearch(null, String.Empty); } }
public Dictionary <List <STGridColumnsInfo>, DataSet> GetScreenEmployeeOffWork(string sModuleName, int iObjectID) { DataSet dsScreen = GetScreenByModuleNameAndUserGroupName(sModuleName, "ADMIN"); if (dsScreen == null || dsScreen.Tables.Count == 0 && dsScreen.Tables[0].Rows.Count == 0) { return(null); } STScreensInfo objScreen = new STScreensController().GetObjectFromDataRow(dsScreen.Tables[0].Rows[0]) as STScreensInfo; List <DataRow> dr = GetLocalDataSet("*", "STFields", string.Format(@"STScreenID = {0} AND STFieldType = 'GMCGridControl' AND STFieldGroup <> 'HiddenWeb'", objScreen.STScreenID)); if (dr.Count == 0) { return(null); } STFieldsInfo objField = (STFieldsInfo) new STFieldsController().GetObjectFromDataRow(dr[0]); if (objField == null) { return(null); } BaseBusinessController itemCtrl = BusinessControllerFactory.GetBusinessController(objField.STFieldDataSource + "Controller"); DataSet ds = new DataSet(); if (itemCtrl != null) { ds = itemCtrl.GetDataSetByID(iObjectID); } List <STGridColumnsInfo> lstGridColumns = new List <STGridColumnsInfo>(); dr = GetLocalDataSet("*", "STGridColumns", string.Format("FK_STFieldID = {0}", objField.STFieldID)); STGridColumnsController GridColCtrl = new STGridColumnsController(); dr.Distinct().ToList().ForEach(x => { STGridColumnsInfo colInfo = (STGridColumnsInfo)GridColCtrl.GetObjectFromDataRow(x); lstGridColumns.Add(colInfo); }); return(new Dictionary <List <STGridColumnsInfo>, DataSet>() { { lstGridColumns, ds } }); }
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) { } }