SheetSequenceID.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:3k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Web.UI;
  3. using System.Web.UI.WebControls;
  4. using System.ComponentModel;
  5. using System.Drawing;
  6. using System.Drawing.Design;
  7. [assembly:TagPrefix("OThinker.H3.WorkSheet","SheetControls")]
  8. namespace OThinker.H3.WorkSheet
  9. {
  10. /// <summary>
  11. /// SheetSequenceID1 的摘要说明。
  12. /// </summary>
  13. /// 
  14. [ToolboxBitmap(typeof(SheetSequenceID),"OThinker.H3.WorkSheet.SheetSequenceID.bmp")]
  15. [ToolboxData("<{0}:SheetSequenceID runat=server></{0}:SheetSequenceID>")]
  16. public class SheetSequenceID : System.Web.UI.WebControls.Label, ISheetControl
  17. {
  18. public SheetSequenceID()
  19. {
  20. }
  21.         /// <summary>
  22.         /// 默认的总长度
  23.         /// </summary>
  24.         public const int DefaultLength = 16;
  25.         private int _Length = DefaultLength;
  26.         /// <summary>
  27.         /// 总长度
  28.         /// </summary>
  29.         [Bindable(true), Category("WorkSheet"), Description("总长度")]
  30.         public int Length
  31.         {
  32.             get
  33.             {
  34.                 return this._Length;
  35.             }
  36.             set
  37.             {
  38.                 this._Length = value;
  39.             }
  40.         }
  41. #region ISheetControl 成员
  42.         public virtual void LoadDataField(OThinker.H3.WorkSheet.SheetPage SheetPage)
  43. {
  44.             System.DateTime date;
  45.             long sequenceId;
  46.             if (this.DesignMode || SheetPage.Enviroment.InstanceId == null || SheetPage.Enviroment.InstanceId == "" || SheetPage.Enviroment.InstanceId == Instance.InstanceContext.UnspecifiedID)
  47.             {
  48.                 date = System.DateTime.Now;
  49.                 sequenceId = 0;
  50.             }
  51.             else
  52.             {
  53.                 // 获得流程信息
  54.                 OThinker.H3.Instance.InstanceContext context = SheetPage.Enviroment.InstanceManager.GetInstanceContext(SheetPage.Enviroment.InstanceId);
  55.                 date = context.CreatedTime;
  56.                 sequenceId = context.SequenceID;
  57.             }
  58.             string dateStr = date.Year + string.Format("{0:D2}", date.Month) + string.Format("{0:D2}", date.Day);
  59.             int len = this.Length - dateStr.Length;
  60.             len = len > 0 ? len : 0;
  61.             this.Text = dateStr + string.Format("{0:D" + len + "}", sequenceId);
  62. }
  63.         public virtual bool ValidateDataField(
  64.             OThinker.H3.WorkSheet.SheetPage SheetPage,
  65.             System.Collections.Generic.List<string> Errors)
  66.         {
  67.             return true;
  68.         }
  69.         public virtual void SaveDataField(OThinker.H3.WorkSheet.SheetPage SheetPage)
  70. {
  71. }
  72. #endregion
  73.         protected override void Render(HtmlTextWriter writer)
  74.         {
  75.             if (this.DesignMode)
  76.             {
  77.                 this.LoadDataField(null);
  78.             }
  79.             base.Render(writer);
  80.         }
  81. }
  82. }