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/MsContainerSetCtn/MsContainerSetCtnDAL.cs

112 lines
3.5 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsContainerSetCtn;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using DSWeb.MvcShipping.Models.MsContainerSet;
using HcUtility.Comm;
namespace DSWeb.MvcShipping.DAL.MsContainerSetCtn
{
public class MsContainerSetCtnDAL
{
#region Inquery DataList
static public List<MsContainerSetCtnEntity> GetDataList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("ID,CNT1,CNT2,CNT3,CNT4,CNT5,CNT6,CNT7,CNT8,CNT9,CNT10,CORPID");
strSql.Append(" from code_ctn_disp 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 ID");
}
return SetData(strSql);
}
static public MsContainerSetCtnEntity GetData(string condition)
{
MsContainerSetCtnEntity data = null;
var list = GetDataList(condition);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new MsContainerSetCtnEntity();
}
return data;
}
static public bool IsExist(string condition)
{
bool isR = true;
MsContainerSetCtnEntity data = null;
var list = GetDataList(condition);
if (list.Count > 0)
data = list[0];
if (data == null)
{
isR = false;
}
return isR;
}
private static List<MsContainerSetCtnEntity> SetData(StringBuilder strSql)
{
var headList = new List<MsContainerSetCtnEntity>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsContainerSetCtnEntity data = new MsContainerSetCtnEntity();
#region Set DB data to Object
data.ID = Convert.ToString(reader["ID"]);
data.CNT1 = Convert.ToString(reader["CNT1"]);
data.CNT2 = Convert.ToString(reader["CNT2"]);
data.CNT3 = Convert.ToString(reader["CNT3"]);
data.CNT4 = Convert.ToString(reader["CNT4"]);
data.CNT5 = Convert.ToString(reader["CNT5"]);
data.CNT6 = Convert.ToString(reader["CNT6"]);
data.CNT7 = Convert.ToString(reader["CNT7"]);
data.CNT8 = Convert.ToString(reader["CNT8"]);
data.CNT9 = Convert.ToString(reader["CNT9"]);
data.CNT10 = Convert.ToString(reader["CNT10"]);
data.CORPID = Convert.ToString(reader["CORPID"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
#endregion
}
}