Exemple #1
0
        public ActionResult AddData(string tabName, FormCollection form)
        {
            var           tabInfo = TableInfoHelper.GetTableInfo(_tableInfoService, tabName);
            var           keys    = form.AllKeys;
            StringBuilder sb      = new StringBuilder();

            foreach (string colName in keys)
            {
                var name      = colName;
                var colConfig = tabInfo.ColumnInfos.SingleOrDefault(c => c.Name == name);
                if (colConfig != null)
                {
                    sb.AppendLine(string.Format("declare @{0} {1};", colConfig.Name, colConfig.Type));
                    if (colConfig.FormItemType == FormItemType.Double ||
                        colConfig.FormItemType == FormItemType.Money ||
                        colConfig.FormItemType == FormItemType.Number)
                    {
                        sb.AppendLine(string.Format("set @{0} = {1};", colConfig.Name, form[colName]));
                    }
                    else
                    {
                        sb.AppendLine(string.Format("set @{0} = '{1}';", colConfig.Name, form[colName]));
                    }
                }
                else
                {
                    form.Remove(colName);
                }
            }

            string fields = "";
            string values = "";

            form.AllKeys.ForEach(key =>
            {
                fields += string.Format("[{0}],", key);
                values += string.Format("@{0},", key);
            });
            fields = fields.Substring(0, fields.Length - 1);
            values = values.Substring(0, values.Length - 1);

            sb.AppendLine(string.Format("insert into [{0}] ({1}) values({2})", tabName, fields, values));
            string sql = sb.ToString();

            SqlHelper.ExecuteNonQuery(sql);
            return(RedirectToAction("AddData", new { tabName = tabName }));
        }
Exemple #2
0
 public QueryWrapper(T entity)
 {
     base.entity     = entity;
     base.entityType = entity.GetType();
     base.tableInfo  = TableInfoHelper.GetTableInfo(base.entityType);
 }
Exemple #3
0
        public ActionResult AddData(string tabName)
        {
            var tabInfo = TableInfoHelper.GetTableInfo(_tableInfoService, tabName);

            return(View(tabInfo));
        }