Exemplo n.º 1
0
        //private static string basePath = ConfigurationSettings.AppSettings["Dbf"].ToString();

        /// <summary>
        /// 打开Dbf文件
        /// </summary>
        /// <param name="dbfFile">Dbf文件</param>
        /// <returns></returns>
        public static DataTable OpenDbfFile(string date)
        {
            string tabel = "";// AkConfig.DbfBasePath + date + @"\GNDITEM.Dbf";

            if (!File.Exists(tabel))
            {
                return(null);
            }

            DataTable dt      = null;
            DBFFile   dbfFile = new DBFFile(tabel);

            try
            {
                dbfFile.Open();
                dt = dbfFile.GetDataSet().Tables[0];
            }
            catch (Exception er)
            {
                LogHelper.Error(typeof(DbfHelper) + ".OpenDbfFile Exception error=", er.ToString());
            }
            finally
            {
                dbfFile.Close();
            }
            return(dt);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 读取历史数据
        /// </summary>
        /// <param name="dbfFile">Dbf文件</param>
        /// <returns></returns>
        public static DataTable OpenDbfFile(string date)
        {
            if (string.IsNullOrEmpty(AkConfig.AkDir))
            {
                return(null);
            }

            string table = string.Empty;

            if (string.IsNullOrEmpty(date))
            {
                table = Path.Combine(AkConfig.AkDir, @"DATA\GNDSALE.Dbf");
            }
            else
            {
                table = Path.Combine(AkConfig.AkDir, date + @"\GNDSALE.Dbf");
            }

            if (!File.Exists(table))
            {
                return(null);
            }

            DataTable dt      = null;
            DBFFile   dbfFile = new DBFFile(table);

            try
            {
                dbfFile.Open();
                dt = dbfFile.GetDataSet().Tables[0];
            }
            catch (Exception er)
            {
                LogHelper.Error(typeof(DbfHelper) + ".OpenDbfFile Exception error=", er.ToString());
            }
            finally
            {
                dbfFile.Close();
            }
            return(dt);
        }