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/MsContainerSet/MsContainerSetDAL.cs

112 lines
3.8 KiB
C#

3 years ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsContainerSet;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
namespace DSWeb.MvcShipping.DAL.MsContainerSet
{
public class MsContainerSetDAL
{
#region Inquery DataList
static public List<MsContainerSetEntity> GetDataList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("CTNID,CTNSIZE,CTNTYPE,CTN,EDICODE,CTNWEIGHT,EEXPLAIN,CEXPLAIN,AFRCODE,TEU,DLIKGS");
strSql.Append(" from code_ctn 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 EDICODE");
}
return SetData(strSql);
}
static public MsContainerSetEntity GetData(string condition)
{
MsContainerSetEntity data = null;
var list = GetDataList(condition);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new MsContainerSetEntity();
}
return data;
}
private static List<MsContainerSetEntity> SetData(StringBuilder strSql)
{
var headList = new List<MsContainerSetEntity>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsContainerSetEntity data = new MsContainerSetEntity();
#region Set DB data to Object
data.CTNID = Convert.ToString(reader["CTNID"]);
data.CTNSIZE = Convert.ToString(reader["CTNSIZE"]);
data.CTN = Convert.ToString(reader["CTN"]);
data.EDICODE = Convert.ToString(reader["EDICODE"]);
data.CTNWEIGHT = Convert.ToString(reader["CTNWEIGHT"]);
data.EEXPLAIN = Convert.ToString(reader["EEXPLAIN"]);
data.CEXPLAIN = Convert.ToString(reader["CEXPLAIN"]);
data.AFRCODE = Convert.ToString(reader["AFRCODE"]);
data.TEU = Convert.ToDecimal(reader["TEU"].ToString() == "" ? "0" : reader["TEU"]);
data.DLIKGS = Convert.ToDecimal(reader["DLIKGS"].ToString()==""?"0": reader["DLIKGS"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
2 years ago
static public int GetRdCount(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT Count(CTNID) AS CT from code_ctn (NOLOCK) ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
var ct = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
ct = Convert.ToInt16(reader["CT"]);
}
reader.Close();
}
return ct;
}
3 years ago
#region 参照部分
#endregion
}
}