Beispiel #1
0
        /// <summary>
        /// 加盟商后台管理
        /// </summary>
        /// <returns></returns>
        public ActionResult CompIndex()
        {
            var loginInfo = new SoftProjectAreaEntity
            {
                Sys_LoginInfoID = 1,
                LoginName = "公司1-企业管理员",
                PasswordDigest = "",//;//.Item.PasswordDigest,
                CompanyID = 1,
                CompanyName = "公司",
                LoginCategoryID = 2,
                LoginNameCn = "公司-企业管理员1",
                //HomeConstrollName = "Home",
                //HomeActionName = "Default",
                //CurrNav = "Home",
                //CurrMenuModularOrFunID = 71
            };
            //loginInfo.CurrNavCategoryID = 1;
            //loginInfo.CurrNav = "加盟商仪表盘";
            //loginInfo.CurrNavIdent = 1005;

            //Session["Pre_Users"] = new Pre_Users { Pre_UsersID = 1, UserName = "******", LoginName = "zs" };
            //SoftProjectAreaEntityDomain.Sys_OperLogDetail_AddSave(1, 1, "登录", 1, "登录");
            SoftProjectAreaEntityDomain.Sys_OperLogDetail_AddSave(2, 1, "登录", 1, 1, "公司1-企业管理员", 1, "登录");
            //SoftProjectAreaEntityDomain.Sys_OperLogDetail_AddSave(2, 1, "登录", 1005, "登录");
            Session["LoginInfo"] = loginInfo;

            return View("Index");
        }
 /// <summary>
 /// Jquery树
 /// </summary>
 /// <param name="val"></param>
 /// <param name="NameCn"></param>
 /// <returns></returns>
 public static string JqTreeNs_Pre_OrganizationID(string val, string NameCn, SoftProjectAreaEntity item)
 {
     List<SoftProjectAreaEntity> Items = SoftProjectAreaEntityDomain.Pre_Organizations.Where(p => p.LoginCategoryID == item.LoginCategoryID).ToList();
     var treeList = new TreeList(Items, "0", "OrganizationName", "Pre_OrganizationID", "ParentPre_OrganizationID", "", "", "Pre_OrganizationID", "", "");
     var str = HtmlHelpersProject.JqTreeN(null, "Pre_OrganizationID", treeList, "", 2);
     return str.ToString();
 }
 public static string HtmlDropDownLiss_MG_MemberGradeID(string val, string NameCn, SoftProjectAreaEntity item)
 {
     //必须知道是公司、企业、顾客功能,从而进行过滤
     var MG_MemberGradesTemp = MG_MemberGrades.Where(p => p.Pre_CompanyID == SoftProjectAreaEntityDomain.LoginInfostatic.CompanyID);
     var str = HtmlHelpers.DropDownList(null, "Item.MG_MemberGradeID", MG_MemberGradesTemp, "MG_MemberGradeID", "MemberGradeName", val, "");
     return str.ToString();
 }
        public static MvcHtmlString JqTreeN(this HtmlHelper helper,SoftProjectAreaEntity data, string ID, int? paramNameType = 2)
        {
            string str = "";
            if (ProjectCache.JqTreeNs.ContainsKey(ID))
            {
                str = ProjectCache.JqTreeNs[ID](paramNameType.ToString(), "", data);
                //sbHtml.Append(str);
            }
            #region 原代码

            //List<SoftProjectAreaEntity> Items = new List<SoftProjectAreaEntity>();
            //if (ID == "Pre_OrganizationID")
            //{
            //    var Itemst = ProjectCache.Pre_Organizations;
            //    var treeList = new TreeList(Itemst, "0", "OrganizationName", "Pre_OrganizationID", "ParentOrganizationID", "", "", "Pre_OrganizationID", "", "");
            //    var str = JqTreeN(helper, ID, treeList, "", 2);
            //    return str;
            //}
            //else if (ID == "PreDoc_CategoryID")
            //{
            //    var Itemst = ProjectCache.PreDoc_Categorys;
            //    var treeList = new TreeList(Itemst, "0", "PreDocCategoryName", "PreDoc_CategoryID", "ParentPreDoc_CategoryID", "", "", "PreDoc_CategoryID", "", "");
            //    var str = JqTreeN(helper, ID, treeList, "", 2);
            //    return str;
            //}
            //else if (ID == "CompDoc_CategoryID")
            //{
            //    var Itemst = ProjectCache.PreDoc_Categorys;
            //    var treeList = new TreeList(Itemst, "0", "DocCategoryName", "CompDoc_CategoryID", "ParentCompDoc_CategoryID", "", "", "CompDoc_CategoryID", "", "");
            //    var str = JqTreeN(helper, ID, treeList, "", 2);
            //    return str;
            //}
            #endregion
            return new MvcHtmlString(str);
        }
        /// <summary>
        /// 编辑页面下拉树--公司组织机构ID
        /// </summary>
        /// <param name="val"></param>
        /// <param name="NameCn"></param>
        /// <returns></returns>
        public static string HtmlDropTrees_Pre_OrganizationID(string val, string NameCn, SoftProjectAreaEntity item)
        {
            List<SoftProjectAreaEntity> Items = SoftProjectAreaEntityDomain.Pre_Organizations.Where(p => p.LoginCategoryID == item.LoginCategoryID).ToList();
            var tt = new SelectTreeList(Items, "0", "OrganizationName", "Pre_OrganizationID", "ParentPre_OrganizationID", "Pre_OrganizationID", val, true, "");
            var str = HtmlHelpers.DropDownForTree(null, "Item.Pre_OrganizationID", tt, "");

            return str.ToHtmlString();
        }
 public static string QueryHtmlDropDownList_MG_MemberGradeID(string val, string NameCn, SoftProjectAreaEntity item)
 {
     //var Pre_Roles = ProjectCache.Caches["MG_MemberGradeID"];
     var MG_MemberGradesTemp = MG_MemberGrades.Where(p => p.Pre_CompanyID == SoftProjectAreaEntityDomain.LoginInfostatic.CompanyID);
     var str = HtmlHelpers.DropDownList(null, "MG_MemberGradeID___equal", MG_MemberGradesTemp, "MG_MemberGradeID", "MemberGradeName", val, "", "==" + NameCn + "==");
     var strDrop = str.ToString();
     return strDrop;
 }
 public MyResponseBase()
 {
     searchType = 0;
     Item = new SoftProjectAreaEntity();
     Items = new List<SoftProjectAreaEntity>();
     RespAttachInfo = new RespAttachInfo();
     PageQueryBase = new PageQueryBase();
     Querys = new Querys();
 }
        /// <summary>
        /// 编辑页面下拉树--工具类型父节点
        /// </summary>
        /// <param name="val"></param>
        /// <param name="NameCn"></param>
        /// <returns></returns>
        public static string HtmlDropTrees_T_ToolCategoryID(string val, string NameCn, SoftProjectAreaEntity item)
        {
            //var Pre_Company = HttpContext.Current.Session["LoginInfo"] as SoftProjectAreaEntity;
            //var Items = SoftProjectAreaEntityDomain.T_ToolCategorys.Where(p => p.Pre_CompanyID == Pre_Company.CompanyID);

            List<SoftProjectAreaEntity> Items = SoftProjectAreaEntityDomain.T_ToolCategorys;
            var tt = new SelectTreeList(Items, "0", "ToolCategoryName", "T_ToolCategoryID", "ParentT_ToolCategoryID", "T_ToolCategoryID", val, true, "");
            var str = HtmlHelpers.DropDownForTree(null, "Item.T_ToolCategoryID", tt, "==工具类型==");
            return str.ToHtmlString();
        }
 //#region #区域
 //static List<SoftProjectAreaEntity> _Ba_Areas = new List<SoftProjectAreaEntity>();
 //public static List<SoftProjectAreaEntity> Ba_Areas
 //{
 //    get
 //    {
 //        if (_Ba_Areas.Count == 0)
 //        {
 //            SoftProjectAreaEntityDomain domain = new SoftProjectAreaEntityDomain();
 //            _Ba_Areas = domain.Ba_Area_GetAll();
 //        }
 //        return _Ba_Areas;
 //    }
 //}
 ///// <summary>
 ///// 获取所有1级区域
 ///// </summary>
 //public static List<SoftProjectAreaEntity> Ba_AreaID1s
 //{
 //    get
 //    {
 //        var lists = Ba_Areas.Where(p => p.AreaParentCode == "0");
 //        return lists.ToList();
 //    }
 //}
 ///// <summary>
 ///// 根据ID,获取对应ID父区域下的子区域
 ///// </summary>
 ///// <param name="Ba_AreaID"></param>
 ///// <returns></returns>
 //public static List<SoftProjectAreaEntity> GetBrotherBa_AreaIDss(int? Ba_AreaID)
 //{
 //    var item = Ba_Areas.Where(p => p.Ba_AreaID == Ba_AreaID).First();
 //    var lists = Ba_Areas.Where(p => p.AreaParentCode == item.AreaParentCode);
 //    return lists.ToList();
 //}
 ///// <summary>
 ///// 根据ID,查询所有子区域
 ///// </summary>
 ///// <param name="Ba_AreaID"></param>
 ///// <returns></returns>
 //public static List<SoftProjectAreaEntity> GetSubBa_AreaIDss(int? Ba_AreaID)
 //{
 //    var item = Ba_Areas.Where(p => p.Ba_AreaID == Ba_AreaID).First();
 //    var lists = _Ba_Areas.Where(p => p.AreaParentCode == item.AreaCode);
 //    return lists.ToList();
 //}
 ///// <summary>
 ///// 根据ID查询
 ///// </summary>
 ///// <param name="Ba_AreaID"></param>
 ///// <returns></returns>
 //public static SoftProjectAreaEntity GetByAreaID(int? Ba_AreaID)
 //{
 //    var item = Ba_Areas.Where(p => p.Ba_AreaID == Ba_AreaID).First();
 //    return item;
 //}
 //#endregion
 public static SoftProjectAreaEntity BulidRequest(SoftProjectAreaEntity oldItem, SoftProjectAreaEntity ChildAction)
 {
     //Model.ChildAction.ControllName, Model.ChildAction
     var request = new SoftProjectAreaEntity();
     var ActionFieldNamess = ChildAction.ActionFieldNames.Split(',');
     Type type = oldItem.GetType();
     foreach (var fieldname in ActionFieldNamess)
     {
         PropertyInfo property = type.GetProperty(fieldname);
         object value = property.GetValue(oldItem, null);
         property.SetValue(request, value);
     }
     return request;
 }
 /// <summary>
 /// 查询:根据ID查询
 /// </summary>
 /// <returns></returns>
 public MyResponseBase Sys_PremCode_GetByID()
 {
     Sys_PremCode_PKCheck();
     SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity
     {
         DBTSql = ";WITH T1000 AS (SELECT * FROM [dbo].[Sys_PremCode] A )",
         DBOperType = 8,
         SelectSubType = 1,
         DBSelectResultType = 4,
         EqualQueryParam = "Sys_PremCodeID"
     };
     resp = Execute();
     return resp;
 }
        /// <summary>
        /// 获取所有权限码:将进行缓存:用于判断是否需要进行权限验证
        /// </summary>
        /// <returns></returns>
        public List<SoftProjectAreaEntity> Sys_PremCode_GetAll()
        {
            PageQueryBase.RankInfo = "[PremCode]|1";

            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity
            {
                DBTSql = "SELECT * FROM [dbo].[Sys_PremCode] A Order  By [PremCode]",
                DBOperType = 16,
                DBSelectResultType = 2,
                EqualQueryParam=""
            };
            Sys_HOperControl = hOperControl;

            var resp = Execute();
            resp = Execute();
            return resp.Items;
        }
        //MyResponseBase<LoginInfo> resp = new MyResponseBase<LoginInfo>();
        public MyResponseBase Login()
        {
            if (string.IsNullOrEmpty(Item.MobilePhone) || string.IsNullOrEmpty(Item.PasswordDigest))
            {
                throw new Exception("手机号和密码不能为空");
                //resp.RespAttachInfo.ValidationErrors.ErrorMessage = "用户名或密码不能为空";
                //return resp;
            }
            //return false;

            #region 用户登录

            var Users = SoftProjectAreaEntityDomain.Pre_UserRoleAll.Where(p => p.MobilePhone == Item.MobilePhone && p.PasswordDigest == Item.PasswordDigest && p.UserStatuID == 1);

            if (Users.Count() > 0)
            {
                #region 公司
                var user = Users.First();
                //HomePageName HomePageUrl
                var loginInfo = new SoftProjectAreaEntity
                {
                    Sys_LoginInfoID = user.Pre_UserID,
                    LoginCategoryID = 1,
                    MobilePhone = user.MobilePhone,
                    CompanyID = user.Pre_CompanyID,
                    CompanyName = user.PreCompanyName,
                    UserName = user.UserName,
                    RoleID = user.Pre_RoleID,

                    HomePageName = user.RoleHomePageName,
                    HomePageUrl = user.RoleHomePageUrl,
                };
                resp.Item = loginInfo;
                #endregion
            }
            else
            {
                throw new Exception("用户、密码不正确,或此用户已被停用!");
            }
            #endregion
            return resp;
        }
        /// <summary>
        /// 生成页面记录
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularPageField_BulidRecord()
        {
            var Design_ModularOrFunID = Item.Design_ModularOrFunID;
            Design_ModularOrFun_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            #region 功能模块对象
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
            #endregion

            var sbsql = new StringBuilder();
            string sql = "";
            //sbsql.AppendLine("SELECT 1 Design_ModularFieldID,1 TableInfoSort");
            //sbsql.AppendLine("UNION ALL");
            //sbsql.AppendLine("SELECT 3,100");
            //sbsql.AppendLine("UNION ALL");
            //sbsql.AppendLine("SELECT Design_ModularFieldID,Sort+2 TableInfoSort");
            //sbsql.AppendLine("FROM Design_ModularField");
            //sbsql.AppendLine("WHERE Design_ModularOrFunID={0}");
            //sbsql.AppendLine("ORDER BY TableInfoSort");

            sbsql.AppendLine(";WITH T0 AS");
            sbsql.AppendLine("(");
            sbsql.AppendLine("	SELECT 1 Design_ModularFieldID,1 TableInfoSort");
            sbsql.AppendLine("	UNION ALL");
            sbsql.AppendLine("	SELECT 3,100");
            sbsql.AppendLine("	UNION ALL");
            sbsql.AppendLine("	SELECT Design_ModularFieldID,Sort+2 TableInfoSort");
            sbsql.AppendLine("	FROM Design_ModularField");
            sbsql.AppendLine("	WHERE Design_ModularOrFunID={0}");
            //sbsql.AppendLine("	ORDER BY TableInfoSort");
            sbsql.AppendLine(")");
            sbsql.AppendLine("INSERT INTO Design_ModularPageField(Design_ModularOrFunID,Design_ModularFieldID,TableInfoSort)");
            sbsql.AppendLine("SELECT {0},*");
            sbsql.AppendLine("FROM T0  ");
            sbsql.AppendLine("ORDER BY TableInfoSort");
            sql = sbsql.ToString();
            sql = string.Format(sql, Item.Design_ModularOrFunID);
            Query16(sql, 1);
            return resp;
        }
        /// <summary>
        /// 多选下拉列表框
        /// </summary>
        /// <param name="val"></param>
        /// <param name="NameCn"></param>
        /// <param name="Item"></param>
        /// <returns></returns>
        public static string DropDownListMultiSelect_OperatingItemIDs(string val, string NameCn, SoftProjectAreaEntity Item)
        {
            var OperatingItemIDArrs = new List<string>().ToArray();
            if (!string.IsNullOrEmpty(Item.OperatingItemIDs))
            {
                OperatingItemIDArrs = Item.OperatingItemIDs.Split(',');
            }

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(string.Format("<select id='Item_OperatingItemIDs' name='Item.OperatingItemIDs' multiple='multiple' class='multiselect ' >"));

            var items = SoftProjectAreaEntityDomain.P_Categorys.Where(p => p.ParentP_CategoryID == 0);
            foreach (var item in items)
            {
                if (OperatingItemIDArrs.Contains(item.P_CategoryID.ToString()))
                    sb.AppendLine(string.Format("<option value='{0}' selected>{1}</option>", item.P_CategoryID, item.PCategoryName));//<input class='ck-align' " + disabled + " name='Item." + name + "' type='checkbox' value='" + value.ToString() + "' checked='checked' />" + text.ToString() + "</label>&nbsp;&nbsp;");
                else
                    sb.AppendLine(string.Format("<option value='{0}'>{1}</option>", item.P_CategoryID, item.PCategoryName)); ;// sb.AppendLine("<label class='checkbox-inline'><input class='ck-align' " + disabled + "name='Item." + name + "' type='checkbox' value='" + value.ToString() + "' />" + text.ToString() + "</label>&nbsp;&nbsp;");
            }
            sb.AppendLine("</select>");
            return sb.ToString();
        }
        public MyResponseBase Design_ModularOrFunDomain_AddSave()
        {
            var resp = new MyResponseBase();
            Design_ModularOrFunDomain_Domain();
            #region (2)修改功能模块字段
            using (var scope = new TransactionScope())
            {
                try
                {
                    SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };
                    var DBFieldVals = "";

                    #region (1)添加功能模块
                    //Design_ModularOrFunDomain_PKCheck();

                    Design_ModularOrFunDomain_Domain();
                    DBFieldVals = "ModularOrFunDomainName,MethodName,MethodReturnTypeID,Sort,Design_ModularOrFunID";
                    resp = AddSave(DBFieldVals);

                    #endregion
                    Design_ModularOrFunDomainDetail_EditSave();

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    scope.Dispose();
                }
            }
            #endregion

            return resp;
        }
        /// <summary>
        /// 生成控制器记录
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunControll_EditListBulidRecord()
        {
            Design_ModularOrFunControll_CheckBulid();
            Design_ModularOrFunControll_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            var sqltemp = "SELECT * FROM Design_ModularOrFunControll A WHERE Design_ModularOrFunID=" + Item.Design_ModularOrFunID;
            var controllTemps = Query16(sqltemp);
            if (controllTemps.Items.Count > 0)
                throw new Exception("已生成过控制器,只能生成1次");
            #region 功能模块对象
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;

            #endregion

            #region 获取实体字段
            var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
            var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).Select(p => p.name).ToList();
            var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()

            var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
            var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()

            #endregion

            #region 查询
            StringBuilder sbcode = new StringBuilder();

            ///// <summary>
            ///// 用户管理--查询
            ///// </summary>
            ///// <param name="domain"></param>
            ///// <returns></returns>
            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult Index(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("//if (!domain.Querys.QueryDicts.ContainsKey(\"{0}___equal\"))", FKFields));
            sbcode.AppendLine("//{");
            sbcode.AppendLine(string.Format("//    if (domain.Item.{0} == null)", FKFields));
            sbcode.AppendLine("        //throw new Exception(\"主键不能为空\");");
            sbcode.AppendLine(string.Format("    //domain.Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = domain.Item.{0}.ToString() }});", FKFields));
            sbcode.AppendLine("//}");

            //sbcode.AppendLine("    //domain.Querys.Add(new Query { QuryType = 0, FieldName = \"Pre_CompanyID___equal\", Value = LoginInfo.CompanyID.ToString() });");
            sbcode.AppendLine("");
            //sbcode.AppendLine("    ModularOrFunCode = \"AuthorizationAreas.Pre_User.Index\";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Index\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("    var resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("    if (Request.IsAjaxRequest())");
            sbcode.AppendLine("        return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("    resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("    return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("}");

            var selectItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--查询",
                ActionMethod = "Index",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = null,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "查询",
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.Index", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 1
            };
            #endregion

            #region 添加查询
            sbcode = new StringBuilder();
            sbcode.AppendLine("        public ActionResult Add(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine("            var resp = domain.Default();");
            sbcode.AppendLine("            #region 初始化代码");
            sbcode.AppendLine("            #endregion");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Add\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            resp.FunNameEn = \"Add\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var addItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--添加查询",
                ActionMethod = "Add",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = null,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "添加",
                ControllModularOrFunCode = string.Format("{0}.{1}.Add", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 3
            };
            #endregion

            #region 添加保存
            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpPost]");
            sbcode.AppendLine("        public HJsonResult AddSave(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine("            #region 初始值 ");
            sbcode.AppendLine("            #endregion");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Add\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.AddSave();");
            sbcode.AppendLine("            return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("        }");

            var addSaveItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--添加保存",
                ActionMethod = "AddSave",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 2,
                ParamName = null,//主键名
                ViewName = null,//EditP
                ControllModularOrFunCode = string.Format("{0}.{1}.Add", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 5
            };
            #endregion

            #region 编辑查询
            sbcode = new StringBuilder();
            sbcode.AppendLine("        public ActionResult Edit(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            //sbcode.AppendLine("            ModularOrFunCode = "AuthorizationAreas.Pre_User.Detail";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Edit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.ByID();");
            sbcode.AppendLine("");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Edit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            resp.FunNameEn = \"Edit\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var editItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--编辑查询",
                ActionMethod = "Edit",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "编辑",
                ControllModularOrFunCode = string.Format("{0}.{1}.Edit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 7
            };
            #endregion

            #region 编辑保存
            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpPost]");
            sbcode.AppendLine("        public HJsonResult EditSave(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Edit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("");
            sbcode.AppendLine("            var resp = domain.EditSave();");
            sbcode.AppendLine("            return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("        }");

            var editSaveItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--编辑保存",
                ActionMethod = "EditSave",
                ControllProgramCode = sbcode.ToString(),

                ActionName = 2,
                ParamName = null,
                ViewName = null,
                ControllModularOrFunCode = string.Format("{0}.{1}.Edit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 9
            };
            #endregion

            #region 查看查询
            sbcode = new StringBuilder();

            sbcode.AppendLine("        public ActionResult Detail(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Detail\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.ByID();");
            sbcode.AppendLine("");
            sbcode.AppendLine("            resp.FunNameEn = \"Detail\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var DetailItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--查看",
                ActionMethod = "Detail",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "查看",
                ControllModularOrFunCode = string.Format("{0}.{1}.Detail", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 11
            };
            #endregion

            //Item.Items.Clear();
            if (Item.Design_ModularOrFunControlls == null)
                Item.Design_ModularOrFunControlls = new List<SoftProjectAreaEntity>();
            Item.Design_ModularOrFunControlls.Add(selectItem);
            Item.Design_ModularOrFunControlls.Add(addItem);
            Item.Design_ModularOrFunControlls.Add(addSaveItem);
            Item.Design_ModularOrFunControlls.Add(editItem);
            Item.Design_ModularOrFunControlls.Add(editSaveItem);
            Item.Design_ModularOrFunControlls.Add(DetailItem);

            var resp = Design_ModularOrFunControll_EditListSave();
            return resp;
        }
        private void NewPage(SoftProjectAreaEntity Design_ModularOrFun, List<SoftProjectAreaEntity> Design_ModularOrFunControlls, StringBuilder sbentity)
        {
            foreach (var item in Design_ModularOrFunControlls)
            {
                //public ActionResult Index(SoftProjectAreaEntityDomain domain)
                //{
                //    var resp = domain.BC_ExpertGuidance_Index();
                //    resp.ModularOrFunCode = "BC_PartnerAreas.BC_ExpertGuidance";
                //    ;
                //
                //    return View("IndexPTab", resp);
                //}
                #region 获取ModularOrFunCode
                var ModularOrFunCode = "";
                if (item.Design_ModularOrFunID1 != null)
                {
                    if (item.Design_ModularOrFunID1 == Item.Design_ModularOrFunID)
                        ModularOrFunCode = Design_ModularOrFun.ModularOrFunCode;
                    else
                    {
                        SoftProjectAreaEntityDomain domintemp = new SoftProjectAreaEntityDomain();
                        domintemp.Item = new SoftProjectAreaEntity { Design_ModularOrFunID = item.Design_ModularOrFunID1 };
                        var resptemp1 = domintemp.Design_ModularOrFun_GetByID();
                        ModularOrFunCode = resptemp1.Item.ModularOrFunCode;
                    }
                }
                #endregion

                #region 视图名称

                var ViewName = "";
                if (item.ViewName == 1)
                    ViewName = "IndexP";
                else if (item.ViewName == 2)
                    ViewName = "IndexPFrame";
                else if (item.ViewName == 3)
                    ViewName = "IndexPContext";
                else if (item.ViewName == 4)
                    ViewName = "IndexPChild";

                else if (item.ViewName == 11)
                    ViewName = "Row";
                else if (item.ViewName == 12)
                    ViewName = "Rows";
                else if (item.ViewName == 15)
                    ViewName = "IndexPTab";

                else if (item.ViewName == 20)
                    ViewName = "EditP";
                else if (item.ViewName == 21)
                    ViewName = "EditPFrame";
                else if (item.ViewName == 22)
                    ViewName = "EditPContext";
                else if (item.ViewName == 26)
                    ViewName = "EditArea";

                else if (item.ViewName == 30)
                    ViewName = "PopupEdit";
                else if (item.ViewName == 31)
                    ViewName = "EditPartial";

                #endregion

                var ActionName = item.ActionName == 1 ? "ActionResult" : "HJsonResult";
                sbentity.AppendLine("        /// <summary>");
                sbentity.AppendLine("        /// " + item.ControllName);
                sbentity.AppendLine("        /// </summary>");
                sbentity.AppendLine("        /// <param name=\"domain\"></param>");
                sbentity.AppendLine("        /// <returns></returns>");
                if (item.ActionName == 1)
                {
                    sbentity.AppendLine(string.Format("        public ActionResult {0}(SoftProjectAreaEntityDomain domain)", item.ActionMethod));
                    sbentity.AppendLine("        {");

                    sbentity.AppendLine(string.Format("            var resp = domain.{0}_{1}();", Design_ModularOrFun.ControllCode, item.ActionMethod));
                    sbentity.AppendLine("            resp.ModularOrFunCode = \"" + ModularOrFunCode + "\";");
                    sbentity.AppendLine("            ");
                    sbentity.AppendLine("            ");
                    sbentity.AppendLine(string.Format("            return View(\"{0}\", resp);", ViewName));

                    sbentity.AppendLine("        }");
                }
                else
                {
                    sbentity.AppendLine(string.Format("        public HJsonResult {0}(SoftProjectAreaEntityDomain domain)", item.ActionMethod));
                    sbentity.AppendLine("        {");
                    sbentity.AppendLine(string.Format("            var resp = domain.{0}_{1}();", Design_ModularOrFun.ControllCode, item.ActionMethod));
                    sbentity.AppendLine("            return new HJsonResult(new { Data = resp });");
                    sbentity.AppendLine("        }");
                }
                sbentity.AppendLine();
            }
        }
        public MyResponseBase Design_ModularOrFunControll_EditListSave()
        {
            Design_ModularOrFunControll_Domain();
            #region (2)修改功能模块字段
            using (var scope = new TransactionScope())
            {
                try
                {
                    SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

                    #region (1)修改功能模块(无)

                    #endregion

                    #region (3)根据功能模块ID查询所有字段
                    var resptemp = Design_ModularOrFunControll_GetByModularOrFunID();
                    #endregion

                    #region (2)模块字段--数据整理
                    Item.Design_ModularOrFunControlls.ForEach(p =>
                    { p.Design_ModularOrFunID = Item.Design_ModularOrFunID; });

                    var deleteIDsEnum = (from p in resptemp.Items select p.Design_ModularOrFunControllID).Except(from o in Item.Design_ModularOrFunControlls select o.Design_ModularOrFunControllID);
                    var updateItems = Item.Design_ModularOrFunControlls.Where(p => p.Design_ModularOrFunControllID != null);
                    var addItems = Item.Design_ModularOrFunControlls.Where(p => p.Design_ModularOrFunControllID == null);
                    #endregion

                    #region (4)删除元素:执行删除,通过In进行删除
                    //需要写专门语句?delete xxx where ID IN(XXX)
                    if (deleteIDsEnum.Count() > 0)
                    {
                        var deleteIDs = string.Join(",", deleteIDsEnum);//deleteForecastIDsEnum.ToArray()
                        var sql = string.Format("DELETE [dbo].[Design_ModularOrFunControll] WHERE  Design_ModularOrFunControllID IN({0})", deleteIDs);
                        resptemp = Query16(sql, 1);
                    }
                    #endregion

                    #region (5)更新模块字段

                    if (updateItems.Count() > 0)
                    {
                        SoftProjectAreaEntityDomain domain = new SoftProjectAreaEntityDomain { Items = updateItems.ToList() };
                        domain.Design_ModularOrFunControll_Domain();
                        //var DBFieldVals = "Sort,Design_ModularOrFunID,Design_ModularOrFunID1,Design_ModularOrFunDomainID,ControllName,ControllActionPath,ActionMethod,ActionName,ParamName,ViewName,ControllProgramCode,BPrem,ActionMethodCn,DataRightDict,BMenu,ToolbarButtonAreaWidth,TableWidth,ControllModularOrFunCode";
                        var DBFieldVals = "Sort,Design_ModularOrFunID,Design_ModularOrFunID1,Design_ModularOrFunDomainID,ControllName,ActionMethod,ParamName,BPrem,ActionMethodCn,DataRightDict,ControllModularOrFunCode,ControllProgramCode,ActionName,ViewName";

                        domain.EditSaves(DBFieldVals);
                    }

                    #endregion

                    #region (6)添加

                    if (addItems.Count() > 0)
                    {
                        SoftProjectAreaEntityDomain domain = new SoftProjectAreaEntityDomain { Items = addItems.ToList() };
                        domain.Design_ModularOrFunControll_Domain();
                        //var DBFieldVals = "Sort,Design_ModularOrFunID,Design_ModularOrFunID1,Design_ModularOrFunDomainID,ControllName,ControllActionPath,ActionMethod,ActionName,ParamName,ViewName,ControllProgramCode,BPrem,ActionMethodCn,DataRightDict,BMenu,ToolbarButtonAreaWidth,TableWidth";
                        var DBFieldVals = "Sort,Design_ModularOrFunID,Design_ModularOrFunID1,Design_ModularOrFunDomainID,ControllName,ActionMethod,ParamName,BPrem,ActionMethodCn,DataRightDict,ControllModularOrFunCode,ControllProgramCode,ActionName,ViewName";
                        domain.AddSaves(DBFieldVals);
                    }

                    #endregion

                    scope.Complete();
                    ProjectCache.Design_ModularOrFunBtnControlls_Clear();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    scope.Dispose();
                }
            }
            #endregion

            return resp;
        }
        ///// <summary>
        ///// 生成控制器记录
        ///// </summary>
        ///// <returns></returns>
        //public MyResponseBase Design_ModularOrFunControll_EditListBulidRecordPopup()
        //{
        //    Design_ModularOrFunControll_Domain();
        //    SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };
        //    #region 功能模块对象
        //    var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
        //    #endregion
        //    #region 获取实体字段
        //    var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
        //    var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).Select(p => p.name).ToList();
        //    var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()
        //    var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
        //    var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()
        //    #endregion
        //    #region 查询
        //    var selectItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--查询",
        //        ActionMethod = "Index",
        //        ActionName = 1,
        //        ParamName = null,//主键名
        //        ViewName = 1,//IndexP
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 100
        //    };
        //    #endregion
        //    #region 添加查询
        //    var addItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--添加查询",
        //        ActionMethod = "Add",
        //        ActionName = 1,
        //        ParamName = null,//主键名
        //        ViewName = 30,//PopupEdit
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 105
        //    };
        //    #endregion
        //    #region 添加保存
        //    var addSaveItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--添加保存",
        //        ActionMethod = "AddSave",
        //        ActionName = 2,
        //        ParamName = null,//主键名
        //        ViewName = null,//EditP
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 110
        //    };
        //    #endregion
        //    #region 编辑查询
        //    var editItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--编辑查询",
        //        ActionMethod = "Edit",
        //        ActionName = 1,
        //        ParamName = PKField,//主键名
        //        ViewName = 30,//PopupEdit
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 115
        //    };
        //    #endregion
        //    #region 编辑保存
        //    var editSaveItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--编辑保存",
        //        ActionMethod = "EditSave",
        //        ActionName = 2,
        //        ParamName = null,
        //        ViewName = null,
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 120
        //    };
        //    #endregion
        //    #region Row
        //    var rowItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--Row",
        //        ActionMethod = "Row",
        //        ActionName = 1,
        //        ParamName = PKField,
        //        ViewName = 11,
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 125
        //    };
        //    #endregion
        //    //Item.Items.Clear();
        //    if (Item.Design_ModularOrFunControlls == null)
        //        Item.Design_ModularOrFunControlls = new List<SoftProjectAreaEntity>();
        //    Item.Design_ModularOrFunControlls.Add(selectItem);
        //    Item.Design_ModularOrFunControlls.Add(addItem);
        //    Item.Design_ModularOrFunControlls.Add(addSaveItem);
        //    Item.Design_ModularOrFunControlls.Add(editItem);
        //    Item.Design_ModularOrFunControlls.Add(editSaveItem);
        //    Item.Design_ModularOrFunControlls.Add(rowItem);
        //    var resp = Design_ModularOrFunControll_EditListSave();
        //    return resp;
        //}
        /// <summary>
        /// 生成控制器记录
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunControll_EditListBulidRecordPopup_Old()
        {
            Design_ModularOrFunControll_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            #region 功能模块对象
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
            #endregion

            #region 获取实体字段
            var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
            var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).Select(p => p.name).ToList();
            var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()

            var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
            var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()

            #endregion

            #region 查询
            StringBuilder sbcode = new StringBuilder();
            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult Index(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("    var resp = domain.{0}_Index();", Design_ModularOrFun.ControllCode));
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Index\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    if (Request.IsAjaxRequest())");
            sbcode.AppendLine("        return View(\"IndexPContext\", resp);");
            sbcode.AppendLine("    return View(\"IndexPFrame\", resp);");
            sbcode.AppendLine("}");

            var selectItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--查询",
                ActionMethod = "Index",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = null,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "查询",
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.Index", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 100
            };

            #endregion
            //return null;
            #region 添加查询
            sbcode = new StringBuilder();
            sbcode.AppendLine("public ActionResult Add(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine("    var resp = domain.Default();");
            sbcode.AppendLine("    resp.FunNameEn = \"Add\";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Add\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    return View(\"PopupEdit\", resp);");
            sbcode.AppendLine("}");

            var addItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--添加查询",
                ActionMethod = "Add",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = null,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "添加",
                ControllModularOrFunCode = string.Format("{0}.{1}.Add", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 105
            };
            #endregion

            #region 添加保存
            sbcode = new StringBuilder();
            sbcode.AppendLine("[HttpPost]");
            sbcode.AppendLine("[ActionName(\"AddSave\")]");
            sbcode.AppendLine("public HJsonResult AddSave(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("    var resp = domain.{0}_AddSave();", Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("}");

            var addSaveItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--添加保存",
                ActionMethod = "AddSave",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 2,
                ParamName = null,//主键名
                ViewName = null,//EditP
                ControllModularOrFunCode = string.Format("{0}.{1}.Add", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 110
            };
            #endregion

            #region 编辑查询
            sbcode = new StringBuilder();
            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult Edit(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("    var resp = domain.{0}_ByIDEdit();", Design_ModularOrFun.ControllCode));
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Edit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    return View(\"PopupEdit\", resp);");
            sbcode.AppendLine("}");

            var editItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--编辑查询",
                ActionMethod = "Edit",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "编辑",
                ControllModularOrFunCode = string.Format("{0}.{1}.Edit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 115
            };
            #endregion

            #region 编辑保存
            sbcode = new StringBuilder();
            sbcode.AppendLine("[HttpPost]");
            sbcode.AppendLine("[ActionName(\"EditSave\")]");
            sbcode.AppendLine("public HJsonResult EditSave(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("    var resp = domain.{0}_EditSave();", Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("}");
            var editSaveItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--编辑保存",
                ActionMethod = "EditSave",
                ControllProgramCode = sbcode.ToString(),

                ActionName = 2,
                ParamName = null,
                ViewName = null,
                ControllModularOrFunCode = string.Format("{0}.{1}.Edit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 120
            };
            #endregion

            #region Row
            sbcode = new StringBuilder();

            sbcode.AppendLine("public ActionResult Row(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("    var resp = domain.{0}_ByID();", Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("     resp.Items.Add(resp.Item);");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Index\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    ");
            sbcode.AppendLine("    ");
            sbcode.AppendLine("    return View(\"Rows\", resp);");
            sbcode.AppendLine("}");

            var rowItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--Row",
                ActionMethod = "Row",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = PKField,
                ViewName = 11,
                ControllModularOrFunCode = string.Format("{0}.{1}.Index", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 125
            };
            #endregion

            //Item.Items.Clear();
            if (Item.Design_ModularOrFunControlls == null)
                Item.Design_ModularOrFunControlls = new List<SoftProjectAreaEntity>();
            Item.Design_ModularOrFunControlls.Add(selectItem);
            Item.Design_ModularOrFunControlls.Add(addItem);
            Item.Design_ModularOrFunControlls.Add(addSaveItem);
            Item.Design_ModularOrFunControlls.Add(editItem);
            Item.Design_ModularOrFunControlls.Add(editSaveItem);
            Item.Design_ModularOrFunControlls.Add(rowItem);

            var resp = Design_ModularOrFunControll_EditListSave();
            return resp;
        }
        /// <summary>
        /// 生成控制器记录:领域模型的相关表
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunControll_EditListBulidRecordDomainRefPopup()
        {
            Design_ModularOrFunControll_CheckBulid();

            Design_ModularOrFunControll_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            #region 功能模块对象
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
            #endregion

            #region 获取实体字段
            var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
            var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).Select(p => p.name).ToList();
            var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()

            var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
            var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()

            #endregion

            #region 查询
            var selectItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--查询",
                ActionMethod = "Index",
                ActionName = 1,
                ParamName = FKFields,//主键名
                ViewName = 15,//IndexPTab
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 100
            };
            #endregion

            #region 添加查询
            var addItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--添加查询",
                ActionMethod = "Add",
                ActionName = 1,
                ParamName = FKFields,//主键名
                ViewName = 30,//EditP
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 105
            };
            #endregion

            #region 添加保存
            var addSaveItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--添加保存",
                ActionMethod = "AddSave",
                ActionName = 2,
                ParamName = null,//主键名
                ViewName = null,//EditP
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 110
            };
            #endregion

            #region 编辑查询
            var editItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--编辑查询",
                ActionMethod = "Edit",
                ActionName = 2,
                ParamName = FKFields + "," + PKField,//主键名
                ViewName = 30,//EditP
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 115
            };
            #endregion

            #region 编辑保存
            var editSaveItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--编辑保存",
                ActionMethod = "EditSave",
                ActionName = 2,
                ParamName = null,
                ViewName = null,
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 120
            };
            #endregion

            #region Row
            var rowItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--Row",
                ActionMethod = "Row",
                ActionName = 1,
                ParamName = PKField,
                ViewName = 1,
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 125
            };
            #endregion

            //Item.Items.Clear();
            Item.Design_ModularOrFunControlls.Add(selectItem);
            Item.Design_ModularOrFunControlls.Add(addItem);
            Item.Design_ModularOrFunControlls.Add(addSaveItem);
            Item.Design_ModularOrFunControlls.Add(editItem);
            Item.Design_ModularOrFunControlls.Add(editSaveItem);
            Item.Design_ModularOrFunControlls.Add(rowItem);

            var resp = Design_ModularOrFunControll_EditListSave();
            return resp;
        }
        /// <summary>
        /// 生成控制器
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunControll_EditListBulidControll()
        {
            Design_ModularField_Domain();
            #region (2)修改功能模块字段
            using (var scope = new TransactionScope())
            {
                try
                {
                    SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };
                    //(1)保存或更新数据库数据,更新表结构
                    Design_ModularOrFunControll_EditListSave();

                    //(2)创建控制器
                    #region 1)查询模块功能
                    var resptemp = Design_ModularOrFun_GetByID();
                    var Design_ModularOrFun = resptemp.Item;
                    #endregion

                    #region 3)根据功能模块ID查询所有字段
                    resptemp = Design_ModularOrFunControll_GetByModularOrFunID();
                    var Design_ModularOrFunControlls = resptemp.Items;
                    #endregion
                    StringBuilder sbentity = new StringBuilder();
                    #region 名称空间引用

                    sbentity.AppendLine("using Framework.Core;");
                    sbentity.AppendLine("using Framework.Web.Mvc;");
                    sbentity.AppendLine("using SoftProject.Domain;");
                    sbentity.AppendLine("using System;");
                    sbentity.AppendLine("using System.Collections.Generic;");
                    sbentity.AppendLine("using System.Linq;");
                    sbentity.AppendLine("using System.Text;");
                    sbentity.AppendLine("using System.Web;");
                    sbentity.AppendLine("using System.Web.Mvc;");

                    #endregion

                    sbentity.AppendLine();
                    sbentity.AppendLine("namespace SoftPlatform.Controllers");
                    sbentity.AppendLine("{");
                    sbentity.AppendLine("    /// <summary>");
                    sbentity.AppendLine(string.Format("    /// 控制器:{0}({1})", Design_ModularOrFun.ControllCode, Design_ModularOrFun.ModularName));
                    sbentity.AppendLine("    /// </summary>");
                    sbentity.AppendLine("    public class " + Design_ModularOrFun.ControllCode + "Controller : BaseController");
                    sbentity.AppendLine("    {");
                    sbentity.AppendLine("        public " + Design_ModularOrFun.ControllCode + "Controller()");
                    sbentity.AppendLine("        {");
                    sbentity.AppendLine("        }");
                    sbentity.AppendLine();

                    //                    NewPage(Design_ModularOrFun, Design_ModularOrFunControlls, sbentity);
                    foreach (var item in Design_ModularOrFunControlls)
                    {
                        sbentity.AppendLine("        /// <summary>");
                        sbentity.AppendLine("        /// " + item.ControllName);
                        sbentity.AppendLine("        /// </summary>");
                        sbentity.AppendLine("        /// <param name=\"domain\"></param>");
                        sbentity.AppendLine("        /// <returns></returns>");
                        sbentity.AppendLine(HttpUtility.UrlDecode(item.ControllProgramCode));

                    }
                    sbentity.AppendLine("   }");
                    sbentity.AppendLine("}");

                    //F:\软件项目\SoftPlatformProject\SoftPlatform\SoftPlatform\Areas\C_CustomerAreas\CellModel
                    //string filepath1=System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                    //string filepath2=System.Environment.CurrentDirectory ;
                    //string filepath3=System.IO.Directory.GetCurrentDirectory();
                    //string filepath4=System.AppDomain.CurrentDomain.BaseDirectory;
                    var path = string.Format(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Areas\\{0}\\Controllers\\", Design_ModularOrFun.AreasCode);
                    if (!Directory.Exists(path))
                        Directory.CreateDirectory(path);
                    //string filepath5 = string.Format(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Areas\\{0}\\CellModel\\{1}.cs", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode);
                    string filepath5 = path + Design_ModularOrFun.ControllCode + "Controll.cs";

                    FileStream fs = new FileStream(filepath5, FileMode.Create);
                    StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding(65001));
                    sw.Write(sbentity.ToString());
                    sw.Flush();
                    sw.Close();
                    fs.Close();

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    scope.Dispose();
                }
            }
            #endregion

            return resp;
        }
 public SoftProjectAreaEntityFormat(SoftProjectAreaEntity SoftProjectAreaEntity)
 {
     this._SoftProjectAreaEntity = SoftProjectAreaEntity;
 }
        ///// <summary>
        ///// 生成控制器记录
        ///// </summary>
        ///// <returns></returns>
        //public MyResponseBase Design_ModularOrFunControll_EditListBulidRecord()
        //{
        //    Design_ModularOrFunControll_Domain();
        //    SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };
        //    #region 功能模块对象
        //    var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
        //    #endregion
        //    #region 获取实体字段
        //    var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
        //    var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).Select(p => p.name).ToList();
        //    var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()
        //    var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
        //    var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()
        //    #endregion
        //    #region 查询
        //    var selectItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--查询",
        //        ActionMethod = "Index",
        //        ActionName = 1,
        //        ParamName = null,//主键名
        //        ViewName = 1,//IndexP
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 100
        //    };
        //    #endregion
        //    #region 添加查询
        //    var addItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--添加查询",
        //        ActionMethod = "Add",
        //        ActionName = 1,
        //        ParamName = null,//主键名
        //        ViewName = 20,//EditP
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 105
        //    };
        //    #endregion
        //    #region 添加保存
        //    var addSaveItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--添加保存",
        //        ActionMethod = "AddSave",
        //        ActionName = 2,
        //        ParamName = null,//主键名
        //        ViewName = null,//EditP
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 110
        //    };
        //    #endregion
        //    #region 编辑查询
        //    var editItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--编辑查询",
        //        ActionMethod = "Edit",
        //        ActionName = 1,
        //        ParamName = PKField,//主键名
        //        ViewName = 20,//EditP
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 115
        //    };
        //    #endregion
        //    #region 编辑保存
        //    var editSaveItem = new SoftProjectAreaEntity
        //    {
        //        ControllName = Design_ModularOrFun.ModularName + "--编辑保存",
        //        ActionMethod = "EditSave",
        //        ActionName = 2,
        //        ParamName = null,
        //        ViewName = null,
        //        Design_ModularOrFunID = Item.Design_ModularOrFunID,
        //        Sort = 120
        //    };
        //    #endregion
        //    //Item.Items.Clear();
        //    if (Item.Design_ModularOrFunControlls == null)
        //        Item.Design_ModularOrFunControlls = new List<SoftProjectAreaEntity>();
        //    Item.Design_ModularOrFunControlls.Add(selectItem);
        //    Item.Design_ModularOrFunControlls.Add(addItem);
        //    Item.Design_ModularOrFunControlls.Add(addSaveItem);
        //    Item.Design_ModularOrFunControlls.Add(editItem);
        //    Item.Design_ModularOrFunControlls.Add(editSaveItem);
        //    var resp = Design_ModularOrFunControll_EditListSave();
        //    return resp;
        //}
        public void Design_ModularOrFunControll_CheckBulid()
        {
            Design_ModularOrFunControll_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            var sqltemp = "SELECT * FROM Design_ModularOrFunControll A WHERE Design_ModularOrFunID=" + Item.Design_ModularOrFunID;
            var controllTemps = Query16(sqltemp);
            if (controllTemps.Items.Count > 0)
                throw new Exception("已生成过控制器,只能生成1次");
        }
        /// <summary>
        /// Row
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunDomain_AddSaveMethod()
        {
            MyResponseBase resp = new MyResponseBase();

            var Design_ModularOrFunID = Item.Design_ModularOrFunID;
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;

            //Design_ModularOrFunID
            StringBuilder sbentity = new StringBuilder();
            if (Item.DomainTypeTemp == 1)
            {
                #region 构造函数
                sbentity.AppendLine(string.Format("PKFields = new List<string> {{ \"{0}ID\" }};", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("TableName = \"{0}\";", Design_ModularOrFun.ControllCode));
                //sbentity.AppendLine(string.Format("return resp;"));

                //主表
                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = "构造函数",
                    MethodName = "Domain",
                    MethodReturnTypeID = 1,
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 1,
                };
                //var resp = Design_ModularOrFunDomain_AddSave();
                //明细表
                //Item = resp.Item;
                //StringBuilder sbsql = new StringBuilder();

                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "构造函数",
                    //Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 1,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                Design_ModularOrFunDomain_AddSave();
                //Design_ModularOrFunDomainDetail_EditSave();

                #endregion
            }
            else if (Item.DomainTypeTemp == 2)
            {
                //new TextValue{Text="主键不为空检查",Value="2"},
                #region 主键不能为空
                //var MethodName = "PKCheck";
                //sbentity.AppendLine(string.Format("        public void {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
                //sbentity.AppendLine(string.Format("       {{"));
                sbentity.AppendLine(string.Format("           if (Item.{0}ID == null)", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("           {{"));
                sbentity.AppendLine(string.Format("               throw new Exception(\"{0}主键不能为空!\");", Design_ModularOrFun.ModularName));
                sbentity.AppendLine(string.Format("           }}"));
                //sbentity.AppendLine(string.Format("       }"));
                //sbentity.AppendLine(string.Format("     return resp;"));

                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = "主键不为空检查",
                    MethodName = "PKCheck",
                    MethodReturnTypeID = 1,
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 6,
                };
                //            resp = Design_ModularOrFunDomain_AddSave();
                //明细表
                //Item = resp.Item;
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "主键不为空检查",
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 2,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });

                Design_ModularOrFunDomain_AddSave();
                #endregion
            }
            //new TextValue{Text="根据主键查询-显示",Value="13"},
            //new TextValue{Text="根据主键查询-编辑",Value="14"},
            else if (Item.DomainTypeTemp == 13)
            {
                #region 根据主键查询--显示
                sbentity.AppendLine(string.Format("{0}_PKCheck();", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("OperCode = \"{0}.ByID\";", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("resp = Execute();"));
                sbentity.AppendLine(string.Format("return resp;"));

                //主表
                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = "根据主键查询--显示",
                    MethodName = "ByID",
                    MethodReturnTypeID = 2,// "MyResponseBase",
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 11,
                };
                //resp = Design_ModularOrFunDomain_AddSave();
                //明细表
                //Item = resp.Item;
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "根据主键查询--显示",
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 13,
                    ParamName = sbentity.ToString(),
                    DBOperCode = Design_ModularOrFun.ControllCode + ".ByID",
                    Serial = 1,
                });

                //Design_ModularOrFunDomainDetail_EditSave();
                Design_ModularOrFunDomain_AddSave();

                #endregion
            }
            else if (Item.DomainTypeTemp == 14)
            {
                #region 根据主键查询--编辑

                sbentity.AppendLine(string.Format("{0}_PKCheck();", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("var sql = string.Format(\";SELECT * FROM [dbo].[{0}] A WHERE {0}ID={{0}} \", Item.{0}ID);", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("var resp = Query16(sql, 4);"));
                sbentity.AppendLine(string.Format("return resp;"));

                //主表
                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = "根据主键查询--编辑",
                    MethodName = "ByIDEdit",
                    MethodReturnTypeID = 2,// "MyResponseBase",
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 11,
                };
                //resp = Design_ModularOrFunDomain_AddSave();
                //明细表
                //Item = resp.Item;
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "根据主键查询--编辑",
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 14,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });

                //Design_ModularOrFunDomainDetail_EditSave();
                Design_ModularOrFunDomain_AddSave();

                #endregion
            }
            //new TextValue{Text="列表查询",Value="11"},
            //new TextValue{Text="列表查询--初始条件",Value="12"},
            else if (Item.DomainTypeTemp == 11)
            {
                #region 列表查询
                //主表
                sbentity.AppendLine(string.Format("var resp = new MyResponseBase();"));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("if (PageQueryBase.RankInfo == null || PageQueryBase.RankInfo.Length == 0)"));
                sbentity.AppendLine(string.Format("{{"));
                sbentity.AppendLine(string.Format("    PageQueryBase.RankInfo = \"UpdateDate|0\";"));
                sbentity.AppendLine(string.Format("}}"));
                sbentity.AppendLine(string.Format(""));
                //sbentity.AppendLine(string.Format("if (!Querys.QueryDicts.ContainsKey(\"{0}ID___equal\"))", Design_ModularOrFun.ControllCode));
                //sbentity.AppendLine(string.Format("{{"));
                //sbentity.AppendLine(string.Format("    Querys.Add(new Query { QuryType = 0, FieldName = \"{0}ID___equal\", Value = \"\" });", Design_ModularOrFun.ControllCode));
                //sbentity.AppendLine(string.Format("}}"));
                //sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("//SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity"));
                sbentity.AppendLine(string.Format("//{{"));
                sbentity.AppendLine(string.Format("//    DBTSql =string.Format(\";WITH T1000 AS (SELECT * FROM [dbo].[{0}] A  WHERE 1=1 sqlplaceholder )", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("//    DBOperType = 8,//排序分页"));
                sbentity.AppendLine(string.Format("//    SelectSubType = SelectType,"));
                sbentity.AppendLine(string.Format("//    DBSelectResultType = 2,"));
                sbentity.AppendLine(string.Format("//    EqualQueryParam = \"\""));
                sbentity.AppendLine(string.Format("//}};"));
                sbentity.AppendLine(string.Format("//Sys_HOperControl = hOperControl;"));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("OperCode = \"{0}.Index\";", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("resp = Execute();"));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("resp.Querys = Querys;"));
                sbentity.AppendLine(string.Format("resp.Item = Item;"));
                sbentity.AppendLine(string.Format("return resp;"));

                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = string.Format("列表查询"),
                    MethodName = "Index",
                    MethodReturnTypeID = 2,// "MyResponseBase",
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 11,
                };
                //resp = Design_ModularOrFunDomain_AddSave();
                //明细表
                //Item = resp.Item;
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("列表查询"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 11,
                    ParamName = sbentity.ToString(),
                    DBOperCode = Design_ModularOrFun.ControllCode + ".Index",
                    Serial = 1,
                });

                //Design_ModularOrFunDomainDetail_EditSave();
                Design_ModularOrFunDomain_AddSave();

                #endregion
            }
            else if (Item.DomainTypeTemp == 12)
            {
                #region 列表查询-带初值
                //主表
                sbentity.AppendLine(string.Format("var resp = new MyResponseBase();"));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("if (PageQueryBase.RankInfo == null || PageQueryBase.RankInfo.Length == 0)"));
                sbentity.AppendLine(string.Format("{{"));
                sbentity.AppendLine(string.Format("    PageQueryBase.RankInfo = \"UpdateDate|0\";"));
                sbentity.AppendLine(string.Format("}}"));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("if (!Querys.QueryDicts.ContainsKey(\"{0}ID___equal\"))", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("{{"));
                sbentity.AppendLine(string.Format("    Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}ID___equal\", Value = \"\" }});", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("}}"));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("//SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity"));
                sbentity.AppendLine(string.Format("//{{"));
                sbentity.AppendLine(string.Format("//    DBTSql =string.Format(\";WITH T1000 AS (SELECT * FROM [dbo].[{0}] A  WHERE 1=1 sqlplaceholder )", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("//    DBOperType = 8,//排序分页"));
                sbentity.AppendLine(string.Format("//    SelectSubType = SelectType,"));
                sbentity.AppendLine(string.Format("//    DBSelectResultType = 2,"));
                sbentity.AppendLine(string.Format("//    EqualQueryParam = \"\""));
                sbentity.AppendLine(string.Format("//}};"));
                sbentity.AppendLine(string.Format("//Sys_HOperControl = hOperControl;"));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("OperCode = \"{0}.Index\";", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("resp = Execute();"));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("resp.Querys = Querys;"));
                sbentity.AppendLine(string.Format("resp.Item = Item;"));
                sbentity.AppendLine(string.Format("return resp;"));

                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = string.Format("列表查询"),
                    MethodName = "Index",
                    MethodReturnTypeID = 2,// "MyResponseBase",
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 11,
                };
                //resp = Design_ModularOrFunDomain_AddSave();
                //明细表
                //Item = resp.Item;
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("列表查询"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 12,
                    ParamName = sbentity.ToString(),
                    DBOperCode = Design_ModularOrFun.ControllCode + ".Index",
                    Serial = 1,
                });

                //Design_ModularOrFunDomainDetail_EditSave();
                Design_ModularOrFunDomain_AddSave();

                #endregion
            }

            #region 添加查询
            ////主表
            //Item = new SoftProjectAreaEntity
            //{
            //    ModularOrFunDomainDetailName = string.Format("添加查询--根据{0}初始化", FKFieldss.NameCn),
            //    MethodName = "Add",
            //    Design_ModularOrFunID = Design_ModularOrFunID,
            //    Sort = 31,
            //};
            //resp = Design_ModularOrFunDomain_Add();
            ////明细表
            //Item = resp.Item;
            //Item.Items.Add(new SoftProjectAreaEntity
            //{
            //    ModularOrFunDomainDetailName = string.Format("添加查询--根据{0}初始化", FKFieldss.NameCn),
            //    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
            //    DomainType = 22,
            //    ParamName = FKFieldss.name,
            //    DBOperCode = "",
            //    Serial = 1,
            //});

            //Design_ModularOrFunDomainDetail_EditSave();

            #endregion
            //new TextValue{Text="添加保存--事务",Value="23"},
            //new TextValue{Text="编辑保存--事务",Value="26"},

            else if (Item.DomainTypeTemp == 23)
            {
                #region 添加保存
                sbentity.AppendLine(string.Format("var resp = new MyResponseBase();"));
                sbentity.AppendLine(string.Format("#region (2)添加"));
                sbentity.AppendLine(string.Format("using (var scope = new TransactionScope())"));
                sbentity.AppendLine(string.Format("{{"));
                sbentity.AppendLine(string.Format("    try"));
                sbentity.AppendLine(string.Format("    {{"));
                sbentity.AppendLine(string.Format("        {0}_Domain();", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("        //string DBFieldVals = \"添加的字段\";"));
                sbentity.AppendLine(string.Format("        //resp = AddSave(DBFieldVals);"));
                sbentity.AppendLine(string.Format("        OperCode = \"{0}.AddSave\";", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("        resp = Execute();"));
                sbentity.AppendLine(string.Format("        scope.Complete();"));
                sbentity.AppendLine(string.Format("    }}"));
                sbentity.AppendLine(string.Format("    catch (Exception ex)"));
                sbentity.AppendLine(string.Format("    {{"));
                sbentity.AppendLine(string.Format("        throw new Exception(ex.Message);"));
                sbentity.AppendLine(string.Format("    }}"));
                sbentity.AppendLine(string.Format("    finally"));
                sbentity.AppendLine(string.Format("    {{"));
                sbentity.AppendLine(string.Format("        scope.Dispose();"));
                sbentity.AppendLine(string.Format("    }}"));
                sbentity.AppendLine(string.Format("}}"));
                sbentity.AppendLine(string.Format("#endregion"));
                sbentity.AppendLine(string.Format("return resp;"));

                //主表
                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = string.Format("添加保存"),
                    MethodName = "AddSave",
                    MethodReturnTypeID = 2,// "MyResponseBase",
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 31,
                };
                //resp = Design_ModularOrFunDomain_AddSave();
                //明细表
                //Item = resp.Item;
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("添加保存"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 23,
                    ParamName = sbentity.ToString(),
                    DBOperCode = Design_ModularOrFun.ControllCode + ".AddSave",
                    Serial = 1,
                });

                //Design_ModularOrFunDomainDetail_EditSave();
                Design_ModularOrFunDomain_AddSave();

                #endregion
            }
            else if (Item.DomainTypeTemp == 26)
            {
                #region 编辑保存
                sbentity.AppendLine(string.Format("var resp = new MyResponseBase();"));
                sbentity.AppendLine(string.Format("{0}_PKCheck();", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format(""));
                sbentity.AppendLine(string.Format("#region (2)编辑"));
                sbentity.AppendLine(string.Format("using (var scope = new TransactionScope())"));
                sbentity.AppendLine(string.Format("{{"));
                sbentity.AppendLine(string.Format("    try"));
                sbentity.AppendLine(string.Format("    {{"));
                sbentity.AppendLine(string.Format("        {0}_Domain();", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("        //string DBFieldVals = \"编辑的字段\";"));
                sbentity.AppendLine(string.Format("        //resp = EditSave(DBFieldVals);"));
                sbentity.AppendLine(string.Format("        OperCode = \"{0}.EditSave\";", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("        resp = Execute();"));
                sbentity.AppendLine(string.Format("        scope.Complete();"));
                sbentity.AppendLine(string.Format("    }}"));
                sbentity.AppendLine(string.Format("    catch (Exception ex)"));
                sbentity.AppendLine(string.Format("    {{"));
                sbentity.AppendLine(string.Format("        throw new Exception(ex.Message);"));
                sbentity.AppendLine(string.Format("    }}"));
                sbentity.AppendLine(string.Format("    finally"));
                sbentity.AppendLine(string.Format("    {{"));
                sbentity.AppendLine(string.Format("        scope.Dispose();"));
                sbentity.AppendLine(string.Format("    }}"));
                sbentity.AppendLine(string.Format("}}"));
                sbentity.AppendLine(string.Format("#endregion"));
                sbentity.AppendLine(string.Format("return resp;"));

                //主表
                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = string.Format("编辑保存"),
                    MethodName = "EditSave",
                    MethodReturnTypeID = 2,
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 31,
                };
                //resp = Design_ModularOrFunDomain_AddSave();
                //明细表
                //Item = resp.Item;
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("编辑保存"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 26,
                    ParamName = sbentity.ToString(),
                    DBOperCode = Design_ModularOrFun.ControllCode + ".EditSave",
                    Serial = 1,
                });

                //Design_ModularOrFunDomainDetail_EditSave();
                Design_ModularOrFunDomain_AddSave();

                #endregion
            }

            //resp = Design_ModularOrFunDomain_AddSave();
            else if (Item.DomainTypeTemp == 51)
            {
                #region Add、Edit、Delete
                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = string.Format("添加、编辑、删除"),
                    MethodName = "AddEditDelete",
                    MethodReturnTypeID = 2,// "MyResponseBase",
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 31,
                };
                #region 启动事务
                sbentity = new StringBuilder();
                sbentity.AppendLine("using (var scope = new TransactionScope())");
                sbentity.AppendLine("{");
                sbentity.AppendLine("    try");
                sbentity.AppendLine("    {");
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("启动事务及try"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 71,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion
                #region 查询原始值
                sbentity = new StringBuilder();
                sbentity.AppendLine(string.Format("var OldItems = {0}_GetByXXX();", Design_ModularOrFun.ControllCode));
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("根据{0}ID查询原始值", Design_ModularOrFun.ModularName),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 101,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion
                #region 数据整理
                sbentity = new StringBuilder();
                //sbentity.AppendLine("var OldItems = Pre_UserRole_GetByUserID();");
                sbentity.AppendLine("Item.Items.ForEach(p => p.XXXXID = Item.XXXXID);");
                sbentity.AppendLine(string.Format("var deleteIDsEnum = (from p in OldItems select p.{0}ID).Except(from o in Item.Items select o.{0}ID);", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("var updateItems = Item.Items.Where(p => p.{0}ID != null);", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("var addItems = Item.Items.Where(p => p.{0}ID == null);", Design_ModularOrFun.ControllCode));

                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("数据整理"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 101,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion
                #region 删除
                sbentity = new StringBuilder();
                //sbentity.AppendLine("var OldItems = Pre_UserRole_GetByUserID();");
                sbentity.AppendLine(string.Format("if (deleteIDsEnum.Count() > 0)"));
                sbentity.AppendLine(string.Format("{{"));
                sbentity.AppendLine(string.Format("    var deleteIDs = string.Join(\",\", deleteIDsEnum);"));
                sbentity.AppendLine(string.Format("    var sql = string.Format(\"DELETE [dbo].[{0}] WHERE  {0}ID IN({{0}})\", deleteIDs);", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("    var resptemp = Query16(sql, 1);"));
                sbentity.AppendLine(string.Format("}}"));
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("删除"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 101,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion

                #region 更新
                sbentity = new StringBuilder();
                //sbentity.AppendLine("var OldItems = Pre_UserRole_GetByUserID();");

                sbentity.AppendLine(string.Format("if (updateItems.Count() > 0)"));
                sbentity.AppendLine(string.Format("{{"));
                sbentity.AppendLine(string.Format("    SoftProjectAreaEntityDomain domain = new SoftProjectAreaEntityDomain {{ Items = updateItems.ToList() }};"));
                sbentity.AppendLine(string.Format("    domain.{0}_Domain();", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("    var operCode = \"{0}.EditSave\";", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("    domain.ExecuteEnums(operCode);"));
                sbentity.AppendLine(string.Format("}}"));

                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("更新"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 101,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion

                #region 添加
                sbentity = new StringBuilder();
                //sbentity.AppendLine("var OldItems = Pre_UserRole_GetByUserID();");

                sbentity.AppendLine(string.Format("if (addItems.Count() > 0)"));
                sbentity.AppendLine(string.Format("{{"));
                sbentity.AppendLine(string.Format("    SoftProjectAreaEntityDomain domain = new SoftProjectAreaEntityDomain {{ Items = addItems.ToList() }};"));
                sbentity.AppendLine(string.Format("    domain.{0}_Domain();", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("    var operCode = \"{0}.AddSave\";", Design_ModularOrFun.ControllCode));
                sbentity.AppendLine(string.Format("    domain.ExecuteEnums(operCode);"));
                sbentity.AppendLine(string.Format("}}"));
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("添加"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 101,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion

                #region 提交事务
                sbentity = new StringBuilder();
                sbentity.AppendLine("scope.Complete();");
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "提交事务",
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 73,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion

                #region 结束事务及try
                sbentity = new StringBuilder();
                sbentity.AppendLine("    }");
                sbentity.AppendLine("    catch (Exception ex)");
                sbentity.AppendLine("    {");
                sbentity.AppendLine("        throw new Exception(ex.Message);");
                sbentity.AppendLine("    }");
                sbentity.AppendLine("    finally");
                sbentity.AppendLine("    {");
                sbentity.AppendLine("        scope.Dispose();");
                sbentity.AppendLine("    }");
                sbentity.AppendLine("}");
                sbentity.AppendLine(string.Format("return resp;"));

                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "结束事务及try",
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 72,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion
                Design_ModularOrFunDomain_AddSave();
                #endregion
            }
            else if (Item.DomainTypeTemp == 53)
            {
                #region 结束事务及try模板
                Item = new SoftProjectAreaEntity
                {
                    ModularOrFunDomainName = string.Format("结束事务及try模板"),
                    MethodName = "",
                    MethodReturnTypeID = 2,// "MyResponseBase",
                    Design_ModularOrFunID = Design_ModularOrFunID,
                    Sort = 31,
                };
                #region 启动事务
                sbentity = new StringBuilder();
                sbentity.AppendLine("using (var scope = new TransactionScope())");
                sbentity.AppendLine("{");
                sbentity.AppendLine("    try");
                sbentity.AppendLine("    {");
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = string.Format("启动事务及try"),
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 71,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion

                #region 执行操作
                sbentity = new StringBuilder();
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "执行操作",
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 101,
                    ParamName = "",
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion

                #region 提交事务
                sbentity = new StringBuilder();
                sbentity.AppendLine("scope.Complete();");
                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "提交事务",
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 73,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion

                #region 结束事务及try
                sbentity = new StringBuilder();
                sbentity.AppendLine("    }");
                sbentity.AppendLine("    catch (Exception ex)");
                sbentity.AppendLine("    {");
                sbentity.AppendLine("        throw new Exception(ex.Message);");
                sbentity.AppendLine("    }");
                sbentity.AppendLine("    finally");
                sbentity.AppendLine("    {");
                sbentity.AppendLine("        scope.Dispose();");
                sbentity.AppendLine("    }");
                sbentity.AppendLine("}");
                sbentity.AppendLine(string.Format("return resp;"));

                Item.Items.Add(new SoftProjectAreaEntity
                {
                    ModularOrFunDomainDetailName = "结束事务及try",
                    Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                    DomainType = 72,
                    ParamName = sbentity.ToString(),
                    DBOperCode = "",
                    Serial = 1,
                });
                #endregion
                Design_ModularOrFunDomain_AddSave();
                #endregion
            }
            return resp;
        }
        public MyResponseBase Design_ModularOrFunDomain_Delete()
        {
            Design_ModularOrFunDomain_Domain();
            #region (2)修改功能模块字段
            using (var scope = new TransactionScope())
            {
                try
                {
                    SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };
                    var DBFieldVals = "";

                    #region (1)修改功能模块(无)
                    Design_ModularOrFunDomain_PKCheck();

                    var str = "DELETE Design_ModularOrFunDomain WHERE  Design_ModularOrFunDomainID=" + Item.Design_ModularOrFunDomainID;
                    resp = Query16(str, 1);

                    #endregion

                    //Design_ModularOrFunDomainDetail_EditSave();

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    scope.Dispose();
                }
            }
            #endregion

            return resp;
        }
        /// <summary>
        /// 生成业务层记录:领域模型的相关表
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunDomain_BulidRecordDomainRef()
        {
            var Design_ModularOrFunID = Item.Design_ModularOrFunID;
            Design_ModularOrFunDomain_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            #region 功能模块对象
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
            #endregion

            #region 获取实体字段
            var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
            var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).First();
            //var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()

            var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
            var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()

            #endregion

            #region 构造函数
            //主表
            Item = new SoftProjectAreaEntity
            {
                ModularOrFunDomainName = "构造函数",
                MethodName = "Domain",
                Design_ModularOrFunID = Design_ModularOrFunID,
                Sort = 1,
            };
            var resp = Design_ModularOrFunDomain_AddSave();
            //明细表
            Item = resp.Item;
            Item.Items.Add(new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = "构造函数",
                Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                DomainType = 1,
                ParamName = "",
                DBOperCode = "",
                Serial = 1,
            });

            Design_ModularOrFunDomainDetail_EditSave();

            #endregion

            #region 主键不能为空
            //主表
            Item = new SoftProjectAreaEntity
            {
                ModularOrFunDomainName = "主键不为空检查",
                MethodName = "PKCheck",
                Design_ModularOrFunID = Design_ModularOrFunID,
                Sort = 6,
            };
            resp = Design_ModularOrFunDomain_AddSave();
            //明细表
            Item = resp.Item;
            Item.Items.Add(new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = "主键不为空检查",
                Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                DomainType = 2,
                ParamName = "",
                DBOperCode = "",
                Serial = 1,
            });

            Design_ModularOrFunDomainDetail_EditSave();

            #endregion

            #region 根据主键查询--显示
            //主表
            Item = new SoftProjectAreaEntity
            {
                ModularOrFunDomainName = "根据主键查询--显示",
                MethodName = "ByID",
                Design_ModularOrFunID = Design_ModularOrFunID,
                Sort = 11,
            };
            resp = Design_ModularOrFunDomain_AddSave();
            //明细表
            Item = resp.Item;
            Item.Items.Add(new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = "根据主键查询--显示",
                Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                DomainType = 13,
                ParamName = "",
                DBOperCode = "",
                Serial = 1,
            });

            Design_ModularOrFunDomainDetail_EditSave();

            #endregion

            #region 根据主键查询--显示
            //主表
            Item = new SoftProjectAreaEntity
            {
                ModularOrFunDomainName = "根据主键查询--编辑",
                MethodName = "ByIDEdit",
                Design_ModularOrFunID = Design_ModularOrFunID,
                Sort = 11,
            };
            resp = Design_ModularOrFunDomain_AddSave();
            //明细表
            Item = resp.Item;
            Item.Items.Add(new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = "根据主键查询--编辑",
                Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                DomainType = 14,
                ParamName = "",
                DBOperCode = "",
                Serial = 1,
            });

            Design_ModularOrFunDomainDetail_EditSave();

            #endregion

            #region 列表查询
            //主表
            Item = new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = string.Format("列表查询--根据{0}初始化", FKFieldss.NameCn),
                MethodName = "Index",
                Design_ModularOrFunID = Design_ModularOrFunID,
                Sort = 11,
            };
            resp = Design_ModularOrFunDomain_AddSave();
            //明细表
            Item = resp.Item;
            Item.Items.Add(new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = string.Format("列表查询--根据{0}初始化", FKFieldss.NameCn),
                Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                DomainType = 12,
                ParamName = FKFieldss.name,
                DBOperCode = Design_ModularOrFun.ControllCode + ".Index",
                Serial = 1,
            });

            Design_ModularOrFunDomainDetail_EditSave();

            #endregion

            #region 添加查询
            //主表
            Item = new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = string.Format("添加查询--根据{0}初始化", FKFieldss.NameCn),
                MethodName = "Add",
                Design_ModularOrFunID = Design_ModularOrFunID,
                Sort = 31,
            };
            resp = Design_ModularOrFunDomain_AddSave();
            //明细表
            Item = resp.Item;
            Item.Items.Add(new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = string.Format("添加查询--根据{0}初始化", FKFieldss.NameCn),
                Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                DomainType = 22,
                ParamName = FKFieldss.name,
                DBOperCode = "",
                Serial = 1,
            });

            Design_ModularOrFunDomainDetail_EditSave();

            #endregion

            #region 添加保存
            //主表
            Item = new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = string.Format("添加保存", FKFieldss.NameCn),
                MethodName = "AddSave",
                Design_ModularOrFunID = Design_ModularOrFunID,
                Sort = 31,
            };
            resp = Design_ModularOrFunDomain_AddSave();
            //明细表
            Item = resp.Item;
            Item.Items.Add(new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = string.Format("添加保存"),
                Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                DomainType = 23,
                ParamName = "",
                DBOperCode = Design_ModularOrFun.ControllCode + ".AddSave",
                Serial = 1,
            });

            Design_ModularOrFunDomainDetail_EditSave();

            #endregion

            #region 编辑保存
            //主表
            Item = new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = string.Format("编辑保存"),
                MethodName = "EditSave",
                Design_ModularOrFunID = Design_ModularOrFunID,
                Sort = 31,
            };
            resp = Design_ModularOrFunDomain_AddSave();
            //明细表
            Item = resp.Item;
            Item.Items.Add(new SoftProjectAreaEntity
            {
                ModularOrFunDomainDetailName = string.Format("编辑保存"),
                Design_ModularOrFunDomainID = resp.Item.Design_ModularOrFunDomainID,
                DomainType = 26,
                ParamName = "",
                DBOperCode = Design_ModularOrFun.ControllCode + ".EditSave",
                Serial = 1,
            });

            Design_ModularOrFunDomainDetail_EditSave();

            #endregion

            //var resp = Design_ModularOrFunDomain_EditListSave();
            return resp;
        }
        ///// <summary>
        ///// 生成控制器
        ///// </summary>
        ///// <returns></returns>
        //public MyResponseBase Design_ModularOrFunDomain_BulidDomainFile()
        //{
        //    #region (2)修改功能模块字段
        //    using (var scope = new TransactionScope())
        //    {
        //        try
        //        {
        //            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };
        //            //(2)创建业务层文件
        //            #region 1)查询模块功能
        //            var resptemp = Design_ModularOrFun_GetByID();
        //            var Design_ModularOrFun = resptemp.Item;
        //            #endregion
        //            #region 3)根据功能模块ID查询所有业务方法
        //            resptemp = Design_ModularOrFunDomain_Index();
        //            var Design_ModularOrFunDomains = resptemp.Items;
        //            var ModularOrFunDomainDetails = Design_ModularOrFunDomainDetail_GetByModularOrFunID();
        //            #endregion
        //            StringBuilder sbentity = new StringBuilder();
        //            #region 名称空间引用
        //            sbentity.AppendLine("");
        //            sbentity.AppendLine("using Framework.Core;");
        //            sbentity.AppendLine("using Framework.Web.Mvc;");
        //            sbentity.AppendLine("using Framework.Web.Mvc.Sys;");
        //            sbentity.AppendLine("using SoftProject.CellModel;");
        //            sbentity.AppendLine("using System;");
        //            sbentity.AppendLine("using System.Collections.Generic;");
        //            sbentity.AppendLine("using System.Linq;");
        //            sbentity.AppendLine("using System.Text;");
        //            sbentity.AppendLine("using System.Threading.Tasks;");
        //            sbentity.AppendLine("using System.Transactions;");
        //            #endregion
        //            sbentity.AppendLine();
        //            sbentity.AppendLine("namespace SoftProject.Domain");
        //            sbentity.AppendLine("{");
        //            sbentity.AppendLine("    /// <summary>");
        //            sbentity.AppendLine(string.Format("    /// 业务层:{0}({1})", Design_ModularOrFun.ControllCode, Design_ModularOrFun.ModularName));
        //            sbentity.AppendLine("    /// </summary>");
        //            sbentity.AppendLine("    public partial class SoftProjectAreaEntityDomain");
        //            sbentity.AppendLine("    {");
        //            foreach (var domain in Design_ModularOrFunDomains)
        //            {
        //                sbentity.AppendLine(string.Format("        /// <summary>"));
        //                sbentity.AppendLine(string.Format("        /// {0}", domain.ModularOrFunDomainName));
        //                sbentity.AppendLine(string.Format("        /// </summary>"));
        //                sbentity.AppendLine(string.Format("        /// <returns></returns>"));
        //                var ModularOrFunDomainDetailsTemps = ModularOrFunDomainDetails.Where(p => p.Design_ModularOrFunDomainID == domain.Design_ModularOrFunDomainID).ToList();
        //                for (int i = 0; i < ModularOrFunDomainDetailsTemps.Count; i++)
        //                {
        //                    var item = ModularOrFunDomainDetailsTemps[i];
        //                    if (item.DomainType == 1)
        //                    {
        //                        #region 构造函数
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "Domain" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public void {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        sbentity.AppendLine(string.Format("            PKFields = new List<string> {{ \"{0}ID\" }};", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("            TableName = \"{0}\";", Design_ModularOrFun.ControllCode));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 2)
        //                    {
        //                        #region 主键不能为空
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "PKCheck" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public void {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            sbentity.AppendLine(string.Format("       {{"));
        //                        }
        //                        sbentity.AppendLine(string.Format("           if (Item.{0}ID == null)", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("           {{"));
        //                        sbentity.AppendLine(string.Format("               throw new Exception(\"{0}主键不能为空!\");", Design_ModularOrFun.ModularName));
        //                        sbentity.AppendLine(string.Format("           }}"));
        //                        //sbentity.AppendLine(string.Format("       }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 11)
        //                    {
        //                        #region 列表查询--初始条件
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "Index" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            //                                    sbentity.AppendLine(string.Format("        public MyResponseBase BC_ExpertGuidance_Index(int SelectType = 6)"));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        sbentity.AppendLine(string.Format("            var resp = new MyResponseBase();"));
        //                        //var paramNames = item.ParamName.Split(',');
        //                        //foreach (var paramName in paramNames)
        //                        //{
        //                        //    sbentity.AppendLine(string.Format("            if (!Querys.QueryDicts.ContainsKey(\"{0}___equal\"))", paramName));
        //                        //    sbentity.AppendLine(string.Format("            {{"));
        //                        //    sbentity.AppendLine(string.Format("                if (Item.{0} == null)", paramName));
        //                        //    sbentity.AppendLine(string.Format("                    throw new Exception(\"不能为空\");", ""));
        //                        //    sbentity.AppendLine(string.Format("                else"));
        //                        //    sbentity.AppendLine(string.Format("                    Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = Item.{0}.ToString() }});", paramName));
        //                        //    sbentity.AppendLine(string.Format("            }}"));
        //                        //}
        //                        var DBOperCode = item.DBOperCode;
        //                        if (string.IsNullOrEmpty(item.DBOperCode))
        //                            DBOperCode = Design_ModularOrFun.ControllCode + "." + domain.MethodName;
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            if (PageQueryBase.RankInfo == null || PageQueryBase.RankInfo.Length == 0)"));
        //                        sbentity.AppendLine(string.Format("            {{"));
        //                        sbentity.AppendLine(string.Format("                PageQueryBase.RankInfo = \"UpdateDate|0\";"));
        //                        sbentity.AppendLine(string.Format("            }}"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            //SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity"));
        //                        sbentity.AppendLine(string.Format("            //{{"));
        //                        sbentity.AppendLine(string.Format("            //    DBTSql =string.Format(\";WITH T1000 AS (SELECT * FROM [dbo].[{0}] A  WHERE 1=1 sqlplaceholder )\"),", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("            //    DBOperType = 8,//排序分页"));
        //                        sbentity.AppendLine(string.Format("            //    SelectSubType = SelectType,"));
        //                        sbentity.AppendLine(string.Format("            //    DBSelectResultType = 2,"));
        //                        sbentity.AppendLine(string.Format("            //    EqualQueryParam = \"\""));
        //                        sbentity.AppendLine(string.Format("            //}};"));
        //                        sbentity.AppendLine(string.Format("            //Sys_HOperControl = hOperControl;"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            OperCode=\"{0}\";", DBOperCode));
        //                        sbentity.AppendLine(string.Format("            resp = Execute();"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            resp.Querys = Querys;"));
        //                        sbentity.AppendLine(string.Format("            resp.Item = Item;"));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 12)
        //                    {
        //                        #region 列表查询--初始条件
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "Index" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            //                                    sbentity.AppendLine(string.Format("        public MyResponseBase BC_ExpertGuidance_Index(int SelectType = 6)"));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        sbentity.AppendLine(string.Format("            var resp = new MyResponseBase();"));
        //                        var paramNames = item.ParamName.Split(',');
        //                        foreach (var paramName in paramNames)
        //                        {
        //                            sbentity.AppendLine(string.Format("            if (!Querys.QueryDicts.ContainsKey(\"{0}___equal\"))", paramName));
        //                            sbentity.AppendLine(string.Format("            {{"));
        //                            sbentity.AppendLine(string.Format("                if (Item.{0} == null)", paramName));
        //                            sbentity.AppendLine(string.Format("                    throw new Exception(\"不能为空\");", ""));
        //                            sbentity.AppendLine(string.Format("                else"));
        //                            sbentity.AppendLine(string.Format("                    Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = Item.{0}.ToString() }});", paramName));
        //                            sbentity.AppendLine(string.Format("            }}"));
        //                        }
        //                        var DBOperCode = item.DBOperCode;
        //                        if (string.IsNullOrEmpty(item.DBOperCode))
        //                            DBOperCode = Design_ModularOrFun.ControllCode + "." + domain.MethodName;
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            if (PageQueryBase.RankInfo == null || PageQueryBase.RankInfo.Length == 0)"));
        //                        sbentity.AppendLine(string.Format("            {{"));
        //                        sbentity.AppendLine(string.Format("                PageQueryBase.RankInfo = \"UpdateDate|0\";"));
        //                        sbentity.AppendLine(string.Format("            }}"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            //SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity"));
        //                        sbentity.AppendLine(string.Format("            //{{"));
        //                        sbentity.AppendLine(string.Format("            //    DBTSql =string.Format(\";WITH T1000 AS (SELECT * FROM [dbo].[{0}] A  WHERE 1=1 sqlplaceholder )\"),", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("            //    DBOperType = 8,//排序分页"));
        //                        sbentity.AppendLine(string.Format("            //    SelectSubType = SelectType,"));
        //                        sbentity.AppendLine(string.Format("            //    DBSelectResultType = 2,"));
        //                        sbentity.AppendLine(string.Format("            //    EqualQueryParam = \"\""));
        //                        sbentity.AppendLine(string.Format("            //}};"));
        //                        sbentity.AppendLine(string.Format("            //Sys_HOperControl = hOperControl;"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            OperCode=\"{0}\";", DBOperCode));
        //                        sbentity.AppendLine(string.Format("            resp = Execute();"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            resp.Querys = Querys;"));
        //                        sbentity.AppendLine(string.Format("            resp.Item = Item;"));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 13)
        //                    {
        //                        #region 根据主键查询--显示
        //                        var DBOperCode = item.DBOperCode;
        //                        if (string.IsNullOrEmpty(item.DBOperCode))
        //                            DBOperCode = Design_ModularOrFun.ControllCode + "." + domain.MethodName;
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "ByID" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        sbentity.AppendLine(string.Format("            {0}_PKCheck();", Design_ModularOrFun.ControllCode));
        //                        //sbentity.AppendLine(string.Format("            var sql = string.Format(\";SELECT * FROM [dbo].[{0}] A WHERE {0}ID={{0}} \", Item.{0}ID);", Design_ModularOrFun.ControllCode));
        //                        //sbentity.AppendLine(string.Format("            var resp = Query16(sql, 4);"));
        //                        sbentity.AppendLine(string.Format("             OperCode=\"{0}\";", DBOperCode));
        //                        sbentity.AppendLine(string.Format("             resp=Execute();"));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 14)
        //                    {
        //                        #region 根据主键查询--编辑
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "ByIDEdit" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        sbentity.AppendLine(string.Format("            {0}_PKCheck();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("            var sql = string.Format(\";SELECT * FROM [dbo].[{0}] A WHERE {0}ID={{0}} \", Item.{0}ID);", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("            var resp = Query16(sql, 4);"));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 22)
        //                    {
        //                        #region 添加查询-带初始值
        //                        //var opercode = "";
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "Add" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            //                                    sbentity.AppendLine(string.Format("        public MyResponseBase {0}_Add()", Design_ModularOrFun.ControllCode));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        sbentity.AppendLine(string.Format("            var resp = Default();"));
        //                        var paramNames = item.ParamName.Split(',');
        //                        foreach (var paramName in paramNames)
        //                        {
        //                            sbentity.AppendLine(string.Format("            resp.Item.{0} = Item.{0};", paramName));
        //                        }
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 23)
        //                    {
        //                        #region 添加保存
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "AddSave" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            //sbentity.AppendLine(string.Format("        public MyResponseBase {0}_AddSave()", Design_ModularOrFun.ControllCode));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        var DBOperCode = item.DBOperCode;
        //                        if (string.IsNullOrEmpty(item.DBOperCode))
        //                            DBOperCode = Design_ModularOrFun.ControllCode + "." + domain.MethodName;
        //                        sbentity.AppendLine(string.Format("            var resp = new MyResponseBase();"));
        //                        sbentity.AppendLine(string.Format(" "));
        //                        sbentity.AppendLine(string.Format("            #region (2)添加"));
        //                        sbentity.AppendLine(string.Format("            using (var scope = new TransactionScope())"));
        //                        sbentity.AppendLine(string.Format("            {{"));
        //                        sbentity.AppendLine(string.Format("                try"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    {0}_Domain();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                    //string DBFieldVals = \"添加的字段\";"));
        //                        sbentity.AppendLine(string.Format("                    //resp = AddSave(DBFieldVals);"));
        //                        sbentity.AppendLine(string.Format("                    OperCode=\"{0}\";", DBOperCode));
        //                        sbentity.AppendLine(string.Format("                    resp=Execute();"));
        //                        sbentity.AppendLine(string.Format("                    scope.Complete();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                catch (Exception ex)"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    throw new Exception(ex.Message);"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                finally"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    scope.Dispose();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("            }}"));
        //                        sbentity.AppendLine(string.Format("            #endregion"));
        //                        sbentity.AppendLine(string.Format(" "));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 26)
        //                    {
        //                        #region 编辑保存
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "EditSave" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            //sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode,item.MethodName));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        var DBOperCode = item.DBOperCode;
        //                        if (string.IsNullOrEmpty(item.DBOperCode))
        //                            DBOperCode = Design_ModularOrFun.ControllCode + "." + domain.MethodName;
        //                        sbentity.AppendLine(string.Format("            var resp = new MyResponseBase();"));
        //                        sbentity.AppendLine(string.Format("            {0}_PKCheck();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format(" "));
        //                        sbentity.AppendLine(string.Format("            #region (2)编辑"));
        //                        sbentity.AppendLine(string.Format("            using (var scope = new TransactionScope())"));
        //                        sbentity.AppendLine(string.Format("            {{"));
        //                        sbentity.AppendLine(string.Format("                try"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    {0}_Domain();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                    //string DBFieldVals = \"编辑的字段\";"));
        //                        sbentity.AppendLine(string.Format("                    //resp = EditSave(DBFieldVals);"));
        //                        sbentity.AppendLine(string.Format("                    OperCode=\"{0}\";", DBOperCode));
        //                        sbentity.AppendLine(string.Format("                    resp=Execute();"));
        //                        sbentity.AppendLine(string.Format("                    scope.Complete();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                catch (Exception ex)"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    throw new Exception(ex.Message);"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                finally"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    scope.Dispose();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("            }}"));
        //                        sbentity.AppendLine(string.Format("            #endregion"));
        //                        sbentity.AppendLine(string.Format(" "));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 41)
        //                    {
        //                        #region 添加保存+子表
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "AddSave" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            //sbentity.AppendLine(string.Format("        public MyResponseBase {0}_AddSave()", Design_ModularOrFun.ControllCode));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        //第1个为OperCode,第2个为子表方法。
        //                        var DBOperCode = item.DBOperCode;
        //                        if (string.IsNullOrEmpty(item.DBOperCode))
        //                            DBOperCode = Design_ModularOrFun.ControllCode + "." + domain.MethodName;
        //                        sbentity.AppendLine(string.Format("            var resp = new MyResponseBase();"));
        //                        sbentity.AppendLine(string.Format(" "));
        //                        sbentity.AppendLine(string.Format("            #region (2)添加"));
        //                        sbentity.AppendLine(string.Format("            using (var scope = new TransactionScope())"));
        //                        sbentity.AppendLine(string.Format("            {{"));
        //                        sbentity.AppendLine(string.Format("                try"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    {0}_Domain();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                    //string DBFieldVals = \"添加的字段\";"));
        //                        sbentity.AppendLine(string.Format("                    //resp = AddSave(DBFieldVals);"));
        //                        sbentity.AppendLine(string.Format("                    OperCode=\"{0}\";", DBOperCode));
        //                        sbentity.AppendLine(string.Format("                    resp=Execute();"));
        //                        sbentity.AppendLine(string.Format("                    //调用子表方法"));
        //                        sbentity.AppendLine(string.Format("                    " + item.ParamName));
        //                        sbentity.AppendLine(string.Format("                    scope.Complete();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                catch (Exception ex)"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    throw new Exception(ex.Message);"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                finally"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    scope.Dispose();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("            }}"));
        //                        sbentity.AppendLine(string.Format("            #endregion"));
        //                        sbentity.AppendLine(string.Format(" "));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 42)
        //                    {
        //                        #region 编辑保存+子表
        //                        if (i == 0)
        //                        {
        //                            var MethodName = domain.MethodName == null ? "EditSave" : domain.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            //sbentity.AppendLine(string.Format("        public MyResponseBase {0}_EditSave()", Design_ModularOrFun.ControllCode));
        //                            sbentity.AppendLine(string.Format("        {{"));
        //                        }
        //                        var DBOperCode = item.DBOperCode;
        //                        if (string.IsNullOrEmpty(item.DBOperCode))
        //                            DBOperCode = Design_ModularOrFun.ControllCode + "." + domain.MethodName;
        //                        sbentity.AppendLine(string.Format("            var resp = new MyResponseBase();"));
        //                        sbentity.AppendLine(string.Format("            {0}_PKCheck();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format(" "));
        //                        sbentity.AppendLine(string.Format("            #region (2)编辑"));
        //                        sbentity.AppendLine(string.Format("            using (var scope = new TransactionScope())"));
        //                        sbentity.AppendLine(string.Format("            {{"));
        //                        sbentity.AppendLine(string.Format("                try"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    {0}_Domain();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                    //string DBFieldVals = \"编辑的字段\";"));
        //                        sbentity.AppendLine(string.Format("                    //resp = EditSave(DBFieldVals);"));
        //                        sbentity.AppendLine(string.Format("                    OperCode=\"{0}\";", Design_ModularOrFun.ControllCode, DBOperCode));
        //                        sbentity.AppendLine(string.Format("                    resp=Execute();"));
        //                        sbentity.AppendLine(string.Format("                    //调用子表方法"));
        //                        sbentity.AppendLine(string.Format("                    " + item.ParamName));
        //                        sbentity.AppendLine(string.Format("                    scope.Complete();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                catch (Exception ex)"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    throw new Exception(ex.Message);"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                finally"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    scope.Dispose();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("            }}"));
        //                        sbentity.AppendLine(string.Format("            #endregion"));
        //                        sbentity.AppendLine(string.Format(" "));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    else if (item.DomainType == 52)
        //                    {
        //                        #region 子表Merger
        //                        if (i == 0)
        //                        {
        //                            var MethodName = item.MethodName == null ? "EditSave" : item.MethodName;
        //                            sbentity.AppendLine(string.Format("        public MyResponseBase {0}_{1}()", Design_ModularOrFun.ControllCode, MethodName));
        //                            //sbentity.AppendLine(string.Format("        public MyResponseBase BC_PartnerOrderDetail_EditSave()"));
        //                            sbentity.AppendLine(string.Format("        {"));
        //                        }
        //                        var opercode = item.ParamName;
        //                        if (item.ParamName == null)
        //                            opercode = item.MethodName;
        //                        sbentity.AppendLine(string.Format("            MyResponseBase resp = new MyResponseBase();"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            BC_PartnerOrderDetail_Domain();"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("            #region 处理"));
        //                        sbentity.AppendLine(string.Format("            using (var scope = new TransactionScope())"));
        //                        sbentity.AppendLine(string.Format("            {{"));
        //                        sbentity.AppendLine(string.Format("                try"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    #region (3)根据主表ID查询子表所有数据"));
        //                        sbentity.AppendLine(string.Format("                    var {0}s = {0}_GetByMastTableID();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                    #endregion"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    #region (2)数据整理"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    Item.Items.ForEach(p => p.BCPartnerOrderDetailPriceTotal = p.BCPartnerOrderDetailPrice * p.BCPartnerOrderDetailNumer);"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    var deleteIDsEnum = (from p in {0}s select p.{0}ID).Except(from o in Item.Items select o.{0}ID);", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                    var updateItems = Item.Items.Where(p => p.{0}ID != null);", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                    var addItems = Item.Items.Where(p => p.{0}ID == null);", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                    #endregion"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    MyResponseBase resptemp = new MyResponseBase();"));
        //                        sbentity.AppendLine(string.Format("                    #region (4)删除元素:执行删除,通过In进行删除"));
        //                        sbentity.AppendLine(string.Format("                    if (deleteIDsEnum.Count() > 0)"));
        //                        sbentity.AppendLine(string.Format("                    {{"));
        //                        sbentity.AppendLine(string.Format("                        var deleteIDs = string.Join(\",\", deleteIDsEnum);"));
        //                        sbentity.AppendLine(string.Format("                        var sql = string.Format(\"DELETE [dbo].{0} WHERE  {0}ID IN(\\{0}\\})\", deleteIDs);", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                        resptemp = Query16(sql, 1);"));
        //                        sbentity.AppendLine(string.Format("                    }}"));
        //                        sbentity.AppendLine(string.Format("                    #endregion"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    var DBFieldVals = \"\";"));
        //                        sbentity.AppendLine(string.Format("                    #region (5)更新"));
        //                        sbentity.AppendLine(string.Format("                    if (updateItems.Count() > 0)"));
        //                        sbentity.AppendLine(string.Format("                    {{"));
        //                        sbentity.AppendLine(string.Format("                        SoftProjectAreaEntityDomain domain = new SoftProjectAreaEntityDomain { Items = updateItems.ToList() };"));
        //                        sbentity.AppendLine(string.Format("                        domain.{0}_Domain();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                        //DBFieldVals = \"更新的字段\";"));
        //                        sbentity.AppendLine(string.Format("                        //domain.EditSaves(DBFieldVals);"));
        //                        sbentity.AppendLine(string.Format("                         OperCode=\"{0}.{1}\";", Design_ModularOrFun.ControllCode, item.MethodName));
        //                        sbentity.AppendLine(string.Format("                        domain.EditSaves();"));
        //                        sbentity.AppendLine(string.Format("                    }}"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    #endregion"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    #region (6)添加"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    if (addItems.Count() > 0)"));
        //                        sbentity.AppendLine(string.Format("                    {{"));
        //                        sbentity.AppendLine(string.Format("                        SoftProjectAreaEntityDomain domain = new SoftProjectAreaEntityDomain { Items = addItems.ToList() };"));
        //                        sbentity.AppendLine(string.Format("                        domain.{0}_Domain();", Design_ModularOrFun.ControllCode));
        //                        sbentity.AppendLine(string.Format("                        //DBFieldVals = \"\";"));
        //                        sbentity.AppendLine(string.Format("                        //domain.AddSaves(DBFieldVals);"));
        //                        sbentity.AppendLine(string.Format("                        OperCode=\"{0}.{1}\";", Design_ModularOrFun.ControllCode, item.ParamName));
        //                        sbentity.AppendLine(string.Format("                        domain.AddSaves();"));
        //                        sbentity.AppendLine(string.Format("                    }}"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    #endregion"));
        //                        sbentity.AppendLine(string.Format(""));
        //                        sbentity.AppendLine(string.Format("                    scope.Complete();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                catch (Exception ex)"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    throw new Exception(ex.Message);"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("                finally"));
        //                        sbentity.AppendLine(string.Format("                {{"));
        //                        sbentity.AppendLine(string.Format("                    scope.Dispose();"));
        //                        sbentity.AppendLine(string.Format("                }}"));
        //                        sbentity.AppendLine(string.Format("            }}"));
        //                        sbentity.AppendLine(string.Format("            #endregion"));
        //                        sbentity.AppendLine(string.Format("            return resp;"));
        //                        //sbentity.AppendLine(string.Format("        }"));
        //                        #endregion
        //                    }
        //                    if (ModularOrFunDomainDetailsTemps.Count - 1 == i)
        //                    {
        //                        sbentity.AppendLine("        }");
        //                        break;
        //                    }
        //                }
        //                sbentity.AppendLine();
        //            }
        //            sbentity.AppendLine("   }");
        //            sbentity.AppendLine("}");
        //            //F:\软件项目\SoftPlatformProject\SoftPlatform\SoftPlatform\Areas\C_CustomerAreas\CellModel
        //            //string filepath1=System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
        //            //string filepath2=System.Environment.CurrentDirectory ;
        //            //string filepath3=System.IO.Directory.GetCurrentDirectory();
        //            //string filepath4=System.AppDomain.CurrentDomain.BaseDirectory;
        //            var path = string.Format(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Areas\\{0}\\Domain\\", Design_ModularOrFun.AreasCode);
        //            if (!Directory.Exists(path))
        //                Directory.CreateDirectory(path);
        //            //string filepath5 = string.Format(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Areas\\{0}\\CellModel\\{1}.cs", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode);
        //            string filepath5 = path + Design_ModularOrFun.ControllCode + "Domain.cs";
        //            FileStream fs = new FileStream(filepath5, FileMode.Create);
        //            StreamWriter sw = new StreamWriter(fs);
        //            sw.Write(sbentity.ToString());
        //            sw.Flush();
        //            sw.Close();
        //            fs.Close();
        //            scope.Complete();
        //        }
        //        catch (Exception ex)
        //        {
        //            throw new Exception(ex.Message);
        //        }
        //        finally
        //        {
        //            scope.Dispose();
        //        }
        //    }
        //    #endregion
        //    return resp;
        //}
        /// <summary>
        /// 生成控制器
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunDomain_BulidDomainFile()
        {
            #region (2)修改功能模块字段
            using (var scope = new TransactionScope())
            {
                try
                {
                    SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

                    //(2)创建业务层文件
                    #region 1)查询模块功能
                    var resptemp = Design_ModularOrFun_GetByID();
                    var Design_ModularOrFun = resptemp.Item;
                    #endregion

                    #region 3)根据功能模块ID查询所有业务方法
                    resptemp = Design_ModularOrFunDomain_Index();
                    var Design_ModularOrFunDomains = resptemp.Items;
                    var ModularOrFunDomainDetails = Design_ModularOrFunDomainDetail_GetByModularOrFunID();
                    #endregion
                    StringBuilder sbentity = new StringBuilder();
                    #region 名称空间引用

                    sbentity.AppendLine("");
                    sbentity.AppendLine("using Framework.Core;");
                    sbentity.AppendLine("using Framework.Web.Mvc;");
                    sbentity.AppendLine("using Framework.Web.Mvc.Sys;");
                    sbentity.AppendLine("using SoftProject.CellModel;");
                    sbentity.AppendLine("using System;");
                    sbentity.AppendLine("using System.Collections.Generic;");
                    sbentity.AppendLine("using System.Linq;");
                    sbentity.AppendLine("using System.Text;");
                    sbentity.AppendLine("using System.Threading.Tasks;");
                    sbentity.AppendLine("using System.Transactions;");

                    #endregion

                    sbentity.AppendLine();
                    sbentity.AppendLine("namespace SoftProject.Domain");
                    sbentity.AppendLine("{");
                    sbentity.AppendLine("    /// <summary>");
                    sbentity.AppendLine(string.Format("    /// 业务层:{0}({1})", Design_ModularOrFun.ControllCode, Design_ModularOrFun.ModularName));
                    sbentity.AppendLine("    /// </summary>");
                    sbentity.AppendLine("    public partial class SoftProjectAreaEntityDomain");
                    sbentity.AppendLine("    {");
                    foreach (var domain in Design_ModularOrFunDomains)
                    {
                        var strMethodReturnTypeID = "";
                        if (domain.MethodReturnTypeID == null || domain.MethodReturnTypeID == 1)
                            strMethodReturnTypeID = "void";
                        else
                            strMethodReturnTypeID = " MyResponseBase ";
                        sbentity.AppendLine(string.Format("        /// <summary>"));
                        sbentity.AppendLine(string.Format("        /// {0}", domain.ModularOrFunDomainName));
                        sbentity.AppendLine(string.Format("        /// </summary>"));
                        sbentity.AppendLine(string.Format("        /// <returns></returns>"));
                        sbentity.AppendLine(string.Format("        public {0} {1}_{2}()", strMethodReturnTypeID, Design_ModularOrFun.ControllCode, domain.MethodName));
                        sbentity.AppendLine(string.Format("        {{"));

                        var ModularOrFunDomainDetailsTemps = ModularOrFunDomainDetails.Where(p => p.Design_ModularOrFunDomainID == domain.Design_ModularOrFunDomainID).ToList();
                        #region 具体步骤
                        for (int i = 0; i < ModularOrFunDomainDetailsTemps.Count; i++)
                        {
                            var item = ModularOrFunDomainDetailsTemps[i];
                            sbentity.AppendLine(string.Format("        //{0}", item.ModularOrFunDomainDetailName));
                            sbentity.AppendLine(string.Format("        {0}", HttpUtility.UrlDecode(item.ParamName)));
                        }
                        #endregion
                        sbentity.AppendLine("        }");

                        sbentity.AppendLine();
                    }

                    sbentity.AppendLine("   }");
                    sbentity.AppendLine("}");

                    //F:\软件项目\SoftPlatformProject\SoftPlatform\SoftPlatform\Areas\C_CustomerAreas\CellModel
                    //string filepath1=System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                    //string filepath2=System.Environment.CurrentDirectory ;
                    //string filepath3=System.IO.Directory.GetCurrentDirectory();
                    //string filepath4=System.AppDomain.CurrentDomain.BaseDirectory;
                    var path = string.Format(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Areas\\{0}\\Domain\\", Design_ModularOrFun.AreasCode);
                    if (!Directory.Exists(path))
                        Directory.CreateDirectory(path);
                    //string filepath5 = string.Format(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Areas\\{0}\\CellModel\\{1}.cs", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode);
                    string filepath5 = path + Design_ModularOrFun.ControllCode + "Domain.cs";

                    FileStream fs = new FileStream(filepath5, FileMode.Create);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.Write(sbentity.ToString());
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    scope.Dispose();
                }
            }
            #endregion

            return resp;
        }
        /// <summary>
        /// 生成控制器记录:新建-提交-审核
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunControll_EditListBulidRecord010416()
        {
            Design_ModularOrFunControll_CheckBulid();

            Design_ModularOrFunControll_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            #region 功能模块对象
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
            #endregion

            #region 获取实体字段
            var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
            var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).Select(p => p.name).ToList();
            var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()

            var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
            var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()

            #endregion

            #region 我的查询
            StringBuilder sbcode = new StringBuilder();

            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult Index(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("//if (!domain.Querys.QueryDicts.ContainsKey(\"{0}___equal\"))", FKFields));
            sbcode.AppendLine("//{");
            sbcode.AppendLine(string.Format("//    if (domain.Item.{0} == null)", FKFields));
            sbcode.AppendLine("        //throw new Exception(\"主键不能为空\");");
            sbcode.AppendLine(string.Format("    //domain.Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = domain.Item.{0}.ToString() }});", FKFields));
            sbcode.AppendLine("//}");

            //sbcode.AppendLine("    //domain.Querys.Add(new Query { QuryType = 0, FieldName = \"Pre_CompanyID___equal\", Value = LoginInfo.CompanyID.ToString() });");
            sbcode.AppendLine("");
            //sbcode.AppendLine("    ModularOrFunCode = \"AuthorizationAreas.Pre_User.Index\";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Index\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("    var resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("    if (Request.IsAjaxRequest())");
            sbcode.AppendLine("        return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("    resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("    return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("}");

            var selectItem = new SoftProjectAreaEntity
            {
                ControllName = "我的"+Design_ModularOrFun.ModularName + "--列表",
                ActionMethod = "Index",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = null,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "我的" + Design_ModularOrFun.ModularName + "--列表",
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.Index", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 1
            };
            #endregion

            #region 添加查询
            sbcode = new StringBuilder();
            sbcode.AppendLine("        public ActionResult Add(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine("            var resp = domain.Default();");
            sbcode.AppendLine("            resp.Item.FillTabDate= DateTime.Now;");
            sbcode.AppendLine("            resp.Item.FillTabPersonID= LoginInfo.Sys_LoginInfoID;");
            sbcode.AppendLine("            resp.Item.FillTabPerson= LoginInfo.UserName;");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Add\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            resp.FunNameEn = \"Add\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var addItem = new SoftProjectAreaEntity
            {
                ControllName ="我的"+ Design_ModularOrFun.ModularName + "--添加查询",
                ActionMethod = "Add",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = null,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "添加",
                ControllModularOrFunCode = string.Format("{0}.{1}.Add", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 3
            };
            #endregion

            #region 添加保存
            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpPost]");
            sbcode.AppendLine("        public HJsonResult AddSave(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine("             //domain.Item.Pre_CompanyID = LoginInfo.CompanyID;");
            sbcode.AppendLine("             domain.Item.AuditStatuID = 1;");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Add\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.AddSave();");
            sbcode.AppendLine("            return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("        }");

            var addSaveItem = new SoftProjectAreaEntity
            {
                ControllName ="我的"+ Design_ModularOrFun.ModularName + "--添加保存",
                ActionMethod = "AddSave",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 2,
                ParamName = null,//主键名
                ViewName = null,//EditP
                ControllModularOrFunCode = string.Format("{0}.{1}.Add", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 5
            };
            #endregion

            #region 编辑查询
            sbcode = new StringBuilder();
            sbcode.AppendLine("        public ActionResult Edit(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            //sbcode.AppendLine("            ModularOrFunCode = "AuthorizationAreas.Pre_User.Detail";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Edit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.ByID();");
            sbcode.AppendLine("");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Edit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            resp.FunNameEn = \"Edit\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var editItem = new SoftProjectAreaEntity
            {
                ControllName ="我的"+ Design_ModularOrFun.ModularName + "--编辑查询",
                ActionMethod = "Edit",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "编辑",
                ControllModularOrFunCode = string.Format("{0}.{1}.Edit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 7
            };
            #endregion

            #region 编辑保存
            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpPost]");
            sbcode.AppendLine("        public HJsonResult EditSave(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Edit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("");
            sbcode.AppendLine("            var resp = domain.EditSave();");
            sbcode.AppendLine("            return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("        }");

            var editSaveItem = new SoftProjectAreaEntity
            {
                ControllName = "我的" + Design_ModularOrFun.ModularName + "--编辑保存",
                ActionMethod = "EditSave",
                ControllProgramCode = sbcode.ToString(),

                ActionName = 2,
                ParamName = null,
                ViewName = null,
                ControllModularOrFunCode = string.Format("{0}.{1}.Edit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 9
            };

            #endregion

            #region 提交保存
            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpPost]");
            sbcode.AppendLine("        public HJsonResult Submit(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine("         domain.Item.AuditStatuID = 4;");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Edit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("");
            sbcode.AppendLine("            var resp = domain.EditSave();");
            sbcode.AppendLine("            return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("        }");

            var submitSaveItem = new SoftProjectAreaEntity
            {
                ControllName = "我的" + Design_ModularOrFun.ModularName + "--提交保存",
                ActionMethod = "Submit",
                ControllProgramCode = sbcode.ToString(),

                ActionName = 2,
                ParamName = null,
                ViewName = null,
                ControllModularOrFunCode = string.Format("{0}.{1}.Submit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 11
            };

            #endregion

            #region 我的查询--查看
            sbcode = new StringBuilder();

            sbcode.AppendLine("        public ActionResult Detail(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Detail\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.ByID();");
            sbcode.AppendLine("");
            sbcode.AppendLine("            resp.FunNameEn = \"Detail\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var DetailItem = new SoftProjectAreaEntity
            {
                ControllName ="我的"+ Design_ModularOrFun.ModularName + "--查看",
                ActionMethod = "Detail",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "查看",
                ControllModularOrFunCode = string.Format("{0}.{1}.Detail", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 13
            };
            #endregion

            #region 待审核查询
            sbcode = new StringBuilder();

            sbcode.AppendLine("        [HttpGet]");
            sbcode.AppendLine("        public ActionResult IndexWaitAudit(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine("            domain.Querys.Add(new Query { QuryType = 0, FieldName = \"AuditStatuID___equal\", Value = \"4\" });");
            sbcode.AppendLine("");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexWaitAudit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));

            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("            if (Request.IsAjaxRequest())");
            sbcode.AppendLine("                return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var indexWaitExamine = new SoftProjectAreaEntity
            {
                ControllName = "待审核" + Design_ModularOrFun.ModularName,
                ActionMethod = "IndexWaitExamine",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = null,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "待审核" + Design_ModularOrFun.ModularName,
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.IndexWaitAudit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 20
            };
            #endregion

            #region 审核查询
            sbcode = new StringBuilder();
            sbcode.AppendLine("        public ActionResult Audit(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            //sbcode.AppendLine("            ModularOrFunCode = "AuthorizationAreas.Pre_User.Detail";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Audit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.ByID();");
            sbcode.AppendLine("");

            sbcode.AppendLine("            resp.Item.AuditDate= DateTime.Now;");
            sbcode.AppendLine("            resp.Item.AuditPersonID= LoginInfo.Sys_LoginInfoID;");
            sbcode.AppendLine("            resp.Item.AuditPerson= LoginInfo.UserName;");

            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Audit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            resp.FunNameEn = \"Audit\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var auditItem = new SoftProjectAreaEntity
            {
                ControllName ="待审核"+ Design_ModularOrFun.ModularName + "--审核查询",
                ActionMethod = "Audit",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "审核查询",
                ControllModularOrFunCode = string.Format("{0}.{1}.Audit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 22
            };
            #endregion

            #region 审核保存
            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpPost]");
            sbcode.AppendLine("        public HJsonResult AuditSave(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Audit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("");
            sbcode.AppendLine("            domain.Item.AuditStatuID = 16;");
            sbcode.AppendLine("            var resp = domain.EditSave();");
            sbcode.AppendLine("            return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("        }");

            var auditSaveItem = new SoftProjectAreaEntity
            {
                ControllName = "待审核" + Design_ModularOrFun.ModularName + "--审核保存",
                ActionMethod = "AuditSave",
                ControllProgramCode = sbcode.ToString(),

                ActionName = 2,
                ParamName = null,
                ViewName = null,
                ControllModularOrFunCode = string.Format("{0}.{1}.Audit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 24
            };

            #endregion

            #region 查询列表

            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpGet]");
            sbcode.AppendLine("        public ActionResult IndexSearch(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine("            domain.Querys.Add(new Query { QuryType = 0, FieldName = \"AuditStatuID___equal\", Value = \"16\" });");
            sbcode.AppendLine("");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexSearch\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("            if (Request.IsAjaxRequest())");
            sbcode.AppendLine("                return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var indexSearchtem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "查询--列表",
                ActionMethod = "IndexSearch",
                ControllProgramCode = sbcode.ToString(),

                ActionName = 2,
                ParamName = null,
                ViewName = null,
                ControllModularOrFunCode = string.Format("{0}.{1}.IndexSearch", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 26
            };

            #endregion

            #region 查询--查看

            sbcode = new StringBuilder();
            sbcode.AppendLine("        public ActionResult Detail2(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Detail2\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.ByID();");
            sbcode.AppendLine("");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var detail2Item = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "查询--查看",
                ActionMethod = "Detail2",
                ControllProgramCode = sbcode.ToString(),
                //DonationID
                ActionName = 2,
                ParamName = PKField,
                ViewName = null,
                ControllModularOrFunCode = string.Format("{0}.{1}.Detail2", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 28
            };

            #endregion

            //Item.Items.Clear();
            if (Item.Design_ModularOrFunControlls == null)
                Item.Design_ModularOrFunControlls = new List<SoftProjectAreaEntity>();
            Item.Design_ModularOrFunControlls.Add(selectItem);
            Item.Design_ModularOrFunControlls.Add(addItem);
            Item.Design_ModularOrFunControlls.Add(addSaveItem);
            Item.Design_ModularOrFunControlls.Add(editItem);
            Item.Design_ModularOrFunControlls.Add(editSaveItem);
            Item.Design_ModularOrFunControlls.Add(submitSaveItem);
            Item.Design_ModularOrFunControlls.Add(DetailItem);

            Item.Design_ModularOrFunControlls.Add(indexWaitExamine);
            Item.Design_ModularOrFunControlls.Add(auditItem);
            Item.Design_ModularOrFunControlls.Add(auditSaveItem);

            Item.Design_ModularOrFunControlls.Add(indexSearchtem);
            Item.Design_ModularOrFunControlls.Add(detail2Item);

            var resp = Design_ModularOrFunControll_EditListSave();
            return resp;
        }
        /// <summary>
        /// 生成控制器记录
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunControll_EditListBulidRecordByOrderDetailTemplete()
        {
            Design_ModularOrFunControll_CheckBulid();

            Design_ModularOrFunControll_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            #region 功能模块对象
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
            #endregion

            #region 获取实体字段
            var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
            //var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).Select(p => p.name).ToList();
            //var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()

            var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
            var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()
            PKField = Design_ModularOrFun.PrimaryKey;
            var MainPKField = Design_ModularOrFun.MainPrimaryKey;
            #endregion

            #region 编辑列表

            StringBuilder sbcode = new StringBuilder();

            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult IndexEdit(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine("    var resp = new MyResponseBase();");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexEdit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("");
            sbcode.AppendLine(string.Format("    if (domain.Item.{0} == null)", MainPKField));
            sbcode.AppendLine("    {");
            sbcode.AppendLine("        throw new Exception(\"主键不能为空\");");
            sbcode.AppendLine("    }");
            sbcode.AppendLine(string.Format("    domain.Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = domain.Item.{0}.ToString() }});", MainPKField));
            sbcode.AppendLine("    resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("    return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("}");

            var indexEditItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--编辑列表",
                ActionMethod = ".C_OrderID.",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = MainPKField,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "编辑列表",
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.IndexEdit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 1
            };
            #endregion

            #region 查看列表
            sbcode = new StringBuilder();

            sbcode.AppendLine("        [HttpGet]");
            sbcode.AppendLine("        public ActionResult IndexDetail(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("            if (domain.Item.{0} == null)", MainPKField));
            sbcode.AppendLine("                throw new Exception(\"主键不能为空!\");");
            sbcode.AppendLine("");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexDetail\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("");
            sbcode.AppendLine(string.Format("            domain.Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = domain.Item.{0}.ToString() }});", MainPKField));
            sbcode.AppendLine("            var resp = domain.QueryIndex();");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var indexDetailItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--查看列表",
                ActionMethod = "IndexDetail",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = MainPKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "查看列表",
                ControllModularOrFunCode = string.Format("{0}.{1}.IndexDetail", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 3
            };
            #endregion

            #region Popup
            sbcode = new StringBuilder();
            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult Popup(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Popup\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("");
            sbcode.AppendLine("    domain.PageQueryBase.PageSize = 10000;");
            sbcode.AppendLine("    var resp = domain.QueryIndex();");
            sbcode.AppendLine("    if (Request.IsAjaxRequest())");
            sbcode.AppendLine("        return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("    resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("    return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("}");

            var popupItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--Popup",
                ActionMethod = "Popup",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                //ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "Popup",
                ControllModularOrFunCode = string.Format("{0}.{1}.Popup", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 7
            };
            #endregion

            #region Rows
            sbcode = new StringBuilder();
            sbcode.AppendLine("public ActionResult Rows(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("    var resp = domain.{0}_Rows();", Design_ModularOrFun.ControllCode));
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexEdit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    return View(\"Rows\", resp);");
            sbcode.AppendLine("}");

            var rowsItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--Rows",
                ActionMethod = "Rows",
                ControllProgramCode = sbcode.ToString(),

                ActionName = 2,
                ParamName = null,
                ViewName = null,
                ControllModularOrFunCode = string.Format("{0}.{1}.Rows", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 9
            };
            #endregion

            //Item.Items.Clear();
            if (Item.Design_ModularOrFunControlls == null)
                Item.Design_ModularOrFunControlls = new List<SoftProjectAreaEntity>();
            Item.Design_ModularOrFunControlls.Add(indexEditItem);
            Item.Design_ModularOrFunControlls.Add(indexDetailItem);
            Item.Design_ModularOrFunControlls.Add(popupItem);
            Item.Design_ModularOrFunControlls.Add(rowsItem);

            var resp = Design_ModularOrFunControll_EditListSave();
            return resp;
        }
        /// <summary>
        /// 生成控制器记录--附件
        /// </summary>
        /// <returns></returns>
        public MyResponseBase Design_ModularOrFunControll_EditListBulidRecordByAtt()
        {
            Design_ModularOrFunControll_CheckBulid();
            Design_ModularOrFunControll_Domain();
            SoftProjectAreaEntity hOperControl = new SoftProjectAreaEntity { };

            #region 功能模块对象
            var Design_ModularOrFun = Design_ModularOrFun_GetByID().Item;
            #endregion

            #region 获取实体字段
            var Design_ModularFields = Design_ModularField_GetByModularOrFunID().Items;
            var FKFieldss = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 2) == 2).Select(p => p.name).ToList();
            var FKFields = string.Join(",", FKFieldss);//deleteForecastIDsEnum.ToArray()

            var PKFields = Design_ModularFields.Where(p => p.bPrimaryKeyOrFK != null && ((int)p.bPrimaryKeyOrFK & 1) == 1).Select(p => p.name).ToList();
            var PKField = string.Join(",", PKFields);//deleteForecastIDsEnum.ToArray()

            #endregion

            #region 编辑查询
            StringBuilder sbcode = new StringBuilder();

            ///// <summary>
            ///// 用户管理--查询
            ///// </summary>
            ///// <param name="domain"></param>
            ///// <returns></returns>
            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult IndexEdit(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("domain.Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = domain.Item.{0}.ToString() }});", FKFields));
            //sbcode.AppendLine("    //domain.Querys.Add(new Query { QuryType = 0, FieldName = \"Pre_CompanyID___equal\", Value = LoginInfo.CompanyID.ToString() });");
            sbcode.AppendLine("");
            //sbcode.AppendLine("    ModularOrFunCode = \"AuthorizationAreas.Pre_User.Index\";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexEdit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("    var resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("    if (Request.IsAjaxRequest())");
            sbcode.AppendLine("        return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("    resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("    return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("}");

            var selectItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--编辑列表",
                ActionMethod = "IndexEdit",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = FKFields,//PKField,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "编辑列表",
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.IndexEdit", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 1
            };
            #endregion

            #region 查看列表
            sbcode = new StringBuilder();

            ///// <summary>
            ///// 用户管理--查询
            ///// </summary>
            ///// <param name="domain"></param>
            ///// <returns></returns>
            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult IndexDetail(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("domain.Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = domain.Item.{0}.ToString() }});", FKFields));
            //sbcode.AppendLine("    //domain.Querys.Add(new Query { QuryType = 0, FieldName = \"Pre_CompanyID___equal\", Value = LoginInfo.CompanyID.ToString() });");
            sbcode.AppendLine("");
            //sbcode.AppendLine("    ModularOrFunCode = \"AuthorizationAreas.Pre_User.Index\";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexDetail\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("    var resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("    if (Request.IsAjaxRequest())");
            sbcode.AppendLine("        return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("    resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("    return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("}");

            var indexDetailItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--查看列表",
                ActionMethod = "IndexDetail",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = FKFields,//PKField,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "查看列表",
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.IndexDetail", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 1
            };
            #endregion

            #region 上传
            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpGet]");
            sbcode.AppendLine("        public ActionResult UpLoad(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine("            #region 保存文件");
            sbcode.AppendLine("");
            sbcode.AppendLine("            if (domain.Item.RefPKTableGuid == null)");
            sbcode.AppendLine("                throw new Exception(\"附件Guid不能为空\")");
            sbcode.AppendLine("            domain.Item.AttachmentFileSizeDisp = ProjectCommon.FileSizeDisp(domain.Item.AttachmentFileSize);");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Upload\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var respadd = domain.AddSave();");
            sbcode.AppendLine("            #endregion");
            sbcode.AppendLine("");
            sbcode.AppendLine("            #region 查询");
            sbcode.AppendLine(string.Format("            if (respadd.Item.{0} == null)", PKField));
            sbcode.AppendLine("                throw new Exception(\"添加失败\");");
            sbcode.AppendLine("            domain.Item.Doc_DocmentAttachmentID = respadd.Item.Doc_DocmentAttachmentID;");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexEdit\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.ByID();");
            sbcode.AppendLine("");
            sbcode.AppendLine("            resp.Items.Add(resp.Item);");
            sbcode.AppendLine("            resp.FunNameEn = \"Detail\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("");
            sbcode.AppendLine("            #endregion");
            sbcode.AppendLine("            return View(\"Rows\", resp);");
            sbcode.AppendLine("        }");

            var uploadItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--上传",
                ActionMethod = "UpLoad",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = null,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "上传",
                ControllModularOrFunCode = string.Format("{0}.{1}.UpLoad", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 3
            };
            #endregion

            #region 删除
            sbcode = new StringBuilder();
            sbcode.AppendLine("        [HttpPost]");
            sbcode.AppendLine("        public HJsonResult Delete(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Delete\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.DeleteByID();");
            sbcode.AppendLine("            return new HJsonResult(new { Data = resp });");
            sbcode.AppendLine("        }");

            var deleteItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--删除",
                ActionMethod = "Delete",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 2,
                ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = null,//EditP
                ControllModularOrFunCode = string.Format("{0}.{1}.Delete", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 5
            };
            #endregion

            #region 查看查询
            sbcode = new StringBuilder();

            sbcode.AppendLine("        public ActionResult Detail(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("        {");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.Detail\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("            domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("            var resp = domain.ByID();");
            sbcode.AppendLine("");
            sbcode.AppendLine("            resp.FunNameEn = \"Detail\";");
            sbcode.AppendLine("            resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("            return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("        }");

            var DetailItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--查看",
                ActionMethod = "Detail",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = Design_ModularOrFun.ControllCode + "ID",//PKField,//主键名
                ViewName = 30,//PopupEdit
                BPrem = 1,
                ActionMethodCn = "查看",
                ControllModularOrFunCode = string.Format("{0}.{1}.Detail", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 11
            };
            #endregion

            #region 下载列表
            sbcode = new StringBuilder();

            ///// <summary>
            ///// 附件管理--下载列表
            ///// </summary>
            ///// <param name="domain"></param>
            ///// <returns></returns>
            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult IndexDown(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            sbcode.AppendLine(string.Format("domain.Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = domain.Item.{0}.ToString() }});", FKFields));
            //sbcode.AppendLine("    //domain.Querys.Add(new Query { QuryType = 0, FieldName = \"Pre_CompanyID___equal\", Value = LoginInfo.CompanyID.ToString() });");
            sbcode.AppendLine("");
            //sbcode.AppendLine("    ModularOrFunCode = \"AuthorizationAreas.Pre_User.Index\";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexDown\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("    var resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("    if (Request.IsAjaxRequest())");
            sbcode.AppendLine("        return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("    resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("    return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("}");

            var downItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--下载列表",
                ActionMethod = "IndexDown",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = FKFields,//PKField,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "下载列表",
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.Index", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 11
            };
            #endregion

            #region 图片显示列表
            sbcode = new StringBuilder();

            ///// <summary>
            ///// 附件管理--下载列表
            ///// </summary>
            ///// <param name="domain"></param>
            ///// <returns></returns>
            sbcode.AppendLine("[HttpGet]");
            sbcode.AppendLine("public ActionResult IndexImage(SoftProjectAreaEntityDomain domain)");
            sbcode.AppendLine("{");
            //sbcode.AppendLine("    //domain.Querys.Add(new Query { QuryType = 0, FieldName = \"Pre_CompanyID___equal\", Value = LoginInfo.CompanyID.ToString() });");
            sbcode.AppendLine(string.Format("domain.Querys.Add(new Query {{ QuryType = 0, FieldName = \"{0}___equal\", Value = domain.Item.{0}.ToString() }});", FKFields));
            sbcode.AppendLine("");
            //sbcode.AppendLine("    ModularOrFunCode = \"AuthorizationAreas.Pre_User.Index\";");
            sbcode.AppendLine(string.Format("    ModularOrFunCode = \"{0}.{1}.IndexImage\";", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode));
            sbcode.AppendLine("    domain.Design_ModularOrFun = Design_ModularOrFun;");
            sbcode.AppendLine("    var resp = domain.QueryIndex();");
            sbcode.AppendLine("");
            sbcode.AppendLine("    if (Request.IsAjaxRequest())");
            sbcode.AppendLine("        return View(Design_ModularOrFun.PartialView, resp);");
            sbcode.AppendLine("    resp.ViewContextName = Design_ModularOrFun.PartialView;");
            sbcode.AppendLine("    return View(Design_ModularOrFun.MainView, resp);");
            sbcode.AppendLine("}");

            var imageItem = new SoftProjectAreaEntity
            {
                ControllName = Design_ModularOrFun.ModularName + "--图片列表",
                ActionMethod = "IndexImage",
                ControllProgramCode = sbcode.ToString(),
                ActionName = 1,
                ParamName = FKFields,//PKField,//主键名
                ViewName = 1,//IndexP
                BPrem = 1,
                ActionMethodCn = "图片列表",
                //DataRightDict="",
                ControllModularOrFunCode = string.Format("{0}.{1}.IndexImage", Design_ModularOrFun.AreasCode, Design_ModularOrFun.ControllCode),
                Design_ModularOrFunID = Item.Design_ModularOrFunID,
                Sort = 13
            };
            #endregion

            //Item.Items.Clear();
            if (Item.Design_ModularOrFunControlls == null)
                Item.Design_ModularOrFunControlls = new List<SoftProjectAreaEntity>();
            Item.Design_ModularOrFunControlls.Add(selectItem);
            Item.Design_ModularOrFunControlls.Add(indexDetailItem);

            Item.Design_ModularOrFunControlls.Add(uploadItem);
            Item.Design_ModularOrFunControlls.Add(deleteItem);
            Item.Design_ModularOrFunControlls.Add(DetailItem);
            Item.Design_ModularOrFunControlls.Add(downItem);
            Item.Design_ModularOrFunControlls.Add(imageItem);

            var resp = Design_ModularOrFunControll_EditListSave();
            return resp;
        }
 //public static MvcHtmlString MainMenu(this HtmlHelper html)
 //{
 //    var controll = html.ViewContext.Controller as BaseController;
 //    //var html.GetRouteString("Controller").ToLower()
 //    //var area = "";
 //    //if (controll.RouteData.DataTokens["area"] != null)
 //    //    area = controll.RouteData.DataTokens["area"].ToString();
 //    //var constrollName = controll.RouteData.Values["controller"].ToString();
 //    //var actionName = controll.RouteData.Values["action"].ToString();
 //    List<Sys_PremSet> Sys_PremSets = controll.LoginMenu();
 //    var currpath = "";
 //    if (HttpContext.Current.Session["MenuUrl"] != null)
 //        currpath = HttpContext.Current.Session["MenuUrl"].ToString();
 //    ////根据Action,选中路径
 //    //var Sys_PremSetsAll = controll.Sys_PremSets;//所有角色权限权限集
 //    //var premSet = Sys_PremSetsAll.Where(p => p.Area == area && p.ConstrollName == constrollName && p.ActionName == actionName).First();
 //    //if (premSet.PermSetCategory == 0)
 //    //{
 //    //    var temp1 = Sys_PremSets.Where(p => p.Sys_PremCodeID == premSet.PermSetParentID).First();
 //    //    //var temp2 = Sys_PremSets.Where(p => p.Sys_PremCodeID == temp1.PermSetParentID).First();
 //    //    currpath = temp1.PermSetParentID + "/" + temp1.Sys_PermSetID + "/";
 //    //}
 //    //else
 //    //    currpath = premSet.PermSetParentID + "/" + premSet.Sys_PermSetID + "/";
 //    //var ActionSys_PremSet = Sys_PremSets.Where(p => p.Area == area && p.ConstrollName == constrollName && p.ActionName == actionName).First();
 //    //var ActionSys_PremSet = Sys_PremSets.Where(p => p.Area == area && p.ConstrollName == constrollName && p.ActionName == actionName).First();
 //    //var currpath =ActionSys_PremSet.PermSetParentID + "/" + ActionSys_PremSet.Sys_PermSetID+"/";//
 //    //获取路径
 //    var path = controll.Request.ApplicationPath;
 //    StringBuilder sb = new StringBuilder();//string.Format("<ul id='{0}' class='easyui-tree'>", name));
 //    sb.AppendLine("<ul id='mymenu' class='mymenu'>");
 //    //<li class='active'>
 //    //        <a href='/Home/Index'>
 //    //            <i class='glyphicon glyphicon-th-large'></i>
 //    //            <span>首页</span>
 //    //        </a>
 //    //        <ul class='submenu'>
 //    //        </ul>
 //    //    </li>
 //    if (currpath.Contains("/Home/Index"))
 //        sb.AppendLine("<li class='active'>");
 //    else
 //        sb.AppendLine("<li class=''>");
 //    sb.AppendLine("    <a href='/'>");
 //    sb.AppendLine("        <i class='glyphicon glyphicon-th-large'></i>");
 //    sb.AppendLine("        <span>首页</span>");
 //    sb.AppendLine("    <b class='icon-angle-down'></b></a>");
 //    sb.AppendLine("<ul class='submenu' style='display: block;'>");
 //    sb.AppendLine("</ul>");
 //    sb.AppendLine("</li>");
 //    var root = Sys_PremSets.Where(p => p.PermSetParentID == 0).OrderBy(p => p.OrderNum).ToList();
 //    var count = root.Count();
 //    if (count > 0)
 //    {
 //        for (int i = 0; i < count; i++)
 //        {
 //            var active = "";
 //            var bopen = false;
 //            if (currpath.Contains("/" + root[i].Sys_PermSetID + "/"))
 //            {
 //                active = "active";
 //                bopen = true;
 //            }
 //            sb.AppendLine("<li class='" + active + "'>");
 //            //sb.AppendLine("    <a class='" + selected + "'  href='" + path + root[i].ActionPath + "'>");
 //            if (root[i].ActionPath == "")
 //                sb.AppendLine("    <a href='#'>");
 //            else
 //                sb.AppendLine("    <a href='/" + root[i].ActionPath + "'>");
 //            sb.AppendLine("        <i class='glyphicon glyphicon-th-large'></i>");
 //            sb.AppendLine("        <span>" + root[i].PermSetName + "</span>");
 //            sb.AppendLine("    </a>");
 //            sb.AppendLine(BindMainMenu(Sys_PremSets, (int)root[i].Sys_PermSetID, currpath, path, bopen));
 //            sb.AppendLine("</li>");
 //        }
 //    }
 //    sb.AppendLine("</ul>");//结束
 //    MvcHtmlString mstr = new MvcHtmlString(sb.ToString());
 //    return mstr;
 //}
 //private static string BindMainMenu(List<Sys_PremSet> Sys_PremSets, int Sys_PermSetID, string currpath, string path, bool bopen)
 //{
 //    StringBuilder sb = new StringBuilder();
 //    if (bopen)
 //        sb.AppendLine("<ul class='submenu' style='display: block;'>");
 //    else
 //        sb.AppendLine("<ul class='submenu'>");
 //    var root = Sys_PremSets.Where(p => p.PermSetParentID == Sys_PermSetID).OrderBy(p => p.OrderNum).ToList();
 //    int count = root.Count;
 //    if (count > 0)
 //    {
 //        for (int i = 0; i < count; i++)
 //        {
 //            var selected = "";
 //            if (currpath == "/" + Sys_PermSetID + "/" + root[i].Sys_PermSetID + "/")
 //                selected = "selected";
 //            sb.AppendLine("<li>");
 //            sb.AppendLine("    <a class='" + selected + "'  href='" + path + root[i].ActionPath + "'>");
 //            sb.AppendLine("        <span>" + root[i].PermSetName + "</span>");
 //            sb.AppendLine("    </a>");
 //            sb.AppendLine("</li>");
 //        }
 //    }
 //    sb.AppendLine("</ul>");
 //    return sb.ToString();
 //}
 //public Breadcrumb Menu(SoftProjectAreaEntity item)
 //{
 //    //var conts = ViewContext.Controller as BaseController;
 //    Menus.Items.Clear();
 //    if (MenuFun == null)
 //        return Menus;
 //    var Items = new List<SoftProjectAreaEntity>();
 //    var btns = LoginModulerBtns(MenuCode, 1);
 //    var sbhtml = new StringBuilder();
 //    foreach (var btn in btns)
 //    {
 //        var controllss = ProjectCache.Design_ModularOrFunBtnControlls.Where(p => p.Design_ModularOrFunBtnID == btn.Design_ModularOrFunBtnID).ToList();
 //        var action = "";
 //        if (controllss[0].ActionPath == Request.Path)
 //            action = "active";
 //        var url = UrlByControll(item, controllss.First());
 //        //sbhtml.AppendLine("<li class='" + action + "'>");
 //        //sbhtml.AppendLine(string.Format("<a href='{0}'>{1}</a>", url, btn.BtnNameCn));
 //        //sbhtml.AppendLine("</li>");
 //        ////////////////////////////////////////////////////////
 //        Menus.Items.Add(new BreadcrumbItem { Name = btn.BtnNameCn, URL = url });
 //    }
 //    var strHtml = new MvcHtmlString(sbhtml.ToString());
 //    return Menus;
 //}
 //private static string UrlByControll(object item, SoftProjectAreaEntity controlls)
 //{
 //    var strParam = "?";
 //    if (controlls.ParamName != null && controlls.ParamName.Length > 0 && item != null)
 //    {
 //        #region 对象数据类型
 //        Type type = item.GetType();
 //        #endregion
 //        var paramNames = controlls.ParamName.Split(',');
 //        foreach (var param in paramNames)
 //        {
 //            PropertyInfo property = type.GetProperty(param);
 //            var value = property.GetValue(item, null);
 //            strParam += "Item." + param + "=" + value;
 //            //var val=item.
 //        }
 //    }
 //    //var url = "/" + controlls.AreasCode + "/" + controlls.ControllCode + "/" + controlls.ActionMethod + strParam;
 //    var url = controlls.ActionPath + strParam;
 //    return url;
 //}
 //public int? MenuPostion()
 //{
 //    if (Design_ModularOrFun != null)
 //    {
 //        var MenuPanelItem = MenuPanel(Design_ModularOrFun);
 //        //var MenuPanel = Design_ModularOrFun;
 //        //var Items = new List<SoftProjectAreaEntity>();
 //        //if (MenuPanel.BMenuPanel != 1)//是控制面板
 //        //{
 //        //    //MenuPanel = ProjectCache.Design_ModularOrFuns.Where(p => p.Design_ModularOrFunID == MenuPanel.Design_ModularOrFunParentID).FirstOrDefault();
 //        //    MenuPanel = ProjectCache.Design_ModularOrFuns.Where(p => p.Design_ModularOrFunID == MenuPanel.ParentPremID).FirstOrDefault();
 //        //}
 //        //var respItem = ProjectCache.Design_ModularOrFuns.Where(p => p.Design_ModularOrFunID == LoginInfo.CurrMenuModularOrFunID).FirstOrDefault();
 //        return MenuPanelItem.MenuPostion;
 //    }
 //    return 0;
 //}
 //public Breadcrumb Menu(SoftProjectAreaEntity obj)
 //{
 //    Menus.Items.Clear();
 //    if (Design_ModularOrFun == null)
 //        return Menus;
 //    var Items = new List<SoftProjectAreaEntity>();
 //    var MenuPanelItem = MenuPanel(Design_ModularOrFun);
 //    Items = ProjectCache.Design_ModularOrFuns.Where(p => p.ParentPremID == MenuPanelItem.Design_ModularOrFunID && p.BMenu == 1).OrderBy(p=>p.Sort).ToList();
 //    if (MenuPanelItem.BMenu == 1)
 //    {
 //        #region 参数
 //        var strParam = "";
 //        if (MenuPanelItem.ParamName != null && MenuPanelItem.ParamName.Length > 0 && obj != null)
 //        {
 //            #region 对象数据类型
 //            Type type = obj.GetType();
 //            #endregion
 //            var paramNames = MenuPanelItem.ParamName.Split(',');
 //            foreach (var param in paramNames)
 //            {
 //                PropertyInfo property = type.GetProperty(param);
 //                var value = property.GetValue(obj, null);
 //                strParam += "Item." + param + "=" + value;
 //                //var val=item.
 //            }
 //        }
 //        if (strParam.Length > 0)
 //            strParam = "?" + strParam;
 //        #endregion
 //        var ActionPath = MenuPanelItem.ActionPath + strParam;
 //        //strNav += string.Format("<li><a href='{0}{1}'>{2}</a></li>", modular.ActionPath, strParam, modular.ModularName);
 //        Menus.Items.Add(new BreadcrumbItem { Name = MenuPanelItem.ModularName, URL = ActionPath });
 //    }
 //    foreach (var item in Items)
 //    {
 //        #region 参数
 //        var strParam = "";
 //        if (item.ParamName != null && item.ParamName.Length > 0 && obj != null)
 //        {
 //            #region 对象数据类型
 //            Type type = obj.GetType();
 //            #endregion
 //            var paramNames = item.ParamName.Split(',');
 //            foreach (var param in paramNames)
 //            {
 //                PropertyInfo property = type.GetProperty(param);
 //                var value = property.GetValue(obj, null);
 //                strParam += "Item." + param + "=" + value;
 //                //var val=item.
 //            }
 //        }
 //        if (strParam.Length > 0)
 //            strParam = "?" + strParam;
 //        #endregion
 //        var ActionPath = item.ActionPath + strParam;
 //        Menus.Items.Add(new BreadcrumbItem { Name = item.ModularName, URL = ActionPath });
 //    }
 //    return Menus;
 //}
 public SoftProjectAreaEntity MenuPanel(SoftProjectAreaEntity MenuPanelItem)
 {
     if (MenuPanelItem.BMenuPanel == 1 || MenuPanelItem.ParentPremID == 0)
         return MenuPanelItem;
     MenuPanelItem = ProjectCache.Design_ModularOrFuns.Where(p => p.Design_ModularOrFunID == MenuPanelItem.ParentPremID).FirstOrDefault();
     return MenuPanel(MenuPanelItem);
 }