Project.aspx.cs
上传用户:xgw_05
上传日期:2009-12-11
资源大小:20208k
文件大小:10k
源码类别:

OA系统

开发平台:

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