public bool UpdateRawUnitDeletedStatusById(int Id, int DeletedStatus)
 {
     if (Id < 0)
     {
         return false;
     }
     //修改  直接修改
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         try
         {
             var type = entities.RawUnit.SingleOrDefault(bt => bt.UnitId == Id);
             if (type != null)
             {
                 type.Deleted = DeletedStatus;
                 entities.SaveChanges();
                 return true;
             }
         }
         catch (Exception e)
         {
             e.ToString();
             return false;
         }
         return false;
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
      public   List<DishesMenu> QueryAll() {

          using (ChooseDishesEntities entities = new ChooseDishesEntities()) {
              return entities.DishesMenu.Where(bt=>bt.Deleted == 0 ).ToList();
          }

      }
 public List<TableItem> GetAll()
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         return entities.TableItem.Include(typeof(Table).Name).Where(t => t.Deleted == 0).ToList();
     }
 }
        //0添加失败,-1添加重复
        public int addLocation(Location location)
        {
            int flag = 0;
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {

                //查询编码是否存在
                var type = entities.Location.SingleOrDefault(bt => bt.Code == location.Code && bt.Deleted == 0);
                if (type == null)
                {
                    //实体绑定数据
                    entities.Location.Add(location);
                    try
                    {
                        //操作数据库
                        flag = entities.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                    }
                }
                else
                {
                    flag = -1;
                }
            }
            return flag;
        }
        /// <summary>
        /// 按参数所在模块查询
        /// </summary>
        /// <param name="domain"></param>
        public List<Config> QueryByDomain(string domain)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities()) {
                return entities.Config.Where(c => c.Domain.Equals(domain)).ToList();
            }

        }
        public bool UpdateRawUnit(RawUnit rw)
        {
            if (rw == null)
            {
                return false;
            }
            //修改  直接修改
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    var type = entities.RawUnit.SingleOrDefault(bt => bt.UnitId == rw.UnitId);
                    if (type != null)
                    {
                        type.Deleted = rw.Deleted;
                        type.Name = rw.Name;
                        type.Status = rw.Status;
                        type.UpdateBy = rw.UpdateBy;
                        type.UpdateDatetime = rw.UpdateDatetime;
                        entities.SaveChanges();
                        return true;
                    }

                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }
                return false;
            }
        }
        //根据外卖客户id修改外卖客户信息
        public bool UpdateTakeoutClientInfo(TakeoutClientInfo info)
        {
            if (info == null)
            {
                return false;
            }
            //修改  直接修改
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    var type = entities.TakeoutClientInfo.SingleOrDefault(bt => bt.OrderPeopleId == info.OrderPeopleId);
                    if (type != null)
                    {
                        type.Order_people = info.Order_people;
                        type.Mobile = info.Mobile;
                        type.Status = info.Status;
                        type.Telephone = info.Telephone;
                        type.Update_by = info.Update_by;
                        type.Update_datetime = info.Update_datetime;
                        type.Address = info.Address;
                        type.Deleted = info.Deleted;
                        entities.SaveChanges();
                        return true;
                    }

                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }
                return false;
            }
        }
 //根据外卖客户id修改外卖客户Deleted状态
 public bool UpdateTakeoutClientDeletedById(int id,int DeletedStatas)
 {
     if (id <0)
     {
         return false;
     }
     //修改  直接修改
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         try
         {
             var type = entities.TakeoutClientInfo.SingleOrDefault(bt => bt.OrderPeopleId == id);
             if (type != null)
             {
                 type.Deleted = DeletedStatas;
                 entities.SaveChanges();
                 return true;
             }
         }
         catch (Exception e)
         {
             e.ToString();
             return false;
         }
         return false;
     }
 }
 //根据ID查询大类
 public DishType LoadParentId(int? id)
 {
     try
     {
         
         using (ChooseDishesEntities entities = new ChooseDishesEntities())
         {
             DishType type = new DishType(); ;
             if (id != null)
             {
                 type = (DishType)entities.DishType.Where(info => info.DishTypeId == id && info.Deleted == 0 && info.Status == 0).Single();
                 if (type == null)
                 {
                     type = new DishType();
                 }
             }
              
             return type;
         };
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
      public   List<DishesMenu> QueryAll() {

          using (ChooseDishesEntities entities = new ChooseDishesEntities()) {
              return entities.DishesMenu.ToList();
          }

      }
Exemplo n.º 11
0
        //新增桌类
        public int SaveTableType(TableType type)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    Hashtable hash = new Hashtable();//返回结果

                    List<TableType> types;
                    //检查类型编号或者类型名称是否重复
                    types = entities.TableType.Where(info => info.Name == type.Name || info.Code == type.Code).ToList();
                    if (types != null && types.Count > 0)
                    {
                        hash.Add("code", 1);
                        if (types[0].Name == type.Name)
                        {
                            throw new ServiceException("类型名称已经存在,请重新命名!");
                        }
                        else if (types[0].Code == type.Code)
                        {
                            throw new ServiceException("类型编号已经存在!");
                        }
                    }
                    entities.TableType.Add(type);
                    entities.SaveChanges();
                    return type.TableTypeId;
                }
                catch (Exception e)
                {
                    throw new ServiceException(e.Message);
                }
            };
        }
