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/SoftMng/BLL/DecList.cs

213 lines
6.9 KiB
C#

3 years ago
using System;
using System.Collections.Generic;
using System.Data;
using DSWeb.SoftMng.Model;
// ReSharper disable once CheckNamespace
namespace DSWeb.SoftMng.BLL {
//DecList
public partial class DecListBLL
{
private readonly DAL.DecListDAL dal=new DAL.DecListDAL();
#region Method
/// <summary>
/// 是否存在该记录
/// </summary>
public bool Exists(string GID)
{
return dal.Exists(GID);
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(DecList model)
{
return dal.Add(model);
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Update(DecList model)
{
return dal.Update(model);
}
/// <summary>
/// 删除一条数据
/// </summary>
public int Delete(string GID)
{
return dal.Delete(GID);
}
/// <summary>
/// 按条件批量删除(有风险)
/// </summary>
public int DeleteListWhere(string strWhere)
{
return dal.DeleteListWhere(strWhere);
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public DecList GetModel(string GID)
{
DataSet ds = dal.GetModel(GID);
if(ds.Tables.Count> 0){
var dt = ds.Tables[0];
if(dt.Rows.Count>0){
var dr = dt.Rows[0];
return DataRowToModel(dr);
}
return null;
}
return null;
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
return dal.GetList(strWhere);
}
/// <summary>
/// 获得前几行数据
/// </summary>
public DataSet GetList(int Top,string strWhere,string filedOrder)
{
return dal.GetList(Top,strWhere,filedOrder);
}
/// <summary>
/// 获得数据列表
/// </summary>
public List<DecList> GetModelList(string strWhere)
{
DataSet ds = dal.GetList(strWhere);
return DataTableToList(ds.Tables[0]);
}
/// <summary>
/// 获得数据列表
/// </summary>
public List<DecList> DataTableToList(DataTable dt)
{
List<DecList> modelList = new List<DecList>();
int rowsCount = dt.Rows.Count;
if (rowsCount > 0)
{
for (int n = 0; n < rowsCount; n++)
{
var model = DataRowToModel(dt.Rows[n]);
modelList.Add(model);
}
}
return modelList;
}
/// <summary>
/// 获得数据
/// </summary>
public DecList DataRowToModel(DataRow dr)
{
var model = new DecList();
model.GID= dr["GID"].ToString();
model.GNo= dr["GNo"].ToString();
model.ContrItem= dr["ContrItem"].ToString();
model.CodeTS= dr["CodeTS"].ToString();
model.CiqCode= dr["CiqCode"].ToString();
model.CiqCode_Text= dr["CiqCode_Text"].ToString();
model.GName= dr["GName"].ToString();
model.GModel= dr["GModel"].ToString();
if (dr["GQty"].ToString()!="")
model.GQty=decimal.Parse(dr["GQty"].ToString());
model.GUnit= dr["GUnit"].ToString();
model.GUnit_Text= dr["GUnit_Text"].ToString();
if (dr["DeclPrice"].ToString()!="")
model.DeclPrice=decimal.Parse(dr["DeclPrice"].ToString());
if (dr["DeclTotal"].ToString()!="")
model.DeclTotal=decimal.Parse(dr["DeclTotal"].ToString());
model.TradeCurr= dr["TradeCurr"].ToString();
model.TradeCurr_Text= dr["TradeCurr_Text"].ToString();
if (dr["FirstQty"].ToString()!="")
model.FirstQty=decimal.Parse(dr["FirstQty"].ToString());
model.FirstUnit= dr["FirstUnit"].ToString();
model.FirstUnit_Text= dr["FirstUnit_Text"].ToString();
model.ExgVersion= dr["ExgVersion"].ToString();
model.ExgNo= dr["ExgNo"].ToString();
model.DestinationCountry= dr["DestinationCountry"].ToString();
model.DestinationCountry_Text= dr["DestinationCountry_Text"].ToString();
if (dr["SecondQty"].ToString()!="")
model.SecondQty= decimal.Parse(dr["SecondQty"].ToString());
model.SecondUnit= dr["SecondUnit"].ToString();
model.SecondUnit_Text= dr["SecondUnit_Text"].ToString();
model.OriginCountry= dr["OriginCountry"].ToString();
model.OriginCountry_Text= dr["OriginCountry_Text"].ToString();
model.DistrictCode= dr["DistrictCode"].ToString();
model.DistrictCode_Text= dr["DistrictCode_Text"].ToString();
model.DestCode= dr["DestCode"].ToString();
model.DestCode_Text= dr["DestCode_Text"].ToString();
model.DutyMode= dr["DutyMode"].ToString();
model.DutyMode_Text= dr["DutyMode_Text"].ToString();
model.GoodsAttr= dr["GoodsAttr"].ToString();
model.GoodsAttr_Text= dr["GoodsAttr_Text"].ToString();
model.Purpose= dr["Purpose"].ToString();
model.Purpose_Text= dr["Purpose_Text"].ToString();
if (dr["NoDangFlag"].ToString()!="")
model.NoDangFlag=int.Parse(dr["NoDangFlag"].ToString());
model.Uncode= dr["Uncode"].ToString();
model.DangName= dr["DangName"].ToString();
if (dr["DangPackType"].ToString()!="")
model.DangPackType=int.Parse(dr["DangPackType"].ToString());
model.DangPackSpec= dr["DangPackSpec"].ToString();
model.DangPackSpec_Text= dr["DangPackSpec_Text"].ToString();
model.Stuff= dr["Stuff"].ToString();
if (dr["ProdValidDt"].ToString()!="")
model.ProdValidDt=DateTime.Parse(dr["ProdValidDt"].ToString());
if (dr["ProdQgp"].ToString()!="")
model.ProdQgp=int.Parse(dr["ProdQgp"].ToString());
model.EngManEntCnm= dr["EngManEntCnm"].ToString();
model.GoodsSpec= dr["GoodsSpec"].ToString();
model.GoodsModel= dr["GoodsModel"].ToString();
model.GoodsBrand= dr["GoodsBrand"].ToString();
//if (dr["ProduceDate"].ToString()!="")
//model.ProduceDate=DateTime.Parse(dr["ProduceDate"].ToString());
model.ProduceDate = dr["ProduceDate"].ToString();
model.ProdBatchNo= dr["ProdBatchNo"].ToString();
model.MnufctrRegNo= dr["MnufctrRegNo"].ToString();
model.PID= dr["PID"].ToString();
return model;
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetAllList()
{
return GetList("");
}
/// <summary>
/// 分页获取数据列表
/// </summary>
/// <param name="startIndex"></param>
/// <param name="limit"></param>
/// <param name="strWhere"></param>
/// <param name="orderby"></param>
/// <returns></returns>
public List<DecList> GetModelList(int startIndex, int limit, string strWhere, string orderby)
{
int endIndex = startIndex + limit;
DataSet ds = dal.GetListByPage(strWhere,orderby,startIndex,endIndex);
return DataTableToList(ds.Tables[0]);
}
/// <summary>
/// 获取记录总数
/// </summary>
public int GetRecordCount(string strWhere)
{
return dal.GetRecordCount(strWhere);
}
#endregion
}
}