Exemplo n.º 1
0
        public void updateTextBox(string protocol, fieldType field, string value)
        {
            string txtBxName = protocol + "_" + field.ToString() + "_textBox";

            Control[] controls = this.Controls.Find(txtBxName, true);
            TextBox   txtBox   = controls[0] as TextBox;

            if (txtBox != null)
            {
                txtBox.Text = value;
            }
        }
Exemplo n.º 2
0
        public override string val_toqry(string value, fieldType coltype, dbType type, string nullstr = null, bool add_operator = false, bool tostring = false)
        {
            if (value == null || (nullstr != null && value == nullstr))
            {
                return((add_operator ? " IS " : "") + "NULL");
            }

            string op = add_operator ? " = " : "", ap = !tostring ? "'" : "";

            if (coltype == fieldType.DATETIME)
            {
                return(op + ap + DateTime.Parse(value).ToString(_dateFormatToQuery) + ap);
            }
            else if (coltype == fieldType.DATETIME2)
            {
                return(op + ap + DateTime.Parse(value).ToString(_dateFormatToQuery2) + ap);
            }
            else if (coltype == fieldType.INTEGER || coltype == fieldType.LONG ||
                     coltype == fieldType.SINGLE || coltype == fieldType.SMALLINT)
            {
                return(op + value);
            }
            else if (coltype == fieldType.CHAR || coltype == fieldType.TEXT || coltype == fieldType.VARCHAR)
            {
                return(op + ap + value.Replace("'", "''") + ap);
            }
            else if (coltype == fieldType.XML)
            {
                return(op + ap + value.Replace("'", "''") + ap);
            }
            else if (coltype == fieldType.BOOL)
            {
                return(op + (bool.Parse(value) ? "1" : "0"));
            }
            else if (coltype == fieldType.DECIMAL || coltype == fieldType.DOUBLE || coltype == fieldType.MONEY)
            {
                return(op + value.Replace(",", "."));
            }
            else
            {
                throw new Exception("tipo di dati '" + coltype.ToString() + "' non supportato per l'importazione dei dati");
            }
        }
Exemplo n.º 3
0
        public override string val_toqry(string value, fieldType coltype, dbType type, string nullstr = null, bool add_operator = false, bool tostring = false)
        {
            if (value == null || (nullstr != null && value == nullstr))
            {
                return((add_operator ? " IS " : "") + "NULL");
            }

            string op = add_operator ? " = " : "", ap = !tostring ? "'" : "";

            if (coltype == fieldType.DATETIME)
            {
                return(op + "Format(#" + DateTime.Parse(value).ToString("yyyy/MM/dd HH:mm:ss") + "#, \"yyyy/mm/dd hh:nn:ss\")");
            }
            else if (coltype == fieldType.INTEGER || coltype == fieldType.LONG ||
                     coltype == fieldType.SMALLINT)
            {
                return(op + value);
            }
            else if (coltype == fieldType.CHAR || coltype == fieldType.VARCHAR ||
                     coltype == fieldType.TEXT)
            {
                return(op + ap + (!tostring ? value.Replace("'", "''") : value) + ap);
            }
            else if (coltype == fieldType.BOOL)
            {
                return(op + (bool.Parse(value) ? "True" : "False"));
            }
            else if (coltype == fieldType.DOUBLE || coltype == fieldType.SINGLE ||
                     coltype == fieldType.DECIMAL || coltype == fieldType.MONEY)
            {
                return(op + value.Replace(",", "."));
            }
            else
            {
                throw new Exception("tipo di dati '" + coltype.ToString() + "' non supportato per l'importazione dei dati");
            }
        }
Exemplo n.º 4
0
        static public string getFieldAccess(string name, fieldType type, string numprec, string numscale, string maxlength, bool nullable, string defaultval, bool autonumber)
        {
            string sql = "[" + name + "]";

            if (autonumber)
            {
                sql += " AUTOINCREMENT";
            }
            else if (type == fieldType.BINARY)
            {
                sql += " BINARY";
            }
            else if (type == fieldType.BOOL)
            {
                sql += " BIT";
            }
            else if (type == fieldType.SMALLINT)
            {
                sql += " SMALLINT";
            }
            else if (type == fieldType.MONEY)
            {
                sql += " MONEY";
            }
            else if (type == fieldType.DATETIME)
            {
                sql += " DATETIME";
            }
            else if (type == fieldType.GUID)
            {
                sql += " UNIQUEIDENTIFIER";
            }
            else if (type == fieldType.DOUBLE)
            {
                sql += " DOUBLE";
            }
            else if (type == fieldType.SINGLE)
            {
                sql += " SINGLE";
            }
            else if (type == fieldType.INTEGER)
            {
                sql += " INTEGER";
            }
            else if (type == fieldType.LONG)
            {
                sql += " LONG";
            }
            else if (type == fieldType.DECIMAL)
            {
                sql += " DECIMAL(" + numprec + ", " + numscale + ")";
            }
            else if (type == fieldType.VARCHAR || type == fieldType.CHAR)
            {
                if (maxlength == "0")
                {
                    sql += " MEMO";
                }
                else
                {
                    sql += " VARCHAR(" + (maxlength == "-1" ? "255" : maxlength) + ")";
                }
            }
            else
            {
                throw new Exception("il campo '" + type.ToString() + "' di access non viene gestito per l'aggiornamento struttura tabelle");
            }

            if (defaultval != "")
            {
                sql += " DEFAULT " + defaultval;
            }
            if (!nullable)
            {
                sql += " NOT NULL";
            }

            return(sql);
        }
Exemplo n.º 5
0
        public static string typeToOriginal(dbType typeDb, fieldType type)
        {
            if (typeDb == dbType.access)
            {
                if (type == fieldType.BINARY)
                {
                    return("binary");
                }
                else if (type == fieldType.BOOL)
                {
                    return("boolean");
                }
                else if (type == fieldType.MONEY)
                {
                    return("currency");
                }
                else if (type == fieldType.DATETIME)
                {
                    return("date");
                }
                else if (type == fieldType.GUID)
                {
                    return("guid");
                }
                else if (type == fieldType.DOUBLE)
                {
                    return("double");
                }
                else if (type == fieldType.SINGLE)
                {
                    return("single");
                }
                else if (type == fieldType.SMALLINT)
                {
                    return("smallint");
                }
                else if (type == fieldType.INTEGER)
                {
                    return("integer");
                }
                else if (type == fieldType.DECIMAL)
                {
                    return("decimal");
                }
                else if (type == fieldType.VARCHAR)
                {
                    return("varchar");
                }
                else if (type == fieldType.CHAR)
                {
                    return("char");
                }
            }
            else if (typeDb == dbType.sqlserver)
            {
                if (type == fieldType.BINARY)
                {
                    return("varbinary");
                }
                else if (type == fieldType.BOOL)
                {
                    return("bit");
                }
                else if (type == fieldType.MONEY)
                {
                    return("money");
                }
                else if (type == fieldType.DATETIME)
                {
                    return("datetime");
                }
                else if (type == fieldType.DATETIME2)
                {
                    return("datetime2");
                }
                else if (type == fieldType.DOUBLE)
                {
                    return("float");
                }
                else if (type == fieldType.SMALLINT)
                {
                    return("smallint");
                }
                else if (type == fieldType.INTEGER)
                {
                    return("int");
                }
                else if (type == fieldType.LONG)
                {
                    return("bigint");
                }
                else if (type == fieldType.DECIMAL)
                {
                    return("decimal");
                }
                else if (type == fieldType.VARCHAR)
                {
                    return("varchar");
                }
                else if (type == fieldType.CHAR)
                {
                    return("char");
                }
                else if (type == fieldType.TEXT)
                {
                    return("text");
                }
                else if (type == fieldType.XML)
                {
                    return("xml");
                }
            }

            throw new Exception("type field '" + type.ToString() + "' not supported for '" + typeDb.ToString() + "'");
        }
