Ejemplo n.º 1
0
        private static string CreateBatEditData()
        {
            StringBuilder batEditContent = new StringBuilder();
            StringBuilder createModel    = new StringBuilder();
            var           batEditModel   = PageCache.GetCmd("批量编辑");

            if (batEditModel != null)
            {
                batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtBatEdit{1}\"]);\r\n", PageCache.KeyId, PageCache.KeyId);
                batEditContent.AppendFormat(@"           List<string> idList = {0}.Split(new char[]{{','}}, StringSplitOptions.RemoveEmptyEntries).ToList();{1}", PageCache.KeyId, Environment.NewLine);
                foreach (var item in batEditModel.AttrList)
                {
                    string attribute      = item.AttrName;
                    string eval_attribute = item.ColName;
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        batEditContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(Request[\"txtBatEdit{0}\"]);\r\n", attribute);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            batEditContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", attribute);
                            batEditContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", attribute);
                        }
                        else
                        {
                            batEditContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", attribute);
                            batEditContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", attribute);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", eval_attribute, ExtendMethod.ToStringToType_ExceptIntDate(attribute, item.DbType));
                    }
                    else
                    {
                        batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtBatEdit{1}\"]);\r\n", attribute, attribute);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", eval_attribute, ExtendMethod.ToStringToType_ExceptIntDate(attribute, item.DbType));
                    }
                }

                string template = @"
        private void BatEditData()
        {{
{0}
            {1} model = new {1}();
{2}
            {3} dal = new {3}();
            dal.BatUpdate{4}(idList, model);

            Response.Write(""0"");
        }}
";

                return(string.Format(template,
                                     batEditContent.ToString(),
                                     PageCache.TableName_Model,
                                     createModel.ToString(),
                                     PageCache.TableName_DAL,
                                     PageCache.TableName));
            }
            else
            {
                return(string.Empty);
            }
        }
        private static string CreateBatEditData(int action, List <SqlColumnInfo> colList, string table_name, string dal_name)
        {
            StringBuilder batEditContent    = new StringBuilder();
            StringBuilder createModel       = new StringBuilder();
            StringBuilder batEditStrContent = new StringBuilder();

            if ((action & (int)action_type.bat_edit) == (int)action_type.bat_edit)
            {
                batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtBatEdit{1});\r\n", colList.ToKeyId(), colList.ToKeyId());
                batEditContent.AppendFormat(@"           List<string> idList = {0}.Split(new char[]{{','}}, StringSplitOptions.RemoveEmptyEntries).ToList();{1}", colList.ToKeyId(), Environment.NewLine);
                batEditStrContent.AppendFormat("string txtBatEdit{0},", colList.ToKeyId());
                foreach (var item in colList.ToNotMainIdList())
                {
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        batEditContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(txtBatEdit{0});\r\n", item.Name);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            batEditContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", item.Name);
                            batEditContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", item.Name);
                        }
                        else
                        {
                            batEditContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", item.Name);
                            batEditContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", item.Name);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                    else
                    {
                        batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtBatEdit{1});\r\n", item.Name, item.Name);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }

                    batEditStrContent.AppendFormat("string txtBatEdit{0},", item.Name);
                }

                if (batEditStrContent.Length > 0)
                {
                    batEditStrContent.Remove(batEditStrContent.Length - 1, 1);
                }

                string template = @"
        [HttpPost]
        public ActionResult batedit({0})
        {{
{1}
            {2} model = new {2}();
            {3} dal = new {3}();
            dal.Update{4}(model);

            return new ContentResult() {{ Content = ""0"" }};
        }}
";

                return(string.Format(template,
                                     batEditStrContent.ToString(),
                                     batEditContent.ToString(),
                                     table_name,
                                     createModel.ToString(),
                                     dal_name,
                                     table_name));
            }
            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 3
