예제 #1
0
        protected void ParseUpdateQuery()
        {
            DataColumnCollection cols;
            TableEntity          te;
            string pv, sql;
            string tb = FormatFieldName(Form["tb"]);
            string pk = Form["pk"];

            te = new TableEntity(tb, Database);
            DataRow dr = te.GetNewRow();

            cols = te.GetColumns();
            pv   = Form["fld_" + pk];
            foreach (DataColumn col in cols)
            {
                string v = Form["fld_" + col.ColumnName];
                if (!string.IsNullOrEmpty(v))
                {
                    string rlt;
                    te.MakeFieldSql(col.ColumnName, v, out rlt, false, false);
                    dr[col.ColumnName] = rlt;
                }
            }
            sql = te.MakeUpdateSql(dr, te.MakeOpSql(pk, pv), true, false);
            Sql = sql;
        }
예제 #2
0
        private string GenerateTableCode(List <TableControl> tables)
        {
            StringBuilder sb = new StringBuilder();

            int i = 0;

            foreach (TableControl t in tables)
            {
                i++;

                TableEntity te = t.GetTableEntity();

                if (te.GetSchema() == null)
                {
                    sb.AppendLine("CREATE TABLE " + te.GetName());
                }
                else
                {
                    sb.AppendLine("CREATE TABLE " + te.GetSchema() + "." + te.GetName());
                }
                sb.AppendLine("(");

                foreach (ColumnEntity ce in te.GetColumns())
                {
                    sb.Append("\t" + ce.GetColumnName() + "\t\t" + ce.GetColumnType() + "(" + ce.GetColumnLength() + ")");
                    if (i == tables.Count)
                    {
                        sb.AppendLine();
                    }
                    else
                    {
                        sb.AppendLine(",");
                    }
                }

                sb.AppendLine(");\n\n / \n\n");
            }

            return(sb.ToString());
        }