public List <Chain.Model.GiftClass> DataTableToList(DataTable dt) { List <Chain.Model.GiftClass> modelList = new List <Chain.Model.GiftClass>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { for (int i = 0; i < rowsCount; i++) { Chain.Model.GiftClass model = new Chain.Model.GiftClass(); if (dt.Rows[i]["GiftClassID"] != null && dt.Rows[i]["GiftClassID"].ToString() != "") { model.GiftClassID = int.Parse(dt.Rows[i]["GiftClassID"].ToString()); } if (dt.Rows[i]["GiftClassName"] != null && dt.Rows[i]["GiftClassName"].ToString() != "") { model.GiftClassName = dt.Rows[i]["GiftClassName"].ToString(); } if (dt.Rows[i]["GiftClassRemark"] != null && dt.Rows[i]["GiftClassRemark"].ToString() != "") { model.GiftClassRemark = dt.Rows[i]["GiftClassRemark"].ToString(); } if (dt.Rows[i]["GiftParentID"] != null && dt.Rows[i]["GiftParentID"].ToString() != "") { model.GiftParentID = int.Parse(dt.Rows[i]["GiftParentID"].ToString()); } modelList.Add(model); } } return(modelList); }
public int Update(Chain.Model.GiftClass model) { int result; if (this.Exists(model.GiftClassName, model.GiftClassID)) { result = -1; } else { result = this.dal.Update(model); } return(result); }