using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using Model;
|
using Common;
|
using Oracle.ManagedDataAccess.Client;
|
using System.Data.Common;
|
|
namespace Dao
|
{
|
/// <summary>
|
/// 流程定义表操作
|
/// </summary>
|
public class SysFlowDao : IDisposable
|
{
|
public void Dispose()
|
{
|
}
|
|
private static SysFlowDao _instance;
|
public static SysFlowDao Instance
|
{
|
get {
|
if (_instance == null)
|
{
|
_instance = new SysFlowDao();
|
}
|
return _instance;
|
}
|
}
|
|
/// <summary>
|
/// 获取信息列表
|
/// </summary>
|
/// <returns></returns>
|
public List<SysFlow> List(SysFlow sysFlow)
|
{
|
List<SysFlow> list = new List<SysFlow>();
|
try
|
{
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("SELECT SFN.* ");
|
stringBuilder.Append(" FROM SYS_FLOW SFN ");
|
stringBuilder.Append(" WHERE 1=1 ");
|
|
if (sysFlow.FlowCode != null && sysFlow.FlowCode != "")
|
{
|
stringBuilder.Append(" AND FLOW_CODE= '" + sysFlow.FlowCode + "' ");
|
}
|
if (sysFlow.Status != 0)
|
{
|
stringBuilder.Append(" AND STATUS= " + sysFlow.Status + " ");
|
}
|
stringBuilder.Append(" ORDER BY FLOW_CODE ");
|
|
using (OracleDataReader reader = OracleHelper.ExecuteReader(stringBuilder.ToString() , OracleHelper.Connection))
|
{
|
while (((DbDataReader)reader).Read())
|
{
|
SysFlow o = new SysFlow();
|
if (this.ReadInfo(reader, o))
|
list.Add(o);
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex);
|
return list;
|
}
|
return list;
|
}
|
|
|
//添加信息
|
public bool Add(SysFlow o)
|
{
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("INSERT INTO SYS_FLOW ( ");
|
stringBuilder.Append(" ID, FLOW_CODE, FLOW_NAME, FLOW_GROUP, STATUS ");
|
stringBuilder.Append(" ) ");
|
stringBuilder.Append(" VALUES (:ID, :FLOW_CODE, :FLOW_NAME, :FLOW_GROUP, :STATUS ");
|
stringBuilder.Append(" ) ");
|
|
string sql = stringBuilder.ToString();
|
|
return OracleHelper.ExecuteSql(sql,
|
OracleHelper.Connection,
|
new OracleParameter(":ID", (object)o.Id),
|
new OracleParameter(":FLOW_CODE", (object)o.FlowCode),
|
new OracleParameter(":FLOW_NAME", (object)o.FlowName),
|
new OracleParameter(":FLOW_GROUP", (object)o.FlowGroup),
|
new OracleParameter(":STATUS", (object)o.Status)
|
) > 0;
|
}
|
|
//删除
|
public bool Delete(string id)
|
{
|
if (string.IsNullOrEmpty(id) )
|
return false;
|
return OracleHelper.ExecuteSql("delete from SYS_FLOW where ID=:ID", OracleHelper.Connection, new OracleParameter(":ID", (object)id)) > 0;
|
}
|
|
//更新产品或产品分类信息
|
public bool Update(SysFlow o)
|
{
|
OracleParameter[] cmdParms = new OracleParameter[] {
|
new OracleParameter(":ID", (object)o.Id),
|
new OracleParameter(":FLOW_CODE", (object)o.FlowCode),
|
new OracleParameter(":FLOW_NAME", (object)o.FlowName),
|
new OracleParameter(":FLOW_GROUP", (object)o.FlowGroup),
|
new OracleParameter(":STATUS", (object)o.Status)
|
};
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("UPDATE SYS_FLOW SET ");
|
stringBuilder.Append(" , FLOW_CODE =:FLOW_CODE ");
|
stringBuilder.Append(" , FLOW_NAME =:FLOW_NAME ");
|
stringBuilder.Append(" , FLOW_GROUP =:FLOW_GROUP ");
|
stringBuilder.Append(" , STATUS=:STATUS ");
|
stringBuilder.Append(" WHERE ID=:ID ");
|
|
string sql = stringBuilder.ToString();
|
return (OracleHelper.ExecuteSql(sql, OracleHelper.Connection, cmdParms) > 0);
|
}
|
|
//获取信息
|
public SysFlow Get(string id)
|
{
|
SysFlow o = new SysFlow();
|
if (string.IsNullOrEmpty(id))
|
return o;
|
using (OracleDataReader reader = OracleHelper.ExecuteReader(string.Format("select * from SYS_FLOW where ID=:ID"), OracleHelper.Connection, new OracleParameter(":ID", (object)id)))
|
{
|
if (((DbDataReader)reader).Read())
|
{
|
this.ReadInfo(reader, o);
|
return o;
|
}
|
}
|
return o;
|
}
|
|
//获取信息
|
public SysFlow Get(SysFlow sysFlow)
|
{
|
SysFlow o = new SysFlow();
|
if (sysFlow==null)
|
return o;
|
|
try
|
{
|
StringBuilder stringBuilder = new StringBuilder();
|
stringBuilder.Append("SELECT SFN.* ");
|
stringBuilder.Append(" FROM SYS_FLOW SFN ");
|
stringBuilder.Append(" WHERE 1=1 ");
|
|
if (sysFlow.Id != null && sysFlow.Id != "")
|
{
|
stringBuilder.Append(" AND ID= '" + sysFlow.Id + "' ");
|
}
|
if (sysFlow.FlowCode != null && sysFlow.FlowCode != "")
|
{
|
stringBuilder.Append(" AND FLOW_CODE= '" + sysFlow.FlowCode + "' ");
|
}
|
if (sysFlow.Status != 0)
|
{
|
stringBuilder.Append(" AND STATUS= " + sysFlow.Status + " ");
|
}
|
|
using (OracleDataReader reader = OracleHelper.ExecuteReader(stringBuilder.ToString(), OracleHelper.Connection))
|
{
|
if (((DbDataReader)reader).Read())
|
{
|
this.ReadInfo(reader, o);
|
return o;
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex);
|
return null;
|
}
|
|
return o;
|
}
|
|
//统计记录数
|
private int ReadCount(OracleDataReader reader)
|
{
|
OracleReaderWrapper wrapper = new OracleReaderWrapper(reader);
|
return wrapper.GetInt("count", 0);
|
}
|
|
//数据封装
|
private bool ReadInfo(OracleDataReader reader, SysFlow o)
|
{
|
OracleReaderWrapper oracleReaderWrapper = new OracleReaderWrapper(reader);
|
o.Id = oracleReaderWrapper.GetString("ID", "");
|
o.FlowCode = oracleReaderWrapper.GetString("FLOW_CODE", "");
|
o.FlowName = oracleReaderWrapper.GetString("FLOW_NAME", "");
|
o.FlowGroup = oracleReaderWrapper.GetString("FLOW_GROUP", "");
|
o.Status = oracleReaderWrapper.GetInt("STATUS", 0);
|
return true;
|
}
|
|
}
|
|
}
|