fmSelFolder.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:6k
- using System;
- using System.Data;
- using System.Web.UI.WebControls;
- using qminoa.Common;
- using qminoa.DA;
- using qminoa.BLL;
- namespace qminoa.Webs.FM
- {
- public class fmSelFolder : qminoa.Webs.PageBase
- {
- protected static int docid;
- protected static int folderid;
- static int IsDoc=0;
- static int SelFolderId=0;
- protected System.Web.UI.WebControls.Label lblErr;
- protected System.Web.UI.WebControls.Label lblBfolder;
- protected System.Web.UI.WebControls.Label lblOpt;
- protected System.Web.UI.WebControls.Label lblSelID;
- protected System.Web.UI.WebControls.Label lblID;
- protected System.Web.UI.WebControls.ImageButton cmdCancel;
- protected System.Web.UI.WebControls.ImageButton cmdOK;
- protected System.Web.UI.WebControls.TextBox txtSelFolder;
- protected System.Web.UI.WebControls.Label Label1;
- protected System.Web.UI.WebControls.DataGrid dgdFolder;
- protected System.Web.UI.WebControls.Image imgDrive;
- protected System.Web.UI.WebControls.TextBox txtFolderPath;
- protected System.Web.UI.WebControls.Label lblAddress;
- protected System.Web.UI.WebControls.Image Image1;
-
- private void Page_Load(object sender, System.EventArgs e)
- {
- if(!this.IsPostBack)
- {
- this.PageBegin("文档管理",true);
- docid=Convert.ToInt32(Request.QueryString["DocId"].ToString(),10);
- folderid=Convert.ToInt32(Request.QueryString["FolderId"].ToString(),10);
- DataView dvdata=BindTable(docid,folderid);
- int counts=dvdata.Count;
- if(counts!=0)
- {
- DataTable dt= GetDataTable(dvdata);
- dgdFolder.DataSource=dt;
- dgdFolder.DataBind();
- }
- else
- {
- Response.Write("<script language='javascript'>alert('没有可以转移的目标文件夹!');</script>");
- }
- txtFolderPath.Text = GetPath(folderid);
- }
- }
- private DataView BindTable(int docid ,int folderid)
- {
- DataView dv= new DataView();
- DocTree folderdata= new DocTree();
- if(docid==0 && folderid!=0)
- {
- dv=folderdata.GetTreeNodeFolder(0);
- IsDoc=0;
- }
- else if(docid!=0 && folderid==0)
- {
- dv=folderdata.GetTreeNodeFolder(0);
- IsDoc=1;
- }
- else if(docid!=0 && folderid!=0)
- {
- int fid = Convert.ToInt32(Session["_fm_id"].ToString());
- if(docid==fid && folderid!=fid)
- {
- dv=folderdata.GetTreeNodeFolder(docid);
- IsDoc=0;
- }
- else
- {
- dv=folderdata.GetTreeNodeFolder(folderid);
- IsDoc=1;
- }
- }
- return dv;
- }
- private DataTable GetDataTable(DataView dv)
- {
- DataTable dt = new DataTable("SelFolder");
- DataColumnCollection d= dt.Columns;
- d.Add("folderid",typeof(System.Int32));
- d.Add("fname",typeof(System.String));
- d.Add("note",typeof(System.String));
- d.Add("empid",typeof(System.String));
- string strImgPath="<img src=img/img-folder.gif border=0 alt=文件>";
- int recordcount = dv.Count;
- for(int i=0;i<recordcount;i++)
- {
- DataRow row = dt.NewRow();
- row["folderid"]=Convert.ToInt32(dv[i].Row[0].ToString(),10);
- row["fname"]=strImgPath+dv[i].Row[15].ToString();
- row["note"]=dv[i].Row[5].ToString();
- row["empid"]= (new FileA()).GetEmpName(Convert.ToInt32(dv[i].Row[9].ToString()));
- dt.Rows.Add(row);
- }
- return dt;
- }
- #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.dgdFolder.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdFolder_ItemCommand);
- this.cmdOK.Click += new System.Web.UI.ImageClickEventHandler(this.cmdOK_Click);
- this.cmdCancel.Click += new System.Web.UI.ImageClickEventHandler(this.cmdCancel_Click);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void dgdFolder_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- int index =Convert.ToInt32(e.Item.Cells[0].Text,10);
- SelFolderId=index;
- if(e.CommandName=="Select")
- {
- if(index==folderid)
- {
- Response.Write("<script language='javascript'>alert('您不能选同一个文件!');</script>");
- txtSelFolder.Text=string.Empty;
- }
- else
- {
- txtSelFolder.Text = GetFolderName(index);
- }
- }
- }
- private string GetFolderName(int folderid)
- {
- DocTree dt= new DocTree();
- DataView dv=dt.GetTreeNodeFolderII(folderid);
- string name= dv[0].Row[15].ToString();
- return name;
- }
- private void cmdOK_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- FileA fa=new FileA();
- try
- {
- if(txtSelFolder.Text!=string.Empty && SelFolderId!=0)
- {
- if(IsDoc!=0)
- {
- fa.MoveDoc(docid,SelFolderId);
- }
- else
- {
- fa.MoveFolder(folderid,SelFolderId);
- }
- Response.Redirect("SecurityFMPage.aspx");
- }
- else
- {
- Response.Write("<script language='javascript'>alert('您必须选择目标文件夹!');</script>");
- }
- }
- catch
- {
- Response.Write("<script language='javascript'>alert('转移文件夹出现错误,转移失败!');</script>");
- }
- }
- private void cmdCancel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- if(IsDoc==1)
- {
- Response.Redirect("SecurityFMPage.aspx?Id="+folderid+"&fid="+docid+"&type=-2");
- }
- else
- {
- Response.Redirect("SecurityFMPage.aspx?Id="+docid+"&fid="+folderid+"&type=-2");
- }
- }
- 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';";
- }
- }
- private string GetPath(int fid)
- {
- FileA fa= new FileA();
- string fpath=fa.GetDocPath(fid);
- return fpath;
- }
- }
- }