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 /// /// 是否存在该记录 /// public bool Exists(string GID) { return dal.Exists(GID); } /// /// 增加一条数据 /// public int Add(DecList model) { return dal.Add(model); } /// /// 更新一条数据 /// public int Update(DecList model) { return dal.Update(model); } /// /// 删除一条数据 /// public int Delete(string GID) { return dal.Delete(GID); } /// /// 按条件批量删除(有风险) /// public int DeleteListWhere(string strWhere) { return dal.DeleteListWhere(strWhere); } /// /// 得到一个对象实体 /// 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; } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { return dal.GetList(strWhere); } /// /// 获得前几行数据 /// public DataSet GetList(int Top,string strWhere,string filedOrder) { return dal.GetList(Top,strWhere,filedOrder); } /// /// 获得数据列表 /// public List GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); return DataTableToList(ds.Tables[0]); } /// /// 获得数据列表 /// public List DataTableToList(DataTable dt) { List modelList = new List(); 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; } /// /// 获得数据 /// 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=int.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=int.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; } /// /// 获得数据列表 /// public DataSet GetAllList() { return GetList(""); } /// /// 分页获取数据列表 /// /// /// /// /// /// public List 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]); } /// /// 获取记录总数 /// public int GetRecordCount(string strWhere) { return dal.GetRecordCount(strWhere); } #endregion } }