/// <summary> /// ComputeAndRefresh DataColumn /// </summary> /// <param name="colID"></param> /// <param name="removeHandler"></param> /// <param name="colVal"></param> private void ComputeAndRefreshColumn(int colID, bool removeHandler, ref object colVal) { Field field = null; if (colID > 0) { int fldIdx = DVDataTableObj.GetFldIdx(colID); field = (Field)DVControl.getForm().getTask().DataView.getField(fldIdx); } //First column is 'Isn'. Give a call to core to fetch PosCache's current Isn. And store it if (colID == 0) { colVal = (int)((TaskBase)DVControl.getForm().getTask()).GetDVControlPosition(); } else if (field != null) { String value = String.Empty; Object dnValue = null; bool isNull = false; //get field's value by ((TaskBase)field.getTask()).getFieldDisplayValue(field, ref value, ref isNull); dnValue = DNConvert.convertMagicToDotNet(value, field.getType(), typeof(Object)); colVal = dnValue; } }
/// <summary>Reject column changes in DataTable. /// </summary> /// <param name="pos"></param> /// <param name="fldIdx"></param> public void RejectColumnChanges(int pos, int fldIdx) { DVDataTableObj.CurrRow = pos; int colID = DVDataTableObj.GetColumnId(fldIdx - 1); Commands.addAsync(GuiCommandType.REJECT_DVCONTROL_COLUMN_CHANGES, DVControl, DVDataTableObj.CurrRow, colID, DVDataTableObj.DataTblObj); Commands.beginInvoke(); }
/// <summary> /// This will be called, while fetching records into DataTable at the start to create row. /// </summary> /// <param name="idx"></param> internal void checkAndCreateRow(int idx) { if (!DVControl.getForm().getTask().DataView.isEmptyDataview()) { if (!initialDataLoading) { // When new row is created in dataTable,"Isn" column which is primary key of dataTable // need to be initialized. this invokes of DataTable's ColumnChanged Handler. So, in order to avoid // this, DVControl Handler should be unregisterd before creating new row. Commands.addAsync(GuiCommandType.REMOVE_DVCONTROL_HANDLER, DVControl, DVDataTableObj.DataTblObj); DVDataTableObj.checkAndCreateRow(idx); Commands.addAsync(GuiCommandType.ADD_DVCONTROL_HANDLER, DVControl, DVDataTableObj.DataTblObj); } else { DVDataTableObj.CurrRow = idx; } } }
/// <summary>compute DataTable's column value /// </summary> /// <param name="fldIdx">Identifies DataColumn.</param> public void ComputeColumnValue(int fldIdx) { int colID = -1; //if fldIdx is 0, means it's first column i.e. "Isn" if (fldIdx == 0) { colID = 0; } else { colID = DVDataTableObj.GetColumnId(fldIdx - 1); } object colVal = null; ComputeAndRefreshColumn(colID, true, ref colVal); Commands.addAsync(GuiCommandType.UPDATE_DVCONTROL_COLUMN, DVDataTableObj, DVDataTableObj.CurrRow, colID, colVal); Commands.beginInvoke(); }
/// <summary>Refresh row of DVControl. /// </summary> internal void RefreshDisplay() { if (DVDataTableObj.ColumnList != null && !DVControl.getForm().getTask().DataView.isEmptyDataview()) { object[] row = new object[DVDataTableObj.DataTblObj.Columns.Count]; for (int i = 0; i <= DVDataTableObj.ColumnList.Count; i++) { ComputeAndRefreshColumn(i, false, ref row[i]); } if (initialDataLoading) { DVDataTableObj.LoadNewRow(row); } else { Commands.addAsync(GuiCommandType.UPDATE_DVCONTROL_ROW, DVDataTableObj, DVDataTableObj.CurrRow, row); } } }