Esempio n. 1
0
 public List<DishEntity> getById(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(11);
         dishList.Add(dish);
     }
     myreader.Close();
     return dishList;
 }
Esempio n. 2
0
 public DishEntity getDishById(int dishId)
 {
     //string mysql = "SELECT * FROM yumiyumi.yumi_account where user_name ='"+email+"'";
     string mysql = "SELECT yumi_dish.dish_id,dish_thumbimage,brand_id,dish_description,dish_price,type_id,dish_name,status,discount_price FROM yumiyumi.yumi_dish LEFT JOIN yumiyumi.yumi_discount on yumi_dish.dish_id = yumi_discount.dish_id where yumi_dish.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);
         dish.discount = myreader.IsDBNull(8)? 0 : myreader.GetInt32(8);
       
         //dish.status = myreader.GetInt32(7);
     }
     myreader.Close();
     return dish;
 }
Esempio n. 3
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;}
        }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     int dish_id = Convert.ToInt32(Request.QueryString["dish_id"]);
     DishDAO dishDAO = new DishDAO();
     DishEntity dish = new DishEntity();
     dish = dishDAO.getDishById(dish_id);
     name = dish.dish_name;
     price = dish.price;
     description = dish.description;
 }
Esempio n. 5
0
        protected void Unnamed_Click(object sender, EventArgs e)
        {
            string DishName = Request.Form["name"];
            int DishPrice = Convert.ToInt32(Request.Form["price"]);
            string DishDescription = Request.Form["description"];
            int Spicy = Convert.ToInt32(Request.Form["spicy"]);

            DishDAO dishDAO = new DishDAO();
            DishEntity dish = new DishEntity();
            dish.dish_name = DishName;
            dish.price = DishPrice;
            dish.description = DishDescription;

            if (dishDAO.addOneDish(dish))
            {
                Response.Write("<Script Language='JavaScript'>alert('添加成功');</Script>");
            }
            else
            {
                Response.Write("<Script Language='JavaScript'>alert('添加错误,亲!');</Script>");
            }
        }
Esempio n. 6
0
        public void addDish()
        {
            string DishName = Request.Form["name"];
            int DishPrice = Convert.ToInt32(Request.Form["price"]);
            string DishDescription = Request.Form["description"];
            int Spicy = Convert.ToInt32(Request.Form["spicy"]);
            string photo;

            DishDAO dishDAO = new DishDAO();
            DishEntity dish = new DishEntity();
            dish.dish_name = DishName;
            dish.price = DishPrice;
            dish.description = DishDescription;

            if (dishDAO.addOneDish(dish))
            {
                Response.Write("<Script Language='JavaScript'>alert('添加成功');</Script>");
                Response.Redirect("menu_list.aspx");
            }
            else
            {
                Response.Write("<Script Language='JavaScript'>alert('添加错误,亲!');</Script>");
            }
        }
Esempio n. 7
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;
 }