ProjectDetail.aspx.cs
上传用户:jdb8708888
上传日期:2013-05-29
资源大小:19971k
文件大小:10k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. using UDS.Components ;
  13. namespace UDS.SubModule.UnitiveDocument
  14. {
  15. /// <summary>
  16. /// ProjectDetail 的摘要说明。
  17. /// </summary>
  18. public class ProjectDetail : System.Web.UI.Page
  19. {
  20. protected System.Web.UI.WebControls.Label lblClassName;
  21. protected System.Web.UI.WebControls.Label lblBuildDate;
  22. protected System.Web.UI.WebControls.Label lblEndDate;
  23. protected System.Web.UI.WebControls.Label lblParentClassName;
  24. protected System.Web.UI.WebControls.Label lblDescription;
  25. protected System.Web.UI.WebControls.Label lblFinishedScale;
  26. protected System.Web.UI.WebControls.Label lblSubClass;
  27. protected System.Web.UI.WebControls.Label lblMember;
  28. protected System.Web.UI.WebControls.Label lblParentLeader;
  29. protected System.Web.UI.WebControls.Label lblLeader;
  30. public int classID = 0;
  31. protected HttpCookie UserCookie;
  32. protected System.Web.UI.WebControls.Label lblManageProject;
  33. protected System.Web.UI.WebControls.Label lblManageDirectory;
  34. protected System.Web.UI.WebControls.Label lblComposeMail;
  35. protected System.Web.UI.WebControls.Label lblDeliveryDoc;
  36. protected System.Web.UI.WebControls.Label lblShowMember;
  37. protected System.Web.UI.WebControls.Label lblManagePermission;
  38. protected System.Web.UI.HtmlControls.HtmlTable tblMailList;
  39. protected System.Web.UI.WebControls.Label lblSubscribe;
  40. protected System.Web.UI.WebControls.Label lblRemove;
  41. public static string Username;
  42. public static string Action="";
  43. protected System.Web.UI.WebControls.Image imgSubscribe;
  44. protected System.Web.UI.WebControls.Image imgComposeMail;
  45. protected System.Web.UI.WebControls.Image imgDeliveryDoc;
  46.     protected System.Web.UI.WebControls.Image imgManageDirectory;
  47. protected System.Web.UI.WebControls.Image imgShowMember;
  48. protected System.Web.UI.WebControls.Image imgManagePermission;
  49. protected System.Web.UI.WebControls.Image imgManageProject;
  50. protected System.Web.UI.WebControls.Image imgRemove;
  51. public static bool bSubscription;
  52. private void Page_Load(object sender, System.EventArgs e)
  53. {
  54. if(Request.QueryString["classID"]!=null)
  55. {
  56. classID = Int32.Parse(Request.QueryString["classID"]);
  57. }
  58. Action  = (Request.QueryString["Action"]!=null)?Request.QueryString["Action"].ToString():"";
  59. if(Action=="5") SubscribeProject();
  60. UserCookie = Request.Cookies["Username"];
  61. Username   = UserCookie.Value.ToString(); 
  62. if(Request.QueryString["Subscription"]==null)
  63. {
  64. bSubscription= false;
  65. }
  66. else
  67. {
  68. bSubscription = Int32.Parse(Request.QueryString["Subscription"])>0?true:false;
  69. }
  70. if(!Page.IsPostBack)
  71. {
  72. PopulateData();
  73. }
  74. }
  75. #region 显示数据
  76. /// <summary>
  77. /// 显示数据
  78. /// </summary>
  79. private void PopulateData()
  80. {
  81. #region 初始化数据
  82. DataTable dataTable      = new DataTable();
  83. SqlDataReader dataReader = null;
  84. ProjectClass pjt  = new ProjectClass ();
  85. MailClass mail  = new MailClass();
  86. DocumentClass doc  = new DocumentClass();
  87. #endregion
  88. #region 获取项目信息
  89. dataReader = pjt.GetClassInfo(classID);
  90. try 
  91. {
  92. if(dataReader.Read())
  93. {   
  94. this.lblClassName.Text  = dataReader[0].ToString();
  95. this.lblParentClassName.Text = dataReader[2].ToString();
  96. this.lblBuildDate.Text      = dataReader[3].ToString();
  97. this.lblEndDate.Text  = dataReader[4].ToString();
  98. this.lblFinishedScale.Text   = dataReader[8].ToString();
  99. this.lblDescription.Text  = dataReader[7].ToString();
  100. }
  101. }
  102. catch(Exception ex)
  103. {
  104. UDS.Components.Error.Log(ex.ToString());
  105. Server.Transfer("../Error.aspx");
  106. }
  107. dataReader = null;
  108. #endregion
  109. #region 获取子项目信息
  110. dataReader = pjt.GetSubClassInfo(classID);
  111. try 
  112. {
  113. while(dataReader.Read())
  114. {   
  115. this.lblSubClass.Text += "<a href='Switch.aspx?Action=1&ClassID="+dataReader[0].ToString()+"'>"+dataReader[1].ToString()+"</a>&nbsp;&nbsp;";
  116. }
  117. if(this.lblSubClass.Text=="") this.lblSubClass.Text="无";
  118. }
  119. catch(Exception ex)
  120. {
  121. UDS.Components.Error.Log(ex.ToString());
  122. Server.Transfer("../Error.aspx");
  123. }
  124. dataReader = null;
  125. #endregion
  126. #region 获取项目成员信息
  127. dataReader = pjt.GetMemberInClass(classID);
  128. try 
  129. {
  130. while(dataReader.Read())
  131. {   
  132. this.lblMember.Text  += "<a href='Mail/Compose.aspx?Action=3"
  133. +"&ClassID="+classID.ToString()
  134. +"&Username="+dataReader["Staff_Name"].ToString()
  135. +"&Name="+Server.UrlEncode(dataReader["RealName"].ToString())
  136. +"'>"
  137. +dataReader["RealName"].ToString()
  138. +"</a> &nbsp;&nbsp;";
  139. }
  140. if(this.lblMember.Text=="") this.lblMember.Text="无";
  141. }
  142. catch(Exception ex)
  143. {
  144. UDS.Components.Error.Log(ex.ToString());
  145. Server.Transfer("../Error.aspx");
  146. }
  147. dataReader = null;
  148. #endregion
  149. #region 获取项目上级负责人信息
  150. dataReader = pjt.GetParentLeader(classID);
  151. try 
  152. {
  153. if(dataReader.Read())
  154. {   
  155. this.lblParentLeader.Text  += "<a href='Mail/Compose.aspx?Action=3"
  156. +"&ClassID="+classID.ToString()
  157. +"&Username="+dataReader["Staff_Name"].ToString()
  158. +"&Name="+Server.UrlEncode(dataReader["RealName"].ToString())
  159. +"'>"
  160. +dataReader["RealName"].ToString()
  161. +"</a> &nbsp;&nbsp;";
  162. }
  163. if(this.lblParentLeader.Text=="") this.lblParentLeader.Text="无";
  164. }
  165. catch(Exception ex)
  166. {
  167. UDS.Components.Error.Log(ex.ToString());
  168. Server.Transfer("../Error.aspx");
  169. }
  170. dataReader = null;
  171. #endregion
  172. #region 获取项目负责人信息
  173. dataReader = pjt.GetLeader(classID);
  174. try 
  175. {
  176. while(dataReader.Read())
  177. {   
  178. this.lblLeader.Text  += "<a href='Mail/Compose.aspx?Action=3"
  179. +"&ClassID="+classID.ToString()
  180. +"&Username="+dataReader["Staff_Name"].ToString()
  181. +"&Name="+Server.UrlEncode(dataReader["RealName"].ToString())
  182. +"'>"
  183. +dataReader["RealName"].ToString()
  184. +"</a> &nbsp;&nbsp;";
  185. }
  186. if(this.lblLeader.Text=="") this.lblLeader.Text="无";
  187. }
  188. catch(Exception ex)
  189. {
  190. UDS.Components.Error.Log(ex.ToString());
  191. Server.Transfer("../Error.aspx");
  192. }
  193. dataReader = null;
  194. #endregion
  195. #region 注释
  196. /*
  197. #region 根据权限显示相关功能标题
  198. // 设置缺省值
  199. int cstRightToApproveDocument  = 2;
  200. int cstRightToViewDocument = 10;
  201. int cstRightToBuildNode   = 5;
  202. int cstDisplayMember = 6;
  203. int cstTeamRight = 7;
  204. int cstComposeMail = 11;
  205. int cstDeliveryDoc = 11;
  206. int cstProjectMove = 5;
  207. this.lblManageProject.Visible   = pjt.GetAccessPermission(classID,Username,cstRightToBuildNode);
  208. this.imgManageProject .Visible  = this.lblManageProject .Visible ;
  209. this.lblManageDirectory.Visible = pjt.GetAccessPermission(classID,Username,cstRightToBuildNode);
  210. this.imgManageDirectory .Visible= this.lblManageDirectory .Visible ;
  211. this.lblComposeMail.Visible     = pjt.GetAccessPermission(classID,Username,cstComposeMail);
  212. this.imgComposeMail .Visible    = this.lblComposeMail .Visible ;
  213. this.lblDeliveryDoc.Visible     = pjt.GetAccessPermission(classID,Username,cstDeliveryDoc);
  214. this.imgDeliveryDoc.Visible     = this.lblDeliveryDoc .Visible ;
  215. this.lblShowMember.Visible      = pjt.GetAccessPermission(classID,Username,cstDisplayMember);
  216. this.imgShowMember .Visible     = this.lblShowMember .Visible ;
  217. this.lblManagePermission.Visible= pjt.GetAccessPermission(classID,Username,cstTeamRight);
  218. this.imgManagePermission .Visible = this.lblManagePermission .Visible ;
  219. this.lblRemove.Visible = pjt.GetAccessPermission(classID,Username,cstProjectMove);
  220. this.imgRemove.Visible = this.lblRemove.Visible;
  221. #endregion
  222. #region 根据权限取出邮件数据
  223. /// <summary>
  224. /// 将某用户的取出邮件数据
  225. /// </summary>
  226. dataTable   = mail.GetClassMails(classID,UserCookie.Value.ToString());
  227. dgMailList.DataSource = dataTable.DefaultView;
  228. dgMailList.DataBind(); 
  229. mail = null;
  230. #endregion
  231. #region 根据权限取出文档数据
  232. /// <summary>
  233. /// 将某用户的文档数据取出
  234. /// </summary>
  235. if(pjt.GetAccessPermission(classID,Username,cstRightToViewDocument)||bSubscription)
  236. {
  237. dataTable   = doc.GetClassDocs(classID);
  238. dgDocList.DataSource  = dataTable.DefaultView;
  239. dgDocList.DataBind(); 
  240. dataTable = null;
  241. }
  242. else
  243. {
  244. IMG1.Visible   = false;
  245. IMG4.Visible      = false;
  246. dgDocList.Visible = false;
  247. }
  248. #endregion
  249. #region 根据权限取出某项目的审批文档数据
  250. /// <summary>
  251. /// 将某项目的审批文档数据取出
  252. /// </summary>
  253. if(pjt.GetAccessPermission(classID,Username,cstRightToApproveDocument))
  254. {
  255. dataTable          = doc.GetApproveClassDocs(classID);
  256. dgAppDocList.DataSource  = dataTable.DefaultView;
  257. dgAppDocList.DataBind(); 
  258. dataTable = null;
  259. doc   = null;
  260. }
  261. else
  262. {
  263. IMG3.Visible  = false;
  264. dgAppDocList.Visible = false;
  265. lblApp.Visible       = false;
  266. }
  267. #endregion
  268. */
  269. #endregion
  270. }
  271. #endregion
  272. #region 订阅项目
  273. /// <summary>
  274. /// 订阅项目
  275. /// </summary>
  276. private void SubscribeProject() 
  277. {
  278. ProjectClass prj = new ProjectClass();
  279. try
  280. {
  281. prj.Subscribe(Username,classID);
  282. prj = null;
  283. Response.Write("<script language=javascript>alert('订阅成功!');</script>");
  284. }
  285. catch(Exception ex)
  286. {
  287. UDS.Components.Error.Log(ex.ToString());
  288. Server.Transfer("../Error.aspx");
  289. }
  290. }
  291. #endregion
  292. #region Web Form Designer generated code
  293. override protected void OnInit(EventArgs e)
  294. {
  295. //
  296. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  297. //
  298. InitializeComponent();
  299. base.OnInit(e);
  300. }
  301. /// <summary>
  302. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  303. /// 此方法的内容。
  304. /// </summary>
  305. private void InitializeComponent()
  306. {    
  307. this.Load += new System.EventHandler(this.Page_Load);
  308. }
  309. #endregion
  310. }
  311. }