/// <summary> /// 特产 /// </summary> public void Bindtc(string types) { if (Request.QueryString["ids"] != null && Request.QueryString["ids"].ToString() != "") { foodmodel = foodbll.GetModel(Convert.ToInt32(Request.QueryString["ids"])); if (foodmodel != null) { contentstr = foodmodel.Introduction; headname = foodmodel.FoodName; if (foodmodel.Picture.ToString() != "") { string[] strlist = foodmodel.Picture.ToString().Split(','); if (strlist.Length > 0) { picimageurl1 = geturl(strlist[0].Trim(), types); if (strlist.Length > 1) { picimageurl2 = geturl(strlist[1].Trim(), types); } if (strlist.Length > 2) { picimageurl3 = geturl(strlist[2].Trim(), types); } } } } } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(HeqiaoDaoshiCore.Model.Food model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Food("); strSql.Append("CreateTime,FoodUUID,FoodName,Title,Introduction,Address,Price,Picture,State,IsDelete,FoodorTechan,Cover,Lon,Lat,ytype,PlayType,ShopId)"); strSql.Append(" values ("); strSql.Append("@CreateTime,@FoodUUID,@FoodName,@Title,@Introduction,@Address,@Price,@Picture,@State,@IsDelete,@FoodorTechan,@Cover,@Lon,@Lat,@ytype,@PlayType,@ShopId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@FoodUUID", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@FoodName", SqlDbType.NVarChar, 255), new SqlParameter("@Title", SqlDbType.NVarChar, -1), new SqlParameter("@Introduction", SqlDbType.NVarChar, -1), new SqlParameter("@Address", SqlDbType.NVarChar, -1), new SqlParameter("@Price", SqlDbType.NVarChar, 20), new SqlParameter("@Picture", SqlDbType.NVarChar, -1), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@IsDelete", SqlDbType.Int, 4), new SqlParameter("@FoodorTechan", SqlDbType.Int, 4), new SqlParameter("@Cover", SqlDbType.VarChar, 255), new SqlParameter("@Lon", SqlDbType.NVarChar, 255), new SqlParameter("@Lat", SqlDbType.NVarChar, 255), new SqlParameter("@ytype", SqlDbType.NVarChar, 255), new SqlParameter("@PlayType", SqlDbType.NVarChar, 255), new SqlParameter("@ShopId", SqlDbType.Int, 4) }; parameters[0].Value = model.CreateTime; parameters[1].Value = Guid.NewGuid(); parameters[2].Value = model.FoodName; parameters[3].Value = model.Title; parameters[4].Value = model.Introduction; parameters[5].Value = model.Address; parameters[6].Value = model.Price; parameters[7].Value = model.Picture; parameters[8].Value = model.State; parameters[9].Value = model.IsDelete; parameters[10].Value = model.FoodorTechan; parameters[11].Value = model.Cover; parameters[12].Value = model.Lon; parameters[13].Value = model.Lat; parameters[14].Value = model.ytype; parameters[15].Value = model.PlayType; parameters[16].Value = model.ShopId; object obj = DbHelperSql.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public HeqiaoDaoshiCore.Model.Food GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,CreateTime,FoodUUID,FoodName,Title,Introduction,Address,Price,Picture,State,IsDelete,FoodorTechan,Cover,Lon,Lat,ytype,PlayType,ShopId from Food "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; HeqiaoDaoshiCore.Model.Food model = new HeqiaoDaoshiCore.Model.Food(); 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 HeqiaoDaoshiCore.Model.Food DataRowToModel(DataRow row) { HeqiaoDaoshiCore.Model.Food model = new HeqiaoDaoshiCore.Model.Food(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["CreateTime"] != null && row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } if (row["FoodUUID"] != null && row["FoodUUID"].ToString() != "") { model.FoodUUID = new Guid(row["FoodUUID"].ToString()); } if (row["FoodName"] != null) { model.FoodName = row["FoodName"].ToString(); } if (row["Title"] != null) { model.Title = row["Title"].ToString(); } if (row["Introduction"] != null) { model.Introduction = row["Introduction"].ToString(); } if (row["Address"] != null) { model.Address = row["Address"].ToString(); } if (row["Price"] != null) { model.Price = row["Price"].ToString(); } if (row["Picture"] != null) { model.Picture = row["Picture"].ToString(); } if (row["State"] != null && row["State"].ToString() != "") { model.State = int.Parse(row["State"].ToString()); } if (row["IsDelete"] != null && row["IsDelete"].ToString() != "") { model.IsDelete = int.Parse(row["IsDelete"].ToString()); } if (row["FoodorTechan"] != null && row["FoodorTechan"].ToString() != "") { model.FoodorTechan = int.Parse(row["FoodorTechan"].ToString()); } if (row["Cover"] != null) { model.Cover = row["Cover"].ToString(); } if (row["Lon"] != null) { model.Lon = row["Lon"].ToString(); } if (row["Lat"] != null) { model.Lat = row["Lat"].ToString(); } if (row["ytype"] != null) { model.ytype = row["ytype"].ToString(); } if (row["PlayType"] != null) { model.PlayType = row["PlayType"].ToString(); } if (row["ShopId"] != null && row["ShopId"].ToString() != "") { model.ShopId = int.Parse(row["ShopId"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(HeqiaoDaoshiCore.Model.Food model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Food set "); strSql.Append("CreateTime=@CreateTime,"); strSql.Append("FoodName=@FoodName,"); strSql.Append("Title=@Title,"); strSql.Append("Introduction=@Introduction,"); strSql.Append("Address=@Address,"); strSql.Append("Price=@Price,"); strSql.Append("Picture=@Picture,"); strSql.Append("State=@State,"); strSql.Append("IsDelete=@IsDelete,"); strSql.Append("FoodorTechan=@FoodorTechan,"); strSql.Append("Cover=@Cover,"); strSql.Append("Lon=@Lon,"); strSql.Append("Lat=@Lat,"); strSql.Append("ytype=@ytype,"); strSql.Append("PlayType=@PlayType,"); strSql.Append("ShopId=@ShopId"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@FoodName", SqlDbType.NVarChar, 255), new SqlParameter("@Title", SqlDbType.NVarChar, -1), new SqlParameter("@Introduction", SqlDbType.NVarChar, -1), new SqlParameter("@Address", SqlDbType.NVarChar, -1), new SqlParameter("@Price", SqlDbType.NVarChar, 20), new SqlParameter("@Picture", SqlDbType.NVarChar, -1), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@IsDelete", SqlDbType.Int, 4), new SqlParameter("@FoodorTechan", SqlDbType.Int, 4), new SqlParameter("@Cover", SqlDbType.VarChar, 255), new SqlParameter("@Lon", SqlDbType.NVarChar, 255), new SqlParameter("@Lat", SqlDbType.NVarChar, 255), new SqlParameter("@ytype", SqlDbType.NVarChar, 255), new SqlParameter("@PlayType", SqlDbType.NVarChar, 255), new SqlParameter("@ShopId", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@FoodUUID", SqlDbType.UniqueIdentifier, 16) }; parameters[0].Value = model.CreateTime; parameters[1].Value = model.FoodName; parameters[2].Value = model.Title; parameters[3].Value = model.Introduction; parameters[4].Value = model.Address; parameters[5].Value = model.Price; parameters[6].Value = model.Picture; parameters[7].Value = model.State; parameters[8].Value = model.IsDelete; parameters[9].Value = model.FoodorTechan; parameters[10].Value = model.Cover; parameters[11].Value = model.Lon; parameters[12].Value = model.Lat; parameters[13].Value = model.ytype; parameters[14].Value = model.PlayType; parameters[15].Value = model.ShopId; parameters[16].Value = model.ID; parameters[17].Value = model.FoodUUID; int rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }