📄 stream.cs
字号:
using System;
using System.Collections;
using OI.Modules;
namespace OI.Data
{
//设计人:陈仕欣 日期:2003-11-19
//v1.0 修改日期:2003-11-19
/// <summary>
/// 枚举类:Streams
/// 集合元素类:Stream
/// </summary>
/// <example>
/// <code>
/// Streams oFileList=new Streams()
/// foreach(Streams.Stream in oFileList)
/// {
/// }
/// </code>
/// <code>
/// Streams.Stream oFileList=new
/// </code>
/// </example>
public class Streams :OI.Data.DbObject,IEnumerable
{
public enum SearchSystemSignType
{
All,System,NotSystem
}
private SearchSystemSignType systemSign=SearchSystemSignType.All;
private int nCurrentRecordNum;
private string cSearchKey;
private int nStreamID=0;
private string cStreamName="";
private int nUserID=0;
public Streams()
{
}
public Streams(string newConnectionString):base( newConnectionString)
{
}
//属性接口
/// <summary>
/// 设置系统标识搜索类型
/// </summary>
public SearchSystemSignType SystemSign
{
get
{
return systemSign;
}
set
{
systemSign=value;
}
}
/// <summary>
/// 设置过滤条件:工作流ID
/// </summary>
public int StreamID
{
get
{
return nStreamID;
}
set
{
nStreamID=value;
}
}
/// <summary>
/// 设置过滤条件:工作流名称
/// </summary>
public string StreamName
{
get
{
return cStreamName;
}
set
{
cStreamName=OI.Modules.String.GenSafeChars(value);;
}
}
/// <summary>
/// 设置过滤条件:用户ID
/// </summary>
public int UserID
{
get
{
return nUserID;
}
set
{
nUserID=value;
}
}
System.Data.DataSet oDataSet;
/// <summary>
/// 当前的记录
/// </summary>
public int CurrentRecordNum
{
get
{
return nCurrentRecordNum;
}
set
{
nCurrentRecordNum=value;
}
}
/// <summary>
/// 组织查询条件
/// </summary>
/// <returns>查询字符串</returns>
private string GenSqlFilter()
{
string cSql="";
if(this.nStreamID!=0)
{
if(cSql!="")
cSql=cSql+" and StreamID ='"+this.nStreamID.ToString()+"' " ;
else
cSql=cSql+" where StreamID ='"+this.nStreamID.ToString()+"' " ;
}
if(this.cStreamName!="")
{
if(cSql!="")
cSql=cSql+" and StreamName ='"+this.cStreamName+"' " ;
else
cSql=cSql+" where StreamName ='"+this.cStreamName+"' " ;
}
if(this.nUserID!=0)
{
if(cSql!="")
cSql=cSql+" and UserID ='"+this.nUserID.ToString()+"' " ;
else
cSql=cSql+" where UserID ='"+this.nUserID.ToString()+"' " ;
}
switch(systemSign)
{
case SearchSystemSignType.All:
break;
case SearchSystemSignType.NotSystem:
if(cSql!="")
cSql=cSql+" and systemSign =0" ;
else
cSql=cSql+" where systemSign=0" ;
break;
case SearchSystemSignType.System:
if(cSql!="")
cSql=cSql+" and systemSign =1" ;
else
cSql=cSql+" where systemSign=1" ;
break;
}
if(cSearchKey!=null&&cSearchKey!="")
{
if(cSql!="")
cSql=cSql+" And ( StreamName like '%"+cSearchKey+"%')";
else
cSql=cSql+" Where ( StreamName like '%"+cSearchKey+"%')";
}
return cSql;
}
/// <summary>
/// 从项目中获取数据
/// </summary>
/// <returns>成功/失败</returns>
public void GetData()
{
if(oDataSet !=null)
oDataSet.Clear();
string sqlFilter=this.GenSqlFilter();
string calculateCmdString="SELECT count(StreamID) FROM Stream"+sqlFilter;//在此写入查询总记录数Sql查询语句
string sql="SELECT StreamID, StreamName, LastEditDate, UserID, Stream, SystemSign,Description FROM Stream"+sqlFilter;//在此写入Sql查询语句
try
{
oDataSet=this.RunCommand(calculateCmdString,sql,"Stream");//在此写入表名
}
catch(System.Data.SqlClient.SqlException e)
{
if(this.Connection.State==System.Data.ConnectionState.Open)
this.Connection.Close();
throw new AppException("执行下列语句出错:\n\r"+sql,e);
}
}
public void GetData(string departmentid)
{
if(oDataSet !=null)
oDataSet.Clear();
string sqlFilter=this.GenSqlFilter();
string calculateCmdString="SELECT count(StreamID) FROM Stream where departmentid in"+departmentid ;//在此写入查询总记录数Sql查询语句
string sql="SELECT StreamID, StreamName, LastEditDate, UserID, Stream, SystemSign,Description FROM Stream where departmentid in"+departmentid ;//在此写入Sql查询语句
try
{
oDataSet=this.RunCommand(calculateCmdString,sql,"Stream");//在此写入表名
}
catch(System.Data.SqlClient.SqlException e)
{
if(this.Connection.State==System.Data.ConnectionState.Open)
this.Connection.Close();
throw new AppException("执行下列语句出错:\n\r"+sql,e);
}
}
/// <summary>
/// 查询关键字
///在以下项目中查询:
///工作流名称、
/// </summary>
public string SearchKey
{
get
{
return cSearchKey;
}
set
{
cSearchKey=OI.Modules.String.GenSafeChars(value);
}
}
/// <summary>
/// 获取查询后的数据XML格式字符串
/// </summary>
/// <returns>成功或失败</returns>
public string GetDataXml()
{
if(this.oDataSet==null)
GetData();
return oDataSet.GetXml() ;
}
/// <summary>
///
/// </summary>
/// <param name="StreamName"></param>
/// <param name="UserID"></param>
/// <param name="Stream"></param>
/// <returns></returns>
public bool AddStream( string StreamName, int UserID,string Description,string Stream,int departmentid )
{
StreamName=OI.Modules.String.GenSafeChars(StreamName);
Stream=OI.Modules.String.GenSafeChars(Stream);
Description=OI.Modules.String.GenSafeChars(Description);
string sql="insert into Stream( StreamName, LastEditDate, UserID, Stream, SystemSign ,Description,departmentid) "+
" values('"+StreamName+"','"+System.DateTime.Now+"','"+UserID.ToString()+"','"+Stream+"','0','"+Description+"',"+departmentid +")";
int rowsAffected;
try
{
this.RunCommand(sql,out rowsAffected);
}
catch(System.Data.SqlClient.SqlException e)
{
if(this.Connection.State==System.Data.ConnectionState.Open)
this.Connection.Close();
throw new AppException("执行下列SQL语句发生错误\n\r"+sql,e);
}
if(rowsAffected<1)
return false;
return true;
}
/// <summary>
///
/// </summary>
/// <param name="StreamName"></param>
/// <param name="UserID"></param>
/// <param name="Stream"></param>
/// <param name="StreamID"></param>
/// <returns></returns>
public bool AddStream( string StreamName, int UserID,string Stream,string Description,out int StreamID,int departmentid)
{
StreamName=OI.Modules.String.GenSafeChars(StreamName);
Stream=OI.Modules.String.GenSafeChars(Stream);
Description=OI.Modules.String.GenSafeChars(Description);
string sql="insert into Stream( StreamName, LastEditDate, UserID, Stream, SystemSign ,Description,departmentid) "+
" values('"+StreamName+"','"+System.DateTime.Now+"','"+UserID.ToString()+"','"+Stream+"','0','"+Description+"',"+ departmentid +")"+
" select @@identity ";
System.Data.SqlClient.SqlDataReader oReader;
try
{
oReader=this.RunCommand(sql);
if(oReader.Read())
{
if(!oReader.IsDBNull(0))
StreamID=System.Convert.ToInt32(oReader.GetValue(0));
else
{
StreamID=0;
return false;
}
}
else
{
StreamID=0;
return false;
}
}
catch(System.Data.SqlClient.SqlException e)
{
if(this.Connection.State==System.Data.ConnectionState.Open)
this.Connection.Close();
throw new AppException("执行下列SQL语句发生错误\n\r"+sql,e);
}
return true;
}
/// <summary>
/// 修改
/// </summary>
/// <returns></returns>
public bool EditStream(int StreamID,string StreamName,int UserID,string Stream,string Description)
{
StreamName=OI.Modules.String.GenSafeChars(StreamName);
Stream=OI.Modules.String.GenSafeChars(Stream);
Description=OI.Modules.String.GenSafeChars(Description);
string sql="update Stream set StreamName='"+StreamName+"',"+
"LastEditDate='"+System.DateTime.Now+"',"+
"UserID='"+UserID+"',"+
"Stream='"+Stream+"',"+
"Description='"+Description+"' "+
" where StreamID='"+StreamID+"'";
int rowsAffected;
try
{
this.RunCommand(sql,out rowsAffected);
}
catch(System.Data.SqlClient.SqlException e)
{
if(this.Connection.State==System.Data.ConnectionState.Open)
this.Connection.Close();
throw new AppException("执行下列SQL语句发生错误\n\r"+sql,e);
}
if(rowsAffected<1)
return false;
return true;
}
/// <summary>
/// 删除
/// </summary>
/// <returns></returns>
public bool DeleteStream(int StreamID)
{
string sql="delete from Stream where StreamID='"+StreamID+"'";
int rowsAffected;
try
{
this.RunCommand(sql,out rowsAffected);
}
catch(System.Data.SqlClient.SqlException e)
{
if(this.Connection.State==System.Data.ConnectionState.Open)
this.Connection.Close();
throw new AppException("执行下列SQL语句发生错误\n\r"+sql,e);
}
if(rowsAffected<1)
return false;
return true;
}
/// <summary>
/// 获取当前的元素
/// </summary>
/// <returns>返回元素类</returns>
public IEnumerator GetEnumerator()
{
return new Stream(this);
}
public bool Disponse()
{
if(this.oDataSet!=null)
{
this.oDataSet.Clear();
this.oDataSet.Dispose();
}
return true;
}
//内含的类
/// <summary>
/// 内含的类
/// </summary>
public class Stream:Data.DbObject,IEnumerator
{
//============================以下代码为类:Stream的属性变量
int nStreamID;
string cStreamName;
System.DateTime dLastEditDate;
int nUserID;
string cStream;
bool systemSign;
string description;
//以下代码为类:Stream的属性变量
/// <summary>
/// 属性:工作流描述
/// </summary>
public string Description
{
get
{
return description;
}
set
{
description=value;
}
}
/// <summary>
/// 属性:工作流ID
/// </summary>
public int StreamID
{
get
{
return nStreamID;
}
set
{
nStreamID=value;
}
}
/// <summary>
/// 属性:工作流名称
/// </summary>
public string StreamName
{
get
{
return cStreamName;
}
set
{
cStreamName=value;
}
}
/// <summary>
/// 属性:修改日期
/// </summary>
public System.DateTime LastEditDate
{
get
{
return dLastEditDate;
}
set
{
dLastEditDate=value;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -