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

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