Exemplo n.º 6
0
        public static string type_to_original(dbType type_db, fieldType type)
        {
            if (type_db == dbType.access)
            {
                if (type == fieldType.BINARY)
                {
                    return("binary");
                }
                else if (type == fieldType.BOOL)
                {
                    return("boolean");
                }
                else if (type == fieldType.MONEY)
                {
                    return("currency");
                }
                else if (type == fieldType.DATETIME)
                {
                    return("date");
                }
                else if (type == fieldType.GUID)
                {
                    return("guid");
                }
                else if (type == fieldType.DOUBLE)
                {
                    return("double");
                }
                else if (type == fieldType.SINGLE)
                {
                    return("single");
                }
                else if (type == fieldType.SMALLINT)
                {
                    return("smallint");
                }
                else if (type == fieldType.INTEGER)
                {
                    return("integer");
                }
                else if (type == fieldType.DECIMAL)
                {
                    return("decimal");
                }
                else if (type == fieldType.VARCHAR)
                {
                    return("varchar");
                }
                else if (type == fieldType.CHAR)
                {
                    return("char");
                }
            }
            else if (type_db == dbType.sqlserver)
            {
                if (type == fieldType.BINARY)
                {
                    return("varbinary");
                }
                else if (type == fieldType.BOOL)
                {
                    return("bit");
                }
                else if (type == fieldType.MONEY)
                {
                    return("money");
                }
                else if (type == fieldType.SMALLDATETIME)
                {
                    return("smalldatetime");
                }
                else if (type == fieldType.VARIANT)
                {
                    return("sql_variant");
                }
                else if (type == fieldType.TIMESTAMP)
                {
                    return("timestamp");
                }
                else if (type == fieldType.DATE)
                {
                    return("date");
                }
                else if (type == fieldType.DATETIME)
                {
                    return("datetime");
                }
                else if (type == fieldType.DOUBLE)
                {
                    return("float");
                }
                else if (type == fieldType.SMALLINT)
                {
                    return("smallint");
                }
                else if (type == fieldType.INTEGER)
                {
                    return("int");
                }
                else if (type == fieldType.LONG)
                {
                    return("bigint");
                }
                else if (type == fieldType.DECIMAL)
                {
                    return("decimal");
                }
                else if (type == fieldType.VARCHAR)
                {
                    return("varchar");
                }
                else if (type == fieldType.CHAR)
                {
                    return("char");
                }
                else if (type == fieldType.TEXT)
                {
                    return("text");
                }
                else if (type == fieldType.IMAGE)
                {
                    return("image");
                }
                else if (type == fieldType.XML)
                {
                    return("xml");
                }
                else if (type == fieldType.GUID)
                {
                    return("uniqueidentifier");
                }
            }
            else if (type_db == dbType.mysql)
            {
                if (type == fieldType.BINARY)
                {
                    return("varbinary");
                }
                else if (type == fieldType.BOOL)
                {
                    return("bit");
                }
                else if (type == fieldType.MONEY)
                {
                    return("decimal");
                }
                else if (type == fieldType.DATETIME)
                {
                    return("datetime");
                }
                else if (type == fieldType.DOUBLE)
                {
                    return("double");
                }
                else if (type == fieldType.SMALLINT)
                {
                    return("smallint");
                }
                else if (type == fieldType.INTEGER)
                {
                    return("int");
                }
                else if (type == fieldType.LONG)
                {
                    return("bigint");
                }
                else if (type == fieldType.DECIMAL)
                {
                    return("decimal");
                }
                else if (type == fieldType.VARCHAR)
                {
                    return("varchar");
                }
                else if (type == fieldType.CHAR)
                {
                    return("char");
                }
                else if (type == fieldType.TEXT)
                {
                    return("text");
                }
                else if (type == fieldType.XML)
                {
                    return("varchar");
                }
            }
            else if (type_db == dbType.odbc)
            {
                if (type == fieldType.VARCHAR)
                {
                    return("System.String");
                }
                else if (type == fieldType.DOUBLE)
                {
                    return("System.Double");
                }
                else if (type == fieldType.DATETIME)
                {
                    return("System.DateTime");
                }
                else if (type == fieldType.BOOL)
                {
                    return("System.Boolean");
                }
            }

            throw new Exception("type field '" + type.ToString() + "' not supported for '" + type_db.ToString() + "'");
        }