📄 documentfile.ascx.cs
字号:
/**************************************************************************************
作者:蒲丰.
创建日期:2003-12-5
修改者:
修改日期:
修改部分:
类功能: 只针对当前节点的己处理功能..
调用方式:
1:拖控件.
2:声明当前进行的是哪一步.StreamStep="公文校核"
例如:要显示"公文校核"的己校核文档.
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;
using System.Collections;
/// <summary>
/// documentfile 的摘要说明。
/// </summary>
public class documentfile: 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 ;
protected string sqlwhere ="";
protected string linkurltitle="" ;
protected string opratercloumnName ="";
protected string streamstep;
protected OI.cs.readStream rs =new OI.cs.readStream ();
protected System.Web.UI.WebControls.ImageButton ImgFind;
protected System.Web.UI.WebControls.TextBox TxtTitle;
protected string stepID;
/// <summary>
/// 你当前进行的是哪一步,例如:公文起草:
/// </summary>
public string StreamStep
{
set
{
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;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
//Page.Controls .Add (divage);
SetDivePage();
if(!Page.IsPostBack )
{
// stepID=rs.GetNodeIdByType (streamstep);
dataBind11();
}
}
private void CreateDataSource()
{
string str= " select * from ViewDocument where transactsign=2";
if (TxtTitle.Text.Trim() !="")
{
str +=" and title like '%" +TxtTitle.Text.Trim().Replace("'","''") +"%'" ;
}
str +=" and userid ="+Session["userid"].ToString () +" order by TransactDate desc";
ds=new DataSet ();
ds=Dbc.getBinding(str,"t");
foreach (DataRow dr in ds.Tables[0].Rows )
{
rs.doucmentID =int.Parse (dr["documentid"].ToString ());
if (!rs.IsCurrentOprateNode (dr["stepid"].ToString (),streamstep ))
{
dr.Delete ();
}
}
ds.Tables[0].AcceptChanges ();
if (opratercloumnName !="")
{
DataColumn dc=new DataColumn ("oprater",typeof(String));
dc.DefaultValue ="";
ds.Tables[0].Columns .Add (dc);
}
}
private void SetDivePage()
{
if (!Page.IsPostBack )
{
ZHENGYI.BindDataDelegate f =new ZHENGYI.BindDataDelegate (dataBind11);//修改这个dataBind11,让f 指向你的方法。
divage.SetTarget(dg,f,20);
}
else
{
ZHENGYI.BindDataDelegate f =new ZHENGYI.BindDataDelegate (dataBind11);
divage.SetTarget(dg,f,20);
}
}
private void dataBind11()
{
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 ="transtype";
dg.Columns .Add (bc);
}
try
{
dg.DataBind ();
}
catch(Exception er)
{
Response.Write (er.Message );
}
// dg.DataBind ();
// if (opratercloumnName !="")
// {
// BoundColumn bc=new BoundColumn ();
// bc.HeaderText=opratercloumnName;
// bc.DataField ="oprater";
// dg.Columns .Add (bc);
// }
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ImgFind.Click += new System.Web.UI.ImageClickEventHandler(this.ImgFind_Click);
this.dg.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dg_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
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 >10 )
{
if (linkurltitle !="")
{
e.Item .Cells[1].Text="<a href=\"" + linkurltitle+"?documentid="+e.Item.Cells[0].Text +"\" title=\""+e.Item .Cells[1].Text +"\">" + e.Item .Cells[1].Text .Substring (0,8)+"...</a>";
}
else
{
e.Item .Cells[1].Text="<a href=\"#\" title=\""+e.Item .Cells[1].Text +"\">" + e.Item .Cells[1].Text .Substring (0,8)+"...</a>";
}
}
else //标题长度不超过10
{
if (linkurltitle !="")
{
e.Item .Cells[1].Text="<a href=\""+ linkurltitle+"?documentid="+e.Item.Cells[0].Text +"\" >" + e.Item .Cells[1].Text +"</a>";
}
else
{
e.Item .Cells[1].Text="<a href=\"#\" >" + e.Item .Cells[1].Text+"</a>";
}
}
//end
//处理增加的操作列
if(opratercloumnName!="")
{
if (opratercloumnName != "操作类型")
{
e.Item .Cells[6].Text ="<a href=\"#\" onclick=oprate(\""+e.Item.Cells[0].Text +"\">"+opratercloumnName+"</a>";
}
else
{
//OI.cs .viewTransactType tt=new OI.cs.viewTransactType () ;
//string userid=Session["userid"].ToString ();
//string backvalue= tt.transactType (streamstep,e.Item.Cells[0].Text,userid);
//e.Item .Cells[6].Text =backvalue;
}
}
}
}
private int GetLengtByString(string s)
{
if (s=="") return 0;
else
return System.Text.Encoding.Default.GetByteCount(s);
}
private void ImgFind_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
dataBind11();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -