/// <summary>
        /// 创建代码配置
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateCode(long codeTypeID)
        {
            var ent = dalCodeType.GetEntity(codeTypeID);
            if (ent == null)
                throw new JsMiracleException("代码大类不存在");

            ViewBag.LXMC = string.Format("{0}({1})", ent.LXMC, ent.LXDM);

            var data = new IMS_CM_DM();
            data.LXDM = ent.LXDM;

            return View("EditCode", data);
        }
        public ActionResult SaveCode(IMS_CM_DM entity)
        {
            Func<ExtResult> saveFun = () => 
            {
                if (entity.ID == 0)
                {
                    string filter = string.Format(" LXDM = \"{0}\" && (DM = \"{1}\" || SZ = {2} ) "
                        , entity.LXDM , entity.DM , entity.SZ);

                    if (dalCode.Exists(filter))
                        throw new JsMiracleException(string.Format("类型'{0}'已存在代码'{1}',数值'{2}'"
                            , entity.LXDM, entity.DM, entity.SZ));
                }
                else
                {
                    string filter = string.Format(" LXDM = \"{0}\" && (DM = \"{1}\" || SZ = {2} ) && ID != {3} "
                       , entity.LXDM, entity.DM, entity.SZ, entity.ID);

                    if (dalCode.Exists(filter))
                        throw new JsMiracleException(string.Format("类型'{0}'已存在代码'{1}',数值'{2}'"
                            , entity.LXDM, entity.DM, entity.SZ));
                }

                //entity.CJR = CurrentUser.GetCurrentUser().UserInfo.YHID;
                entity.XGR = CurrentUser.GetCurrentUser().UserInfo.YHID;
                entity.XGRQ = System.DateTime.Now;
                if (entity.LXDM == CodeTypeEnum.TableName.ToString())
                    entity.DM = entity.DM.ToUpperInvariant();

                dalCode.SaveOrUpdate(entity);
                ExtResult ret = new ExtResult();
                ret.success = true;
                ret.msg = "保存成功";

                var codeTypeEnt = dalCodeType.GetEntityBylxdm(entity.LXDM);
                if (codeTypeEnt != null)
                    ret.parentid = codeTypeEnt.LXDM;

                return ret;
            };

            return base.Save(saveFun);
        }