📄 backdocument.ascx.cs
字号:
namespace OI.UserControls
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Data .SqlClient ;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using ZHENGYI;
/// <summary>
/// backDocument 的摘要说明。
/// </summary>
public class backDocument : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataGrid dg;
protected OI.cs.readStream rs =new OI.cs.readStream ();
protected OI.DatabaseOper.DatabaseConnect Dbc=new OI.DatabaseOper.DatabaseConnect ();
protected DataGridNavigation divage ;
protected string linkurltitle ;
protected string optype="";
public string StreamStep
{
set
{
ViewState["streamstep"]=value;
}
}
public string LinkUrlByTitle
{
set
{
linkurltitle=value;
}
}
public string OPtype
{
set
{
optype=value;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
SetDivePage();
if (!Page.IsPostBack )
{
dataBind();
}
}
private void dataBind()
{
dg.DataSource =CreateDataSource();
dg.DataBind ();
}
private void SetDivePage()
{
ZHENGYI.BindDataDelegate f =new ZHENGYI.BindDataDelegate (dataBind);//修改这个dataBind,让f 指向你的方法。
divage.SetTarget(dg,f,15);
}
private DataTable CreateDataSource()
{
string sql=" select documentid,title,ExigenceDegreeName,SecretGreadName, DocumentTypeName,CurrentStepID from ViewDocumentno where CompleteSign=0 and currentstepid != 2 order by FileDate desc";
System.Data.DataSet ds=new DataSet ();
ds=Dbc.getBinding(sql,"t");
DataColumn dc=new DataColumn("backuser",typeof(String));
ds.Tables [0].Columns .Add (dc);
dc=new DataColumn ("transtime",typeof(String));
ds.Tables [0].Columns .Add (dc);
foreach (DataRow dr in ds.Tables[0].Rows )
{
rs.doucmentID =int.Parse (dr["documentid"].ToString ());
//如果当前用户没在当前节点中,则应当删除.
if (Dbc.GetValueBySql ("select count(*) from TransactUsers where documentid="+dr["documentid"] +" and stepID="+dr["CurrentStepID"].ToString () +" and userid="+Session["userid"].ToString () ).ToString ()=="0")
{
dr.Delete ();
}
else
{ //用户存在当前节点中。
string CurrentOprateType=rs.GetCurrentOprateTypeByNodeID (dr["CurrentStepID"].ToString ());
if (CurrentOprateType !=ViewState["streamstep"].ToString ()) //文档指向当前节点如果不是待处理的节点类型
{
dr.Delete (); //那么删除
}
else
{
sql="select count(*) from DocumentTransact where documentid="+dr["documentid"].ToString () +" and " ;
sql += " StepID=" + dr["CurrentStepID"].ToString () + " and userid="+Session["userid"].ToString ();
sql +=" and BackState=(select max(BackState) from DocumentTransact where documentid= "+dr["documentid"].ToString () +")";
if (int.Parse (Dbc.GetValueBySql(sql)) <1) //如果当前用户,当前节点在处理表中不存在,那么删除.
{
dr.Delete ();
}
else
{
string []trans=getBackmas(dr["documentid"].ToString (),dr["CurrentStepID"].ToString ());
dr["backuser"]=trans[0];
dr["transtime"]=trans[1];
}
}
}
}
return ds.Tables [0];
}
private string [] getBackmas(string documentid,string currentnodeid)
{
OI.cs .readStream rs=new OI.cs.readStream ();
rs.doucmentID =int.Parse (documentid);
currentnodeid= rs.GetNextNodeIdByID(currentnodeid);
//rs.GetCurrentNodeUsersByID(nextid)
string sql="select TransactDate,a.username from documenttransact d,accounts_users a where transtype='退回' and BackState=(select max(BackState) from DocumentTransact where documentid= "+documentid +")" ;
sql +=" and documentid="+documentid +" and d.userid=a.userid and stepid="+currentnodeid ;
//System.Data.DataSet ds=new DataSet ();
DataRow dr=Dbc.getBinding (sql,"t").Tables [0].Rows[0];
string []trans=new string [2];
trans[0]=dr["username"].ToString ();
trans[1]=dr["TransactDate"].ToString ();
return trans;
}
private void dg_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType ==ListItemType.Item ||e.Item.ItemType ==ListItemType.AlternatingItem )
{
//处理标题列
if(e.Item .Cells[1].Text.Length >20 )
{
if (linkurltitle !="")
{
e.Item .Cells[1].Text="<a href=\"" + linkurltitle+"?documentid="+e.Item.Cells[0].Text +"&type="+optype+"\" title=\""+e.Item .Cells[1].Text +"\">" + e.Item .Cells[1].Text .Substring (0,20)+"...</a>";
}
else
{
e.Item .Cells[1].Text="<a href=\"#\" title=\""+e.Item .Cells[1].Text +"\">" + e.Item .Cells[1].Text .Substring (0,20)+"...</a>";
}
}
else //标题长度不超过10
{
if (linkurltitle !="")
{
e.Item .Cells[1].Text="<a href=\""+ linkurltitle+"?documentid="+e.Item.Cells[0].Text +"&type="+optype+"\" >" + e.Item .Cells[1].Text +"</a>";
}
else
{
e.Item .Cells[1].Text="<a href=\"#\" >" + e.Item .Cells[1].Text+"</a>";
}
}
//end
//处理增加的操作列
// if(opratercloumnName!="")
//{
// e.Item .Cells[5].Text ="<a href=\"#\"><a href=\"../sendmessage/sendfile.aspx?DocumentID="+e.Item.Cells[0].Text +"\"><img border=0 alt='发文登记' src=\"../images/fw1.gif\"</a>";
// }
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.dg.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dg_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -