ShowAccount.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:8k
源码类别:

.net编程

开发平台:

Others

  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 qminoa.DA;
  12. using qminoa.Common;  
  13. namespace qminoa.Webs.FM
  14. {
  15. public class ShowAccount : qminoa.Webs.PageBase
  16. {
  17. protected System.Web.UI.WebControls.ImageButton cmdCancel;
  18. protected System.Web.UI.WebControls.ImageButton cmdFinish;
  19. protected System.Web.UI.WebControls.ImageButton cmdLast;
  20. protected System.Web.UI.WebControls.Button cmdDelAll;
  21. protected System.Web.UI.WebControls.Button cmdAddAll;
  22. protected System.Web.UI.WebControls.Button cmdDel;
  23. protected System.Web.UI.WebControls.Button cmdAdd;
  24. protected System.Web.UI.WebControls.Label Label5;
  25. protected System.Web.UI.WebControls.Label Label4;
  26. protected System.Web.UI.WebControls.ListBox lstSelEmp;
  27. protected System.Web.UI.WebControls.Label Label6;
  28. protected System.Web.UI.WebControls.Label Label2;
  29. protected System.Web.UI.WebControls.Label Label3;
  30. protected System.Web.UI.WebControls.DropDownList BranchDropList;
  31. protected System.Web.UI.WebControls.DropDownList DepartmentDropList;
  32. protected System.Web.UI.WebControls.ListBox UserList;
  33. protected System.Web.UI.WebControls.Label Label1;
  34. private void Page_Load(object sender, System.EventArgs e)
  35. {
  36. if(!IsPostBack)
  37. {
  38. this.PageBegin("文档管理",true);
  39. AdminDB admin = new AdminDB();
  40. BranchDropList.DataSource=admin.GetAllBranch();
  41. BranchDropList.DataBind();
  42. BranchDropList.Items[0].Selected=true;
  43. DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
  44. DepartmentDropList.DataBind();
  45. DepartmentDropList.Items[0].Selected=true;
  46. UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
  47. UserList.DataTextField = "EmpName";
  48. UserList.DataValueField = "EmpID";
  49. UserList.DataBind();
  50. }
  51. }
  52. #region Web Form Designer generated code
  53. override protected void OnInit(EventArgs e)
  54. {
  55. //
  56. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  57. //
  58. InitializeComponent();
  59. base.OnInit(e);
  60. }
  61. /// <summary>
  62. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  63. /// 此方法的内容。
  64. /// </summary>
  65. private void InitializeComponent()
  66. {    
  67. this.DepartmentDropList.SelectedIndexChanged += new System.EventHandler(this.DepartmentDropList_SelectedIndexChanged);
  68. this.cmdAdd.Click += new System.EventHandler(this.cmdAdd_Click);
  69. this.cmdDel.Click += new System.EventHandler(this.cmdDel_Click);
  70. this.cmdAddAll.Click += new System.EventHandler(this.cmdAddAll_Click);
  71. this.cmdDelAll.Click += new System.EventHandler(this.cmdDelAll_Click);
  72. this.BranchDropList.SelectedIndexChanged += new System.EventHandler(this.BranchDropList_SelectedIndexChanged);
  73. this.cmdLast.Click += new System.Web.UI.ImageClickEventHandler(this.cmdLast_Click);
  74. this.cmdFinish.Click += new System.Web.UI.ImageClickEventHandler(this.cmdFinish_Click);
  75. this.cmdCancel.Click += new System.Web.UI.ImageClickEventHandler(this.cmdCancel_Click);
  76. this.Load += new System.EventHandler(this.Page_Load);
  77. }
  78. #endregion
  79. private void cmdAdd_Click(object sender, System.EventArgs e)
  80. {
  81. bool exist=false;
  82. foreach( ListItem li in lstSelEmp.Items)
  83. {
  84. if(li.Value==UserList.SelectedItem.Value)
  85. {
  86. exist=true;
  87. }
  88. }
  89. if(exist==false)
  90. {
  91. lstSelEmp.Items.Add(new ListItem(UserList.SelectedItem.Text,UserList.SelectedItem.Value));
  92. }
  93. }
  94. private void cmdDel_Click(object sender, System.EventArgs e)
  95. {
  96. lstSelEmp.Items.Remove(lstSelEmp.SelectedItem);
  97. }
  98. private void cmdDelAll_Click(object sender, System.EventArgs e)
  99. {
  100. for(int i=0;i<lstSelEmp.Items.Count; )
  101. lstSelEmp.Items.Remove(lstSelEmp.Items[i]);
  102. }
  103. private void cmdAddAll_Click(object sender, System.EventArgs e)
  104. {
  105. foreach(ListItem li in UserList.Items)
  106. {
  107. bool exist=false;
  108. foreach( ListItem lised in lstSelEmp.Items)
  109. if(lised.Value==li.Value)
  110. exist=true;
  111. if(exist==false)
  112. lstSelEmp.Items.Add(new ListItem(li.Text,li.Value));
  113. }
  114. }
  115. private void cmdLast_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  116. {
  117. Response.Redirect("SetRightType.aspx?type=0",false);
  118. }
  119. private void cmdFinish_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  120. {
  121. int righttype=Convert.ToInt32(Session["RightType"]);
  122. int num=lstSelEmp.Items.Count;//所选的用户数量
  123. for(int i=0;i<lstSelEmp.Items.Count;i++ )
  124. {
  125. FileRight fright =new FileRight();
  126. int empid=Convert.ToInt32(lstSelEmp.Items[i].Value);
  127. if(righttype==4)
  128. {
  129. fright.SaveDocFolderRight(GetSaveData_Folder(empid),1);
  130. }
  131. else
  132. {
  133.    fright.SaveDocRight(GetSaveData_Doc(empid),1);
  134. }
  135. }
  136. int type=Convert.ToInt32(Session["Type"]) ;
  137. int doc_id=Convert.ToInt32(Session["_docid"]);
  138. int fid=Convert.ToInt32(Session["_FolderId"]);
  139. if(righttype==4)
  140. {
  141. if(type==-2)
  142. {
  143.     Response.Redirect("fmNewFolder.aspx?righttype=4&type=-2&id="+fid,false); 
  144. }
  145. else
  146. {
  147. Response.Redirect("fmNewFolder.aspx?docid="+doc_id+"&id="+fid+"&type=-3",false);
  148. }
  149. }
  150. if(righttype==5)
  151. {
  152. if(type==-2)
  153. {
  154.     Response.Redirect("fmNewFile.aspx?righttype=5&type=-2&did="+doc_id+"&fid="+fid,false); 
  155. }
  156. else
  157. {
  158.    Response.Redirect("fmNewFile.aspx?did="+doc_id+"&fid="+fid+"&type=-3",false);
  159. }
  160. }
  161. }
  162. private void cmdCancel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  163. {
  164. int righttype;
  165. int fid;
  166. int doc_id;
  167. righttype=Convert.ToInt32(Session["RightType"]);
  168. fid=Convert.ToInt32(Session["_FolderId"]);
  169. doc_id=Convert.ToInt32(Session["_docid"]);
  170. if(righttype==4)
  171.    Response.Redirect("fmNewFolder.aspx?docid="+doc_id+"&id="+fid+"&type=-3",false);
  172. }
  173. else if(righttype==5)
  174. {
  175.   Response.Redirect("fmNewFile.aspx?did="+doc_id+"&fid="+fid+"&type=-3",false);
  176. }
  177. }
  178. public FileData GetSaveData_Doc(int EmpId)
  179. {
  180. int DocId;
  181. int type=Convert.ToInt32(Session["type"].ToString(),10);
  182. if(type==-2)
  183. {
  184. DocId=0; 
  185. }
  186. else
  187. {
  188. DocId=Convert.ToInt32(Session["_docid"]);
  189. }
  190. FileData rightdata=new FileData();
  191. DataTable userdata =rightdata.Tables[FileData.FMDOCFOLDERCTR_TABLE];
  192. DataRow row =userdata.NewRow();  
  193. row[0]=0;
  194. row[1]=DocId;
  195. row[2]=0;
  196. row[3]=EmpId;
  197. row[4]=0;
  198. row[5]=0;                        
  199. row[6]=1;
  200. row[7]=EmpId;
  201. userdata.Rows.Add(row);
  202. userdata.AcceptChanges();
  203. rightdata.AcceptChanges();
  204. return rightdata;
  205. }
  206. public FileData GetSaveData_Folder(int EmpId)
  207. {
  208. int FolderId;
  209. int type=Convert.ToInt32(Session["type"].ToString(),10);
  210. if(type==-2)
  211. {
  212.    FolderId=0; 
  213. }
  214. else
  215. {
  216. FolderId=Convert.ToInt32(Session["_FolderId"]);
  217. }
  218. FileData rightdata=new FileData();
  219. DataTable userdata =rightdata.Tables[FileData.FMDOCFOLDERCTR_TABLE];
  220. DataRow row =userdata.NewRow();  
  221. row[0]=0;
  222. row[1]=FolderId;
  223. row[2]=0;
  224. row[3]=EmpId;
  225. row[4]=0;
  226. row[5]=0;                     
  227. row[6]=1;
  228. row[7]=EmpId;
  229. userdata.Rows.Add(row);
  230. userdata.AcceptChanges();
  231. rightdata.AcceptChanges();
  232. return rightdata;
  233. }
  234. private void BranchDropList_SelectedIndexChanged(object sender, System.EventArgs e)
  235. {
  236. AdminDB admin = new AdminDB();
  237. DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
  238. DepartmentDropList.DataBind();
  239. if(DepartmentDropList.Items.Count !=0)
  240. {
  241. UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
  242. UserList.DataTextField = "EmpName";
  243. UserList.DataValueField = "EmpID";
  244. UserList.DataBind();
  245. }
  246. else
  247. {
  248. UserList.Items.Clear();
  249. }
  250. }
  251. private void DepartmentDropList_SelectedIndexChanged(object sender, System.EventArgs e)
  252. {
  253. AdminDB admin = new AdminDB();
  254. UserList.DataSource=admin.GetEmpInfo(Int32.Parse(DepartmentDropList.SelectedItem.Value),"dep");
  255. UserList.DataTextField = "EmpName";
  256. UserList.DataValueField = "EmpID";
  257. UserList.DataBind();
  258. }
  259. }
  260. }