Exemplo n.º 12
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="employeeId"></param>
       public int Add(int employeeId,string username,string passwd) {
           using (ChooseDishesEntities entities = new ChooseDishesEntities()) {
               Employee employee = entities.Employee.Find(employeeId);
               if (null == employee) {
                   throw new ServiceException("无法找到对应的员工,编号为:【"+employeeId+"】");
               }
               int authorId=SubjectUtils.GetAuthenticationId();
               UserInfo _UserInfo = new UserInfo();
              
               _UserInfo.EmployeeId = employeeId;
               if (null != username || null!=passwd) {
                   _UserInfo.Username = username;
                   _UserInfo.Salt = CryptoUtils.GetSalt();
                   _UserInfo.Password = CryptoUtils.MD5Encrypt(passwd);
                   _UserInfo.CreateBy = SubjectUtils.GetAuthenticationId();
               }
               _UserInfo.CreateDatetime = DateTime.Now;
               entities.UserInfo.Add(_UserInfo);
               try
               {
                   entities.SaveChanges();
                   Log.A(Loggers.USER_NEW, authorId, _UserInfo.UserId);
               }catch(DbEntityValidationException e){
                   throw new ServiceException(e.Message);
               }
               return _UserInfo.UserId;
           }

       }
Exemplo n.º 13
0
 /// <summary>
 /// 查询所有用户
 /// </summary>
 /// <returns></returns>
 public List<UserInfo> QueryUsers() {
     
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         //查询所有非删除的
         return entities.UserInfo.Where(t => t.Deleted == 0).ToList();
     }
 }
 public List<Location> queryByLocation()
 {
     List<Location> local;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         local = entities.Location.Where(Location => Location.Deleted == 0).ToList();
     }
     return local;
 }
 //查询所有折扣方案
 public DiscountProgram queryById(int id)
 {
     DiscountProgram program;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         program = entities.DiscountProgram.Where(Program => Program.Deleted == 0 && Program.Status == 0&& Program.DiscountId == id).Single();
     }
     return program;
 }
 //查询折扣方案明细
 public List<DiscountDetail> queryByDetailId(int id)
 {
     List<DiscountDetail> program;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         program = entities.DiscountDetail.Where(Detail => Detail.Deleted == 0 && Detail.Status == 0 && Detail.DiscountId == id).ToList();
     }
     return program;
 }
 //查询所有折扣方案
 public List<DiscountProgram> queryAll()
 {
     List<DiscountProgram> program;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         program = entities.DiscountProgram.Where(Program => Program.Deleted == 0 && Program.Status==0).ToList();
     }
     return program;
 }
Exemplo n.º 18
0
 //TODO 建立与开台关联的关系和获取订单对象
 public List<TableItem> GetDetailByTableId(int TableId)
 {
     List<TableItem> tis;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         tis=entities.TableItem.Include(typeof(Table).Name).Include(typeof(DeskDishes).Name).Where(t => t.Deleted == 0&&t.TableId==TableId).ToList();
         
     }
     return tis;
 }
Exemplo n.º 19
0
 public int Add(string code, string name)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         DishesMenu menu = DishesMenuModel.build(code, name, 1000);
        entities.DishesMenu.Add(menu);
        entities.SaveChanges();
        return menu.MenusId;
     }
   
   }
 /// <summary>
 /// 通过名称获取该值,该接口未查找到相应的值时,抛出异常
 /// </summary>
 /// <param name="name"></param>
 /// <param name="domain"></param>
 /// <returns></returns>
 public Config Find(string name)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         Config config = entities.Config.Single(c => c.Name.Equals(name));
         if (null == config)
         {
             throw new NotFoundException("参数名【" + name + "】未找到匹配的项!");
         }
         return config;
     }
 }
Exemplo n.º 21
0
 public void Delete(int dishesMenuId)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         var delObj=entities.DishesMenu.Find(dishesMenuId);
         if (null == delObj) {
             throw new NotFoundException();
         }
         entities.DishesMenu.Remove(delObj);
         entities.SaveChanges();
     }
 }
        /// <summary>
        /// 更新指定的参数的值
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        public void Update(string name, string value) {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                Config config = entities.Config.Single(c => c.Name.Equals(name));
               if (null == config) {
                   throw new NotFoundException("参数名【"+name+"】未找到匹配的项!");
               }
               config.Value = value;
               entities.SaveChanges();
            }

        }
