DocumentDetails.aspx.cs
上传用户:tree100901
上传日期:2007-06-03
资源大小:2295k
文件大小:9k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Drawing;
  7. using System.Web;
  8. using System.Web.SessionState;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.HtmlControls;
  12. namespace OA
  13. {
  14. /// <summary>
  15. /// DocumentDetails 的摘要说明。
  16. /// </summary>
  17. public class DocumentDetails : System.Web.UI.Page
  18. {
  19. protected System.Web.UI.WebControls.Label Title;
  20. protected System.Web.UI.WebControls.Label Sender;
  21. protected System.Web.UI.WebControls.Label Date;
  22. protected System.Web.UI.WebControls.Label SendType;
  23. protected System.Web.UI.WebControls.TextBox TextBox1;
  24. protected System.Web.UI.HtmlControls.HtmlInputButton Button1;
  25. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
  26. protected System.Data.SqlClient.SqlConnection MyConnection;
  27. public int DID;
  28. public int ACID,AccepterID,AccepterID0;
  29. public string AID,PID,CID,Process,Result,NextAccepter,State,CheckedMarker;
  30. protected System.Web.UI.HtmlControls.HtmlGenericControl DIV1;
  31. protected System.Web.UI.WebControls.Label Result0;
  32. protected System.Web.UI.WebControls.Label DocumentType;
  33. private void Page_Load(object sender, System.EventArgs e)
  34. {
  35. MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
  36. if(Request.Params["DocumentID"]!=null)
  37. {
  38. if(Request.Params["ResultID"]!=null)
  39. DIV1.Visible=false;
  40. DID = Int32.Parse(Request.Params["DocumentID"]);
  41. SqlCommand MyCommand00 = new SqlCommand("PersonID",MyConnection);
  42. MyCommand00.CommandType = CommandType.StoredProcedure;
  43. MyCommand00.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 50));
  44. MyCommand00.Parameters["@Name"].Value = User.Identity.Name;
  45. MyConnection.Open();
  46. SqlDataReader myReader00 =  MyCommand00.ExecuteReader();
  47. try
  48. {
  49. while(myReader00.Read()) 
  50. {
  51. AID = myReader00.GetInt32(0).ToString();
  52. }
  53. myReader00.Close();
  54. }
  55. finally 
  56. {
  57. }
  58. string PROID="";
  59. SqlCommand MyCommand = new SqlCommand("DocumentContents",MyConnection);
  60. MyCommand.CommandType = CommandType.StoredProcedure;
  61. MyCommand.Parameters.Add(new SqlParameter("@DocumentID", SqlDbType.Int, 4));
  62. MyCommand.Parameters["@DocumentID"].Value = Int32.Parse(Request.Params["DocumentID"]);
  63. SqlDataReader myReader =  MyCommand.ExecuteReader();
  64. while(myReader.Read())
  65. PID = myReader["PersonID"].ToString();
  66. Title.Text = myReader["Title"].ToString();
  67. Date.Text = DateTime.Parse(myReader["Date"].ToString()).ToString("yy-MM-dd HH:mm");
  68. if(myReader["Result"].ToString().Trim()!=null)
  69. Result = myReader["Result"].ToString();
  70. if(myReader["Contents"]!=null)
  71. Session["DocuContents"] = myReader["Contents"];
  72. CID = myReader["Process"].ToString();
  73. PROID = myReader["WriterID"].ToString();
  74. CheckedMarker= myReader["CheckedMarker"].ToString().Trim();
  75. int fa = myReader["AccepterID"].ToString().Trim().IndexOf("(");
  76. if(fa==-1)
  77. AccepterID0 =Int32.Parse(myReader["AccepterID"].ToString());
  78. }
  79. myReader.Close();
  80. if(Result.Trim()!="")
  81. Result0.Text = "<br>"+Result;
  82. if(AID.Trim()==PROID.Trim())
  83. DocumentType.Text="(回复文档)";
  84. int FP =  CID.IndexOf("→");
  85. if(FP==-1)
  86. {
  87. SendType.Text="<b>此文档采用的是平行发送方式!<b>";
  88. }
  89. else
  90. {
  91. string NCID=CID.Trim().Replace("(","").Replace(")","");
  92. SendType.Text="<b>此文档采用流程审阅:</b>&nbsp;&nbsp;";
  93. string [] str = NCID.Split(new char[] {'→'});
  94. ACID = Int32.Parse(PID);
  95. for(int i=0; i<str.Length; i++)
  96. {
  97. if(str[i]==AID.ToString()&&(i+1)<str.Length)
  98. ACID=Int32.Parse(str[i+1]);
  99. if(str[str.Length-1]==AID.ToString())
  100. ACID=Int32.Parse(str[0]);
  101. if(str[0]==AccepterID0.ToString())
  102. {
  103. DocumentType.Text="(本文档已经审阅)";
  104. Button1.Visible=false;
  105. }
  106. SqlCommand MyCommand0 = new SqlCommand("PersonName",MyConnection);
  107. MyCommand0.CommandType = CommandType.StoredProcedure;
  108. MyCommand0.Parameters.Add(new SqlParameter("@PersonID", SqlDbType.Int, 4));
  109. MyCommand0.Parameters["@PersonID"].Value = str[i];
  110. if(MyConnection.State.ToString()=="Closed")
  111. MyConnection.Open(); 
  112. SqlDataReader myReader0 =  MyCommand0.ExecuteReader();
  113. while(myReader0.Read())
  114. {
  115. if(myReader0["Name"].ToString()==User.Identity.Name)
  116. Process += "→<Font color='red'>"+myReader0["Name"].ToString()+"</Font>";
  117. else
  118. Process += "→"+myReader0["Name"].ToString();
  119. }
  120. myReader0.Close();
  121. }
  122. SendType.Text += Process.Substring(1);
  123. }
  124. SqlCommand MyCommand1 = new SqlCommand("PersonName",MyConnection);
  125. MyCommand1.CommandType = CommandType.StoredProcedure;
  126. MyCommand1.Parameters.Add(new SqlParameter("@PersonID", SqlDbType.Int, 4));
  127. MyCommand1.Parameters["@PersonID"].Value = Int32.Parse(PID);
  128. SqlDataReader myReader1 =  MyCommand1.ExecuteReader();
  129. while(myReader1.Read()) 
  130. Sender.Text += myReader1["Name"].ToString();
  131. myReader1.Close();
  132. SqlCommand MyCommand2= new SqlCommand("UpdateDocumentState", MyConnection);
  133. MyCommand2.CommandType = CommandType.StoredProcedure;
  134. MyCommand2.Parameters.Add(new SqlParameter("@DocumentID", SqlDbType.Int, 4));
  135. MyCommand2.Parameters["@DocumentID"].Value = DID;
  136. MyCommand2.Parameters.Add(new SqlParameter("@State", SqlDbType.Char,10));
  137. MyCommand2.Parameters["@State"].Value ="1";
  138. MyCommand2.Parameters.Add(new SqlParameter("@Result", SqlDbType.NVarChar,4000));
  139. MyCommand2.Parameters["@Result"].Value = Result;
  140. MyCommand2.Parameters.Add(new SqlParameter("@AccepterID", SqlDbType.Int, 4));
  141. MyCommand2.Parameters["@AccepterID"].Value = AccepterID0;
  142. MyCommand2.ExecuteNonQuery();
  143. MyConnection.Close();
  144. }
  145. // 在此处放置用户代码以初始化页面
  146. }
  147. #region Web 窗体设计器生成的代码
  148. override protected void OnInit(EventArgs e)
  149. {
  150. //
  151. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  152. //
  153. InitializeComponent();
  154. base.OnInit(e);
  155. }
  156. /// <summary>
  157. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  158. /// 此方法的内容。
  159. /// </summary>
  160. private void InitializeComponent()
  161. {    
  162. this.Button1.ServerClick += new System.EventHandler(this.Button1_ServerClick);
  163. this.Load += new System.EventHandler(this.Page_Load);
  164. }
  165. #endregion
  166. private void Button1_ServerClick(object sender, System.EventArgs e)
  167. {
  168. if(CID.Trim()=="0")
  169. {
  170. AccepterID = Int32.Parse(PID);
  171. if(CheckedMarker=="")
  172. CheckedMarker = "("+AID+")";
  173. }
  174. else
  175. {
  176. AccepterID = ACID;
  177. if(CheckedMarker!="")
  178.               CheckedMarker += ",("+AID+")";
  179. else
  180.               CheckedMarker = "("+AID+")";
  181. }
  182. Result += "<br><b>审阅人:</b>"+User.Identity.Name+"&nbsp;&nbsp;<b>回复时间:</b>"+DateTime.Now.ToString()+"<br>"+TextBox1.Text;
  183. MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
  184. SqlCommand MyCommand2= new SqlCommand("UpdateDocument", MyConnection);
  185. MyCommand2.CommandType = CommandType.StoredProcedure;
  186. MyCommand2.Parameters.Add(new SqlParameter("@DocumentID", SqlDbType.Int, 4));
  187. MyCommand2.Parameters["@DocumentID"].Value = DID;
  188. MyCommand2.Parameters.Add(new SqlParameter("@State", SqlDbType.Char,10));
  189. MyCommand2.Parameters["@State"].Value ="0";
  190.     MyCommand2.Parameters.Add(new SqlParameter("@Result", SqlDbType.NVarChar,4000));
  191. MyCommand2.Parameters["@Result"].Value =Result;
  192. MyCommand2.Parameters.Add(new SqlParameter("@CheckedMarker", SqlDbType.NVarChar,120));
  193. MyCommand2.Parameters["@CheckedMarker"].Value =CheckedMarker;
  194. MyCommand2.Parameters.Add(new SqlParameter("@AccepterID", SqlDbType.Int, 4));
  195. MyCommand2.Parameters["@AccepterID"].Value = AccepterID;
  196. MyCommand2.Parameters.Add(new SqlParameter("@PersonID", SqlDbType.Int, 4));
  197. MyCommand2.Parameters["@PersonID"].Value = AID;
  198. if(MyConnection.State.ToString()=="Closed")
  199. MyConnection.Open(); 
  200. MyCommand2.ExecuteNonQuery();
  201. MyConnection.Close();
  202. // Response.Write("<script>alert('')</"+"script>");
  203.             RegisterStartupScript("alert","<script language=javascript>window.alert('文档回复完毕!');window.close();</script>");
  204. MyCommand2.Parameters.Add(new SqlParameter("@CheckedMarker", SqlDbType.NVarChar,120));
  205. MyCommand2.Parameters["@CheckedMarker"].Value =CheckedMarker;
  206. }
  207. }
  208. }