コード例 #1
0
        public string GetUser(string empNo)
        {
            using (var dbContext = new EFInfusionDbContext())
            {
                Employee employee = dbContext.Employees.FirstOrDefault(p => p.EmpNo.Equals(empNo));
                if (employee != null)
                {
                    // if(employee.Password.Equals(pwd))
                    //{
                    log.Info("获取用户成功!");
                    return("成功");
                    //}
                    // else
                    //{
                    //    return "密码不正确";
                    //}
                    //return   Json()
                }
                else
                {
                    return("用户不存在");

                    //return
                }
            }
            //return "测试";
        }
コード例 #2
0
        public List <InfusionSeat> GetAll()
        {
            List <InfusionSeat> list = new List <InfusionSeat>();

            using (var dbContext = new EFInfusionDbContext())
            {
                list = dbContext.InfusionSeats.ToList <InfusionSeat>();
            }
            return(list);
        }
コード例 #3
0
        public bool Modify(InfusionSeat infusionSeat)
        {
            bool tfSuccess = false;

            try
            {
                using (var dbContext = new EFInfusionDbContext())
                {
                    var del = false;
                    while (!del)
                    {
                        try
                        {
                            // 设置状态为修改
                            dbContext.Entry(infusionSeat).State = EntityState.Modified;
                            tfSuccess = dbContext.SaveChanges() > 0 ? true : false;
                            del       = true;
                        }
                        catch (DbUpdateException ex)
                        {
                            foreach (var entry in ex.Entries)
                            {
                                if (entry.Entity is InfusionSeat)
                                {
                                    var proposedValues = entry.CurrentValues;
                                    var databaseValues = entry.GetDatabaseValues();

                                    foreach (var property in proposedValues.Properties)
                                    {
                                        var proposedValue = proposedValues[property];
                                        var databaseValue = databaseValues[property];
                                    }

                                    entry.OriginalValues.SetValues(databaseValues);
                                }
                                else
                                {
                                    throw new NotSupportedException(
                                              "Don't know how to handle concurrency conflicts for "
                                              + entry.Metadata.Name);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(tfSuccess);
        }
コード例 #4
0
        public bool Add(InfusionSeat infusionSeat)
        {
            bool tfSuccess = false;

            try
            {
                using (var dbContext = new EFInfusionDbContext())
                {
                    // 设置状态为新增
                    dbContext.Entry(infusionSeat).State = EntityState.Added;
                    tfSuccess = dbContext.SaveChanges() > 0 ? true : false;
                }
            }
            catch (Exception ex)
            {
            }
            return(tfSuccess);
        }
コード例 #5
0
        public bool Delete(int id)
        {
            bool tfSuccess = false;

            try
            {
                using (var dbContext = new EFInfusionDbContext())
                {
                    InfusionSeat infusionSeat = new InfusionSeat()
                    {
                        SeatId = id
                    };
                    // 设置状态是删除
                    dbContext.Entry(infusionSeat).State = EntityState.Deleted;
                    tfSuccess = dbContext.SaveChanges() > 0 ? true : false;
                }
            }
            catch (Exception ex)
            {
            }
            return(tfSuccess);
        }