예제 #1
0
        /// <summary>
        /// Method that make the creation of the table
        /// </summary>
        /// <param name="delete">Identify if delete the values on the table if it exists</param>
        /// <param name="num_lines">Number of lines to be fill on the table if 'fill' is true</param>
        public StringBuilder CreateTable(bool delete)
        {
            if (delete)
            {
                this.DeleteTable();
            }

            StringBuilder command = new StringBuilder();

            command.AppendLine("CREATE TABLE " + this.Table_Name + " (");
            int qt = fields_Table.Count, i = 0;

            foreach (MDN_Campo field in fields_Table)
            {
                i++;
                command.AppendLine(field.InsertFieldDataBase() + (i != qt ? ", " : ""));
            }

            string primary = CreateCommandPrimaryKey();

            if (!string.IsNullOrEmpty(primary))
            {
                command.AppendLine(", " + primary);
            }

            command.AppendLine(")");

            if (!ExistsTable())
            {
                DataBase.Connection.CreateTable(command.ToString());
                data_table.Clear();
                foreach (MDN_Campo field in fields_Table)
                {
                    data_table.Columns.Add(new DataColumn(field.Name_Field));
                }

                if (!Table_Name.Equals("TABELAS"))
                {
                    FillLib();
                }
            }

            return(command);
        }
예제 #2
0
        /// <summary>
        /// Method that make the creation of the table
        /// </summary>
        /// <param name="delete">Identify if delete the values on the table if it exists</param>
        /// <param name="num_lines">Number of lines to be fill on the table if 'fill' is true</param>
        public void CreateTable(bool delete)
        {
            if (delete)
            {
                this.DeleteTable();
            }

            if (!ExistsTable())
            {
                string command = "CREATE TABLE " + this.Table_Name + " (";
                int    qt = fields_Table.Count, i = 0;
                foreach (MDN_Campo field in fields_Table)
                {
                    i++;
                    command += field.InsertFieldDataBase() + (i != qt ? ", " : "");
                }

                string primary = CreateCommandPrimaryKey();
                if (!string.IsNullOrEmpty(primary))
                {
                    command += ", " + primary;
                }

                command += ")";

                Util.DataBase.CreateTable(command);
            }

            data_table.Clear();
            foreach (MDN_Campo field in fields_Table)
            {
                data_table.Columns.Add(new DataColumn(field.Name_Field));
            }

            if (!Table_Name.Equals("LDXED"))
            {
                //FillLib();
            }
        }