NotificationGrid.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:7k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.ComponentModel;
- namespace OThinker.H3.Portal
- {
- /// <summary>
- /// 用于显示消息的控件
- /// </summary>
- [DefaultProperty("Text"),
- ToolboxData("<{0}:NotificationGrid runat=server></{0}:NotificationGrid>")]
- public class NotificationGrid : DataGrid
- {
- #region 列集合
- protected BoundColumn NotificationIDColumn = new BoundColumn();
- protected int NotificationIDColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.NotificationIDColumn);
- }
- }
- protected BoundColumn FromColumn = new BoundColumn();
- protected int FromColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.FromColumn);
- }
- }
- protected BoundColumn ToColumn = new BoundColumn();
- protected int ToColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.ToColumn);
- }
- }
- protected BoundColumn WorkflowPackageColumn = new BoundColumn();
- protected int WorkflowPackageColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.WorkflowPackageColumn);
- }
- }
- protected BoundColumn WorkflowNameColumn = new BoundColumn();
- protected int WorkflowNameColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.WorkflowNameColumn);
- }
- }
- protected BoundColumn WorkflowVersionColumn = new BoundColumn();
- protected int WorkflowVersionColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.WorkflowVersionColumn);
- }
- }
- protected BoundColumn InstanceIDColumn = new BoundColumn();
- protected int InstanceIDColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.InstanceIDColumn);
- }
- }
- protected BoundColumn TitleColumn = new BoundColumn();
- protected int TitleColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.TitleColumn);
- }
- }
- protected BoundColumn UrlColumn = new BoundColumn();
- protected int UrlColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.UrlColumn);
- }
- }
- protected BoundColumn ReceiveTimeColumn = new BoundColumn();
- protected int ReceiveTimeColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.ReceiveTimeColumn);
- }
- }
- protected BoundColumn StateColumn = new BoundColumn();
- protected int StateColumnIndex
- {
- get
- {
- return this.Columns.IndexOf(this.StateColumn);
- }
- }
- private void InitializeColumn(BoundColumn Column, string HeaderText, string DataField)
- {
- Column.HeaderText = HeaderText;
- Column.DataField = DataField;
- Column.ItemStyle.CssClass = this.ItemStyle.CssClass;
- this.Columns.Add(Column);
- }
- #endregion
- public NotificationGrid()
- {
- this.AutoGenerateColumns = false;
- this.ItemDataBound += new DataGridItemEventHandler(Grid_ItemDataBound);
- this.PageIndexChanged += new DataGridPageChangedEventHandler(WorkItemGrid_PageIndexChanged);
- this.AllowPaging = true;
- this.PagerStyle.Mode = PagerMode.NumericPages;
- this.InitializeColumn(this.NotificationIDColumn, "NotificationID", OThinker.Data.Database.Serialization.SerializableObject.PropertyName_ObjectID);
- this.InitializeColumn(this.FromColumn, "发送方", OThinker.H3.Notification.Notification.PropertyName_SenderID);
- this.InitializeColumn(this.ToColumn, "接收方", OThinker.H3.Notification.Notification.PropertyName_ReceiverID);
- this.InitializeColumn(this.WorkflowPackageColumn, "工作流类型", OThinker.H3.Notification.Notification.PropertyName_WorkflowPackage);
- this.InitializeColumn(this.WorkflowNameColumn, "工作流名称", OThinker.H3.Notification.Notification.PropertyName_WorkflowName);
- this.InitializeColumn(this.WorkflowVersionColumn, "工作流版本", OThinker.H3.Notification.Notification.PropertyName_WorkflowVersion);
- this.InitializeColumn(this.InstanceIDColumn, "流程ID", OThinker.H3.Notification.Notification.PropertyName_InstanceId);
- this.InitializeColumn(this.TitleColumn, "主题", OThinker.H3.Notification.Notification.PropertyName_Title);
- this.InitializeColumn(this.ReceiveTimeColumn, "接收时间", OThinker.H3.Notification.Notification.PropertyName_SendTime);
- this.InitializeColumn(this.StateColumn, "状态", OThinker.H3.Notification.Notification.PropertyName_State);
- this.InitializeColumn(this.UrlColumn, "Url", null);
- }
- private System.Data.DataTable WorkItemTable;
- public void BindDataGrid(System.Data.DataTable Table)
- {
- this.WorkItemTable = Table;
- this.DataSource = Table;
- this.DataBind();
- }
- protected override void Render(HtmlTextWriter writer)
- {
- if (this.DesignMode)
- {
- base.Render(writer);
- }
- else if (this.WorkItemTable == null || this.WorkItemTable.Rows.Count == 0)
- {
- writer.Write("没有找到消息");
- }
- else
- {
- base.Render(writer);
- }
- }
- protected virtual void Grid_ItemDataBound(object sender, DataGridItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer)
- {
- e.Item.Cells[this.UrlColumnIndex].Text = PortalPage.PageName_NotificationDetail + "?" + PortalPage.Param_NotificationID + "=" +e.Item.Cells[this.NotificationIDColumnIndex].Text;
- }
- }
- private void WorkItemGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
- {
- this.CurrentPageIndex = e.NewPageIndex;
- this.DataBind();
- }
- }
- }