SecurityFMPage.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:15k
- using System;
- using System.Collections;
- using System.Data;
- using System.Web.UI.WebControls;
- using qminoa.Common;
- using qminoa.DA;
- using qminoa.BLL;
- namespace qminoa.Webs.FM
- {
- public class SecurityFMPage : qminoa.Webs.PageBase
- {
- protected System.Web.UI.WebControls.DataGrid dgdFolder;
- protected System.Web.UI.WebControls.Image Image1;
- protected System.Web.UI.WebControls.ImageButton cmdClose;
- protected System.Web.UI.WebControls.ImageButton cmdBack;
- protected System.Web.UI.WebControls.ImageButton cmdForword;
- protected System.Web.UI.WebControls.ImageButton cmdUp;
- protected System.Web.UI.WebControls.ImageButton cmdSeach;
- protected System.Web.UI.WebControls.ImageButton cmdFolderShow;
- protected System.Web.UI.WebControls.ImageButton cmdNewFolder;
- protected System.Web.UI.WebControls.ImageButton cmdNewFile;
- protected System.Web.UI.WebControls.Label lblAddress;
- protected System.Web.UI.WebControls.TextBox txtFolderPath;
- protected System.Web.UI.WebControls.Image imgDrive;
- protected System.Web.UI.WebControls.ImageButton cmdGoto;
- protected System.Web.UI.WebControls.Label lblObjNum;
- protected System.Web.UI.WebControls.Label lblLastID;
- protected System.Web.UI.WebControls.Label lblID;
- protected System.Web.UI.WebControls.Label lblFID;
- protected System.Web.UI.WebControls.Label lblBID;
- static int DocId;
- static int id;
- static int Type;
- static int fm_empid;
- private void Page_Load(object sender, System.EventArgs e)
- {
- if(!IsPostBack)
- {
- this.PageBegin("项目管理",true);
- fm_empid=Convert.ToInt16(this.Empid);
- DocId=Convert.ToInt32(Request.QueryString["fid"],10);
- id= Convert.ToInt32( Request.QueryString["Id"],10);
- Type=Convert.ToInt32(Request.QueryString["type"],10);
- txtFolderPath.Text="C:\";
- if(Type==-1)
- {
- if( id!=0 && DocId==0)
- {
- RightForReBind_Folder(id,0,fm_empid);
- }
- else if(id==0 && DocId!=0)
- {
- RightForReBind_Doc(0,DocId,fm_empid);
- }
- else if(id!=0 && DocId!=0)
- {
- int fid = Convert.ToInt32(Session["_fm_id"].ToString());
- if(id!=fid )
- {
- RightForReBind_Folder(id,DocId,fm_empid);
- }
- else
- {
- RightForReBind_Doc(id,DocId,fm_empid);
- }
- }
- }
- else if((id!=0 && Type==-2) || (id!=0 && Type==-3) )
- {
- RightForReBind_Folder(id,0,fm_empid);
- UpdateLeftTree();
- }
- else if(Type==-4)
- {
- RightForReBind_Folder(id,DocId,fm_empid);
- }
- else
- {
- FirstLoad();
- UpdateLeftTree();
- }
- }
- }
- public void FirstLoad()
- {
- FileData filedata = (new FileA()).LoadFile();
- DataView dv=filedata.Tables[FileData.FMDOCFOLDER_TABLE].DefaultView;
- DataTable dt=CreateTable(dv);
- dgdFolder.DataSource =dt.DefaultView;
- dgdFolder.DataBind();
- txtFolderPath.Text="C:\";
- Session["_fm_id"]=0;
- }
- public void RightForReBind_Doc(int folderid,int docid,int empid)
- {
- int depid=(new FileRight()).GetDepId(empid);
- string rightctr_emp=(new FileBLL()).GetDocRight(docid,empid);
- if(rightctr_emp=="Admin"||rightctr_emp=="Write"||rightctr_emp=="Read")
- {
- Response.Redirect("fmNewFile.aspx?fid="+id+"&did="+docid+"&type=-1",true);
- }
- else
- {
- string rightctr_dep=(new FileBLL()).GetDocRightForDep(docid,depid);
- if(rightctr_dep=="Admin"||rightctr_dep=="Write"||rightctr_dep=="Read")
- {
- Response.Redirect("fmNewFile.aspx?fid="+id+"&did="+DocId+"&type=-1",true);
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限访问这个文件!');</script>");
- if(folderid==0)
- {
- FirstLoad();
- }
- else
- {
- ReBind(folderid);
- }
- }
- }
- }
-
- public void RightForReBind_Folder(int folderid,int docid,int empid)
- {
- string rightctr_emp=(new FileBLL()).GetFolderRight(folderid,empid);
- if(rightctr_emp=="Admin"||rightctr_emp=="Write"||rightctr_emp=="Read")
- {
- ReBind(folderid);
- }
- else
- {
- int depid=(new FileRight()).GetDepId(empid);
- string rightctr_dep=(new FileBLL()).GetFolderRightForDep(folderid,depid);
- if(rightctr_dep=="Admin"||rightctr_dep=="Write"||rightctr_dep=="Read")
- {
- ReBind(folderid);
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限访问改文件夹!');</script>");
- FirstLoad();
- }
- }
- }
- public void ReBind(int id)
- {
- DataView dvdata;
- FileData filedata =(new FileA()).LoadDocFolder(id);
- dvdata=filedata.Tables[FileData.FMDOCFOLDER_TABLE].DefaultView;
- DataTable dt=CreateTable(dvdata);
- dgdFolder.DataSource=dt.DefaultView;
- dgdFolder.DataBind();
- cmdBack.ImageUrl="img/button/fmback.gif";
- txtFolderPath.Text=GetPath(id);
- Session["_fm_id"]=id;
- }
- private string GetPath(int fid)
- {
- FileA fa= new FileA();
- string fpath=fa.GetDocPath(fid);
- return fpath;
- }
- private void cmdNewFolder_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- int fid =id;
- Response.Redirect("fmNewFolder.aspx?id="+fid+"&type=-2");
- }
-
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.cmdUp.Click += new System.Web.UI.ImageClickEventHandler(this.cmdUp_Click);
- this.cmdSeach.Click += new System.Web.UI.ImageClickEventHandler(this.cmdSeach_Click);
- this.cmdNewFolder.Click += new System.Web.UI.ImageClickEventHandler(this.cmdNewFolder_Click);
- this.cmdNewFile.Click += new System.Web.UI.ImageClickEventHandler(this.cmdNewFile_Click);
- this.dgdFolder.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdFolder_ItemCommand);
- this.dgdFolder.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdFolder_EditCommand);
-
- this.Load += new System.EventHandler(this.Page_Load);
- this.dgdFolder.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgdFolder_ItemCreated);
- }
- #endregion
- private void cmdNewFile_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- int fid=id;
- FileA fa=new FileA();
- fa.UpdateFileCont();
- if(txtFolderPath.Text=="C:\")
- {
- Response.Redirect("fmNewFile.aspx?did=0&fid=0&type=-2",true);
- }
- else
- {
- Response.Redirect("fmNewFile.aspx?did=0&fid="+id+"&type=-2",true);
- }
- }
- private void cmdSeach_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- Response.Redirect("FileSearch.aspx",false);
- }
- private void cmdUp_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- try
- {
- int _id = Convert.ToInt32(Session["_fm_id"].ToString(),10);
- int _fid=FileA.gethifolderid(_id);
- id=_fid;
- if(_fid!=0)
- {
- RightForReBind_Folder(_fid,0,fm_empid);
- }
- else
- {
- FirstLoad();
- }
- }
- catch
- {}
- }
- private void dgdFolder_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- int FolderId =Convert.ToInt32(e.Item.Cells[1].Text);
- int DocId=Convert.ToInt32(e.Item.Cells[0].Text);
-
- if(e.CommandName=="edit")
- {
- if( DocId==0 && FolderId!=0 )
- {
- RightForEdit_Folder(FolderId,0,fm_empid);
- }
- else if(DocId!=0 && FolderId!=0)
- {
- int id=Convert.ToInt32(Session["_fm_id"].ToString());
- if( FolderId!=id )
- {
- RightForEdit_Folder(FolderId,DocId,fm_empid);
- }
- else
- {
- RightForReBind_Doc(FolderId,DocId,fm_empid);
- }
- }
- else if( DocId!=0 && FolderId==0 )
- {
- RightForReBind_Doc(FolderId,DocId,fm_empid);
- }
- }
- }
- public void dgdFolder_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
- {
- if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
- {
- TableCell myTableCell = new TableCell();
- myTableCell = e.Item.Cells[10];
- LinkButton myDeleteButton =new LinkButton();
- int count=myTableCell.Controls.Count;
- myDeleteButton = (LinkButton)myTableCell.Controls[0];
- myDeleteButton.Attributes.Add("onclick", "return confirm('您真的要删除该记录吗?');");
- }
- }
- public void dgdFolder_delete(object Sender , DataGridCommandEventArgs E)
- {
- int FolderId =Convert.ToInt32(E.Item.Cells[1].Text);
- int DocId=Convert.ToInt32(E.Item.Cells[0].Text);
- if(FolderId==0)
- {
- if(RightForManage_Doc(DocId)==true)
- {
- DeleteDoc(DocId,fm_empid);
- FirstLoad();
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限管理该文件!');</script>");
- }
- }
- else
- {
- if(RightForManage_Folder(FolderId)==true)
- {
- if( DocId==0)
- {
- DeleteFolder(FolderId);
- }
- else
- {
- int fid;
- fid = Convert.ToInt32(Session["_fm_id"].ToString());
- if(FolderId==fid)
- {
- if(RightForManage_Doc(DocId)==true)
- {
- DeleteDoc(DocId,fm_empid);
- ReBind(fid);
- }
- }
- else
- {
- DeleteFolder(FolderId);
- ReBind(fid);
- }
- }
- UpdateLeftTree();
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限管理该文件夹!');</script>");
- }
- }
- }
- public void DeleteFolder(int folderid)
- {
- FileA FileA =new FileA();
- ArrayList arrlist=(new FileA()).GetDelFolderId(folderid);
- for(int i=0;i<arrlist.Count;i++)
- {
- int foldid=Convert.ToInt32(arrlist[i].ToString(),10);
- FileA.DeleteFolder(foldid,fm_empid,1);
- }
- ArrayList arrlistDoc= FileA.GetDelDocId(arrlist);
- for(int j=0;j<arrlistDoc.Count;j++)
- {
- int docid=Convert.ToInt32(arrlistDoc[j].ToString(),10);
- DeleteDoc(docid,fm_empid);
- }
- int fid=Convert.ToInt32(Session["_fm_id"].ToString(),10);
- if(fid==0)
- {
- FirstLoad();
- }
- else
- {
- ReBind(fid);
- }
- }
- public void DeleteDoc(int docid,int empid)
- {
- FileA filedata=new FileA();
- filedata.DeleteDoc(docid,empid);
- }
-
- public bool RightForManage_Folder(int folderid)
- {
- int depid=(new FileRight()).GetDepId(fm_empid);
- string rightctr_dep=(new FileBLL()).GetFolderRightForDep(folderid,depid);
- if(rightctr_dep=="Admin")
- {
- return true;
- }
- else
- {
- string rightctr_emp=(new FileBLL()).GetFolderRight(folderid,fm_empid);
- if(rightctr_emp=="Admin")
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
-
- public bool RightForManage_Doc(int docid)
- {
- int depid=(new FileRight()).GetDepId(fm_empid);
- string rightctr_dep=(new FileBLL()).GetDocRightForDep(docid,depid);
- if(rightctr_dep=="Admin")
- {
- return true;
- }
- else
- {
- string rightctr_emp=(new FileBLL()).GetDocRight(docid,fm_empid);
- if(rightctr_emp=="Admin")
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- public void RightForEdit_Folder(int folderid,int docid,int empid)
- {
- string rightctr_emp=(new FileBLL()).GetFolderRight(folderid,empid);
- if(rightctr_emp=="Admin"||rightctr_emp=="Write"||rightctr_emp=="Read")
- {
- Response.Redirect("fmNewFolder.aspx?type=-3&id="+ folderid+"&docid="+docid);
- }
- else
- {
- int depid=(new FileRight()).GetDepId(empid);
- string rightctr_dep=(new FileBLL()).GetFolderRightForDep(folderid,depid);
- if(rightctr_dep=="Admin"||rightctr_dep=="Write"||rightctr_dep=="Read")
- {
- Response.Redirect("fmNewFolder.aspx?type=-3&id="+ folderid+"&docid="+docid);
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限访问改文件夹!');</script>");
- }
- }
- }
- public DataTable CreateTable(DataView dv)
- {
- DataTable dvtable=new DataTable();
- DataColumnCollection d= dvtable.Columns;
- d.Add("folderid",typeof(System.Int32));
- d.Add("Docid", typeof(System.Int32));
- d.Add("fname",typeof(System.String));
- d.Add("typename",typeof(System.String));
- d.Add("note",typeof(System.String));
- d.Add("empid",typeof(System.String));
- d.Add("cdate",typeof(System.String));
- int recordcount = dv.Count;
- for(int i=0;i<recordcount;i++)
- {
- DataRow row = dvtable.NewRow();
- row["folderid"]=Convert.ToInt32(dv[i].Row[0].ToString(),10);
- row["Docid"] =Convert.ToInt32(dv[i].Row[1].ToString(),10);
- row["fname"]=dv[i].Row[14].ToString()+dv[i].Row[3].ToString();
- row["note"]=dv[i].Row[5].ToString();
- DateTime cdate=Convert.ToDateTime(dv[i].Row[7].ToString());
- row["cdate"]=cdate.Year+"-"+cdate.Month+"-"+cdate.Day;
- row["empid"]=(new FileA()).GetEmpName(Convert.ToInt32(dv[i].Row[9].ToString()));
- row["typename"]=dv[i].Row[13].ToString();
- dvtable.Rows.Add(row);
- }
- return dvtable;
- }
-
- private void dgdFolder_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- if(e.CommandName=="move")
- {
- int did=Convert.ToInt32(e.Item.Cells[0].Text.ToString(),10);
- int fid=Convert.ToInt32(e.Item.Cells[1].Text.ToString(),10);
- if(did==0&&fid!=0)
- {
- if(RightForManage_Folder(fid)==true)
- {
- Response.Redirect("fmSelFolder.aspx?DocId="+did+"&FolderId="+fid);
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限管理该文件夹!');</script>");
- }
- }
- else if(did!=0&&fid==0)
- {
- if(RightForManage_Doc(did)==true)
- {
- Response.Redirect("fmSelFolder.aspx?DocId="+did+"&FolderId="+fid);
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限管理该文件!');</script>");
- }
- }
- else if(did!=0&&fid!=0)
- {
- int id=Convert.ToInt32(Session["_fm_id"].ToString());
- if(fid!=id )
- {
- if(RightForManage_Folder(fid)==true)
- {
- Response.Redirect("fmSelFolder.aspx?DocId="+did+"&FolderId="+fid);
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限管理该文件夹!');</script>");
- }
-
- }
- else
- {
- if(RightForManage_Doc(did)==true)
- {
- Response.Redirect("fmSelFolder.aspx?DocId="+did+"&FolderId="+fid);
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您没有权限管理该文件!');</script>");
- }
- }
- }
- }
- }
-
- private void UpdateLeftTree()
- {
- Response.Write("<script>parent.frmDocTree.location.reload();</script>");
- }
- private void dgdFolder_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
- {
- ListItemType itemType = e.Item.ItemType;
- e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';" ;
- if (itemType == ListItemType.Item )
- {
- e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#dedfde';";
- }
- else if( itemType == ListItemType.AlternatingItem)
- {
- e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
- }
- }
- }
- }