/// <summary> /// 获得数据列表 /// </summary> public List <XHD.Model.CRM_product> DataTableToList(DataTable dt) { List <XHD.Model.CRM_product> modelList = new List <XHD.Model.CRM_product>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { XHD.Model.CRM_product model; for (int n = 0; n < rowsCount; n++) { model = new XHD.Model.CRM_product(); if (dt.Rows[n]["product_id"] != null && dt.Rows[n]["product_id"].ToString() != "") { model.product_id = int.Parse(dt.Rows[n]["product_id"].ToString()); } if (dt.Rows[n]["product_name"] != null && dt.Rows[n]["product_name"].ToString() != "") { model.product_name = dt.Rows[n]["product_name"].ToString(); } if (dt.Rows[n]["category_id"] != null && dt.Rows[n]["category_id"].ToString() != "") { model.category_id = int.Parse(dt.Rows[n]["category_id"].ToString()); } if (dt.Rows[n]["category_name"] != null && dt.Rows[n]["category_name"].ToString() != "") { model.category_name = dt.Rows[n]["category_name"].ToString(); } if (dt.Rows[n]["specifications"] != null && dt.Rows[n]["specifications"].ToString() != "") { model.specifications = dt.Rows[n]["specifications"].ToString(); } if (dt.Rows[n]["status"] != null && dt.Rows[n]["status"].ToString() != "") { model.status = dt.Rows[n]["status"].ToString(); } if (dt.Rows[n]["unit"] != null && dt.Rows[n]["unit"].ToString() != "") { model.unit = dt.Rows[n]["unit"].ToString(); } if (dt.Rows[n]["remarks"] != null && dt.Rows[n]["remarks"].ToString() != "") { model.remarks = dt.Rows[n]["remarks"].ToString(); } if (dt.Rows[n]["price"] != null && dt.Rows[n]["price"].ToString() != "") { model.price = decimal.Parse(dt.Rows[n]["price"].ToString()); } if (dt.Rows[n]["isDelete"] != null && dt.Rows[n]["isDelete"].ToString() != "") { model.isDelete = int.Parse(dt.Rows[n]["isDelete"].ToString()); } if (dt.Rows[n]["Delete_time"] != null && dt.Rows[n]["Delete_time"].ToString() != "") { model.Delete_time = DateTime.Parse(dt.Rows[n]["Delete_time"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// ��������б� /// </summary> public List<XHD.Model.CRM_product> DataTableToList(DataTable dt) { List<XHD.Model.CRM_product> modelList = new List<XHD.Model.CRM_product>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { XHD.Model.CRM_product model; for (int n = 0; n < rowsCount; n++) { model = new XHD.Model.CRM_product(); if(dt.Rows[n]["product_id"]!=null && dt.Rows[n]["product_id"].ToString()!="") { model.product_id=int.Parse(dt.Rows[n]["product_id"].ToString()); } if(dt.Rows[n]["product_name"]!=null && dt.Rows[n]["product_name"].ToString()!="") { model.product_name=dt.Rows[n]["product_name"].ToString(); } if(dt.Rows[n]["category_id"]!=null && dt.Rows[n]["category_id"].ToString()!="") { model.category_id=int.Parse(dt.Rows[n]["category_id"].ToString()); } if(dt.Rows[n]["category_name"]!=null && dt.Rows[n]["category_name"].ToString()!="") { model.category_name=dt.Rows[n]["category_name"].ToString(); } if(dt.Rows[n]["specifications"]!=null && dt.Rows[n]["specifications"].ToString()!="") { model.specifications=dt.Rows[n]["specifications"].ToString(); } if(dt.Rows[n]["status"]!=null && dt.Rows[n]["status"].ToString()!="") { model.status=dt.Rows[n]["status"].ToString(); } if(dt.Rows[n]["unit"]!=null && dt.Rows[n]["unit"].ToString()!="") { model.unit=dt.Rows[n]["unit"].ToString(); } if(dt.Rows[n]["remarks"]!=null && dt.Rows[n]["remarks"].ToString()!="") { model.remarks=dt.Rows[n]["remarks"].ToString(); } if(dt.Rows[n]["price"]!=null && dt.Rows[n]["price"].ToString()!="") { model.price=decimal.Parse(dt.Rows[n]["price"].ToString()); } if (dt.Rows[n]["base_price"] != null && dt.Rows[n]["base_price"].ToString() != "") { model.base_price = decimal.Parse(dt.Rows[n]["base_price"].ToString()); } if(dt.Rows[n]["isDelete"]!=null && dt.Rows[n]["isDelete"].ToString()!="") { model.isDelete=int.Parse(dt.Rows[n]["isDelete"].ToString()); } if(dt.Rows[n]["Delete_time"]!=null && dt.Rows[n]["Delete_time"].ToString()!="") { model.Delete_time=DateTime.Parse(dt.Rows[n]["Delete_time"].ToString()); } if (dt.Rows[n]["pway_content"] != null && dt.Rows[n]["pway_content"].ToString() != "") { model.pway_content = dt.Rows[n]["pway_content"].ToString(); } modelList.Add(model); } } return modelList; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(XHD.Model.CRM_product model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(XHD.Model.CRM_product model) { return(dal.Add(model)); }