示例#1
0
 public List<DishEntity> getDishListById(string id)
 {
     //string mysql = "SELECT * FROM yumiyumi.yumi_account where user_name ='"+email+"'";
     string mysql = "SELECT * FROM yumiyumi.yumi_dish natural join yumi_brand natural join yumi_brand_type where brand_id = ?id";
     MySqlParameter[] parameters = {
             new MySqlParameter("?id", MySqlDbType.VarChar, 255),
             };
     parameters[0].Value = id;
     MySqlDataReader myreader = MySqlHelper.ExecuteReader(mysql, parameters);
     List<DishEntity> dishList = new List<DishEntity>();
     while (myreader.Read())
     {
         DishEntity dish = new DishEntity();
         dish.id = myreader.GetInt32(2);
         dish.photo = myreader.GetString(3);
         dish.brand_id = myreader.GetInt32(0);
         dish.description = myreader.GetString(4);
         dish.price = myreader.GetInt32(5);
         dish.dish_name = myreader.GetString(6);
         dish.type_id = myreader.GetInt32(1);
         dish.type_name = myreader.GetString(12);
         dishList.Add(dish);
     }
     myreader.Close();
     return dishList;
 }
示例#2
0
        public bool addOneDish(DishEntity dish)
        {
            string mysql = "INSERT INTO `yumi_dish`( `dish_thumbimage` , `brand_id` , `dish_description` ,"
                + "`dish_price` , `type_id` , `dish_name`,`status` ) values(?dish_thumbimage,"
                + "?brand_id,?dish_description,?dish_price,?type_id,?dish_name,?status)";
            MySqlParameter[] parameters = {
                    new MySqlParameter("?dish_thumbimage", MySqlDbType.VarChar,255),
                    new MySqlParameter("?brand_id", MySqlDbType.UInt32),
                    new MySqlParameter("?dish_description", MySqlDbType.VarChar,255),
                    new MySqlParameter("?dish_price", MySqlDbType.UInt32),
                    new MySqlParameter("?type_id", MySqlDbType.UInt32),
                    new MySqlParameter("?dish_name", MySqlDbType.VarChar,255),
                    new MySqlParameter("?status", MySqlDbType.UInt32)
                    };
            parameters[0].Value = "";
            parameters[1].Value = 1;
            parameters[2].Value = dish.description;
            parameters[3].Value = dish.price;
            parameters[4].Value = dish.type_id;
            parameters[5].Value = dish.dish_name;
            parameters[6].Value = dish.status;

            //通过MySqlCommand的ExecuteReader()方法构造DataReader对象
            int count = MySqlHelper.ExecuteNonQuery(mysql, parameters);
            if (count > 0) { return true; }
            else{return false;}
        }
示例#3
0
 public DishEntity getDishById(int dishId)
 {
     //string mysql = "SELECT * FROM yumiyumi.yumi_account where user_name ='"+email+"'";
     string mysql = "SELECT dish_id,dish_thumbimage,brand_id,dish_description,dish_price,type_id,dish_name FROM yumiyumi.yumi_dish where dish_id = ?dish_id";
     MySqlParameter[] parameters = {
             new MySqlParameter("?dish_id", MySqlDbType.UInt32),
             };
     parameters[0].Value = dishId;
     MySqlDataReader myreader = MySqlHelper.ExecuteReader(mysql, parameters);
     DishEntity dish = new DishEntity();
     while (myreader.Read())
     {
         dish.id = dishId;
         dish.photo = myreader.GetString(1);
         dish.brand_id = myreader.GetInt32(2);
         dish.description = myreader.GetString(3);
         dish.price = myreader.GetInt32(4);
         dish.type_id = myreader.GetInt32(5);
         dish.dish_name = myreader.GetString(6);
     }
     myreader.Close();
     return dish;
 }
示例#4
0
 public List<DishEntity> getByResaurantId(int brandId)
 {
     string mysql = "SELECT * FROM yumiyumi.yumi_dish where brand_id = ?brand_id";
     MySqlParameter[] parameters = {
             new MySqlParameter("?brand_id", MySqlDbType.UInt32),
             };
     parameters[0].Value = brandId;
     MySqlDataReader myreader = MySqlHelper.ExecuteReader(mysql, parameters);
     List<DishEntity> list = new List<DishEntity>();
     while (myreader.Read())
     {
         DishEntity dish = new DishEntity();
         dish.id = myreader.GetInt32(0);
         dish.photo = myreader.GetString(1);
         dish.brand_id = brandId;
         dish.description = myreader.IsDBNull(3) ? "" : myreader.GetString(3);
         dish.price = myreader.IsDBNull(4) ? 0 : myreader.GetInt32(4);
         dish.type_id = myreader.GetInt32(5);
         dish.dish_name = myreader.IsDBNull(6) ? "" : myreader.GetString(6);
         list.Add(dish);
     }
     myreader.Close();
     return list;
 }