Beispiel #1
0
        public string UnBind(string groundId)
        {
            string result = string.Empty;

            try
            {
                using (GeelyPtlEntities dbContext = new GeelyPtlEntities())
                {
                    FeedZone item = dbContext.FeedZones.FirstOrDefault(x => x.GroundId == groundId);
                    if (item == null)
                    {
                        result = "该地堆不存在!";
                    }
                    else
                    {
                        item.MaterialId = null;
                        dbContext.SaveChanges();
                        result = "解绑成功!";
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }


            return(result);
        }
Beispiel #2
0
        public string Bind(string materialId, string groundId)
        {
            string result = string.Empty;

            try
            {
                materialId = materialId.Trim();
                groundId   = groundId.Trim();

                using (GeelyPtlEntities dbContext = new GeelyPtlEntities())
                {
                    FeedZone item = dbContext.FeedZones.FirstOrDefault(x => x.GroundId == groundId);
                    if (item == null)
                    {
                        result = "该地堆不存在!";
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(item.MaterialId))
                        {
                            item.MaterialId = materialId;
                            dbContext.SaveChanges();
                            result = "绑定成功!";
                        }
                        else
                        {
                            result = "该地堆已绑定小车,不能重复绑定!";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }