public static int InsertFood(Foods F) { int n = 0; string sql = "Insert Food(FoodName,Price,FoodType,FoodTime,FoodImage) "; sql += "Values ('{0}','{1}','{2}','{3}','{4}')"; sql = string.Format(sql, F.FoodName, F.FoodPrice, F.FoodType, F.FoodTime, F.FoodName); n = DBHelper.ExecuteNonQuery(sql); return(n); }
public static int UpdateFood(Foods CII) { int n = 0; string sql = "Update Food Set FoodName='{0}',Price='{1}',"; sql += "FoodType='{2}',FoodTime='{3}' Where FoodId='{4}'"; sql = string.Format(sql, CII.FoodName, CII.FoodPrice, CII.FoodType, CII.FoodTime, CII.FoodId); n = DBHelper.ExecuteNonQuery(sql); return(n); }
//查询所有菜品信息 public static List <Foods> SelectColdFoodAll() { List <Foods> tb = new List <Foods>(); string sql = "Select f.FoodId,ft.Ftype,f.FoodName,f.Price,f.FoodTime "; sql += "From Food f,FoodType ft Where f.FoodType = ft.FoodTypeId and ft.FType='凉菜'"; SqlDataReader dr = DBHelper.ExecuteReader(sql); while (dr.Read()) { Foods tbs = new Foods(); tbs.FoodId = (int)dr["FoodId"]; tbs.FoodName = (string)dr["FoodName"]; tbs.FoodPrice = (decimal)dr["Price"]; tbs.FoodTime = (TimeSpan)dr["FoodTime"]; tbs.FoodType = (string)dr["Ftype"]; tb.Add(tbs); } dr.Close(); DBHelper.Closecon(); return(tb); }