/// <summary>
        /// 编辑时,获取指定信息;还有显示详细信息Detail
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Bus_TakeError GetModel(string Id)
        {
            var tempModel = this.LoadEntities(t => t.ID == Id).FirstOrDefault();

            if (tempModel == null)
            {
                return(new Bus_TakeError());
            }
            Bus_TakeErrorAttributeService attributeService = new Bus_TakeErrorAttributeService();
            var attrList = from a in attributeService.LoadEntities(a => a.AttributeID == Id)
                           join l in langService.LoadEntities(l => l.TABLE_NAME == "Bus_TakeErrorAttribute_AttributeIDItem") on a.AttributeIDItem equals l.ID
                           select new { ID = a.ID, AttributeID = a.AttributeID, AttributeIDItem = a.AttributeIDItem, AttributeIDItemName = l.COLUMN_NAME };

            List <Bus_TakeErrorAttribute> list = new List <Bus_TakeErrorAttribute>();

            foreach (var item in attrList)
            {
                Bus_TakeErrorAttribute obj = new Bus_TakeErrorAttribute();
                obj.ID                  = item.ID;
                obj.AttributeID         = item.AttributeID;
                obj.AttributeIDItem     = item.AttributeIDItem;
                obj.AttributeIDItemName = item.AttributeIDItemName;
                list.Add(obj);
            }

            if (list != null)
            {
                tempModel.AttrList = list;
            }

            var sourceObj = langService.GetModel("Bus_TakeError_FromSource", tempModel.FromSource);
            var typeObj   = langService.GetModel("Bus_TakeError_TypeVal", tempModel.TypeVal);
            var overObj   = langService.GetModel("Bus_TakeError_OverQuality", tempModel.OverQuality);

            if (sourceObj != null)
            {
                tempModel.FromSourceName = sourceObj.COLUMN_NAME;
            }
            if (typeObj != null)
            {
                tempModel.TypeValName = typeObj.COLUMN_NAME;
            }
            if (overObj != null)
            {
                tempModel.OverQualityName = overObj.COLUMN_NAME;
            }


            return(tempModel);
        }
        /// <summary>
        /// 修改或者添加一条数据
        /// </summary>
        /// <param name="model">实体参数</param>
        /// <returns>大于0,操作成功,反之失败</returns>
        public int OperateModel(Bus_TakeErrorAttribute model)
        {
            if (!string.IsNullOrEmpty(model.ID) && model.ID.Length == 36)
            {
                //编辑
                var existModel = this.LoadEntities(t => t.ID == model.ID).FirstOrDefault();
                existModel.AttributeID = model.AttributeID;
            }
            else if (string.IsNullOrEmpty(model.ID))
            {
                //添加
                var addModel = new Bus_TakeErrorAttribute();
                addModel.ID          = Guid.NewGuid().ToString();
                addModel.AttributeID = model.AttributeID;
                DbSession.Bus_TakeErrorAttributeRepository.AddEntity(addModel);
            }

            return(DbSession.SaveChange());
        }
        /// <summary>
        /// 修改或者添加一条数据
        /// </summary>
        /// <param name="model">实体参数</param>
        /// <returns>大于0,操作成功,反之失败</returns>
        public int OperateModel(Bus_TakeError model)
        {
            if (!string.IsNullOrEmpty(model.ID) && model.ID.Length == 36)
            {
                //编辑
                var existModel = this.LoadEntities(t => t.ID == model.ID).FirstOrDefault();
                existModel.FromSource   = model.FromSource;
                existModel.ActionId     = model.ActionId;
                existModel.TypeVal      = model.TypeVal;
                existModel.ResCompany   = model.ResCompany;
                existModel.ResCompanyId = model.ResCompanyId;
                existModel.ResPerson    = model.ResPerson;
                //existModel.AttributeID = model.AttributeID;
                existModel.DelFlag         = 0;
                existModel.AccessCompany   = model.AccessCompany;
                existModel.AccessCompanyId = model.AccessCompanyId;
                existModel.IsOverTime      = model.IsOverTime;
                existModel.IsSearch        = model.IsSearch;
                existModel.OverQuality     = model.OverQuality;
                existModel.Remark          = model.Remark;
                existModel.LevelRecords    = model.LevelRecords;

                #region 性质
                var existAttributes = DbSession.Bus_TakeErrorAttributeRepository.LoadEntities(ur => ur.AttributeID == existModel.ID);
                //删除现有数据
                foreach (var item in existAttributes)
                {
                    DbSession.Bus_TakeErrorAttributeRepository.DeleteEntity(item);
                }

                if (model.AttributeIds != null)
                {
                    foreach (var attrId in model.AttributeIds)
                    {
                        Bus_TakeErrorAttribute attrModel = new Bus_TakeErrorAttribute();
                        attrModel.ID              = Guid.NewGuid().ToString();
                        attrModel.AttributeID     = existModel.ID;
                        attrModel.AttributeIDItem = attrId;
                        DbSession.Bus_TakeErrorAttributeRepository.AddEntity(attrModel);
                    }
                }
                #endregion
            }
            else if (string.IsNullOrEmpty(model.ID))
            {
                //添加
                var addModel = new Bus_TakeError();
                addModel.ID           = Guid.NewGuid().ToString();
                addModel.FromSource   = model.FromSource;
                addModel.ActionId     = model.ActionId;
                addModel.TypeVal      = model.TypeVal;
                addModel.ResCompany   = model.ResCompany;
                addModel.ResCompanyId = model.ResCompanyId;
                addModel.ResPerson    = model.ResPerson;
                //addModel.AttributeID = model.AttributeID;
                addModel.DelFlag         = 0;
                addModel.AccessCompany   = model.AccessCompany;
                addModel.CreateTime      = DateTime.Now;
                addModel.AccessCompanyId = model.AccessCompanyId;

                addModel.IsOverTime   = model.IsOverTime;
                addModel.IsSearch     = model.IsSearch;
                addModel.OverQuality  = model.OverQuality;
                addModel.Remark       = model.Remark;
                addModel.LevelRecords = model.LevelRecords;
                addModel.OrderBy      = model.OrderBy;
                addModel.IsPass       = 0;
                addModel.UserId       = model.UserId;
                DbSession.Bus_TakeErrorRepository.AddEntity(addModel);

                #region 新增性质
                //添加
                if (model.AttributeIds != null)
                {
                    foreach (var attrId in model.AttributeIds)
                    {
                        Bus_TakeErrorAttribute attrModel = new Bus_TakeErrorAttribute();
                        attrModel.ID              = Guid.NewGuid().ToString();
                        attrModel.AttributeID     = addModel.ID;
                        attrModel.AttributeIDItem = attrId;
                        DbSession.Bus_TakeErrorAttributeRepository.AddEntity(attrModel);
                    }
                }
                #endregion
            }

            return(DbSession.SaveChange());
        }