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

OA系统

开发平台:

C#

  1. using System;
  2. using System.IO;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Drawing;
  8. using System.Web;
  9. using System.Web.SessionState;
  10. using System.Web.UI;
  11. using System.Web.UI.WebControls;
  12. using System.Web.UI.HtmlControls;
  13. namespace OA
  14. {
  15. /// <summary>
  16. /// _Default1 的摘要说明。
  17. /// </summary>
  18. public class _Default1 : System.Web.UI.Page
  19. {
  20. protected System.Web.UI.WebControls.Label Label1;
  21. protected Microsoft.Web.UI.WebControls.TreeView TreeView1;
  22. protected System.Web.UI.HtmlControls.HtmlTable SystemManager;
  23. protected System.Web.UI.HtmlControls.HtmlTable Myshortcut;
  24. protected System.Web.UI.HtmlControls.HtmlTable Mylink;
  25. protected System.Data.SqlClient.SqlConnection MyConnection;
  26. private void Page_Load(object sender, System.EventArgs e)
  27. {
  28. CheckUser CHU = new CheckUser();
  29. CHU.UserName = User.Identity.Name;
  30. MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
  31. string datafile = "menu/SystemManageMenu.xml" ;
  32. try
  33. {
  34. DataSet guestData = new DataSet();
  35. FileStream fin ;
  36. fin = new FileStream(Server.MapPath(datafile),FileMode.Open, FileAccess.Read,FileShare.ReadWrite) ; 
  37. guestData.ReadXml(fin);
  38. fin.Close();
  39. DataTable ndt = guestData.Tables[0];
  40. for(int i=0;i<ndt.Rows.Count;i++)
  41. {
  42. HtmlTableRow r = new HtmlTableRow();
  43. HtmlTableCell c = new HtmlTableCell();
  44. c.BgColor = "White";
  45. c.Attributes["Height"] = "20";
  46. c.Attributes.Add("onmouseover", "this.style.backgroundImage='url(images//item_selected_bg.gif)'");
  47. c.Attributes.Add("onmouseout", "this.style.backgroundImage='url(none)'");
  48. c.Style["cursor"] = "hand";
  49. c.Controls.Add(new LiteralControl(""+ndt.Rows[i]["Label"]+""));
  50.         if(CHU.Is_SystemManager() == false)
  51.            c.Attributes.Add("onclick","alert('你没有查看此页面的权限!')");  
  52. else
  53.     c.Attributes.Add("onclick","window.open('"+ndt.Rows[i]["URL"]+"','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,revisable=no,left=100,top=0,width=600,height=250')");  
  54. r.Cells.Add(c);
  55. SystemManager.Rows.Add(r);
  56. }
  57. }
  58. catch
  59. {
  60. }
  61. string shortcut = "menu/shortcut.xml" ;
  62. try
  63. {
  64. DataSet shortcutData = new DataSet();
  65. FileStream fin ;
  66. fin = new FileStream(Server.MapPath(shortcut),FileMode.Open, FileAccess.Read,FileShare.ReadWrite) ; 
  67. shortcutData.ReadXml(fin);
  68. fin.Close();
  69. DataTable ndt = shortcutData.Tables[0];
  70. for(int i=0;i<ndt.Rows.Count;i++)
  71. {
  72. HtmlTableRow r = new HtmlTableRow();
  73. HtmlTableCell c = new HtmlTableCell();
  74. c.BgColor = "White";
  75. c.Attributes["Height"] = "20";
  76. c.Attributes.Add("onmouseover", "this.style.backgroundImage='url(images//item_selected_bg.gif)'");
  77. c.Attributes.Add("onmouseout", "this.style.backgroundImage='url(none)'");
  78. c.Style["cursor"] = "hand";
  79. c.Controls.Add(new LiteralControl(""+ndt.Rows[i]["Label"]+""));
  80. c.Attributes.Add("onclick","window.open('"+ndt.Rows[i]["URL"]+"','Doc','')");  
  81. r.Cells.Add(c);
  82. Myshortcut.Rows.Add(r);
  83. }
  84. }
  85. catch
  86. {
  87. }
  88. string link = "menu/link.xml" ;
  89. try
  90. {
  91. DataSet linkData = new DataSet();
  92. FileStream fin ;
  93. fin = new FileStream(Server.MapPath(link),FileMode.Open, FileAccess.Read,FileShare.ReadWrite) ; 
  94. linkData.ReadXml(fin);
  95. fin.Close();
  96. DataTable ndt = linkData.Tables[0];
  97. for(int i=0;i<ndt.Rows.Count;i++)
  98. {
  99. HtmlTableRow r = new HtmlTableRow();
  100. HtmlTableCell c = new HtmlTableCell();
  101. c.BgColor = "White";
  102. c.Attributes["Height"] = "20";
  103. c.Attributes.Add("onmouseover", "this.style.backgroundImage='url(images//item_selected_bg.gif)'");
  104. c.Attributes.Add("onmouseout", "this.style.backgroundImage='url(none)'");
  105. c.Style["cursor"] = "hand";
  106. c.Controls.Add(new LiteralControl(""+ndt.Rows[i]["Label"]+""));
  107. c.Attributes.Add("onclick","window.open('"+ndt.Rows[i]["URL"]+"','_blank','')");  
  108. r.Cells.Add(c);
  109. Mylink.Rows.Add(r);
  110. }
  111. }
  112. catch
  113. {
  114. }
  115. DataSet ds = new DataSet();
  116. SqlDataAdapter MyCommand=new SqlDataAdapter("SystemSelect",MyConnection);
  117. MyCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
  118. if(MyConnection.State.ToString()=="Closed")
  119. MyConnection.Open(); 
  120. MyCommand.Fill(ds,"Root");
  121. DataTable dt = ds.Tables["Root"];
  122. DataRow dtr = dt.NewRow();
  123. dtr["SystemID"]="0";
  124. dtr["SystemName"]="文件管理员";
  125. dt.Rows.Add(dtr);
  126. SqlDataAdapter MyCommand3=new SqlDataAdapter("OrganizationSelect ",MyConnection);
  127. MyCommand3.SelectCommand.CommandType = CommandType.StoredProcedure;
  128. MyCommand3.Fill(ds,"tree2");
  129. SqlDataAdapter MyCommand1 = new SqlDataAdapter("PersonIDTree0",MyConnection);
  130. MyCommand1.SelectCommand.CommandType = CommandType.StoredProcedure;
  131. MyCommand1.SelectCommand.Parameters.Add(new SqlParameter("@JobID", SqlDbType.NVarChar, 50));
  132. MyCommand1.SelectCommand.Parameters["@JobID"].Value = "%";
  133. MyCommand1.Fill(ds,"tree3");
  134. SqlDataAdapter MyCommand2 = new SqlDataAdapter("PersonIDTree0",MyConnection);
  135. MyCommand2.SelectCommand.CommandType = CommandType.StoredProcedure;
  136. MyCommand2.SelectCommand.Parameters.Add(new SqlParameter("@JobID", SqlDbType.NVarChar, 50));
  137. MyCommand2.SelectCommand.Parameters["@JobID"].Value = "6";
  138. MyCommand2.Fill(ds,"tree");
  139. for(int i = 0; i<ds.Tables["Root"].Rows.Count; i++)
  140. {
  141. Microsoft.Web.UI.WebControls.TreeNode tree1 = new Microsoft.Web.UI.WebControls.TreeNode();
  142. tree1.ID = ds.Tables["Root"].Rows[i]["SystemID"].ToString();
  143. tree1.Text = ds.Tables["Root"].Rows[i]["SystemName"].ToString();
  144. TreeView1.Nodes.Add(tree1);
  145. for(int j = 0; j<ds.Tables["tree2"].Rows.Count; j++)
  146. {
  147. Microsoft.Web.UI.WebControls.TreeNode tree2;
  148. string str = ds.Tables["tree2"].Rows[j]["SystemID"].ToString();
  149. string [] str1 = str.Split( new char[]{','});
  150. foreach (string s in str1) 
  151. {
  152. if(s == tree1.ID)
  153. {
  154. tree2 = new Microsoft.Web.UI.WebControls.TreeNode();
  155. tree2.ID = ds.Tables["tree2"].Rows[j]["OrganizationID"].ToString();
  156. tree2.Text = ds.Tables["tree2"].Rows[j]["OrganizationName"].ToString();
  157. tree1.Nodes.Add(tree2);
  158. for(int k = 0; k<ds.Tables["tree3"].Rows.Count; k++)
  159. {
  160. Microsoft.Web.UI.WebControls.TreeNode tree3;
  161. string str0 = ds.Tables["tree3"].Rows[k]["OrganizationID"].ToString();
  162. string [] str2 = str0.Split( new char[]{','});
  163. foreach (string t in str2) 
  164. {
  165. if(t == tree2.ID)
  166. {
  167. tree3 = new Microsoft.Web.UI.WebControls.TreeNode();
  168. tree3.ID = ds.Tables["tree3"].Rows[k]["PersonID"].ToString();
  169. tree3.Text = "<input type='button' onclick=javascript:window.open('ShortcutNewMessage.aspx?Accepter="+ds.Tables["tree3"].Rows[k]["Name"].ToString()+"','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,revisable=no,left=100,top=0,width=600,height=500'); value="+ds.Tables["tree3"].Rows[k]["Name"].ToString()+" style='COLOR: background; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none'>";
  170. tree2.Nodes.Add(tree3);
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. for(int l = 0; l<ds.Tables["tree"].Rows.Count; l++)
  178. {
  179. if(tree1.ID=="0")
  180. {
  181. Microsoft.Web.UI.WebControls.TreeNode tree2;
  182. tree2 = new Microsoft.Web.UI.WebControls.TreeNode();
  183. tree2.ID = ds.Tables["tree"].Rows[l]["PersonID"].ToString();
  184. tree2.Text = "<input type='button' onclick=javascript:window.open('ShortcutNewMessage.aspx?Accepter="+ds.Tables["tree"].Rows[l]["Name"].ToString()+"','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,revisable=no,left=100,top=0,width=600,height=500'); value="+ds.Tables["tree"].Rows[l]["Name"].ToString()+" style='COLOR: background; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none'>";
  185. tree1.Nodes.Add(tree2);
  186. }
  187. }
  188. } // 在此处放置用户代码以初始化页面
  189. SqlDataAdapter MyCommand11 = new SqlDataAdapter("NotificationPrompt",MyConnection);
  190. MyCommand11.SelectCommand.CommandType = CommandType.StoredProcedure;
  191. MyCommand11.Fill(ds,"NotificationPrompt");
  192. for(int i =0; i<ds.Tables["NotificationPrompt"].Rows.Count;i++)
  193. {
  194. if(ds.Tables["NotificationPrompt"].Rows[i]["Contents"].ToString()!="")
  195. Response.Write("<script>window.open('notification.aspx?NotificationID="+ds.Tables["NotificationPrompt"].Rows[i]["NotificationID"].ToString().Trim()+"','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,revisable=no,left=100,top=0,width=300,height=300')</script>");
  196. }
  197. MyConnection.Close(); 
  198. }
  199. #region Web 窗体设计器生成的代码
  200. override protected void OnInit(EventArgs e)
  201. {
  202. //
  203. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  204. //
  205. InitializeComponent();
  206. base.OnInit(e);
  207. }
  208. /// <summary>
  209. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  210. /// 此方法的内容。
  211. /// </summary>
  212. private void InitializeComponent()
  213. {    
  214. this.Load += new System.EventHandler(this.Page_Load);
  215. }
  216. #endregion
  217. }
  218. }