Beispiel #1
0
        public static Dictionary <string, object> CreateParam(DBProcedure procedure, DBItem document = null)
        {
            var parameters = DBProcedure.CreateParams(document);

            CheckParam(procedure, parameters);
            return(parameters);
        }
Beispiel #2
0
        public void BuildParameters()
        {
            parameters = DBProcedure.CreateParams(document);
            //Clear Fields
            foreach (var field in fields)
            {
                Tools.Items.Remove(field);
                field.Dispose();
            }
            fields.Clear();

            DBItem row = null;

            foreach (var param in procedure.Parameters)
            {
                if (!parameters.ContainsKey(param.Name))
                {
                    //New temporary table
                    if (table == null || table.Name != (procedure.Name + "Param"))
                    {
                        if (table != null)
                        {
                            table.Dispose();
                        }
                        table = new DBTable <DBItem>(procedure.Name + "Param")
                        {
                            Schema    = procedure.Schema,
                            BlockSize = 1
                        };
                    }
                    if (row == null)
                    {
                        row = table.NewItem();
                    }

                    DBColumn col = new DBColumn
                    {
                        Name  = !string.IsNullOrEmpty(param.Name) ? param.Name : "NewParam",
                        Table = table
                    };
                    if (param.Column != null)
                    {
                        if (param.Column.IsPrimaryKey)
                        {
                            col.ReferenceTable = param.Column.Table;
                        }
                        if (param.Column.IsReference)
                        {
                            col.ReferenceTable = param.Column.ReferenceTable;
                        }
                    }
                    col.DataType = param.DataType;
                    table.Columns.Add(col);

                    var tool = new ToolDataFieldEditor
                    {
                        FieldWidth = col.ReferenceTable != null ? 150 : 80,
                        Visible    = true
                    };
                    tool.Field.LabelSize = -1;
                    tool.Field.BindData(row, col.Name);

                    fields.Add(tool);
                    Tools.Add(tool);
                }
            }
            if (Query == null || Query.Name != procedure.Name)
            {
                var commnad = procedure.BuildCommand(parameters);
                SetCommand(commnad, procedure.Schema, procedure.Name);
            }
            procedure.UpdateCommand(command, parameters);
        }