⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 projectlist.aspx.cs

📁 专业的办公oa代码下载 c#语言编写 三层结构
💻 CS
字号:
using System;
using System.Web.UI.WebControls;
using qminoa.BLL.PM;

namespace qminoa.Webs.PM
{
	public class ProjectList : qminoa.Webs.PageBase
	{
		public const string UserRoleNone = "0";
		public const string UserRoleAdministrator = "1";
		public const string UserRoleProjectManager = "2";
		public const string UserRoleConsultant = "3";
		protected System.Web.UI.WebControls.LinkButton	LinkButton1;
		protected System.Web.UI.WebControls.Button		NewProjectButton;
		protected System.Web.UI.WebControls.DataGrid	ProjectsGrid;

		private PMUser	 _user;

		private void Page_Load(object sender, System.EventArgs e)
		{
			this.PageBegin("项目管理",true);
			_user = new PMUser(Convert.ToInt16(this.Empid));
			if(_user.Role == UserRoleConsultant || _user.Role == UserRoleNone)
			{
				Response.Redirect(Application["vRoot"]+"/login.aspx");  
			}
			if (!IsPostBack)
			{
				BindProjects();
			}
		}
		
		private void BindProjects()
		{
			ProjectsCollection projectList = Project.GetProjects(_user.UserID, _user.Role);

			SortGridData(projectList, SortField, SortAscending);

			ProjectsGrid.DataSource = projectList;
			ProjectsGrid.DataBind();
		}
		
		private void SortGridData(ProjectsCollection list, string sortField, bool asc)
		{
			ProjectsCollection.ProjectFields sortCol = ProjectsCollection.ProjectFields.InitValue;

			switch(sortField)
			{
				case "Name":
					sortCol = ProjectsCollection.ProjectFields.Name;
					break;
				case "Manager":
					sortCol = ProjectsCollection.ProjectFields.ManagerUserName;
					break;
				case "Completion":
					sortCol = ProjectsCollection.ProjectFields.CompletionDate;
					break;
				case "Duration":
					sortCol = ProjectsCollection.ProjectFields.Duration;
					break;
				default:
					break;
			}

			list.Sort(sortCol, asc);
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.NewProjectButton.Click += new System.EventHandler(this.NewProjectButton_Click);
			this.ProjectsGrid.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.ProjectsGrid_Sort);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void NewProjectButton_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("ProjectDetails.aspx", false);
		}

		protected void ProjectsGrid_Page(Object sender, DataGridPageChangedEventArgs e) 
		{
			ProjectsGrid.CurrentPageIndex = e.NewPageIndex;

			BindProjects();
		}

		private void ProjectsGrid_Sort(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
		{
			SortField = e.SortExpression;

			BindProjects();
		}

		string SortField 
		{
			get 
			{
				object o = ViewState["SortField"];
				if (o == null) 
				{
					return String.Empty;
				}
				return (string)o;
			}

			set 
			{
				if (value == SortField) 
				{
					SortAscending = !SortAscending;
				}
				ViewState["SortField"] = value;
			}
		}

		bool SortAscending 
		{
			get 
			{
				object o = ViewState["SortAscending"];
				if (o == null) 
				{
					return true;
				}
				return (bool)o;
			}

			set 
			{
				ViewState["SortAscending"] = value;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -