using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using QMAPP.DAL;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.Equipment;
using QMAPP.FJC.Entity.MesB9;
using QMAPP.FJC.Entity.ODS;
using QMAPP.FJC.Entity.WarnManage;
using QMFrameWork.Data;
using QMFrameWork.Log;
namespace QMAPP.FJC.DAL.ODS
{
public class VideoTypeDAL : BaseDAL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// *信息
public VideoTypeEntity Get(VideoTypeEntity model)
{
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
model = session.Get(model);
}
return model;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
public List GetAllList()
{
//DataParameter[] parameters;
List parameters = new List();
//string sql = this.GetQuerySql(condition, ref parameters);
string sql = "SELECT * FROM T_ODS_VideoType ";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.GetList(sql, parameters.ToArray()).ToList();
}
}
#region 获取页面
///
/// 播放视频
///
/// 条件
/// 数据页
/// 数据页
public DataPage GetDataPageList(VideoTypeEntity condition, DataPage page)
{
string sql = null;
List parameters = new List();
try
{
sql = this.GetQuerySql(condition, ref parameters);
//分页关键字段及排序
page.KeyName = "VideoType";
page.SortExpression = "VideoType DESC";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
page = session.GetDataPage(sql, parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "视频类型数据层-视频类型页面"
});
throw;
}
}
#endregion
#region 播放视频查询语句
///
/// 播放类型查询语句
///
/// 查询条件
/// 参数
/// 查询语句
private string GetQuerySql(VideoTypeEntity condition, ref List parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.Append(@"SELECT PID
,VideoType
,MEMO
,CREATEDATE
,CREATEUSER
,UPDATEUSER
,UPDATEDATE
FROM T_ODS_VideoType T ");
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public int Insert(VideoTypeEntity model)
{
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//插入基本信息
count = session.Insert(model);
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public int Update(VideoTypeEntity model)
{
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
count = session.Update(model);
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
///
/// 判断名称是否存在
///
///
/// true:已存在;fasel:不存在。
public bool ExistsVideoType(VideoTypeEntity model)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
List parameters = new List();
int count = 0;
try
{
sqlBuilder.Append("SELECT COUNT(VideoType) FROM T_ODS_VideoType");
if (string.IsNullOrEmpty(model.VideoType) == false)
{
whereBuilder.Append(" AND VideoType = @VideoType ");
parameters.Add(new DataParameter { ParameterName = "VideoType", DataType = DbType.String, Value = model.VideoType });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
count = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), parameters.ToArray()));
}
if (count > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
///
/// 删除信息
///
///
/// 删除个数
public int Delete(VideoTypeEntity model)
{
StringBuilder sqlBuilder = new StringBuilder();
List parameters = new List();
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//删除基本信息
sqlBuilder.Append("DELETE T_ODS_VideoType ");
sqlBuilder.Append("WHERE PID = @PID ");
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = model.PID });
count = session.ExecuteSql(sqlBuilder.ToString(), parameters.ToArray());
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}