/// <summary> /// 获得数据列表 /// </summary> public List <JY.Model.Collection> DataTableToList(DataTable dt) { List <JY.Model.Collection> modelList = new List <JY.Model.Collection>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JY.Model.Collection model; for (int n = 0; n < rowsCount; n++) { model = new JY.Model.Collection(); if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "") { model.ID = long.Parse(dt.Rows[n]["ID"].ToString()); } if (dt.Rows[n]["ProductId"] != null && dt.Rows[n]["ProductId"].ToString() != "") { model.ProductId = int.Parse(dt.Rows[n]["ProductId"].ToString()); } if (dt.Rows[n]["ProductName"] != null && dt.Rows[n]["ProductName"].ToString() != "") { model.ProductName = dt.Rows[n]["ProductName"].ToString(); } if (dt.Rows[n]["MemberId"] != null && dt.Rows[n]["MemberId"].ToString() != "") { model.MemberId = int.Parse(dt.Rows[n]["MemberId"].ToString()); } if (dt.Rows[n]["MemberName"] != null && dt.Rows[n]["MemberName"].ToString() != "") { model.MemberName = dt.Rows[n]["MemberName"].ToString(); } if (dt.Rows[n]["CollectionDate"] != null && dt.Rows[n]["CollectionDate"].ToString() != "") { model.CollectionDate = DateTime.Parse(dt.Rows[n]["CollectionDate"].ToString()); } if (dt.Rows[n]["Sort"] != null && dt.Rows[n]["Sort"].ToString() != "") { model.Sort = int.Parse(dt.Rows[n]["Sort"].ToString()); } if (dt.Rows[n]["IsDelete"] != null && dt.Rows[n]["IsDelete"].ToString() != "") { if ((dt.Rows[n]["IsDelete"].ToString() == "1") || (dt.Rows[n]["IsDelete"].ToString().ToLower() == "true")) { model.IsDelete = true; } else { model.IsDelete = false; } } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JY.Model.Collection model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public long Add(JY.Model.Collection model) { return(dal.Add(model)); }