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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.ComponentModel;
  11. namespace OThinker.H3.Portal
  12. {
  13.     /// <summary>
  14.     /// 用于显示消息的控件
  15.     /// </summary>
  16.     [DefaultProperty("Text"),
  17.     ToolboxData("<{0}:NotificationGrid runat=server></{0}:NotificationGrid>")]
  18.     public class NotificationGrid : DataGrid
  19.     {
  20.         #region 列集合
  21.         protected BoundColumn NotificationIDColumn = new BoundColumn();
  22.         protected int NotificationIDColumnIndex
  23.         {
  24.             get
  25.             {
  26.                 return this.Columns.IndexOf(this.NotificationIDColumn);
  27.             }
  28.         }
  29.         protected BoundColumn FromColumn = new BoundColumn();
  30.         protected int FromColumnIndex
  31.         {
  32.             get
  33.             {
  34.                 return this.Columns.IndexOf(this.FromColumn);
  35.             }
  36.         }
  37.         protected BoundColumn ToColumn = new BoundColumn();
  38.         protected int ToColumnIndex
  39.         {
  40.             get
  41.             {
  42.                 return this.Columns.IndexOf(this.ToColumn);
  43.             }
  44.         }
  45.         protected BoundColumn WorkflowPackageColumn = new BoundColumn();
  46.         protected int WorkflowPackageColumnIndex
  47.         {
  48.             get
  49.             {
  50.                 return this.Columns.IndexOf(this.WorkflowPackageColumn);
  51.             }
  52.         }
  53.         protected BoundColumn WorkflowNameColumn = new BoundColumn();
  54.         protected int WorkflowNameColumnIndex
  55.         {
  56.             get
  57.             {
  58.                 return this.Columns.IndexOf(this.WorkflowNameColumn);
  59.             }
  60.         }
  61.         protected BoundColumn WorkflowVersionColumn = new BoundColumn();
  62.         protected int WorkflowVersionColumnIndex
  63.         {
  64.             get
  65.             {
  66.                 return this.Columns.IndexOf(this.WorkflowVersionColumn);
  67.             }
  68.         }
  69.         protected BoundColumn InstanceIDColumn = new BoundColumn();
  70.         protected int InstanceIDColumnIndex
  71.         {
  72.             get
  73.             {
  74.                 return this.Columns.IndexOf(this.InstanceIDColumn);
  75.             }
  76.         }
  77.         protected BoundColumn TitleColumn = new BoundColumn();
  78.         protected int TitleColumnIndex
  79.         {
  80.             get
  81.             {
  82.                 return this.Columns.IndexOf(this.TitleColumn);
  83.             }
  84.         }
  85.         protected BoundColumn UrlColumn = new BoundColumn();
  86.         protected int UrlColumnIndex
  87.         {
  88.             get
  89.             {
  90.                 return this.Columns.IndexOf(this.UrlColumn);
  91.             }
  92.         }
  93.         protected BoundColumn ReceiveTimeColumn = new BoundColumn();
  94.         protected int ReceiveTimeColumnIndex
  95.         {
  96.             get
  97.             {
  98.                 return this.Columns.IndexOf(this.ReceiveTimeColumn);
  99.             }
  100.         }
  101.         protected BoundColumn StateColumn = new BoundColumn();
  102.         protected int StateColumnIndex
  103.         {
  104.             get
  105.             {
  106.                 return this.Columns.IndexOf(this.StateColumn);
  107.             }
  108.         }
  109.         private void InitializeColumn(BoundColumn Column, string HeaderText, string DataField)
  110.         {
  111.             Column.HeaderText = HeaderText;
  112.             Column.DataField = DataField;
  113.             Column.ItemStyle.CssClass = this.ItemStyle.CssClass;
  114.             this.Columns.Add(Column);
  115.         }
  116.         #endregion
  117.         public NotificationGrid()
  118.         {
  119.             this.AutoGenerateColumns = false;
  120.             this.ItemDataBound += new DataGridItemEventHandler(Grid_ItemDataBound);
  121.             this.PageIndexChanged += new DataGridPageChangedEventHandler(WorkItemGrid_PageIndexChanged);
  122.             this.AllowPaging = true;
  123.             this.PagerStyle.Mode = PagerMode.NumericPages;
  124.             this.InitializeColumn(this.NotificationIDColumn,    "NotificationID",   OThinker.Data.Database.Serialization.SerializableObject.PropertyName_ObjectID);
  125.             this.InitializeColumn(this.FromColumn,              "发送方",           OThinker.H3.Notification.Notification.PropertyName_SenderID);
  126.             this.InitializeColumn(this.ToColumn,                "接收方",           OThinker.H3.Notification.Notification.PropertyName_ReceiverID);
  127.             this.InitializeColumn(this.WorkflowPackageColumn,   "工作流类型",       OThinker.H3.Notification.Notification.PropertyName_WorkflowPackage);
  128.             this.InitializeColumn(this.WorkflowNameColumn,      "工作流名称",       OThinker.H3.Notification.Notification.PropertyName_WorkflowName);
  129.             this.InitializeColumn(this.WorkflowVersionColumn,   "工作流版本",       OThinker.H3.Notification.Notification.PropertyName_WorkflowVersion);
  130.             this.InitializeColumn(this.InstanceIDColumn,        "流程ID",           OThinker.H3.Notification.Notification.PropertyName_InstanceId);
  131.             this.InitializeColumn(this.TitleColumn,             "主题",             OThinker.H3.Notification.Notification.PropertyName_Title);
  132.             this.InitializeColumn(this.ReceiveTimeColumn,       "接收时间",         OThinker.H3.Notification.Notification.PropertyName_SendTime);
  133.             this.InitializeColumn(this.StateColumn,             "状态",             OThinker.H3.Notification.Notification.PropertyName_State);
  134.             this.InitializeColumn(this.UrlColumn,               "Url",              null);
  135.         }
  136.         private System.Data.DataTable WorkItemTable;
  137.         public void BindDataGrid(System.Data.DataTable Table)
  138.         {
  139.             this.WorkItemTable = Table;
  140.             this.DataSource = Table;
  141.             this.DataBind();
  142.         }
  143.         protected override void Render(HtmlTextWriter writer)
  144.         {
  145.             if (this.DesignMode)
  146.             {
  147.                 base.Render(writer);
  148.             }
  149.             else if (this.WorkItemTable == null || this.WorkItemTable.Rows.Count == 0)
  150.             {
  151.                 writer.Write("没有找到消息");
  152.             }
  153.             else
  154.             {
  155.                 base.Render(writer);
  156.             }
  157.         }
  158.         protected virtual void Grid_ItemDataBound(object sender, DataGridItemEventArgs e)
  159.         {
  160.             if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer)
  161.             {
  162.                 e.Item.Cells[this.UrlColumnIndex].Text = PortalPage.PageName_NotificationDetail + "?" + PortalPage.Param_NotificationID + "=" +e.Item.Cells[this.NotificationIDColumnIndex].Text;
  163.             }
  164.         }
  165.         private void WorkItemGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
  166.         {
  167.             this.CurrentPageIndex = e.NewPageIndex;
  168.             this.DataBind();
  169.         }
  170.     }
  171. }