📄 fmnewfolder.aspx.cs
字号:
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 fmNewFolder : qminoa.Webs.PageBase
{
static int id;
static int type;
protected System.Web.UI.WebControls.ImageButton cmdSaveCon;
static int docid;
static int fm_empid;
protected System.Web.UI.WebControls.Label lblID;
protected System.Web.UI.WebControls.Label lblAttID;
protected System.Web.UI.WebControls.Label lblErr;
protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
protected System.Web.UI.WebControls.ImageButton cmdExit;
protected System.Web.UI.WebControls.ImageButton cmdSaveExi;
protected System.Web.UI.WebControls.CheckBox chkSubFoldFileRight;
protected System.Web.UI.WebControls.DataGrid dgdRight;
protected System.Web.UI.WebControls.Label lblEName;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.LinkButton cmdRightAdd;
protected System.Web.UI.WebControls.LinkButton cmdRightSet;
protected System.Web.UI.WebControls.Label lblCDate;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.TextBox txtNote;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox txtFolderName;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.Label lblLocation;
protected System.Web.UI.WebControls.Image Image1;
static int righttype;
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
this.PageBegin("文档管理",true);
fm_empid=Convert.ToInt16(this.Empid);
id = Convert.ToInt32(Request.Params["id"]);
type=Convert.ToInt32(Request.Params["type"]);
docid=Convert.ToInt32(Request.Params["docid"]);
righttype=Convert.ToInt32(Request.Params["righttype"],10);
Session["_folderid"]=id;
Session["_docid"]=docid;
Session["Type"]=type;
Session["RightType"]=righttype;
if(type==-2 && righttype!=4)
{
if(id==0)
{
lblLocation.Text="C:\\";
lblCDate.Text = DateTime.Now.Year+"-"+ DateTime.Now.Month+"-"+DateTime.Now.Day;
lblEName.Text=this.EmpName;
}
else if(id!=0)
{
lblLocation.Text="---"+GetPath(id);
lblCDate.Text = DateTime.Now.Year+"-"+ DateTime.Now.Month+"-"+DateTime.Now.Day;
lblEName.Text=this.EmpName;
}
}
else if(docid==0 && id!=0 && type==-3)
{
FileData filedata = (new FileA()).LoadFile();
DataView dvdata = filedata.Tables[FileData.FMDOCFOLDER_TABLE].DefaultView;
dvdata.RowFilter="FolderID =" +id;
txtFolderName.Text=dvdata[0].Row[3].ToString();
lblLocation.Text ="C:\\";
txtNote.Text=dvdata[0].Row[5].ToString();
DateTime tmpDate =Convert.ToDateTime(dvdata[0].Row[7].ToString());
lblCDate.Text =tmpDate.Year+"-"+tmpDate.Month+"-"+tmpDate.Day;
lblEName.Text=(new FileA()).GetEmpName(Convert.ToInt32(dvdata[0].Row[9].ToString()));
filldgdRight(id,fm_empid);
RightforWrite();
}
else if(id!=0 && type==-3 && docid!=0 )
{
int fid=docid;
FileData filedata=(new FileA()).LoadSubFolder(id);
DataView dvdata=filedata.Tables[FileData.FMDOCFOLDER_TABLE].DefaultView;
DateTime tmpDate =Convert.ToDateTime(dvdata[0].Row[7].ToString());
lblCDate.Text =tmpDate.Year+"-"+tmpDate.Month+"-"+tmpDate.Day;
txtFolderName.Text=dvdata[0].Row[15].ToString();
txtNote.Text=dvdata[0].Row[5].ToString();
lblEName.Text=(new FileA()).GetEmpName(Convert.ToInt32(dvdata[0].Row[9].ToString()));
lblLocation.Text=GetPath(id);
filldgdRight(id,fm_empid);
RightforWrite();
}
else if(righttype==4)
{
if(Session["NewFolder"]!=null)
{
DataTable data=(DataTable)Session["NewFolder"];
txtFolderName.Text=data.Rows[0][0].ToString();
lblLocation.Text=data.Rows[0][1].ToString();
txtNote.Text=data.Rows[0][2].ToString();
lblCDate.Text=data.Rows[0][3].ToString();
lblEName.Text=this.EmpName;
}
filldgdRight(0,fm_empid);
}
}
}
#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.cmdRightSet.Click += new System.EventHandler(this.cmdRightSet_Click);
this.cmdRightAdd.Click += new System.EventHandler(this.cmdRightAdd_Click);
this.dgdRight.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgdRight_ItemCreated);
this.cmdSaveExi.Click += new System.Web.UI.ImageClickEventHandler(this.cmdSaveExi_Click);
this.cmdExit.Click += new System.Web.UI.ImageClickEventHandler(this.cmdExit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void cmdSaveExi_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
type=Convert.ToInt32(Session["Type"].ToString(),10);
if(type==-3)
{
SaveFolderRight();
if(id!=0 && docid==0 )
{
Saveinfo(id,0,fm_empid);
Response.Redirect("SecurityFMPage.aspx?Id="+id+"&fid="+docid);
}
else
{
Saveinfo(id,docid,fm_empid);
Response.Redirect("SecurityFMPage.aspx?Id="+docid+"&type=-3");
}
}
else if(type==-2)
{
SaveFolderRight();
if(id!=0)
{
Insertinfo(id);
Response.Redirect("SecurityFMPage.aspx?Id="+id+"&type=-2",true);
}
else if(id==0)
{
int folderid = 0;
string name =txtFolderName.Text.ToString();
string note =txtNote.Text.ToString();
bool iherctr =true;
FileA filedata = new FileA();
filedata.ChangFolderInfo(folderid,0,name,note,DateTime.Now,iherctr,fm_empid,13);
Response.Redirect("SecurityFMPage.aspx");
}
}
}
private void filldgdRight(int folderid,int empid)
{
FileData filedata = (new FileRight()).GetDocFolderCtr(folderid,empid,0);
dgdRight.DataSource =filedata.Tables[FileData.FMDOCFOLDERCTR_TABLE].DefaultView;
dgdRight.DataBind();
}
private void cmdExit_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(type==-2)
{
DeleteRight();
Response.Redirect("SecurityFMPage.aspx?Id="+id+"&type=-2",true);
}
else if(type==-3)
{
Response.Redirect("SecurityFMPage.aspx?Id="+docid+"&type=-3");
}
}
private void Insertinfo(int fid)
{
//int folderid=id;
string name =txtFolderName.Text.ToString();
string note =txtNote.Text.ToString();
bool iherctr =true;
FileA filedata =new FileA();
filedata.ChangFolderInfo(0,fid,name,note,DateTime.Now,iherctr,fm_empid,13);
}
private void Saveinfo(int id,int fid,int empid)
{
string name =txtFolderName.Text.ToString();
string note =txtNote.Text.ToString();
bool iherctr = true;
FileA filedata =new FileA();
filedata.ChangFolderInfo(id,fid,name,note,DateTime.Now,iherctr,empid,13);
}
private void cmdRightAdd_Click(object sender, System.EventArgs e)
{
if(Session["NewFolder"]!=null)
{
Session["NewFolder"]=null;
}
if(type==-2)
{
DataTable data= new DataTable();
DataColumnCollection d= data.Columns;
d.Add("title",typeof(System.String));
d.Add("location", typeof(System.String));
d.Add("note",typeof(System.String));
d.Add("cdate",typeof(System.String));
DataRow row=data.NewRow();
row[0]=txtFolderName.Text;
row[1]=lblLocation.Text;
row[2]=txtNote.Text;
row[3]=lblCDate.Text;
data.Rows.Add(row);
data.AcceptChanges();
Session["NewFolder"]=data;
}
Response.Redirect("SetRightType.aspx?did=0&fid="+id+"&type=4");
}
public void dgdRight_delete(object Sender , DataGridCommandEventArgs E)
{
int rightkey=Convert.ToInt32(E.Item.Cells[0].Text);
FileA fa = new FileA();
fa.DeleteRight(rightkey,0);
this.WriteOptLog("删除文件权限信息:"+rightkey.ToString());
filldgdRight(id,fm_empid);
}
public void dgdRight_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[5];
LinkButton myDeleteButton =new LinkButton();
int count=myTableCell.Controls.Count;
myDeleteButton = (LinkButton)myTableCell.Controls[0];
myDeleteButton.Attributes.Add("onclick", "return confirm('您真的要删除这个权限吗?');");
}
}
public void SaveFolderRight()
{
int num=dgdRight.Items.Count;
FileRight fright =new FileRight();
for(int i=0;i<num;i++)
{
int key=Convert.ToInt32(dgdRight.Items[i].Cells[0].Text.ToString(),10);
int empid=FileRight.GetEmpId(dgdRight.Items[i].Cells[1].Text.Trim());
if(empid>0)
{
fright.SaveDocFolderRight(GetSaveData_emp(empid,i,key),2);
}
else
{
int Depid=(new FileRight()).GetDepId(dgdRight.Items[i].Cells[1].Text.Trim());
fright.SaveDocFolderRight(GetSaveData_dep(Depid,i,key),6);
}
}
}
private void DeleteRight()
{
FileRight fright =new FileRight();
FileData fa= new FileData();
DataRow row =fa.Tables[FileData.FMDOCFOLDERCTR_TABLE].NewRow();
row[0]=0;
row[1]=0;
row[2]=0;
row[3]=0;
row[4]=true;
row[5]=false;
row[6]=false;
fa.Tables[FileData.FMDOCFOLDERCTR_TABLE].Rows.Add(row);
fa.AcceptChanges();
fright.SaveDocFolderRight(fa,4);
}
public FileData GetSaveData_dep(int DepId,int index,int key)
{
int FolderId = FileRight.Right_GetFolderId(key);
FileData rightdata=new FileData();
DataTable userdata =rightdata.Tables[FileData.FMDOCFOLDERCTR_TABLE];
DataRow row =userdata.NewRow();
row[0]=0;
row[1]=FolderId;
row[2]=DepId;
row[3]=0;
if(((RadioButton)dgdRight.Items[index].FindControl("radAdmin")).Checked==true)
row[4]=1;
else row[4]=0;
if(((RadioButton)dgdRight.Items[index].FindControl("radRead")).Checked==true)
row[5]=1;
else row[5]=0;
if(((RadioButton)dgdRight.Items[index].FindControl("radWrite")).Checked==true)
row[6]=1;
else row[6]=0;
row[7]=DepId;
userdata.Rows.Add(row);
userdata.AcceptChanges();
rightdata.AcceptChanges();
return rightdata;
}
public FileData GetSaveData_emp(int EmpId,int index,int key)
{
int FolderId = FileRight.Right_GetFolderId(key);
FileData rightdata=new FileData();
DataTable userdata =rightdata.Tables[FileData.FMDOCFOLDERCTR_TABLE];
DataRow row =userdata.NewRow();
row[0]=0;
row[1]=FolderId;
row[2]=0;
row[3]=EmpId;
if(((RadioButton)dgdRight.Items[index].FindControl("radAdmin")).Checked==true)
row[4]=1;
else row[4]=0;
if(((RadioButton)dgdRight.Items[index].FindControl("radRead")).Checked==true)
row[5]=1;
else row[5]=0;
if(((RadioButton)dgdRight.Items[index].FindControl("radWrite")).Checked==true)
row[6]=1;
else row[6]=0;
row[7]=EmpId;//empname
userdata.Rows.Add(row);
userdata.AcceptChanges();
rightdata.AcceptChanges();
return rightdata;
}
private void cmdRightSet_Click(object sender, System.EventArgs e)
{
dgdRight.Visible =!dgdRight.Visible;
cmdRightAdd.Visible =!cmdRightAdd.Visible;
}
public void RightforWrite()
{
int depid=(new FileRight()).GetDepId(fm_empid);
string rightctr_dep=(new FileBLL()).GetFolderRightForDep(id,depid);
if(rightctr_dep=="Admin")
{
cmdRightSet.Visible=true;
}
else if(rightctr_dep=="Write")
{
cmdRightSet.Visible=false;
}
else if(rightctr_dep=="Read")
{
cmdRightSet.Visible=false;
txtFolderName.Enabled=false;
txtNote.Enabled=false;
}
else
{
string rightctr_emp=(new FileBLL()).GetFolderRight(id,fm_empid);
if(rightctr_emp=="Admin")
{
cmdRightSet.Visible=true;
}
else if(rightctr_emp=="Write")
{
cmdRightSet.Visible=false;
}
else if(rightctr_emp=="Read")
{
cmdRightSet.Visible=false;
txtFolderName.Enabled=false;
txtNote.Enabled=false;
}
}
}
private string GetPath(int fid)
{
FileA fa= new FileA();
string fpath=fa.GetDocPath(fid);
return fpath;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -