Exemplo n.º 1
0
        //员工状态修改
        public int EditEmployeeFlag(Employee employee)
        {
            int flag = 0;

            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                //直接修改的方式
                DbEntityEntry <Employee> entry = entities.Entry <Employee>(employee);
                entry.State = System.Data.Entity.EntityState.Unchanged;
                //设置修改状态为ture 否则数据库不会更新
                entry.Property("UpdateDatetime").IsModified = true;
                entry.Property("Flag").IsModified           = true;
                entry.Property("UpdateBy").IsModified       = true;
                try
                {
                    //关闭实体验证,不关闭验证需要整个对象全部传值
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    flag = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }
            return(flag);
        }
Exemplo n.º 2
0
        public void UpdateTableType(TableType type)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                DbEntityEntry <TableType> entry = entities.Entry <TableType>(type);

                entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                entry.Property("Name").IsModified              = true;
                entry.Property("PeopleMin").IsModified         = true;
                entry.Property("PeopleMax").IsModified         = true;
                entry.Property("PriceType").IsModified         = true;
                entry.Property("ServerfreeModel").IsModified   = true;
                entry.Property("ColorType").IsModified         = true;
                entry.Property("UpdateBy").IsModified          = true;
                entry.Property("UpdateDatetime").IsModified    = true;
                entry.Property("LowConsCalcType").IsModified   = true;
                entry.Property("ServerFeeCalcType").IsModified = true;
                entry.Property("CanDiscount").IsModified       = true;
                entry.Property("InLowConsume").IsModified      = true;
                try
                {
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;
                }
                catch (Exception e)
                {
                    throw new ServiceException(e.Message);
                }
            }
        }
        //根据做法类型编码删除菜品做法类型,如果删除失败返回false,如果删除成功,则返回true
        public bool DeleteDishesWayNameByCode(int id)
        {
            //先判断是否存在有做法,如果有做法,则不能返回false
            List <DischesWay> orgDischesWay = FindAllDishesWayByTypeId(id);

            if (orgDischesWay != null && orgDischesWay.Count > 0)
            {
                return(false);
            }
            //删除
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    DischesWayName booktype = new DischesWayName()
                    {
                        DischesWayNameId = id,
                    };
                    DbEntityEntry <DischesWayName> entry = entities.Entry <DischesWayName>(booktype);
                    entry.State = System.Data.Entity.EntityState.Deleted;

                    entities.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    e.ToString();
                    return(false);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="detailId"></param>
        /// <returns></returns>
        public bool DeleteTableTypeDetail(int detailId)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    TableTypeDetail detail = new TableTypeDetail();
                    detail.TableTypeDetailId = detailId;
                    detail.Deleted           = 1;
                    DbEntityEntry <IShow.ChooseDishes.Data.TableTypeDetail> entry = entities.Entry <IShow.ChooseDishes.Data.TableTypeDetail>(detail);
                    entry.State = System.Data.Entity.EntityState.Unchanged;
                    entry.Property("Deleted").IsModified = true;

                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    if (result == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 public bool DeleteRaw(int id)
 {
     if (id < 0)
     {
         return(false);
     }
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         try
         {
             Raw booktype = new Raw()
             {
                 RawId = id,
             };
             DbEntityEntry <Raw> entry = entities.Entry <Raw>(booktype);
             entry.State = EntityState.Deleted;
             entities.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             e.ToString();
             return(false);
         }
     }
 }
Exemplo n.º 6
0
        public int DelByDepartment(DepartmentInfo departmentInfo)
        {
            int flag = 0;

            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                //直接修改的方式
                DbEntityEntry <DepartmentInfo> entry = entities.Entry <DepartmentInfo>(departmentInfo);
                entry.State = System.Data.Entity.EntityState.Unchanged;
                //设置修改状态为ture 否则数据库不会更新
                entry.Property("UpdateBy").IsModified       = true;
                entry.Property("Deleted").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);
        }
Exemplo n.º 7
0
        /**删除桌类,逻辑删除**/
        public void DeleteTableType(int typeId)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    //检查是否被餐桌关联

                    List <IShow.ChooseDishes.Data.Table> tableList = LoadTableByTypeId(typeId);
                    if (tableList != null && tableList.Count > 0)
                    {
                        throw new ServiceException("该餐桌类别关联了餐桌,不能删除!");
                    }
                    TableType type = new TableType();
                    type.TableTypeId = typeId;
                    type.Deleted     = 1;
                    DbEntityEntry <TableType> entry = entities.Entry <TableType>(type);
                    entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                    entry.Property("Deleted").IsModified = true;

                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;
                    if (result == 1)
                    {
                        throw new ServiceException("修改失败!");
                    }
                }
            }
            catch (Exception e)
            {
                throw new ServiceException(e.Message);
            }
        }
        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 DeleteMarketTypeById(int id)
 {
     if (id < 0)
     {
         return(false);
     }
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         try
         {
             MarketType booktype = new MarketType()
             {
                 Id = id,
             };
             DbEntityEntry <MarketType> entry = entities.Entry <MarketType>(booktype);
             entry.State = EntityState.Deleted;
             entities.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             e.ToString();
             return(false);
         }
     }
 }
        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);
        }
Exemplo n.º 11
0
        /**删除餐桌,逻辑删除**/
        public bool DeleteTable(int tableId)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    IShow.ChooseDishes.Data.Table table = new IShow.ChooseDishes.Data.Table();
                    table.TableId = tableId;
                    DbEntityEntry <IShow.ChooseDishes.Data.Table> entry = entities.Entry <IShow.ChooseDishes.Data.Table>(table);
                    entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                    entry.Property("Deleted").IsModified = true;

                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;
                    if (result == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        //根据做法类型编码删除菜品做法类型,如果删除失败返回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);
                }
            }
        }
Exemplo n.º 13
0
        //删除外卖单

        public bool DeletedTakeoutOrder(int id)
        {
            if (id < 0)
            {
                return(false);
            }
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    TakeoutOrder booktype = new TakeoutOrder()
                    {
                        TakeoutId = id,
                    };
                    DbEntityEntry <TakeoutOrder> entry = entities.Entry <TakeoutOrder>(booktype);
                    entry.State = EntityState.Deleted;
                    entities.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    e.ToString();
                    return(false);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 修改服务费低消设置
        /// </summary>
        /// <param name="detail">服务费设置详细</param>
        /// <param name="serverFeeMode">服务费模式</param>
        /// <returns>成功则返回true,失败返回false</returns>
        public bool UpdateTableTypeDetail(TableTypeDetail detail)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    detail.UpdateBy       = SubjectUtils.GetAuthenticationId();
                    detail.UpdateDatetime = DateTime.Now;
                    DbEntityEntry <IShow.ChooseDishes.Data.TableTypeDetail> entry = entities.Entry <IShow.ChooseDishes.Data.TableTypeDetail>(detail);
                    entry.State = System.Data.Entity.EntityState.Unchanged;
                    entry.Property("StartMoney").IsModified            = true;
                    entry.Property("StartGetMoneyTime").IsModified     = true;
                    entry.Property("StartUnit").IsModified             = true;
                    entry.Property("StartDateTime").IsModified         = true;
                    entry.Property("EndDateTime").IsModified           = true;
                    entry.Property("OutMoney").IsModified              = true;
                    entry.Property("OutTime").IsModified               = true;
                    entry.Property("OutTimeFree").IsModified           = true;
                    entry.Property("ServerfreeNax").IsModified         = true;
                    entry.Property("ServerfreeAccountType").IsModified = true;
                    entry.Property("ServerfreeNum").IsModified         = true;
                    entry.Property("Rate").IsModified           = true;
                    entry.Property("ConsumerMode").IsModified   = true;
                    entry.Property("ConsumerMoney").IsModified  = true;
                    entry.Property("UpdateDatetime").IsModified = true;
                    entry.Property("UpdateBy").IsModified       = true;

                    //entry.Property("TableTypeDetailId").IsModified = false;

                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    if (result == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 根据指定日期删除创建日期比该日期小的日志
        /// deleted SystemLog object from table SystemLog where StartDate less than the parameter date
        /// </summary>
        /// <param name="date">日期</param>
        public void DeleteByDate(DateTime date)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                List <SystemLog> _books;

                _books = entities.SystemLog.Where(book => book.CreateDatetime.CompareTo(date) < 0).ToList();
                if (_books != null)
                {
                    foreach (var bk in _books)
                    {
                        DbEntityEntry <SystemLog> entry = entities.Entry <SystemLog>(bk);
                        entry.State = EntityState.Deleted;
                    }
                }
                entities.SaveChanges();
            }
        }
        //删除折扣方案明细
        public bool DeleteDetail(int typeId)
        {
            bool flag = true;

            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                Expression <Func <DiscountDetail, bool> > checkCourse = Detail => Detail.DiscountId == typeId && Detail.Deleted == 0;
                //先查询 后修改
                List <DiscountDetail> type = entities.DiscountDetail.Where(checkCourse).ToList();
                if (type != null && type.Count > 0)
                {
                    foreach (var t in type)
                    {
                        t.UpdateBy       = SubjectUtils.GetAuthenticationId();
                        t.UpdateDatetime = DateTime.Now;
                        t.Deleted        = 1;
                        //直接修改的方式
                        DbEntityEntry <DiscountDetail> entry = entities.Entry <DiscountDetail>(t);
                        entry.State = System.Data.Entity.EntityState.Modified;
                        //设置修改状态为ture 否则数据库不会更新
                        entry.Property("UpdateBy").IsModified       = true;
                        entry.Property("Deleted").IsModified        = true;
                        entry.Property("UpdateDatetime").IsModified = true;
                        try
                        {
                            //关闭实体验证,不关闭验证需要整个对象全部传值
                            entities.Configuration.ValidateOnSaveEnabled = false;
                            var result = entities.SaveChanges();
                            entities.Configuration.ValidateOnSaveEnabled = true;
                            if (result <= 0)
                            {
                                return(false);
                            }
                        }
                        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);
            }
        }
Exemplo n.º 18
0
        public bool UpdateType(DishType type)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    DbEntityEntry <DishType> entry = entities.Entry <DishType>(type);

                    entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                    entry.Property("Name").IsModified           = true;
                    entry.Property("Status").IsModified         = true;
                    entry.Property("UpdateDatetime").IsModified = true;
                    entry.Property("UpdateBy").IsModified       = true;
                    //TODO 如果更新状态为“删除”则要检查是否关联了菜品
                    try
                    {
                        entities.Configuration.ValidateOnSaveEnabled = false;
                        int result = entities.SaveChanges();
                        entities.Configuration.ValidateOnSaveEnabled = true;

                        if (result == 1)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 19
0
        public bool UpdateTable(IShow.ChooseDishes.Data.Table table)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                DbEntityEntry <IShow.ChooseDishes.Data.Table> entry = entities.Entry <IShow.ChooseDishes.Data.Table>(table);

                entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                entry.Property("Name").IsModified        = true;
                entry.Property("Seat").IsModified        = true;
                entry.Property("TableTypeId").IsModified = true;
                entry.Property("LocationId").IsModified  = true;
                entry.Property("Status").IsModified      = true;

                //TODO 是否已经启用,已启用则不能删除
                entry.Property("TableId").IsModified = false;

                try
                {
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;

                    if (result == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    return(false);
                }
            }
        }
Exemplo n.º 20
0
 public bool DeleteType(int typeId)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         DishType type = new DishType();
         type.DishTypeId = typeId;
         type.Deleted    = 1;
         DbEntityEntry <DishType> entry = entities.Entry <DishType>(type);
         entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
         entry.Property("Deleted").IsModified         = true;
         entry.Property("DishTypeId").IsModified      = false;
         entities.Configuration.ValidateOnSaveEnabled = false;
         var result = entities.SaveChanges();
         entities.Configuration.ValidateOnSaveEnabled = true;
         if (result == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }