Ejemplo n.º 1
0
        /// <summary>
        /// [新]生成读取excel的代码
        /// </summary>
        /// <param name="import"></param>
        /// <returns></returns>
        public static string CreateXss_new(Grids import)
        {
            string s      = "";
            var    models = import.grids.Where(e => e.CONTROL_NAME == "DATAGRID").ToList();

            for (int i = 0; i < models.Count; i++)
            {
                string tmp = "model." + models[i].CODE + " = sheet.GetRow(i).GetCell(" + i + ") == null ? \"\" : sheet.GetRow(i).GetCell(" + i + ").ToString();\r\n\r\n                        ";
                s += tmp;
            }
            return(s);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// [新]检测List内是否有重复数据
        /// </summary>
        /// <param name="import"></param>
        /// <returns></returns>
        public static string CheckImportData_new(Grids import)
        {
            var    models = import.grids.Where(e => e.CONTROL_NAME == "DATAGRID").ToList();
            string s      = "";

            foreach (var ds in models)
            {
                s += "x." + ds.CODE + " == model." + ds.CODE;
                if (ds != models.Last())
                {
                    s += "&&";
                }
            }
            return(s);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// [新]生成校验是否重复的代码
        /// </summary>
        /// <param name="import"></param>
        /// <returns></returns>
        public static string CreateRepeat_new(Grids import)
        {
            var    models = import.grids.Where(e => e.CONTROL_NAME == "DATAGRID").ToList();
            string s      = "else if (HasWord(model." + models[0].CODE;

            for (int i = 1; i < models.Count(); i++)
            {
                string tmp = ",model." + models[i].CODE;
                s += tmp;
            }
            return(s += "))\r\n                        " +
                        "{\r\n                            model.TextState = \"失败!词条数据已存在\";\r\n                            " +
                        "model.Color = \"Red\";\r\n                        " +
                        "model.IsChecked = false;\r\n              " +
                        "}\r\n                        else\r\n                        {\r\n                            model.IsChecked = true;\r\n                            model.TextState = \"成功!\";\r\n                            model.Color = \"Green\";\r\n                        }\r\n\r\n                        ");;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// [新]生成导入的url
        /// </summary>
        /// <param name="ProjectName"></param>
        /// <param name="import"></param>
        /// <returns></returns>
        public static string CreateImportUrl_new(string ProjectName, Grids import)
        {
            var    ls     = ProjectName.Split('.');
            string s      = "\r\n\t\tpublic const string url_hasword = \"/api/" + ls.Last().ToLower() + "/" + ls.Last().ToLower() + "/hasword?";
            var    models = import.grids.Where(e => e.CONTROL_NAME == "DATAGRID").ToList();

            for (int i = 0; i < models.Count(); i++)
            {
                ModelHelper model = new ModelHelper();
                string      tmp   = "";
                if (i > 0)
                {
                    tmp += "&";
                }
                tmp += model.Col(models[i].CODE).Replace("Col", "") + "={" + i + "}";
                s   += tmp;
            }
            return(s + "\";");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// [新]生成校验重复的函数体
        /// </summary>
        /// <param name="import"></param>
        /// <returns></returns>
        public static string CreateRepeatFunction_new(Grids import)
        {
            var    models = import.grids.Where(e => e.CONTROL_NAME == "DATAGRID").ToList();
            string s      = "private bool HasWord(string " + models[0].CODE;

            for (int i = 1; i < models.Count; i++)
            {
                string tmp = ", string " + models[i].CODE;
                s += tmp;
            }
            s += ")\r\n        {\r\n            var res = plugin.Framework.GetData(Services.url_hasword";
            for (int i = 0; i < models.Count; i++)
            {
                ModelHelper model = new ModelHelper();
                string      tmp   = ", " + models[i].CODE;
                s += tmp;
            }
            return(s + ");");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// [新]生成校正导入数据是否为空
        /// </summary>
        /// <param name="import"></param>
        /// <returns></returns>
        public static string CreateNull_new(Grids import)
        {
            var    models = import.grids.Where(e => e.CONTROL_NAME == "DATAGRID").ToList();
            string s      = "";

            for (int i = 0; i < models.Count; i++)
            {
                string tmp = "";
                if (i != 0)
                {
                    tmp += "else ";
                }
                tmp += "if (string.IsNullOrEmpty(model." + models[i].CODE + "))\r\n                        {\r\n                            " +
                       "model.TextState = \"失败!\" + Translator.Get(\"Grid_" + models[i].CODE + "\") + \"不能为空\";\r\n                            " +
                       "model.Color = \"Red\";\r\n              " +
                       "model.IsChecked = false;\r\n              ";
                s += tmp + "}\r\n";
            }
            return(s);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// [新]生成绑定字段
        /// </summary>
        /// <returns></returns>
        public static string CreateWord_new(Grids Contents)
        {
            Model.Helper.ModelHelper model = new ModelHelper();
            string s = "#region 字段\r\n\t";

            foreach (var ds in Contents.grids)
            {
                if (ds.CONTROL_NAME == "TextBox" || ds.CONTROL_NAME == "TextBox带弹出框" || ds.CONTROL_NAME == "DatePicker")
                {
                    s += AddNotify_Click(ds.CODE, ds.NAME) + "\r\n";
                }

                if (ds.CONTROL_NAME == "Combox")
                {
                    //s += "\t//" + ds.NAME + "\r\n\t";
                    s += AddNotify_Click("ObservableCollection<ComboxModel> " + ds.CODE, ds.NAME) + "\r\n";
                    s += AddNotify_Click("ComboxModel " + "Filter_" + ds.CODE, ds.NAME) + "\r\n";
                }
            }
            s += "#endregion\r\n";
            return(s);
        }