/// <summary> /// 初始化数据 /// 有默认值则填充默认值 /// </summary> private void InitData() { try { if (!string.IsNullOrEmpty(myIemMainPageExceptUse.IemexUseId)) { this.Text = myIemMainPageExceptUse.Value; } else { Dictionary <string, string> dicStr = DateElementEntity.GetDataSource(iemExcept.DateElement); if (dicStr == null) { return; } //默认值 string defaultValue = dicStr["DefaultValue"]; this.Text = defaultValue; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 初始化控件数据源 /// </summary> private void InitData() { try { Dictionary <string, string> dicstr = DateElementEntity.GetDataSource(iemExceptEntity.DateElement); if (dicstr == null) { return; } decimal minValue; /*最小值*/ decimal maxValue; /*最大值*/ decimal defaultValue; /*默认值*/ bool isMaxvalue = decimal.TryParse(dicstr["MaxValue"], out maxValue); bool isMinValue = decimal.TryParse(dicstr["MinValue"], out minValue); //转换失败则默认选择0 if (!decimal.TryParse(dicstr["DefaultValue"], out defaultValue)) { defaultValue = 0; } if (isMaxvalue && isMaxvalue) { spinEditIem.Properties.MaxValue = maxValue; spinEditIem.Properties.MinValue = minValue; } spinEditIem.Value = defaultValue; } catch (Exception ex) { throw ex; } }
/// <summary> /// 初始化 /// 没有填充值则填充数据元XML指定默认值 /// </summary> private void InitDefault() { try { Dictionary <string, string> dicstr = DateElementEntity.GetDataSource(iemExceptEntity.DateElement); if (dicstr == null) { return; } string defaultValue = dicstr["DefaultValue"]; this.memoEdit1.Text = defaultValue; } catch (Exception ex) { throw ex; } }