Exemplo n.º 1
0
        /// <summary>
        /// Method that creates a temp table
        /// </summary>
        /// <param name="campos">Filed on the table</param>
        /// <returns>True - Table Created; False - Impossible to create the table</returns>
        public static bool CreateTempTable(List <DAO.MDN_Campo> campos)
        {
            bool retorno = true;

            try
            {
                MDN_Table tabela = new MDN_Table(Util.Global.tempTable);
                tabela.Fields_Table = campos;

                if (tabela.ExistsTable())
                {
                    tabela.DeleteTable();
                    tabela.VerificaColunas();
                }
                else
                {
                    tabela.CreateTable(false);
                }
            }
            catch (Exception e)
            {
                Util.CL_Files.WriteOnTheLog("Error: " + e.Message, Util.Global.TipoLog.SIMPLES);
                retorno = false;
            }

            return(retorno);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method that create the dictionary of the table
        /// </summary>
        public void FillLib()
        {
            MDN_Table table = new MDN_Table("TABELAS");

            table.Fields_Table.Add(new MDN_Campo("TAB", true, Util.Enumerator.DataType.STRING, null, true, true, 40, 0));
            table.Fields_Table.Add(new MDN_Campo("FIELD", true, Util.Enumerator.DataType.STRING, null, true, true, 25, 0));
            table.Fields_Table.Add(new MDN_Campo("TYPE", true, Util.Enumerator.DataType.CHAR, null, true, true, 1, 0));
            table.Fields_Table.Add(new MDN_Campo("SIZE", true, Util.Enumerator.DataType.INT, null, true, true, 1, 0));
            table.Fields_Table.Add(new MDN_Campo("PREC", true, Util.Enumerator.DataType.INT, null, true, true, 1, 0));
            table.Fields_Table.Add(new MDN_Campo("FLAG", true, Util.Enumerator.DataType.INT, null, true, true, 1, 0));
            if (!table.ExistsTable())
            {
                table.CreateTable(false);
            }
            table.VerificaColunas();

            string insert_base = "INSERT INTO TABELAS (tab,field,type,size,prec,flags) VALUES (";
            int    i           = fields_Table.Count;

            foreach (MDN_Campo field in fields_Table)
            {
                string insert = insert_base + "'" + this.Table_Name + "'";
                insert += ", '" + field.Name_Field + "'";
                switch (field.Type)
                {
                case Util.Enumerator.DataType.CHAR:
                    insert += ",'C'";
                    break;

                case Util.Enumerator.DataType.STRING:
                    insert += ",'C'";
                    break;

                case Util.Enumerator.DataType.DATE:
                    insert += ",'T'";
                    break;

                case Util.Enumerator.DataType.DECIMAL:
                    insert += ",'F'";
                    break;

                case Util.Enumerator.DataType.INT:
                    insert += ",'I'";
                    break;
                }
                insert += "," + field.Size;
                insert += "," + field.Precision;
                insert += ",0)";

                DataBase.Connection.Insert(insert);
            }
        }