0
        private static string CreateEditData()
        {
            StringBuilder editContent = new StringBuilder();
            StringBuilder createModel = new StringBuilder();
            var           editModel   = PageCache.GetCmd("编辑");

            if (editModel != null)
            {
                editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtEdit{1}\"]);\r\n", PageCache.KeyId, PageCache.KeyId);
                createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", PageCache.KeyId, ExtendMethod.ToStringToType(PageCache.KeyId, PageCache.KeyId_DbType));
                foreach (var item in editModel.AttrList)
                {
                    string attribute      = item.AttrName;
                    string eval_attribute = item.ColName;
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        editContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(Request[\"txtEdit{0}\"]);\r\n", attribute);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            editContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", attribute);
                            editContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", attribute);
                        }
                        else
                        {
                            editContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", attribute);
                            editContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", attribute);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", eval_attribute, ExtendMethod.ToStringToType_ExceptIntDate(attribute, item.DbType));
                    }
                    else
                    {
                        editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtEdit{1}\"]);\r\n", attribute, attribute);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", eval_attribute, ExtendMethod.ToStringToType_ExceptIntDate(attribute, item.DbType));
                    }
                }

                string template = @"
        private void EditData()
        {{
{0}
            {1} model = new {1}();
{2}
            {3} dal = new {3}();
            dal.Update{4}(model);

            Response.Write(""0"");
        }}
";

                return(string.Format(template,
                                     editContent.ToString(),
                                     PageCache.TableName_Model,
                                     createModel.ToString(),
                                     PageCache.TableName_DAL,
                                     PageCache.TableName));
            }
            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 4
0
        private static string CreateBatEditData()
        {
            StringBuilder batEditContent    = new StringBuilder();
            StringBuilder createModel       = new StringBuilder();
            StringBuilder batEditStrContent = new StringBuilder();
            var           batEditModel      = PageCache.GetCmd("批量编辑");

            if (batEditModel != null)
            {
                batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtBatEdit{1});\r\n", PageCache.KeyId, PageCache.KeyId);
                batEditContent.AppendFormat(@"           List<string> idList = {0}.Split(new char[]{{','}}, StringSplitOptions.RemoveEmptyEntries).ToList();{1}", PageCache.KeyId, Environment.NewLine);
                batEditStrContent.AppendFormat("string txtBatEdit{0},", PageCache.KeyId);
                foreach (var item in batEditModel.AttrList)
                {
                    string attribute      = item.AttrName;
                    string eval_attribute = item.ColName;
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        batEditContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(txtBatEdit{0});\r\n", attribute);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            batEditContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", attribute);
                            batEditContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", attribute);
                        }
                        else
                        {
                            batEditContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", attribute);
                            batEditContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", attribute);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", eval_attribute, ExtendMethod.ToStringToType_ExceptIntDate(attribute, item.DbType));
                    }
                    else
                    {
                        batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtBatEdit{1});\r\n", attribute, attribute);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", eval_attribute, ExtendMethod.ToStringToType_ExceptIntDate(attribute, item.DbType));
                    }

                    batEditStrContent.AppendFormat("string txtBatEdit{0},", attribute);
                }

                if (batEditStrContent.Length > 0)
                {
                    batEditStrContent.Remove(batEditStrContent.Length - 1, 1);
                }

                string template = @"
        [HttpPost]
        public ActionResult batedit({0})
        {{
{1}
            {2} model = new {2}();
            {3} dal = new {3}();
            dal.Update{4}(model);

            return new ContentResult() {{ Content = ""0"" }};
        }}
";

                return(string.Format(template,
                                     batEditStrContent.ToString(),
                                     batEditContent.ToString(),
                                     PageCache.TableName_Model,
                                     createModel.ToString(),
                                     PageCache.TableName_DAL,
                                     PageCache.TableName));
            }
            else
            {
                return(string.Empty);
            }
        }
        private static string CreateEditData(int action, List <SqlColumnInfo> colList, string table_name, string dal_name)
        {
            StringBuilder editContent    = new StringBuilder();
            StringBuilder createModel    = new StringBuilder();
            StringBuilder editStrContent = new StringBuilder();

            if ((action & (int)action_type.edit) == (int)action_type.edit)
            {
                editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtEdit{1});\r\n", colList.ToKeyId(), colList.ToKeyId());
                createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", colList.ToKeyId(), ExtendMethod.ToStringToType(colList.ToKeyId(), colList.ToKeyIdDbType()));
                editStrContent.AppendFormat("string txtEdit{0},", colList.ToKeyId());
                foreach (var item in colList.ToNotMainIdList())
                {
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        editContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(txtEdit{0});\r\n", item.Name);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            editContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", item.Name);
                            editContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", item.Name);
                        }
                        else
                        {
                            editContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", item.Name);
                            editContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", item.Name);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                    else
                    {
                        editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtEdit{1});\r\n", item.Name, item.Name);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }

                    editStrContent.AppendFormat("string txtEdit{0},", item.Name);
                }

                if (editStrContent.Length > 0)
                {
                    editStrContent.Remove(editStrContent.Length - 1, 1);
                }

                string template = @"
        [HttpPost]
        public ActionResult edit({0})
        {{
{1}
            {2} model = new {2}();
{3}
            {4} dal = new {4}();
            dal.Update{5}(model);

            return new ContentResult() {{ Content = ""0"" }};
        }}
