📄 documentno.ascx.cs
字号:
/************************************************************************************
作者:蒲丰.
创建日期:2003-12-9
修改者:
修改日期:
修改部分:
类功能: 只针对当前节点的未处理功能.例如:要显示"公文校核"的未校核文档.
调用方式:
1:拖控件.
2:声明你现在正操作的是哪一步.StreamStep="公文起草";
*/
namespace OI.UserControls
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data .SqlClient ;
using ZHENGYI;
/// <summary>
/// documentno1 的摘要说明。
/// </summary>
public class documentno : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataGrid dg;
protected DataSet ds;
protected OI.DatabaseOper.DatabaseConnect Dbc=new OI.DatabaseOper.DatabaseConnect ();
protected DataGridNavigation divage ;
DataTable dt;
protected string optype="";
protected string sqlwhere ="";
protected string linkurltitle="" ;
protected string opratercloumnName ="";
protected string streamstep;
protected OI.cs.readStream rs =new OI.cs.readStream ();
protected string stepID;
// protected bool qsclumn=false;
/// <summary>
/// 你当前进行的是哪一步,例如:公文起草:
/// </summary>
public string StreamStep
{
set
{
ViewState["streamstep"]=value;
}
}
/// <summary>
/// 标题的莲接地址.
/// </summary>
public string LinkUrlByTitle
{
set
{
linkurltitle=value;
}
}
/// <summary>
/// SqlWhere 查询条件
/// 例: and documentid=4;
/// </summary>
public string SqlWhere
{
set
{
sqlwhere=value;
}
}
public string OpraterCloumnName
{
set
{
opratercloumnName=value;
}
}
public string OPtype
{
set
{
optype=value;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
SetDivePage();
if (!Page.IsPostBack )
{
dataBind();
}
}
private void CreateDataSource()
{
string sql="select * from ViewDocumentno where CompleteSign=0 and currentstepid != 2 order by FileDate desc";
ds=new DataSet ();
ds=Dbc.getBinding(sql,"t");
if (opratercloumnName !="")
{
DataColumn dc=new DataColumn ("oprater",typeof(String));
dc.DefaultValue ="";
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)) >0) //如果当前用户,当前节点在处理表中存在,那么删除.
{
dr.Delete ();
}
}
}
}
ds.Tables [0].AcceptChanges ();
dt=ds.Tables[0];
//dt.AcceptChanges();
//
}
private void SetDivePage()
{
ZHENGYI.BindDataDelegate f =new ZHENGYI.BindDataDelegate (dataBind);//修改这个dataBind,让f 指向你的方法。
divage.SetTarget(dg,f,15);
}
private void dataBind()
{
CreateDataSource();
dg.DataSource = ds.Tables[0];
if (opratercloumnName !="")
{
BoundColumn bc=new BoundColumn ();
bc.HeaderText=opratercloumnName;
bc.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
bc.ItemStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
bc.DataField ="oprater";
dg.Columns .Add (bc);
}
try
{
dg.DataBind ();
}
catch(Exception er)
{
Response.Write (er.Message );
}
}
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>";
}
}
}
private int GetLengtByString(string s)
{
if (s=="") return 0;
else
return System.Text.Encoding.Default.GetByteCount(s);
}
private void dg_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.dg.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dg_ItemCreated);
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 + -