Exemplo n.º 23
0
 public void BatchRemoveDishes(int menuId, int[] dishesIds) { 
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         for (int i = 0; i < dishesIds.Length; i++)
         {
             var id = dishesIds[i];
             var type = entities.DishesMenuRef.SingleOrDefault(bt => bt.Deleted == 0 && bt.DishId == id && bt.MenusId == menuId);
             if (type != null) {
                 string sql = " update DishesMenuRef set Deleted = 1 where DishId = " + id + "  and  MenusId =  " +menuId;
                 entities.Database.ExecuteSqlCommand(sql);
             }
         }
     }
 }
        public bool UpdateRawMaterial(RawMaterial rw)
        {
            if (rw == null)
            {
                return false;
            }
            //修改  直接修改
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    var type = entities.RawMaterial.SingleOrDefault(bt => bt.Id == rw.Id);
                    if (type != null)
                    {
                        type.CheckDay = rw.CheckDay;
                        type.Deleted = rw.Deleted;
                        type.Detail = rw.Detail;
                        type.Format = rw.Format;
                        type.FormulaUnit = rw.FormulaUnit;
                        type.InGoodsPrice = rw.InGoodsPrice;
                        type.InGoodsStock = rw.InGoodsStock;
                        type.InGoodsUnit = rw.InGoodsUnit;
                        type.IsWeight = rw.IsWeight;
                        type.MaterialName = rw.MaterialName;
                        type.OrderRawAdd = rw.OrderRawAdd;
                        type.Pinying = rw.Pinying;
                        type.Raw = rw.Raw;
                        type.RawAddPrice = rw.RawAddPrice;
                        type.SaleUnit = rw.SaleUnit;
                        type.Status = rw.Status;
                        type.StockFormula = rw.StockFormula;
                        type.StockMax = rw.StockMax;
                        type.StockMin = rw.StockMin;
                        type.StockUnit = rw.StockUnit;
                        type.UpdateBy = rw.UpdateBy;
                        type.UpdateDatetime = rw.UpdateDatetime;
                        type.WriteDowns = rw.WriteDowns;
                        entities.SaveChanges();
                        return true;
                    }

                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }
                return false;
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="app"></param>
        /// <param name="function"></param>
        /// <param name="actor"></param>
        /// <param name="itemId"></param>
        /// <param name="message"></param>
        /// <param name="args"></param>
      public  void Log(Format format,LogType type, int actor, int objectId,object[] args) {
          SystemLog _Log = new SystemLog();
          _Log.ItemId = Convert.ToString(objectId);
          _Log.Actor = Convert.ToString(actor);
          _Log.CreateDatetime = DateTime.Now;
          _Log.Module = format.Function.Module.Name;
          _Log.Function = format.Function.Name;
          _Log.Body = LoggerUtils.Format(format, args);
          _Log.OpType = Enum.GetName(typeof(LogType), type);

          using (ChooseDishesEntities entities = new ChooseDishesEntities()) {
              entities.SystemLog.Add(_Log);
              entities.SaveChanges();
          }      
      }
Exemplo n.º 26
0
 /***餐桌类型****/
 #region
 
 //查询所有桌类
 public List<TableType> LoadAllTableType()
 {
     List<TableType> types;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         types = entities.TableType.Where(
             info => info.Deleted == 0
         ).ToList();
         if (types == null || types.Count == 0)
         {
             types = new List<TableType>();
         }
         return types;
     };
 }
Exemplo n.º 27
0
 public bool ModifyStatus(int TableId, int Status)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         var type = entities.TableItem.SingleOrDefault(bt => bt.Deleted == 0 && bt.TableId == TableId);
         if (type != null)
         {
             type.UpdateBy = SubjectUtils.GetAuthenticationId();
             type.UpdateDatetime = DateTime.Now;
             type.Status = Status;
             entities.SaveChanges();
             return true;
         }
         return false;
     }
 }
	    public bool Add(int dishesId, int DishesWayId) {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    entities.DischesWayRef.Add(GetDischesWayRef(dishesId, DishesWayId));
                    entities.SaveChanges();
                    return true;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                throw new ServiceException("新增菜品做法关联失败");
            }
	    }
Exemplo n.º 29
0
 public int Add(string code, string name)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         var list = entities.DishesMenu.Where(t => t.Deleted == 0 && (t.Code == code || t.Name == name)).ToList();
         if (list != null && list.Count > 0)
         {
             return 0;
         }
         DishesMenu menu = DishesMenuModel.build(code, name, SubjectUtils.GetAuthenticationId());
         entities.DishesMenu.Add(menu);
         entities.SaveChanges();
         return menu.MenusId;
     }
   
   }
Exemplo n.º 30
0
 public TableType LoadTableTypeById(int typeId)
 {
     TableType type;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         type = entities.TableType.Where(
             info => info.Deleted == 0
                 && (info.TableTypeId == typeId)
         ).ToList()[0];
         if (type == null)
         {
             type = new TableType();
         }
         return type;
     };
 }