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

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 UDS.Components;
  12. using System.Data.SqlClient;
  13. namespace UDS.SubModule.UnitiveDocument.Flow
  14. {
  15. /// <summary>
  16. /// Listview 的摘要说明。
  17. /// </summary>
  18. public class Listview : System.Web.UI.Page
  19. {
  20. protected System.Web.UI.WebControls.DataGrid dgFlowList;
  21. protected System.Web.UI.WebControls.LinkButton lbMyApprove;
  22. protected System.Web.UI.WebControls.LinkButton LinkButton1;
  23. protected System.Web.UI.WebControls.LinkButton lbMyApproved;
  24. protected System.Web.UI.WebControls.Button cmdDeleteFlow;
  25. protected System.Web.UI.WebControls.LinkButton lbManageFlow;
  26. protected System.Web.UI.WebControls.Button cmdManageStyle;
  27. protected System.Web.UI.WebControls.Button cmdNewFlow;
  28. protected System.Web.UI.HtmlControls.HtmlTableCell ManageFlow;
  29. public string UserName;
  30. protected System.Web.UI.WebControls.LinkButton lbMyDraft;
  31. public bool bManageFlow;
  32. private void Page_Load(object sender, System.EventArgs e)
  33. {
  34. // 在此处放置用户代码以初始化页面
  35. if(!Page.IsPostBack)
  36. Bangding();
  37. UserName = Request.Cookies["UserName"].Value.ToString();
  38. UDS.Components.DocumentFlow df =new UDS.Components.DocumentFlow();
  39. bManageFlow = df.GetAccessPermission(Request.Cookies["ActiveNodeID"]!=null?Int32.Parse(Request.Cookies["ActiveNodeID"].Value):0,UserName,4);
  40. df = null;
  41. }
  42. #region 绑定DBGRID
  43. private void Bangding()
  44. {
  45. SqlDataReader dr; //存放人物的数据
  46. Database mySQL = new Database();
  47. SqlParameter[] parameters = {
  48. mySQL.MakeInParam("@FlowID",SqlDbType.Int ,4,0)
  49. };
  50. mySQL.RunProc("sp_Flow_GetFlow",parameters,out dr);
  51. DataTable dt =Tools.ConvertDataReaderToDataTable(dr);
  52. dr.Close();
  53. dgFlowList.DataSource = dt.DefaultView;
  54. dgFlowList.DataBind();
  55. }
  56. #endregion
  57. #region 翻页事件
  58. public void DataGrid_PageChanged(object sender,DataGridPageChangedEventArgs e)
  59. {
  60. dgFlowList.CurrentPageIndex = e.NewPageIndex;
  61. Bangding();
  62. }
  63. #endregion
  64. #region Web Form Designer generated code
  65. override protected void OnInit(EventArgs e)
  66. {
  67. //
  68. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  69. //
  70. InitializeComponent();
  71. base.OnInit(e);
  72. }
  73. /// <summary>
  74. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  75. /// 此方法的内容。
  76. /// </summary>
  77. private void InitializeComponent()
  78. {    
  79. this.cmdNewFlow.Click += new System.EventHandler(this.cmdNewFlow_Click);
  80. this.cmdDeleteFlow.Click += new System.EventHandler(this.cmdDeleteFlow_Click);
  81. this.cmdManageStyle.Click += new System.EventHandler(this.cmdManageStyle_Click);
  82. this.lbMyApprove.Click += new System.EventHandler(this.lbMyApprove_Click);
  83. this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
  84. this.lbMyApproved.Click += new System.EventHandler(this.lbMyApproved_Click);
  85. this.lbMyDraft.Click += new System.EventHandler(this.lbMyDraft_Click);
  86. this.Load += new System.EventHandler(this.Page_Load);
  87. }
  88. #endregion
  89. public void MyDataGrid_Delete(object sender,DataGridCommandEventArgs e)
  90. {
  91. string FlowID = dgFlowList.DataKeys[e.Item.ItemIndex].ToString();
  92. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  93. df.DeleteFlow(Int32.Parse(FlowID));
  94. df = null;
  95. Bangding();
  96. }
  97. private void lbMyApprove_Click(object sender, System.EventArgs e)
  98. {
  99. Server.Transfer("ListDocument.aspx?DisplayType=1");
  100. }
  101. private void LinkButton1_Click(object sender, System.EventArgs e)
  102. {
  103. Server.Transfer("ListDocument.aspx?DisplayType=2");
  104. }
  105. private void lbMyApproved_Click(object sender, System.EventArgs e)
  106. {
  107. Server.Transfer("ListDocument.aspx?DisplayType=3");
  108. }
  109. private void lbMyDraft_Click(object sender, System.EventArgs e)
  110. {
  111. Server.Transfer("DraftList.aspx");
  112. }
  113. private void cmdNewFlow_Click(object sender, System.EventArgs e)
  114. {
  115. Server.Transfer("EditFlow.aspx?FlowID=0");
  116. }
  117. private void cmdDeleteFlow_Click(object sender, System.EventArgs e)
  118. {
  119. long FlowID;
  120. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  121. string IDstr = this.GetSelectedItemID(dgFlowList,"FlowID");
  122. if(IDstr.Length >0)
  123. {
  124. if(IDstr.IndexOf(",")>0)
  125. Response.Write("<script lanauage='javascript'>alert('不能同时删除多个流程!');</script>");
  126. else
  127. {
  128. FlowID = Int32.Parse(IDstr);
  129. if(df.DeleteFlow(FlowID)!=0)
  130. Response.Write("<script lanauage='javascript'>alert('流程删除失败!此流程正在被一个文档使用!');</script>");
  131. else
  132. Response.Write("<script lanauage='javascript'>alert('流程删除成功!');</script>");
  133. }
  134. }
  135. else
  136. Response.Write("<script lanauage='javascript'>alert('请选择流程!');</script>");
  137. Bangding();
  138. //Response.AddHeader("Refresh","1");
  139. }
  140. private string GetSelectedItemID(DataGrid dg,string controlID)
  141. {
  142. String selectedID;
  143. selectedID = "";
  144. //遍历DataGrid获得checked的ID
  145. foreach (DataGridItem item in dg.Items)
  146. {
  147. if(((CheckBox)item.FindControl(controlID)).Checked==true )
  148. selectedID += dg.DataKeys[item.ItemIndex] + ",";
  149. }
  150. if(selectedID.Length>0)
  151. selectedID=selectedID.Substring(0,selectedID.Length-1);
  152. return selectedID;
  153. }
  154. private void Button1_Click(object sender, System.EventArgs e)
  155. {
  156. Server.Transfer("ManageTache.aspx");
  157. }
  158. private void cmdManageStyle_Click(object sender, System.EventArgs e)
  159. {
  160. Server.Transfer("ManageStyle.aspx");
  161. }
  162. }
  163. }