示例#1
0
        protected override bool beforeDelete()
        {
            // 检查这个类型是否被使用?
            MapAttrs    attrs = new MapAttrs();
            QueryObject qo    = new QueryObject(attrs);

            qo.AddWhere(MapAttrAttr.UIBindKey, this.No);
            int i = qo.DoQuery();

            if (i == 0)
            {
                BP.Sys.SysEnums ses = new SysEnums();
                ses.Delete(BP.Sys.SysEnumAttr.EnumKey, this.No);
            }
            else
            {
                string msg = "错误:下列数据已经引用了枚举您不能删除它。"; // "错误:下列数据已经引用了枚举您不能删除它。";
                foreach (MapAttr attr in attrs)
                {
                    msg += "\t\n" + attr.Field + "" + attr.Name + " Table = " + attr.FK_MapData;
                }

                //抛出异常,阻止删除.
                throw new Exception(msg);
            }
            return(base.beforeDelete());
        }
示例#2
0
        public void RegIt(string EnumKey, string vals)
        {
            try
            {
                string[] strs = vals.Split('@');
                SysEnums ens  = new SysEnums();
                ens.Delete(SysEnumAttr.EnumKey, EnumKey);
                this.Clear();

                foreach (string s in strs)
                {
                    if (s == "" || s == null)
                    {
                        continue;
                    }

                    string[] vk = s.Split('=');
                    SysEnum  se = new SysEnum();
                    se.IntKey  = int.Parse(vk[0]);
                    se.Lab     = vk[1];
                    se.EnumKey = EnumKey;
                    se.Lang    = BP.Web.WebUser.SysLang;
                    se.Insert();
                    this.AddEntity(se);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + " - " + vals);
            }
            //  this.Full(EnumKey);
        }
示例#3
0
        public void RegIt(string EnumKey, string vals)
        {
            try
            {
                string[] strs = vals.Split('@');
                SysEnums ens  = new SysEnums();
                ens.Delete(SysEnumAttr.EnumKey, EnumKey);
                this.Clear();

                foreach (string s in strs)
                {
                    if (s == "" || s == null)
                    {
                        continue;
                    }

                    string[] vk = s.Split('=');
                    SysEnum  se = new SysEnum();
                    se.IntKey = int.Parse(vk[0]);
                    //杨玉慧
                    //解决当  枚举值含有 ‘=’号时,保存不进去的方法
                    string[] kvsValues = new string[vk.Length - 1];
                    for (int i = 0; i < kvsValues.Length; i++)
                    {
                        kvsValues[i] = vk[i + 1];
                    }
                    se.Lab     = string.Join("=", kvsValues);
                    se.EnumKey = EnumKey;
                    se.Lang    = BP.Web.WebUser.SysLang;
                    se.Insert();
                    this.AddEntity(se);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + " - " + vals);
            }
            //  this.Full(EnumKey);
        }