SheetLabel.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:5k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Design;
- namespace OThinker.H3.WorkSheet
- {
- /// <summary>
- /// SheetLabel 的摘要说明。
- /// </summary>
- ///
- [ToolboxBitmap(typeof(SheetLabel),"OThinker.H3.WorkSheet.SheetLabel.bmp")]
- [ToolboxData("<{0}:SheetLabel runat=server></{0}:SheetLabel>")]
- public class SheetLabel : System.Web.UI.WebControls.Label, ISheetControl
- {
- public SheetLabel()
- {
- }
- #region 类SheetLabel属性
- private string _DataField = null;
- [Bindable(true),Category("WorkSheet"),DefaultValue("")]
- [Editor(typeof(DataSelector),typeof(UITypeEditor))]
- public string DataField
- {
- get
- {
- return this._DataField;
- }
- set
- {
- this._DataField = value;
- }
- }
- private RenderType _RenderType = RenderType.Normal;
- [Category("WorkSheet"), DefaultValue(true)]
- public RenderType RenderType
- {
- get
- {
- return this._RenderType;
- }
- set
- {
- this._RenderType = value;
- }
- }
- private BindType _BindType = BindType.All;
- [Bindable(true), Category("WorkSheet"), DefaultValue("")]
- [Editor(typeof(DataSelector), typeof(UITypeEditor))]
- public BindType BindType
- {
- get
- {
- return this._BindType;
- }
- set
- {
- this._BindType = value;
- }
- }
- #endregion
- #region ISheetControl 成员
- public virtual void LoadDataField(OThinker.H3.WorkSheet.SheetPage SheetPage)
- {
- if(this.DataField == null || this.DataField == "")
- {
- }
- else if(SheetPage.Enviroment.InstanceData[this.DataField] == null)
- {
- }
- else if (SheetPage.Enviroment.InstanceData[this.DataField].Visible == false && this.BindType != BindType.OnlyData)
- {
- this.Visible = false;
- }
- else
- {
- if(this.BindType != BindType.OnlyVisibility)
- {
- if (SheetPage.Enviroment.InstanceData[this.DataField].Value == null)
- {
- this.Text = null;
- }
- else
- {
- this.Text = SheetPage.Enviroment.InstanceData[this.DataField].Value.ToString();
- }
- }
- }
- }
- public virtual bool ValidateDataField(
- OThinker.H3.WorkSheet.SheetPage SheetPage,
- System.Collections.Generic.List<string> Errors)
- {
- if (
- this.DataField != null &&
- this.DataField != "" &&
- (this.BindType == BindType.All || this.BindType == BindType.OnlyData) &&
- SheetPage.Enviroment.InstanceData[this.DataField] != null &&
- SheetPage.Enviroment.InstanceData[this.DataField].Visible &&
- SheetPage.Enviroment.InstanceData[this.DataField].Editable &&
- this.Text != "" &&
- this.Text != null)
- {
- try
- {
- OThinker.Data.Convertor.Convert(
- this.Text,
- SheetPage.Enviroment.InstanceData[this.DataField].ItemType);
- }
- catch
- {
- Errors.Add(
- "数据格式不正确,发生转换错误,请确认输入数据的格式正确!" +
- "字段名称为:" + this.DataField + "," +
- "类型为:" + OThinker.H3.Data.DataLogicTypeConvertor.ToLogicTypeName(SheetPage.Enviroment.InstanceData[this.DataField].LogicType));
- return false;
- }
- }
- return true;
- }
- public virtual void SaveDataField(OThinker.H3.WorkSheet.SheetPage SheetPage)
- {
- if(
- this.DataField != null &&
- this.DataField != "" &&
- (this.BindType == BindType.All || this.BindType == BindType.OnlyData) &&
- SheetPage.Enviroment.InstanceData[this.DataField] != null &&
- SheetPage.Enviroment.InstanceData[this.DataField].Visible &&
- SheetPage.Enviroment.InstanceData[this.DataField].Editable)
- {
- //写回数据
- object convertedValue;
- try
- {
- convertedValue = OThinker.Data.Convertor.Convert(
- this.Text,
- SheetPage.Enviroment.InstanceData[this.DataField].ItemType,
- true);
- }
- catch
- {
- SheetPage.Enviroment.NotifyMessage(
- "数据格式不正确,发生转换错误,请确认输入数据的格式正确!" +
- "字段名称为:" + this.DataField + "," +
- "类型为:" + OThinker.H3.Data.DataLogicTypeConvertor.ToLogicTypeName(SheetPage.Enviroment.InstanceData[this.DataField].LogicType));
- return;
- }
- SheetPage.Enviroment.InstanceData[DataField].Value = convertedValue;
- }
- }
- #endregion
- protected override void Render(HtmlTextWriter writer)
- {
- if (this.RenderType != RenderType.Normal)
- {
- this.Enabled = true;
- }
- base.Render(writer);
- }
- }
- }