You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/DAL/MsSysUpdateSql/MsSysUpdateSqlDAL.cs

92 lines
2.9 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsSysUpdateSql;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
namespace DSWeb.MvcShipping.DAL.MsSysUpdateSql
{
public class MsSysUpdateSqlDAL
{
#region Inquery DataList
static public List<SysUpdateSql> GetDataList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT [GID],[SQLVER],[SORT],[SQLTEXT],[REMARKS],[INPUTBY],[INPUTTIME]");
strSql.Append(" from sys_update_sql where 1=1 ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else {
strSql.Append(" order by SQLVER DESC");
}
return SetData(strSql);
}
static public SysUpdateSql GetData(string condition)
{
SysUpdateSql data = null;
var list = GetDataList(condition);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new SysUpdateSql();
}
return data;
}
private static List<SysUpdateSql> SetData(StringBuilder strSql)
{
var headList = new List<SysUpdateSql>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
SysUpdateSql data = new SysUpdateSql();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.SQLVER = Convert.ToString(reader["SQLVER"]);
if (reader["SORT"] != DBNull.Value)
data.SORT = Convert.ToInt16(reader["SORT"]);
data.SQLTEXT = Convert.ToString(reader["SQLTEXT"]);
data.REMARKS = Convert.ToString(reader["REMARKS"]);
data.INPUTBY = Convert.ToString(reader["INPUTBY"]);
data.INPUTBYREF = Convert.ToString(reader["INPUTBYREF"]);
if (reader["INPUTTIME"] != DBNull.Value)
data.INPUTTIME = Convert.ToDateTime(reader["INPUTTIME"]).ToString("yyyy-MM-dd HH:mm:ss");
#endregion
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
#endregion
}
}