Files
lserp_cs_6.0/插件库/Lskj.Control/Model/GridColumnModel.cs
T

537 lines
25 KiB
C#

/******************************
* 说明:GridView Column Model
* 创建人:龚宇超
* 创建日期:2017-09-14
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
namespace Lskj.Control.Model
{
/// <summary>
/// GridView Column Model
/// </summary>
public class GridColumnModel
{
#region private properties
private int _id;
private int _width;
private int _limitLength;
private int _calcOrder;
private int _fieldtype;
private int _dataDec;
private bool _edit;
private bool _visible;
private bool _canNull;
private bool _canSum;
private bool _canMerge;
private bool _canCopy;
private bool _canAccuracy;
private string _fieldName;
private string _fieldText;
private string _defaultValue;
private string _valueMember;
private string _textMember;
private string _sqlSource;
private string _unionFields;
private string _unionValues;
private string _calcExpr;
private string _dataFormat;
private string _bandTitle;
private string _bandFields;
private DataRow _sourceRow;
private int _isFixColumn;
private string _autoPadDataReleColName;
private bool _onlyCanNull;
private string _modelCode;
private int _popupWidth;
private string _treeCheckModel;
private bool _frozenFlag;
private int _lookUpWidth;
private string _lookUpFieldsWidth;
private string _resultFields;
#endregion
#region public properties
/// <summary>
/// Gets the identifier.
/// </summary>
/// <value>The identifier.</value>
public int Id { get { return this._id; } }
/// <summary>
/// Gets the width.
/// </summary>
/// <value>The width.</value>
public int Width { get { return this._width; } }
/// <summary>
/// Gets the length of the limit.
/// </summary>
/// <value>The length of the limit.</value>
public int LimitLength { get { return this._limitLength; } }
/// <summary>
/// Gets the calculate order.
/// </summary>
/// <value>The calculate order.</value>
public int CalcOrder { get { return this._calcOrder; } }
/// <summary>
/// Gets the fieldtype.
/// </summary>
/// <value>The fieldtype.</value>
public int FieldType { get { return this._fieldtype; } }
/// <summary>
/// 计算保留小数位数
/// </summary>
/// <value>The decimals.</value>
public int Decimals { get { return this._dataDec; } }
/// <summary>
/// Gets a value indicating whether this <see cref="GridColumnModel"/> is edit.
/// </summary>
/// <value><c>true</c> if edit; otherwise, <c>false</c>.</value>
public bool Edit { get { return this._edit; } }
/// <summary>
/// Gets a value indicating whether this <see cref="GridColumnModel"/> is visible.
/// </summary>
/// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
public bool Visible { get { return this._visible; } }
/// <summary>
/// 是否允许为空
/// </summary>
/// <value><c>true</c> if this instance can null; otherwise, <c>false</c>.</value>
public bool CanNull { get { return _canNull; } }
/// <summary>
/// Gets a value indicating whether this instance can sum.
/// </summary>
/// <value><c>true</c> if this instance can sum; otherwise, <c>false</c>.</value>
public bool CanSum { get { return this._canSum; } }
/// <summary>
/// Gets a value indicating whether this instance can merge.
/// </summary>
/// <value><c>true</c> if this instance can merge; otherwise, <c>false</c>.</value>
public bool CanMerge { get { return this._canMerge; } }
/// <summary>
/// Gets the accurary.
/// </summary>
/// <value>The accurary.</value>
public bool CanAccuracy { get { return this._canAccuracy; } }
/// <summary>
/// Gets a value indicating whether this <see cref="GridColumnModel"/> is visible.
/// </summary>
/// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
public bool CanCopy { get { return this._canCopy; } }
/// <summary>
/// Gets the name of the field.
/// </summary>
/// <value>The name of the field.</value>
public string FieldName { get { return this._fieldName; } }
/// <summary>
/// Gets the field text.
/// </summary>
/// <value>The field text.</value>
public string FieldText
{
get
{
return this._fieldText;
}
}
/// <summary>
/// Gets the default value.
/// </summary>
/// <value>The default value.</value>
public string DefaultValue { get { return this._defaultValue; } }
/// <summary>
/// Gets the value member.
/// </summary>
/// <value>The value member.</value>
public string ValueMember { get { return this._valueMember; } }
/// <summary>
/// Gets the text member.
/// </summary>
/// <value>The text member.</value>
public string TextMember { get { return this._textMember; } }
/// <summary>
/// Gets the SQL source.
/// </summary>
/// <value>The SQL source.</value>
public string SqlSource { get { return this._sqlSource; } }
/// <summary>
/// Gets the calculate expr.
/// </summary>
/// <value>The calculate expr.</value>
public string CalcExpr { get { return this._calcExpr; } }
/// <summary>
/// 关联字段
/// </summary>
/// <value>The union fields.</value>
public string UnionFields { get { return this._unionFields; } }
/// <summary>
/// 关联值
/// </summary>
/// <value>The union values.</value>
public string UnionValues { get { return this._unionValues; } }
/// <summary>
/// Gets the data format.
/// </summary>
/// <value>The data format.</value>
public string DataFormat { get { return this._dataFormat; } }
/// <summary>
/// Gets the band title.
/// </summary>
/// <value>The band title.</value>
public string BandTitle { get { return this._bandTitle; } }
/// <summary>
/// Gets the band fields.
/// </summary>
/// <value>The band fields.</value>
public string BandFields { get { return this._bandFields; } }
/// <summary>
/// 可用条件
/// </summary>
/// <value>The enable cond.</value>
public string DisableCond { get; set; }
/// <summary>
/// 单据列的可用条件
/// </summary>
/// <value>The enable cond.</value>
public string EnableCond;
/// <summary>
/// 可以方式
/// </summary>
/// <value>The type of the enable.</value>
public string DisableType { get; set; }
/// <summary>
/// 列文字摆放位置(0.左侧,1中间,2右侧)
/// </summary>
public int DataAlignment;
/// <summary>
/// 列字体设置
/// </summary>
public string FontName;
/// <summary>
/// 合计格式
/// </summary>
public string SumText { get; set; }
/// <summary>
/// 合计条件
/// </summary>
public string SumCond { get; set; }
/// <summary>
/// 合计计算公式
/// </summary>
public string sumCalc { get; set; }
/// <summary>
/// 合并分组
/// </summary>
public string MergeGroup { get; set; }
/// <summary>
/// 合并数据是否求和(合并单元格只计算一次)
/// </summary>
public bool isSumMerge { get; set; }
/// <summary>
/// 字体大小
/// </summary>
public int FontSize;
/// <summary>
/// Gets the source row.
/// </summary>
/// <value>The source row.</value>
public DataRow SourceRow { get { return this._sourceRow; } }
/// <summary>
/// 是否为冻结列
/// </summary>
/// <value>The fix column.</value>
public int IsFixColumn { get { return this._isFixColumn; } }
/// <summary>
/// 模块返回列
/// </summary>
/// <value>The fix column.</value>
public string addModuleResult { get; set; }
/// <summary>
/// 模块id
/// </summary>
/// <value>The fix column.</value>
public string addModuleld { get; set; }
/// <summary>
/// 根据关联列自动填充数据
/// </summary>
/// <value>The relevance column.</value>
public string AutoPadDataReleColName { get { return this._autoPadDataReleColName; } }
/// <summary>
/// 弹出数据源对应字段
/// </summary>
public string unionCompare { get; set; }
/// <summary>
///是否为导出列
/// </summary>
public bool isExportColumns { get; set; }
/// <summary>
/// 是否允许为空,不受只读影响
/// </summary>
public bool OnlyCanNull { get { return this._onlyCanNull; } }
/// <summary>
/// 合计汇总是否为显示值相加
/// </summary>
public bool Summation;
/// <summary>
/// 模块编号
/// </summary>
public string ModelCode { get { return this._modelCode; } }
/// <summary>
/// 弹出框宽度
/// </summary>
public int PopupWidth { get { return this._popupWidth; } }
/// <summary>
/// 树选择模式
/// </summary>
public string TreeCheckModel { get { return this._treeCheckModel; } }
/// <summary>
///模块选择返回框,是否单选模式
/// </summary>
public bool IsRadio { get; set; }
/// <summary>
///模块选择返回框,配置列加载模式(默认根据sql动态加载列)
/// </summary>
public bool ConfigureColumnMode { get; set; }
/// <summary>
///搜索框是否可以把输入值添加到数据源中
/// </summary>
public bool SearchBoxAddition { get; set; }
/// <summary>
/// 保存时需要验证是否重复(保存时存在所有配置字段重复的行则提示用户,并提示相关字段)
/// </summary>
public bool RepeatedVerification { get; set; }
/// <summary>
///左侧选中加载主表时,拼接的条件
/// </summary>
public string SelectionConditions { get; set; }
/// <summary>
/// 是否为冻结列(工具中打勾的属性,和IsFixColumn功能一致,名字不一致)
/// </summary>
public bool FrozenFlag { get { return this._frozenFlag; } }
/// <summary>
/// 下拉框宽度
/// </summary>
public int LookUpWidth { get { return this._lookUpWidth; } }
/// <summary>
/// 下拉框列宽度,逗号分隔一一对应
/// </summary>
public string LookUpFieldsWidth { get { return this._lookUpFieldsWidth; } }
/// <summary>
/// 扩展选择结果映射,格式:业务表字段=返回数据字段;业务表字段1=返回数据字段1。
/// </summary>
public string ResultFields { get { return this._resultFields; } }
/// <summary>
/// 动态列
/// </summary>
public bool isDynamic;
/// <summary>
/// 条件
/// </summary>
public string SplicingConditions;
/// <summary>
/// 禁显状态(true是禁显)
/// </summary>
public bool isVislble;
/// <summary>
/// Url图片列缓存
/// </summary>
public Hashtable LabPicUrlImages;
/// <summary>
/// Url图片列高度
/// </summary>
public int LabPicUrlHeight;
/// <summary>
/// 聚合主键列
/// </summary>
public bool IsCustomGroupPrimary;
/// <summary>
/// 聚合字段列
/// </summary>
public int IsCustomGroupField;
/// <summary>
/// 导入时转格式
/// </summary>
public string ImportConversionFormat;
/// <summary>
/// 字段浏览权限
/// </summary>
public string PrivilegeView;
/// <summary>
/// 字段操作权限
/// </summary>
public string PrivilegeOper;
/// <summary>
/// 附加关联(附件模块关联主表树型)
/// </summary>
public bool AdditionalAssociations;
/// <summary>
/// 禁止粘贴
/// </summary>
public bool ProhibitPaste;
/// <summary>
/// 新版模块返回框类型,显示对应text值(默认只显示数据库中对应内容)
/// </summary>
public bool ModuleFrameDisplayText;
/// <summary>
/// 编辑框格式化(和显示格式一致)
/// </summary>
public bool FormatEditBox;
/// <summary>
/// 单元格内容为空时的提示信息
/// </summary>
public string PromptText;
/// <summary>
/// 列注释(标题注释)
/// </summary>
public string ColumnAnnotation;
/// <summary>
/// 标题颜色
/// </summary>
public string TitleColor;
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="GridColumnModel"/> class.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="canEdit">if set to <c>true</c> [can only].</param>
public GridColumnModel(DataRow item, bool canEdit = true)
{
this._id = item.Table.Columns.Contains("id") ? Convert.ToInt32(item["id"] + "") : 0;
this._width = string.IsNullOrWhiteSpace(item["width"] + "") ? 0 : Convert.ToInt32(item["width"] + "");
this._visible = this._width > 0;
this._fieldName = item["fieldName"] + "";
this._fieldText = string.IsNullOrWhiteSpace(item["username"] + "") ? item["sysname"] + "" : item["username"] + "";
if (Business.Impl.LanguageTranslation.Translatable)
{
this._fieldText = Business.Impl.LanguageTranslation.GetTranslatedText(this._fieldText);
}
this._dataFormat = item.Table.Columns.Contains("dataFormat") ? item["dataFormat"] + "" : string.Empty;
this._canSum = item.Table.Columns.Contains("isSum") && ("1".Equals(item["isSum"] + "") || "True".Equals(item["isSum"] + ""));
this._canMerge = item.Table.Columns.Contains("ifMerge") && "1".Equals(item["ifMerge"] + "");
this._canCopy = item.Table.Columns.Contains("canCopy") && "1".Equals(item["canCopy"] + "");
this._limitLength = item.Table.Columns.Contains("LimitLen") && !string.IsNullOrWhiteSpace(item["LimitLen"] + "") ? Convert.ToInt32(item["LimitLen"] + "") : 0;
this._canAccuracy = item.Table.Columns.Contains("accuracy") && !string.IsNullOrWhiteSpace(item["accuracy"] + "") && item["accuracy"] + "" != "0";
this._bandTitle = item.Table.Columns.Contains("bandTitle") ? item["bandTitle"] + "" : string.Empty;
this._bandFields = item.Table.Columns.Contains("bandFields") ? item["bandFields"] + "" : string.Empty;
this._fieldtype = item.Table.Columns.Contains("fieldsqltag") && !string.IsNullOrWhiteSpace(item["fieldsqltag"] + "") ? Convert.ToInt32(item["fieldsqltag"] + "") : 0;
//if (this._fieldtype == 5 || this._fieldtype == 15)
//{
// _fieldtype = 181;
//}
this._sqlSource = item.Table.Columns.Contains("fieldsql") && !string.IsNullOrWhiteSpace(item["fieldsql"] + "") ? item["fieldsql"] + "" : string.Empty;
this._valueMember = item.Table.Columns.Contains("fieldsqlid") && !string.IsNullOrWhiteSpace(item["fieldsqlid"] + "") ? item["fieldsqlid"] + "" : "dm";
this._textMember = item.Table.Columns.Contains("fieldsqlname") && !string.IsNullOrWhiteSpace(item["fieldsqlname"] + "") ? item["fieldsqlname"] + "" : "mc";
this._dataDec = item.Table.Columns.Contains("DataDec") && !string.IsNullOrEmpty(item["dataDec"] + "") ? Convert.ToInt32(item["dataDec"] + "") : 2;
this._sourceRow = item;
this.DataAlignment = item.Table.Columns.Contains("DataAlignment") && !string.IsNullOrEmpty(item["DataAlignment"] + "") ? Convert.ToInt32(item["DataAlignment"] + "") : 0;
this.FontName = item.Table.Columns.Contains("FontName") ? item["FontName"] + "" : "";
this.SumText = item.Table.Columns.Contains("SumText") ? item["SumText"] + "" : "";
this.SumCond = item.Table.Columns.Contains("SumCond") ? item["SumCond"] + "" : "";
this.sumCalc = item.Table.Columns.Contains("sumCalc") ? item["sumCalc"] + "" : "";
this.MergeGroup = item.Table.Columns.Contains("MergeGroup") ? item["MergeGroup"] + "" : "";
this.FontSize = item.Table.Columns.Contains("FontSize") && !string.IsNullOrEmpty(item["FontSize"] + "") ? Convert.ToInt32(item["FontSize"] + "") : 0;
this.isSumMerge = (item.Table.Columns.Contains("isSumMerge") && !string.IsNullOrWhiteSpace(item["isSumMerge"] + "") && item["isSumMerge"] + "" != "0");
this._isFixColumn = item.Table.Columns.Contains("IsFixColumn") && !string.IsNullOrEmpty(item["IsFixColumn"] + "") ? Convert.ToInt32(item["IsFixColumn"] + "") : 0;
this._autoPadDataReleColName = item.Table.Columns.Contains("AutoPadDataReleColName") && !string.IsNullOrEmpty(item["AutoPadDataReleColName"] + "") ? item["AutoPadDataReleColName"] + "" : "";
this._onlyCanNull = item.Table.Columns.Contains("nullable") && ("1".Equals(item["nullable"] + "") || "True".Equals(item["nullable"] + ""));
if (canEdit)
{
this._calcOrder = string.IsNullOrWhiteSpace(item["CalcOrder"] + "") ? 0 : Convert.ToInt32(item["CalcOrder"] + "");
this._edit = item.Table.Columns.Contains("Edit") && !string.IsNullOrWhiteSpace(item["Edit"] + "") ? "0".Equals(item["Edit"] + "") : false;
this._canNull = item.Table.Columns.Contains("nullable") && ("1".Equals(item["nullable"] + "") || "True".Equals(item["nullable"] + ""));
this._defaultValue = item.Table.Columns.Contains("defaultdate") ? item["defaultdate"] + "" : string.Empty; ;
this._calcExpr = item["calcExpr"] + "";
this._unionFields = item.Table.Columns.Contains("unionFields") ? item["unionFields"] + "" : string.Empty;
this._unionValues = item.Table.Columns.Contains("unionValue") ? item["unionValue"] + "" : string.Empty;
this.DisableCond = item.Table.Columns.Contains("DisableCond") ? item["DisableCond"] + "" : string.Empty;
this.EnableCond = item.Table.Columns.Contains("enableCond") ? item["enableCond"] + "" : string.Empty;
this.DisableType = item.Table.Columns.Contains("DisableType") ? item["DisableType"] + "" : string.Empty;
}
this.addModuleResult = item.Table.Columns.Contains("addModuleResult") ? item["addModuleResult"] + "" : string.Empty;
this._resultFields = item.Table.Columns.Contains("resultfields") ? item["resultfields"] + "" : string.Empty;
this.addModuleld = item.Table.Columns.Contains("addModuleId") ? item["addModuleId"] + "" : string.Empty;
this.unionCompare = item.Table.Columns.Contains("UnionCompare") ? item["UnionCompare"] + "" : string.Empty;
this.isExportColumns = item.Table.Columns.Contains("isExportColumns") && !string.IsNullOrWhiteSpace(item["isExportColumns"] + "") ? "1".Equals(item["isExportColumns"] + "") : false;
this.Summation = item.Table.Columns.Contains("Summation") && !string.IsNullOrWhiteSpace(item["Summation"] + "") ? "1".Equals(item["Summation"] + "") : false;
this._modelCode = item.Table.Columns.Contains("tab") ? item["tab"] + "" : string.Empty;
if (string.IsNullOrEmpty(_modelCode))
{
this._modelCode = item.Table.Columns.Contains("typeCode") ? item["typeCode"] + "" : string.Empty;
}
this._popupWidth = item.Table.Columns.Contains("popupWidth") && int.TryParse(item["popupWidth"] + "", out this._popupWidth) ? this._popupWidth : -1;
this._treeCheckModel = item.Table.Columns.Contains("treeCheckModel") ? item["treeCheckModel"] + "" : "";
this.IsRadio = item.Table.Columns.Contains("IsRadio") && !string.IsNullOrWhiteSpace(item["IsRadio"] + "") ? "1".Equals(item["IsRadio"] + "") : false;
this.SearchBoxAddition = item.Table.Columns.Contains("SearchBoxAddition") && !string.IsNullOrWhiteSpace(item["SearchBoxAddition"] + "") ? "1".Equals(item["SearchBoxAddition"] + "") : false;
this.RepeatedVerification = item.Table.Columns.Contains("RepeatedVerification") && !string.IsNullOrWhiteSpace(item["RepeatedVerification"] + "") ? "1".Equals(item["RepeatedVerification"] + "") : false;
this.SelectionConditions = item.Table.Columns.Contains("SelectionConditions") ? item["SelectionConditions"] + "" : string.Empty;
this._frozenFlag = item.Table.Columns.Contains("frozenFlag") && ("1".Equals(item["frozenFlag"] + "") || "True".Equals(item["frozenFlag"] + ""));
this._lookUpWidth = item.Table.Columns.Contains("LookUpWidth") ? int.TryParse(item["LookUpWidth"] + "", out int lookUpWidth) ? lookUpWidth : 0 : 0;
this._lookUpFieldsWidth = item.Table.Columns.Contains("LookUpFieldsWidth") ? item["LookUpFieldsWidth"] + "" : "";
this.isDynamic = item.Table.Columns.Contains("isDynamic") && !string.IsNullOrWhiteSpace(item["isDynamic"] + "") ? "1".Equals(item["isDynamic"] + "") : false;
this.ConfigureColumnMode = item.Table.Columns.Contains("ConfigureColumnMode") && !string.IsNullOrWhiteSpace(item["ConfigureColumnMode"] + "") ? "1".Equals(item["ConfigureColumnMode"] + "") : false;
this.SplicingConditions = item.Table.Columns.Contains("SplicingConditions") ? item["SplicingConditions"] + "" : "";
this.isVislble = item.Table.Columns.Contains("vislble") && !string.IsNullOrWhiteSpace(item["vislble"] + "") ? "1".Equals(item["vislble"] + "") : false;
if (item.Table.Columns.Contains("LabPicUrlHeight"))
{
int.TryParse(item["LabPicUrlHeight"] + "", out LabPicUrlHeight);
}
this.IsCustomGroupPrimary = item.Table.Columns.Contains("IsCustomGroupPrimary") ? "1".Equals(item["IsCustomGroupPrimary"] + "") : false;
this.IsCustomGroupField = item.Table.Columns.Contains("IsCustomGroupField")&&int.TryParse(item["IsCustomGroupField"] + "",out IsCustomGroupField) ? IsCustomGroupField : 0;
this.ImportConversionFormat = item.Table.Columns.Contains("ImportConversionFormat") ? item["ImportConversionFormat"]+"" : string.Empty;
this.PrivilegeView = item.Table.Columns.Contains("PrivilegeView") ? item["PrivilegeView"] + "" : string.Empty;
this.PrivilegeOper = item.Table.Columns.Contains("PrivilegeOper") ? item["PrivilegeOper"] + "" : string.Empty;
this.AdditionalAssociations = item.Table.Columns.Contains("AdditionalAssociations") ? "1".Equals(item["AdditionalAssociations"] + "") : false;
this.ProhibitPaste = item.Table.Columns.Contains("ProhibitPaste") ? "1".Equals(item["ProhibitPaste"] + "") : false;
this.ModuleFrameDisplayText = item.Table.Columns.Contains("ModuleFrameDisplayText") ? "1".Equals(item["ModuleFrameDisplayText"] + "") : false;
this.FormatEditBox = item.Table.Columns.Contains("FormatEditBox") ? "1".Equals(item["FormatEditBox"] + "") : false;
this.PromptText = item.Table.Columns.Contains("PromptText") ? item["PromptText"] + "" : string.Empty;
this.ColumnAnnotation = item.Table.Columns.Contains("ColumnAnnotation") ? item["ColumnAnnotation"] + "" : string.Empty;
this.TitleColor = item.Table.Columns.Contains("TitleColor") ? item["TitleColor"] + "" : string.Empty;
//为了和工具里和bs里统一
if (this._fieldtype == 42)
{
//模块弹出框单选返回id
this._fieldtype = 160;
this.IsRadio = true;
}
if (this._fieldtype == 43)
{
//模块弹出框多选返回id
this._fieldtype = 160;
//this._fieldtype = 116;
this.IsRadio = false;
}
if (this._fieldtype == 171)
{
//模块选择返回ID(新版)单选
this._fieldtype = 160;
this.IsRadio = true;
}
if (this._fieldtype == 172)
{
//模块选择返回Text(新版)单选
this._fieldtype = 161;
this.IsRadio = true;
}
}
}
}