Exemple #1
0
        public int AddDyncForm(SQLDynamicRow sQLDynamicRow, string tblName)
        {
            var model = sQLDynamicRow.Row.ToList();

            model.Add(new SQLDynamicItem()
            {
                Name  = "[Updatetime]",
                Value = DateTime.UtcNow.ToString("yyyy-MM-dd hh:ss")
            });

            var key   = new StringBuilder();
            var value = new StringBuilder();

            foreach (var item in model)
            {
                key.Append(item.Name + ",");
                if (item.Type == "number")
                {
                    value.Append("" + item.Value + ",");
                }
                else
                {
                    value.Append("'" + item.Value + "',");
                }
            }
            var sql = $"insert into [{tblName}]({key.ToString().TrimEnd(',')}) values ({value.ToString().TrimEnd(',')})";

            LogUtil.InfoFormat(sql);
            return(_dbHelper.ExecuteNonQueryTp(sql));
        }
Exemple #2
0
        public int UpdateDyncForm(SQLDynamicRow sQLDynamicRow, string tblName, int id)
        {
            var model = sQLDynamicRow.Row.ToList();

            model.Add(new SQLDynamicItem()
            {
                Name  = "[Updatetime]",
                Value = DateTime.UtcNow.ToString("yyyy-MM-dd hh:ss")
            });
            var content = new StringBuilder();

            foreach (var item in model)
            {
                if (item.Type == "number")
                {
                    content.Append("" + item.Name + "=" + item.Value + ",");
                }
                else
                {
                    content.Append("" + item.Name + "='" + item.Value + "',");
                }
            }
            var sql = $"update [{tblName}] set {content.ToString().TrimEnd(',')} where id={id}";

            LogUtil.InfoFormat(sql);
            return(_dbHelper.ExecuteNonQueryTp(sql));
        }