/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.OrderGoods GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,GoodsID,GoodsCode,GoodsName,type,GoodsUnit,Price,Number,TotalMoney,MasterID,MasterName,ShopID,ShopName,CreateTime from OrderGoods "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; VipSoft.Model.OrderGoods model=new VipSoft.Model.OrderGoods(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public VipSoft.Model.OrderGoods DataRowToModel(DataRow row) { VipSoft.Model.OrderGoods model=new VipSoft.Model.OrderGoods(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["GoodsID"]!=null && row["GoodsID"].ToString()!="") { model.GoodsID=int.Parse(row["GoodsID"].ToString()); } if(row["GoodsCode"]!=null) { model.GoodsCode=row["GoodsCode"].ToString(); } if(row["GoodsName"]!=null) { model.GoodsName=row["GoodsName"].ToString(); } if(row["type"]!=null && row["type"].ToString()!="") { model.type=int.Parse(row["type"].ToString()); } if(row["GoodsUnit"]!=null) { model.GoodsUnit=row["GoodsUnit"].ToString(); } if(row["Price"]!=null && row["Price"].ToString()!="") { model.Price=decimal.Parse(row["Price"].ToString()); } if(row["Number"]!=null && row["Number"].ToString()!="") { model.Number=int.Parse(row["Number"].ToString()); } if(row["TotalMoney"]!=null && row["TotalMoney"].ToString()!="") { model.TotalMoney=decimal.Parse(row["TotalMoney"].ToString()); } if(row["MasterID"]!=null && row["MasterID"].ToString()!="") { model.MasterID=int.Parse(row["MasterID"].ToString()); } if(row["MasterName"]!=null) { model.MasterName=row["MasterName"].ToString(); } if(row["ShopID"]!=null && row["ShopID"].ToString()!="") { model.ShopID=int.Parse(row["ShopID"].ToString()); } if(row["ShopName"]!=null) { model.ShopName=row["ShopName"].ToString(); } if (row["CreateTime"] != null && row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } } return model; }