Ejemplo n.º 1
0
        /// <summary>
        /// 创建值集
        /// </summary>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public ValueSet.Entity.ValueSet CreateValueSet(string name, string description, string userName, string badge)
        {
            string msg = string.Empty;
            var    v   = new ValueSet.Entity.ValueSet()
            {
                Text        = name,
                Description = description,
                Creator     = badge,
                CreateTime  = DateTime.Now,
                CreatorID   = userName,
                IsDelete    = false,
                IsEnabled   = true
            };

            var duptest = db.Fetch <ValueSet.Entity.ValueSet>(" where Text=@0 ", name).Where(o => o.IsDelete == false).ToList();

            if (duptest.Count > 0)
            {
                throw new InfoException("同名的值集已经存在!");
            }

            try
            {
                db.Save(v);
            }
            catch (Exception ex)
            {
                throw new InfoException("创建失败。" + ex.Message + "!");
            }
            return(v);
        }
Ejemplo n.º 2
0
        public void SaveValueSet(ValueSet.Entity.ValueSet v)
        {
            string msg;

            try
            {
                var dupval = db.FirstOrDefault <ValueSet.Entity.ValueSet>(" where id<>@0 and text=@1", v.Id, v.Text);
                if (dupval != null)
                {
                    throw new InfoException("同名的值集已经存在!");
                }
                if (v.Id == 0)
                {
                    v.IsDelete  = false;
                    v.IsEnabled = true;
                    if (string.IsNullOrEmpty(v.Text))
                    {
                        v.Text = v.Value;
                    }
                    if (string.IsNullOrEmpty(v.Value))
                    {
                        v.Value = v.Text;
                    }

                    db.Insert(v);
                }
                else
                {
                    db.Save(v);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }