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.

106 lines
3.6 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.CodeGoodInv;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
namespace DSWeb.MvcShipping.DAL.MsCodeGoodInv
{
public class MsCodeGoodInvDAL
{
#region Inquery DataList
static public List<CodeGoodInv> GetDataList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT [GID],[GOODCODE],[GOODNAME],[DESCRIP],[TAXRATE],[TAXNO],[TAXCLASS]");
strSql.Append(",[TAXCLASSNAME],[ISTAXPRICE],[ISUSEPREF],[ISSTOP],[GoodsTypeGID],ISDEF,SPEC,UNIT,ZTAXTYPE,DEFREMARK,DEFCURR");
strSql.Append(" from code_goods_inv 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 GOODCODE");
}
return SetData(strSql);
}
static public CodeGoodInv GetData(string condition)
{
CodeGoodInv data = null;
var list = GetDataList(condition);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new CodeGoodInv();
}
return data;
}
private static List<CodeGoodInv> SetData(StringBuilder strSql)
{
var headList = new List<CodeGoodInv>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
CodeGoodInv data = new CodeGoodInv();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.GOODCODE = Convert.ToString(reader["GOODCODE"]);
data.GOODNAME = Convert.ToString(reader["GOODNAME"]);
data.DESCRIP = Convert.ToString(reader["DESCRIP"]);
if (reader["TAXRATE"] != DBNull.Value)
data.TAXRATE = Convert.ToDecimal(reader["TAXRATE"]);
data.TAXNO = Convert.ToString(reader["TAXNO"]);
data.TAXCLASS = Convert.ToString(reader["TAXCLASS"]);
data.TAXCLASSNAME = Convert.ToString(reader["TAXCLASSNAME"]);
data.GOODCODENAME = data.GOODNAME + "-" + data.TAXRATE;
data.ISTAXPRICE = Convert.ToString(reader["ISTAXPRICE"]);
data.ISUSEPREF = Convert.ToString(reader["ISUSEPREF"]);
data.ISDEF = Convert.ToString(reader["ISDEF"]);
data.SPEC = Convert.ToString(reader["SPEC"]);
data.UNIT = Convert.ToString(reader["UNIT"]);
data.ZTAXTYPE = Convert.ToString(reader["ZTAXTYPE"]);
data.DEFREMARK = Convert.ToString(reader["DEFREMARK"]);
data.DEFCURR = Convert.ToString(reader["DEFCURR"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
#endregion
}
}