コード例 #1
0
        private static bool FindLasestVersionForTable(string sPartNumber, string sTableName, ref string sVersion)
        {
            string sConn             = @"Data Source=\\BOA\Production\Prodman.vfp\DATABASE\" + sTableName + ".dbf;" + @"Provider=VFPOLEDB.1;";
            string sFormattedPartNum = AmcDataConnection.QUOTE + sPartNumber + AmcDataConnection.QUOTE;

            AmcDataConnection vfpTempConn = new AmcDataConnection()
            {
                DataBaseType     = (int)dbType.vfp,
                TableName        = sTableName,
                ConnectionString = sConn
            };

            if (vfpTempConn.ConnectToDatabase())
            {
                string          sSelectSql = "select top 1 partnumber, version from " + vfpTempConn.TableName + " where Partnumber" + " = " + sFormattedPartNum + " ORDER BY version descending";
                OleDbCommand    cmdSelect  = new OleDbCommand(sSelectSql, vfpTempConn.GetOleConn());
                OleDbDataReader rdr        = cmdSelect.ExecuteReader();

                if (rdr.HasRows)
                {
                    rdr.Read();

                    sVersion = rdr["version"].ToString();

                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public static string GetPartNumberTable(string sPartNumber, string sVersion)
        {
            AmcDataConnection vfpTempConn = new AmcDataConnection(dbType.vfp);

            string sFormattedPartNum = AmcDataConnection.QUOTE + sPartNumber + AmcDataConnection.QUOTE;
            string sFormattedVersion = AmcDataConnection.QUOTE + sVersion + AmcDataConnection.QUOTE;
            string sWhere            = "Partnumber" + " = " + sFormattedPartNum + "and Version = " + sFormattedVersion;
            string sdbName           = "beta.dbf";

            bool bFound = false;
            int  i;

            for (i = 0; i < 4; i++)
            {
                if (i == 0)
                {
                    sdbName = "beta.dbf";
                }
                else if (i == 1)
                {
                    sdbName = "current.dbf";
                }
                else if (i == 2)
                {
                    sdbName = "proto.dbf";
                }
                else if (i == 3)
                {
                    sdbName = "history.dbf";
                }

                vfpTempConn.connect(sdbName);

                string sSelectSql = "select partnumber from ";
                sSelectSql += sdbName + " where " + sWhere;
                OleDbCommand cmdSelect = new OleDbCommand(sSelectSql, vfpTempConn.GetConn());

                OleDbDataReader rdr = cmdSelect.ExecuteReader();

                rdr.Read();

                if (rdr.HasRows)
                {
                    bFound = true;

                    break;
                }
            } // ja - end loop

            if (!bFound)
            {
                sdbName = "";
            }

            return(sdbName);
        }
コード例 #3
0
ファイル: DBWorks.cs プロジェクト: jasonmacleanamc/Common
        public bool InitializeDatabase()
        {
            if (String.IsNullOrWhiteSpace(KeyIdentifier))
            {
                return(false);
            }

            _dbConn = new AmcDataConnection()
            {
                ConnectionString = ConnectionString,
                TableName        = TableName,
                DataBaseType     = DataBaseType,
                KeyIdentifier    = KeyIdentifier,
                KeyValue         = KeyValue,
                WhereClause      = GetWhereSQL()
            };

            //_dbConn.WhereClause = GetWhereSQL() + AddVersionToWhere();

            // ja - connect to a table
            if (!_dbConn.ConnectToDatabase())
            {
                return(false);
            }

            AddColumns();

            if (_ColumnNames.Count > 0)
            {
                Found = _dbConn.FillTable(_ColumnNames);
            }
            else
            {
                Found = _dbConn.FillTable();
            }

            return(true);
        }
コード例 #4
0
        public bool InitializeDatabase()
        {
            // ja - use reflection to get values from the base class
            //DataBaseType = Convert.ToInt32(this.GetType().GetField("nDATABASE_TYPE", BindingFlags.Public | BindingFlags.Instance).GetValue(this).ToString());
            //ConnectionString = this.GetType().GetField("CONNECTION_STRING", BindingFlags.Public | BindingFlags.Instance).GetValue(this).ToString();

            // ja - init the connection object
            //_dbConn = new AmcDataConnection((dbType)DataBaseType);

            _dbConn = new AmcDataConnection()
            {
                ConnectionString = ConnectionString,
                TableName        = TableName,
                DataBaseType     = DataBaseType
            };

            // ja - connect to a table
            if (!_dbConn.__ConnectToDB())
            {
                return(false);
            }

            // ja - call local function to populate the data in the string global array
            // TODO: ja - Move to object
            _sdbValues = ReadData();


            if (String.IsNullOrEmpty(_sdbValues[0]))
            {
                return(false);
            }

            _bIsFound = true;

            return(true);
        }
コード例 #5
0
 public UpdateTables(AmcDataConnection dbConn, Dictionary <string, string> setParams)
 {
     _dbConn  = dbConn;
     SetPairs = setParams;
 }