";

                return(string.Format(template,
                                     editStrContent.ToString(),
                                     editContent.ToString(),
                                     table_name,
                                     createModel.ToString(),
                                     dal_name,
                                     table_name));
            }
            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 6
0
        private static string CreateEditData()
        {
            StringBuilder editContent    = new StringBuilder();
            StringBuilder createModel    = new StringBuilder();
            StringBuilder editStrContent = new StringBuilder();
            var           editModel      = PageCache.GetCmd("编辑");

            if (editModel != null)
            {
                editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtEdit{1});\r\n", PageCache.KeyId, PageCache.KeyId);
                createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", PageCache.KeyId, ExtendMethod.ToStringToType(PageCache.KeyId, PageCache.KeyId_DbType));
                editStrContent.AppendFormat("string txtEdit{0},", PageCache.KeyId);
                foreach (var item in editModel.AttrList)
                {
                    string attribute      = item.AttrName;
                    string eval_attribute = item.ColName;
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        editContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(txtEdit{0});\r\n", attribute);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            editContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", attribute);
                            editContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", attribute);
                        }
                        else
                        {
                            editContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", attribute);
                            editContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", attribute);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", eval_attribute, ExtendMethod.ToStringToType_ExceptIntDate(attribute, item.DbType));
                    }
                    else
                    {
                        editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtEdit{1});\r\n", attribute, attribute);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", eval_attribute, ExtendMethod.ToStringToType_ExceptIntDate(attribute, item.DbType));
                    }

                    editStrContent.AppendFormat("string txtEdit{0},", attribute);
                }

                if (editStrContent.Length > 0)
                {
                    editStrContent.Remove(editStrContent.Length - 1, 1);
                }

                string template = @"
        [HttpPost]
        public ActionResult edit({0})
        {{
{1}
            {2} model = new {2}();
{3}
            {4} dal = new {4}();
            dal.Update{5}(model);

            return new ContentResult() {{ Content = ""0"" }};
        }}
";

                return(string.Format(template,
                                     editStrContent.ToString(),
                                     editContent.ToString(),
                                     PageCache.TableName_Model,
                                     createModel.ToString(),
                                     PageCache.TableName_DAL,
                                     PageCache.TableName));
            }
            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 7
