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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Web;
  3. using System.Web.UI;
  4. using System.Web.UI.WebControls;
  5. using System.Web.UI.HtmlControls;
  6. using System.ComponentModel;
  7. using System.Drawing;
  8. using System.Drawing.Design;
  9. [assembly: TagPrefix("OThinker.H3.WorkSheet", "SheetControls")]
  10. namespace OThinker.H3.WorkSheet
  11. {
  12.     /// <summary>
  13.     /// SheetController 的摘要说明。
  14.     /// </summary>
  15.     [ToolboxBitmap(typeof(SheetController), "OThinker.H3.WorkSheet.SheetController.bmp")]
  16.     [ToolboxData("<{0}:SheetController runat=server></{0}:SheetController>"), DefaultValue("")]
  17.     public class SheetController : System.Web.UI.WebControls.WebControl
  18.     {
  19.         public SheetController()
  20.         {
  21.             this._Enviroment = new SheetEnviroment(this);
  22.         }
  23.         private SheetEnviroment _Enviroment;
  24.         /// <summary>
  25.         /// 环境
  26.         /// </summary>
  27.         public virtual SheetEnviroment Enviroment
  28.         {
  29.             get
  30.             {
  31.                 return this._Enviroment;
  32.             }
  33.         }
  34.         // 工作项头
  35.         protected SheetHeader SheetHeader;
  36.         // 添加操作面板
  37.         protected OThinker.H3.WorkSheet.SheetActionPane ActionPane;
  38.         // 用户评论区
  39.         protected SheetUserComment UserComment;
  40.         // 查看其他人的评论区
  41.         protected SheetWorkItemComments WorkItemComments;
  42.         protected void UserComment_FinishedUserComment(object sender, EventArgs e)
  43.         {
  44.             //若是FinishedButton,则进行工作项的提交,也就是smButton.DataType == EnumButtonType.FinishedButton
  45.             this.Enviroment.WorkItemManager.FinishWorkItem(this.Enviroment.WorkItemID, this.Enviroment.UserValidator.UserID, false);
  46.             this.Enviroment.WorkItem.State = OThinker.H3.WorkItem.WorkItemState.Finished;
  47.             // 转到另外一个页面上
  48.             this.Enviroment.NotifyMessage("任务已完成!");
  49.         }
  50.         protected virtual void Load()
  51.         {
  52.             if (this.Enviroment == null)
  53.             {
  54.                 return;
  55.             }
  56.             // 工作模式的条件
  57.             bool workCondition =
  58.                 this.Enviroment.SheetMode == SheetMode.Work &&
  59.                 this.Enviroment.WorkItem != null &&
  60.                 this.Enviroment.WorkItem.State != OThinker.H3.WorkItem.WorkItemState.Finished;
  61.             // 普通工作模式
  62.             bool normalCondition = workCondition && this.Enviroment.WorkItem.ItemType == OThinker.H3.WorkItem.WorkItemType.Normal;
  63.             // 征询意见模式
  64.             bool consultCondition = workCondition && this.Enviroment.WorkItem.ItemType == OThinker.H3.WorkItem.WorkItemType.Consultancy;
  65.             // 发起模式的条件
  66.             bool originateCondition = this.Enviroment.SheetMode == SheetMode.Originate;
  67.             // 取回模式
  68.             bool retrieveCondition =
  69.                 this.Enviroment.SheetMode == SheetMode.View &&
  70.                 this.Enviroment.WorkItem != null &&
  71.                 this.Enviroment.WorkItem.State == OThinker.H3.WorkItem.WorkItemState.Finished &&
  72.                 this.Enviroment.WorkItem.PermittedActions.Retrieve;
  73.             if (workCondition)
  74.             {
  75.                 // 工作项的头
  76.                 this.SheetHeader = new SheetHeader(this.Enviroment.WorkItem);
  77.                 this.Controls.Add(this.SheetHeader);
  78.             }
  79.             if (normalCondition || originateCondition)
  80.             {
  81.                 // 操作面板
  82.                 this.ActionPane = new SheetActionPane();
  83.                 this.ActionPane.InitAsWorkMode(this.Enviroment);
  84.                 this.ActionPane.Submit += new SheetSubmitEventHandler(this.SheetController_Submit);
  85.                 this.Controls.Add(this.ActionPane);
  86.             }
  87.             if (retrieveCondition)
  88.             {
  89.                 // 操作面板
  90.                 this.ActionPane = new SheetActionPane();
  91.                 this.ActionPane.InitAsRetreiveMode(this.Enviroment);
  92.                 this.Controls.Add(this.ActionPane);
  93.             }
  94.             if (consultCondition)
  95.             {
  96.                 // 用户的评论
  97.                 this.UserComment = new SheetUserComment(this.Enviroment.WorkItem);
  98.                 this.UserComment.FinishedUserComment += new EventHandler(UserComment_FinishedUserComment);
  99.                 this.Controls.Add(this.UserComment);
  100.             }
  101.             if (normalCondition)
  102.             {
  103.                 // 我的评论
  104.                 this.WorkItemComments = new SheetWorkItemComments(this.Enviroment);
  105.                 this.Controls.Add(this.WorkItemComments);
  106.             }
  107.         }
  108.         public event SheetSubmitEventHandler Submit;
  109.         protected virtual void SheetController_Submit(object Sender, SheetSubmitEventArgs e)
  110.         {
  111.             if (this.Submit != null)
  112.             {
  113.                 this.Submit(Sender, e);
  114.             }
  115.         }
  116.     }
  117. }