/****************************** * 说明: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 { /// /// GridView Column Model /// 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 /// /// Gets the identifier. /// /// The identifier. public int Id { get { return this._id; } } /// /// Gets the width. /// /// The width. public int Width { get { return this._width; } } /// /// Gets the length of the limit. /// /// The length of the limit. public int LimitLength { get { return this._limitLength; } } /// /// Gets the calculate order. /// /// The calculate order. public int CalcOrder { get { return this._calcOrder; } } /// /// Gets the fieldtype. /// /// The fieldtype. public int FieldType { get { return this._fieldtype; } } /// /// 计算保留小数位数 /// /// The decimals. public int Decimals { get { return this._dataDec; } } /// /// Gets a value indicating whether this is edit. /// /// true if edit; otherwise, false. public bool Edit { get { return this._edit; } } /// /// Gets a value indicating whether this is visible. /// /// true if visible; otherwise, false. public bool Visible { get { return this._visible; } } /// /// 是否允许为空 /// /// true if this instance can null; otherwise, false. public bool CanNull { get { return _canNull; } } /// /// Gets a value indicating whether this instance can sum. /// /// true if this instance can sum; otherwise, false. public bool CanSum { get { return this._canSum; } } /// /// Gets a value indicating whether this instance can merge. /// /// true if this instance can merge; otherwise, false. public bool CanMerge { get { return this._canMerge; } } /// /// Gets the accurary. /// /// The accurary. public bool CanAccuracy { get { return this._canAccuracy; } } /// /// Gets a value indicating whether this is visible. /// /// true if visible; otherwise, false. public bool CanCopy { get { return this._canCopy; } } /// /// Gets the name of the field. /// /// The name of the field. public string FieldName { get { return this._fieldName; } } /// /// Gets the field text. /// /// The field text. public string FieldText { get { return this._fieldText; } } /// /// Gets the default value. /// /// The default value. public string DefaultValue { get { return this._defaultValue; } } /// /// Gets the value member. /// /// The value member. public string ValueMember { get { return this._valueMember; } } /// /// Gets the text member. /// /// The text member. public string TextMember { get { return this._textMember; } } /// /// Gets the SQL source. /// /// The SQL source. public string SqlSource { get { return this._sqlSource; } } /// /// Gets the calculate expr. /// /// The calculate expr. public string CalcExpr { get { return this._calcExpr; } } /// /// 关联字段 /// /// The union fields. public string UnionFields { get { return this._unionFields; } } /// /// 关联值 /// /// The union values. public string UnionValues { get { return this._unionValues; } } /// /// Gets the data format. /// /// The data format. public string DataFormat { get { return this._dataFormat; } } /// /// Gets the band title. /// /// The band title. public string BandTitle { get { return this._bandTitle; } } /// /// Gets the band fields. /// /// The band fields. public string BandFields { get { return this._bandFields; } } /// /// 可用条件 /// /// The enable cond. public string DisableCond { get; set; } /// /// 单据列的可用条件 /// /// The enable cond. public string EnableCond; /// /// 可以方式 /// /// The type of the enable. public string DisableType { get; set; } /// /// 列文字摆放位置(0.左侧,1中间,2右侧) /// public int DataAlignment; /// /// 列字体设置 /// public string FontName; /// /// 合计格式 /// public string SumText { get; set; } /// /// 合计条件 /// public string SumCond { get; set; } /// /// 合计计算公式 /// public string sumCalc { get; set; } /// /// 合并分组 /// public string MergeGroup { get; set; } /// /// 合并数据是否求和(合并单元格只计算一次) /// public bool isSumMerge { get; set; } /// /// 字体大小 /// public int FontSize; /// /// Gets the source row. /// /// The source row. public DataRow SourceRow { get { return this._sourceRow; } } /// /// 是否为冻结列 /// /// The fix column. public int IsFixColumn { get { return this._isFixColumn; } } /// /// 模块返回列 /// /// The fix column. public string addModuleResult { get; set; } /// /// 模块id /// /// The fix column. public string addModuleld { get; set; } /// /// 根据关联列自动填充数据 /// /// The relevance column. public string AutoPadDataReleColName { get { return this._autoPadDataReleColName; } } /// /// 弹出数据源对应字段 /// public string unionCompare { get; set; } /// ///是否为导出列 /// public bool isExportColumns { get; set; } /// /// 是否允许为空,不受只读影响 /// public bool OnlyCanNull { get { return this._onlyCanNull; } } /// /// 合计汇总是否为显示值相加 /// public bool Summation; /// /// 模块编号 /// public string ModelCode { get { return this._modelCode; } } /// /// 弹出框宽度 /// public int PopupWidth { get { return this._popupWidth; } } /// /// 树选择模式 /// public string TreeCheckModel { get { return this._treeCheckModel; } } /// ///模块选择返回框,是否单选模式 /// public bool IsRadio { get; set; } /// ///模块选择返回框,配置列加载模式(默认根据sql动态加载列) /// public bool ConfigureColumnMode { get; set; } /// ///搜索框是否可以把输入值添加到数据源中 /// public bool SearchBoxAddition { get; set; } /// /// 保存时需要验证是否重复(保存时存在所有配置字段重复的行则提示用户,并提示相关字段) /// public bool RepeatedVerification { get; set; } /// ///左侧选中加载主表时,拼接的条件 /// public string SelectionConditions { get; set; } /// /// 是否为冻结列(工具中打勾的属性,和IsFixColumn功能一致,名字不一致) /// public bool FrozenFlag { get { return this._frozenFlag; } } /// /// 下拉框宽度 /// public int LookUpWidth { get { return this._lookUpWidth; } } /// /// 下拉框列宽度,逗号分隔一一对应 /// public string LookUpFieldsWidth { get { return this._lookUpFieldsWidth; } } /// /// 扩展选择结果映射,格式:业务表字段=返回数据字段;业务表字段1=返回数据字段1。 /// public string ResultFields { get { return this._resultFields; } } /// /// 动态列 /// public bool isDynamic; /// /// 条件 /// public string SplicingConditions; /// /// 禁显状态(true是禁显) /// public bool isVislble; /// /// Url图片列缓存 /// public Hashtable LabPicUrlImages; /// /// Url图片列高度 /// public int LabPicUrlHeight; /// /// 聚合主键列 /// public bool IsCustomGroupPrimary; /// /// 聚合字段列 /// public int IsCustomGroupField; /// /// 导入时转格式 /// public string ImportConversionFormat; /// /// 字段浏览权限 /// public string PrivilegeView; /// /// 字段操作权限 /// public string PrivilegeOper; /// /// 附加关联(附件模块关联主表树型) /// public bool AdditionalAssociations; /// /// 禁止粘贴 /// public bool ProhibitPaste; /// /// 新版模块返回框类型,显示对应text值(默认只显示数据库中对应内容) /// public bool ModuleFrameDisplayText; /// /// 编辑框格式化(和显示格式一致) /// public bool FormatEditBox; /// /// 单元格内容为空时的提示信息 /// public string PromptText; /// /// 列注释(标题注释) /// public string ColumnAnnotation; /// /// 标题颜色 /// public string TitleColor; #endregion /// /// Initializes a new instance of the class. /// /// The item. /// if set to true [can only]. 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; } } } }