SheetInstancePrioritySelector.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:4k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.ComponentModel;
- using System.Drawing;
- using System.Web.UI.Design;
- using System.Drawing.Design;
- [assembly: TagPrefix("OThinker.H3.WorkSheet", "SheetControls")]
- namespace OThinker.H3.WorkSheet
- {
- /// <summary>
- /// SheetInstancePrioritySelector 的摘要说明。
- /// </summary>
- [ToolboxBitmap(typeof(SheetInstancePrioritySelector), "OThinker.H3.WorkSheet.SheetInstancePrioritySelector.bmp")]
- [ToolboxData("<{0}:SheetInstancePrioritySelector runat=server></{0}:SheetInstancePrioritySelector>")]
- public class SheetInstancePrioritySelector : System.Web.UI.WebControls.DropDownList, ISheetControl
- {
- public SheetInstancePrioritySelector()
- {
- // this.EnableViewState = false;
- }
- public const string DataField = "InstancePriority";
- public const string Html = "<select name="" + DataField + "" />";
- private RenderType _RenderType = RenderType.LabelWhenDisable;
- /// <summary>
- /// 显示方式
- /// </summary>
- [Bindable(true), Category("WorkSheet"), Description("控制控件的显示方式")]
- public RenderType RenderType
- {
- get
- {
- return this._RenderType;
- }
- set
- {
- this._RenderType = value;
- }
- }
- #region ISheetControl 成员
- public virtual void LoadDataField(OThinker.H3.WorkSheet.SheetPage SheetPage)
- {
- // 获得优先级
- Instance.PriorityType priority = SheetPage.Enviroment.InstanceManager.GetInstancePriority(SheetPage.Enviroment.InstanceId);
- string priorityName = Instance.PriorityTypeConvertor.ToString(priority);
- if (SheetPage.Enviroment.Workflow.StartActivity == SheetPage.Enviroment.ActivityName)
- {
- string[] names = Instance.PriorityTypeConvertor.GetAllPriority();
- foreach (string name in names)
- {
- this.Items.Add(name);
- }
- this.SelectedValue = priorityName;
- // 如果当期活动为发起活动的话,则允许写
- this.Enabled = true;
- }
- else
- {
- this.Items.Add(priorityName);
- this.Enabled = false;
- }
- }
- public virtual bool ValidateDataField(OThinker.H3.WorkSheet.SheetPage SheetPage, System.Collections.Generic.List<string> Errors)
- {
- return true;
- }
- public virtual void SaveDataField(OThinker.H3.WorkSheet.SheetPage SheetPage)
- {
- if (SheetPage.Enviroment.Workflow.StartActivity == SheetPage.Enviroment.ActivityName)
- {
- // 获得优先级
- string priorityName = this.SelectedValue;
- Instance.PriorityType priority = Instance.PriorityTypeConvertor.ToPriorityType(priorityName);
- SheetPage.Enviroment.InstanceManager.SetInstancePriority(SheetPage.Enviroment.InstanceId, priority);
- SheetPage.Enviroment.WorkItemManager.UpdatePriority(SheetPage.Enviroment.WorkItemID, priority);
- }
- }
- #endregion
- protected override void Render(HtmlTextWriter writer)
- {
- if (this.Enabled || this.RenderType != RenderType.LabelWhenDisable)
- {
- base.Render(writer);
- }
- else
- {
- writer.Write(this.SelectedItem.Text);
- }
- }
- }
- }