public int editByLocation(string id, string name, string no)
        {
            int flag = 0;
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                Location local = new Location()
                {
                    LocationId = int.Parse(id),
                    Code = no,
                    Name = name,
                    UpdateBy=1,
                    UpdateDatetime=DateTime.Now

                };
                DbEntityEntry<Location> entry = entities.Entry<Location>(local);
                entry.State = System.Data.EntityState.Unchanged;
                entry.Property("Code").IsModified = true;
                entry.Property("Name").IsModified = true;
                entry.Property("UpdateBy").IsModified = true;
                entry.Property("UpdateDatetime").IsModified = true;
                try
                {
                    flag=entities.SaveChanges();
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }
            return flag;
        }
        //根据做法类型编码删除菜品做法类型,如果删除失败返回false,如果删除成功,则返回true
        public bool DeleteDischesWayName(int id)
        {
            //先判断是否存在有做法,如果有做法,则不能返回false
            DischesWayDataService odws = new DischesWayDataService();
            List<DischesWay> orgDischesWay = odws.FindAllDischesWay(id);
            if (orgDischesWay != null)
            {
                return false;
            }
            //删除
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                DischesWayName booktype = new DischesWayName()
                {
                    DischesWayNameId = id,
                };
                DbEntityEntry<DischesWayName> entry = entities.Entry<DischesWayName>(booktype);
                entry.State = System.Data.EntityState.Deleted;

                entities.SaveChanges();

                var newtype = entities.DischesWayName.SingleOrDefault(bt => bt.DischesWayNameId == id);
                if (newtype != null)
                {
                    //Console.WriteLine(newtype.name);
                    return false;
                }
                else
                {
                    //Console.WriteLine("No Found");
                    return true;
                }
            }
           
        }
        public int delByLocation(string id)
        {
            int flag = 0;
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                Location local = new Location()
                {
                    LocationId = int.Parse(id),
                    Deleted=1,
                    UpdateBy = 1,
                    UpdateDatetime = DateTime.Now

                };
                DbEntityEntry<Location> entry = entities.Entry<Location>(local);
                entry.State = System.Data.EntityState.Unchanged;
                entry.Property("Deleted").IsModified = true;
                entry.Property("UpdateBy").IsModified = true;
                entry.Property("UpdateDatetime").IsModified = true;
                try
                {
                    entities.Configuration.ValidateOnSaveEnabled = false; 
                    flag = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true; 
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }
            return flag;
        }
        /**根据指定编码删除对应做法*/
        public bool DeleteDischesWay(int id)
        {

            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                var type = entities.DischesWay.SingleOrDefault(bt => bt.DischesWayId == id);
                if (type == null)
                {
                    return false;
                }
                DischesWay booktype = new DischesWay()
                {
                    DischesWayId = id,
                };
                DbEntityEntry<DischesWay> entry = entities.Entry<DischesWay>(booktype);
                entry.State = System.Data.EntityState.Deleted;

                entities.SaveChanges();
                return true;
            }
        }