//修改收银方式  返回修改成功后的方式
        public CashType updateCashType(CashType cashType)
        {
            try
            {
                if (cashType == null || cashType.Id == null)
                {
                    return null;
                }
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    var type = entities.CashType.SingleOrDefault(bt => bt.Id == cashType.Id);
                    if (type != null)
                    {
                        type.IsBillIncome = cashType.IsBillIncome;
                        type.IsPaid = cashType.IsPaid;
                        type.IsPrivilege = cashType.IsPrivilege;
                        type.IsScore = cashType.IsScore;
                        type.KeepRecharge = cashType.KeepRecharge;
                        type.Keys = cashType.Keys;
                        type.LossesUsing = cashType.LossesUsing;
                        type.Name = cashType.Name;
                        type.Rate = cashType.Rate;
                        type.ReceptionUseing = cashType.ReceptionUseing;
                        type.RechargeUsing = cashType.RechargeUsing;
                        type.Status = cashType.Status;
                        type.SupplierUsing = cashType.SupplierUsing;
                        type.UpdateBy = type.UpdateBy;
                        type.UpdateDatetime = DateTime.Now;
                        type.UseingKeys = cashType.UseingKeys;
                        entities.SaveChanges();
                    }
                }
                return cashType;
            }
            catch (Exception e)
            {
                e.ToString();
                return null;
            }

        }
 //添加收银方式 返回添加成功后的收银方式
 public CashType addCashType(CashType cashType)
 {
     try
     {
         if (cashType == null)
         {
             return null;
         }
         CashType newCashType = null;
         using (ChooseDishesEntities entities = new ChooseDishesEntities())
         {
             var type = entities.CashType.SingleOrDefault(bt => bt.Code == cashType.Code);
             if (type != null)
             {
                 return null;
             }
             entities.CashType.Add(cashType);
             entities.SaveChanges();
             var typenew = entities.CashType.SingleOrDefault(bt => bt.Code == cashType.Code);
             if (typenew != null)
             {
                 newCashType = type;
             }
         }
         return newCashType;
     }
     catch (Exception e)
     {
         e.ToString();
         return null;
     }
 }