0
        private static string CreateEditData(int action, List <SqlColumnInfo> colList, string table_name, string model_name, string dal_name)
        {
            StringBuilder editContent = new StringBuilder();
            StringBuilder createModel = new StringBuilder();

            if ((action & (int)action_type.edit) == (int)action_type.edit)
            {
                editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtEdit{1}\"]);\r\n", colList.ToKeyId(), colList.ToKeyId());
                createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", colList.ToKeyId(), ExtendMethod.ToStringToType(colList.ToKeyId(), colList.ToKeyIdDbType()));
                var editList = Cache_VMData.GetVMList(table_name, VMType.Edit, colList.ToNotMainIdList());
                foreach (var item in editList)
                {
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        editContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(Request[\"txtEdit{0}\"]);\r\n", item.Name);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            editContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", item.Name);
                            editContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", item.Name);
                        }
                        else
                        {
                            editContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", item.Name);
                            editContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", item.Name);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                    else
                    {
                        editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtEdit{1}\"]);\r\n", item.Name, item.Name);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                }

                string template = @"
        private void EditData()
        {{
{0}
            {1} model = new {1}();
{2}
            {3} dal = new {3}();
            dal.Update{4}(model);

            Response.Write(""0"");
        }}
";

                return(string.Format(template,
                                     editContent.ToString(),
                                     model_name,
                                     createModel.ToString(),
                                     dal_name,
                                     table_name));
            }
            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 8
0
        private static string CreateAddData(int action, List <SqlColumnInfo> colList, string table_name, string dal_name)
        {
            StringBuilder addContent    = new StringBuilder();
            StringBuilder createModel   = new StringBuilder();
            StringBuilder addStrContent = new StringBuilder();

            if ((action & (int)action_type.add) == (int)action_type.add)
            {
                var addList = Cache_VMData.GetVMList(table_name, VMType.Add, colList.ToNotMainIdList());
                foreach (var item in addList)
                {
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        addContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(txtAdd{0});\r\n", item.Name);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            addContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", item.Name);
                            addContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", item.Name);
                        }
                        else
                        {
                            addContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", item.Name);
                            addContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", item.Name);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                    else
                    {
                        addContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(txtAdd{0});\r\n", item.Name);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }

                    addStrContent.AppendFormat("string txtAdd{0},", item.Name);
                }

                if (addStrContent.Length > 0)
                {
                    addStrContent.Remove(addStrContent.Length - 1, 1);
                }

                string template = @"
        [HttpPost]
        public ActionResult add({0})
        {{
{1}
            {2} model = new {2}();
{3}
            {4} dal = new {4}();
            dal.Add{5}(model);

            return new ContentResult() {{ Content = ""0"" }};
        }}
";

                return(string.Format(template,
                                     addStrContent.ToString(),
                                     addContent.ToString(),
                                     table_name,
                                     createModel.ToString(),
                                     dal_name,
                                     table_name));
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 9
0
        private static string CreateBatEditData(int action, List <SqlColumnInfo> colList, string table_name, string model_name, string dal_name)
        {
            StringBuilder batEditContent = new StringBuilder();
            StringBuilder createModel    = new StringBuilder();

            if ((action & (int)action_type.bat_edit) == (int)action_type.bat_edit)
            {
                batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtBatEdit{1}\"]);\r\n", colList.ToKeyId(), colList.ToKeyId());
                batEditContent.AppendFormat(@"           List<string> idList = {0}.Split(new char[]{{','}}, StringSplitOptions.RemoveEmptyEntries).ToList();{1}", colList.ToKeyId(), Environment.NewLine);
                foreach (var item in colList.ToNotMainIdList())
                {
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        batEditContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(Request[\"txtBatEdit{0}\"]);\r\n", item.Name);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            batEditContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", item.Name);
                            batEditContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", item.Name);
                        }
                        else
                        {
                            batEditContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", item.Name);
                            batEditContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", item.Name);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                    else
                    {
                        batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtBatEdit{1}\"]);\r\n", item.Name, item.Name);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                }

                string template = @"
        private void BatEditData()
        {{
{0}
            {1} model = new {1}();
{2}
            {3} dal = new {3}();
            dal.BatUpdate{4}(idList, model);

            Response.Write(""0"");
        }}
";

                return(string.Format(template,
                                     batEditContent.ToString(),
                                     model_name,
                                     createModel.ToString(),
                                     dal_name,
                                     table_name));
            }
            else
            {
                return(string.Empty);
            }
        }
Ejemplo n.º 10
0
        private static string CreateAddData(int action, List <SqlColumnInfo> colList, string table_name, string model_name, string dal_name)
        {
            StringBuilder addContent  = new StringBuilder();
            StringBuilder createModel = new StringBuilder();

            if ((action & (int)action_type.add) == (int)action_type.add)
            {
                foreach (var item in colList.ToNotMainIdList())
                {
                    if (item.DbType.ToLower() == "datetime" ||
                        item.DbType.ToLower() == "date" ||
                        item.DbType.ToLower() == "int" ||
                        item.DbType.ToLower() == "bigint" ||
                        item.DbType.ToLower() == "tinyint")
                    {
                        addContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(Request[\"txtAdd{0}\"]);\r\n", item.Name);
                        if (item.DbType.ToLower() == "datetime" || item.DbType.ToLower() == "date")
                        {
                            addContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", item.Name);
                            addContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", item.Name);
                        }
                        else
                        {
                            addContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", item.Name);
                            addContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", item.Name);
                        }

                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                    else
                    {
                        addContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtAdd{0}\"]);\r\n", item.Name);
                        createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", item.Name, ExtendMethod.ToStringToType_ExceptIntDate(item.Name, item.DbType));
                    }
                }

                string template = @"
        private void AddData()
        {{
{0}
            {1} model = new {1}();
{2}
            {3} dal = new {3}();
            dal.Add{4}(model);

            Response.Write(""0"");
        }}
";

                return(string.Format(template,
                                     addContent.ToString(),
                                     model_name,
                                     createModel.ToString(),
                                     dal_name,
                                     table_name));
            }
            else
            {
                return("");
            }
        }