/// <summary> /// 复制数据对象 /// </summary> /// <param name="sou">源对象,需从DataPacket继承</param> public override void AssignFrom(DataPacket sou) { base.AssignFrom(sou); ColData s = sou as ColData; if (s != null) { _colIndex = s.colIndex; _express = s._express; } }
/// <summary> /// 根据列名取显示值 /// </summary> /// <param name="colname">列名</param> /// <returns></returns> public string GetDspValueByColName(string colname) { ColData coldata = GetColDataByColName(colname); if (coldata != null) { return(GetDspValue(coldata.colIndex)); } else { return(null); } }
/// <summary> /// 根据列名取实际值 /// </summary> /// <param name="colname">列名</param> /// <returns></returns> public string GetValueByColName(string colname) { ColData coldata = GetColDataByColName(colname); if (coldata != null) { return(coldata.express); } else { return(null); } }
/// <summary> /// 根据列号取实际值 /// </summary> /// <param name="col">列号</param> /// <returns></returns> public string GetValue(int col) { ColData coldata = GetColDataByCol(col); if (coldata != null) { return(coldata.express); } else { return(null); } }
/// <summary> /// 根据列号设值 /// </summary> /// <param name="col">列号</param> /// <param name="v">值</param> public void SetValue(int col, string v) { ColData coldata = GetColDataByCol(col); if (coldata != null) { coldata.express = v; } else { coldata = NewColData(); coldata.colIndex = col; coldata.express = v; _colList.Add(coldata); }; }
/// <summary> /// 补全ColList数据 /// </summary> public virtual void CheckColListData() { if (_fields != null) { foreach (ColDef colDef in _fields) { ColData colData = GetColDataByCol(colDef.colIndx); if (colData is null) { colData = NewColData(); colData.colIndex = colDef.colIndx; colList.Add(colData); } } } _colList.Sort(new SortByColIndex()); }
/// <summary> /// 根据列号取显示值 /// </summary> /// <param name="col">列号</param> /// <returns></returns> public string GetDspValue(int col) { string ret = null; ColData coldata = GetColDataByCol(col); if (coldata != null) { ret = coldata.express; if (_fields != null) { ColDef coldef = _fields.Cast <ColDef>().FirstOrDefault(a => a.colIndx == col); if (coldef != null) { switch (coldef.colType) { case (int)_dataType.dtString: ret = coldata.express; break; case (int)_dataType.dtInt: ret = int.Parse(coldata.express).ToString(); break; case (int)_dataType.dtBoolean: ret = Boolean.Parse(coldata.express).ToString(); break; case (int)_dataType.dtFloat: ret = float.Parse(coldata.express).ToString("F" + coldef.colDec.ToString()); break; default: ret = coldata.express; break; } ; } ; } ; } ; return(ret); }
/// <summary> /// 根据列名设值 /// </summary> /// <param name="colname">列名</param> /// <param name="v"></param> public void SetValueByColName(string colname, string v) { ColData coldata = GetColDataByColName(colname); if (coldata != null) { coldata.express = v; } else { if (_fields != null) { ColDef coldef = _fields.Cast <ColDef>().FirstOrDefault(a => a.colName == colname); if (coldef != null) { SetValue(coldef.colIndx, v); } } ; }; }