예제 #1
0
        /// <summary>
        /// 获取数据库 数据
        /// </summary>
        /// <param name="whichMethod">那种方法</param>
        /// <returns></returns>
        public DataTable GetDataFromDb(string dbName, string tableName, GetDataWhichMethod WhichMethod, int LastNumOfExpect, DateTime StartDateTime, DateTime EndDateTime, int StartExpect, int EndExpect)
        {
            string sqlString = "";

            if (WhichMethod == GetDataWhichMethod._根据最近期数获取)
            {
                sqlString = $"select pc28,opentime as 日期,expect as 期号 from {tableName} order by  expect desc" + $" limit {LastNumOfExpect}";
            }
            if (WhichMethod == GetDataWhichMethod._根据日期获取)
            {
                sqlString = $"select pc28,opentime as 日期,expect as 期号 from {tableName} where opentime between '" + StartDateTime.ToString("yyyy-MM-dd") + "' and '" + EndDateTime.AddDays(1).ToString("yyyy-MM-dd") + "'" + "order by  expect desc";
            }
            if (WhichMethod == GetDataWhichMethod._根据期号获取)
            {
                if (EndExpect == 0 || EndExpect <= StartExpect)
                {
                    sqlString = $"select pc28,opentime as 日期,expect as 期号 from {tableName} where expect >= {StartExpect} " + "order by  expect desc";
                }
                else
                {
                    sqlString = $"select pc28,opentime as 日期,expect as 期号 from {tableName} where expect >= {StartExpect} and expect <= {EndExpect} " + "order by  expect desc";
                }
            }
            // 获取数据库pc28数据
            DataTable dbDataTable = Sqlite3Helper.GetDs(dbName, sqlString, tableName).Tables[tableName];

            // 更新字段 并且 返回
            return(dbDataTable);
        }
예제 #2
0
        // 查找
        private void Button_search_Click(object sender, EventArgs e)
        {
            // "SELECT distinct(date(shiJian)) FROM " + type
            string tablename = currentUpdate;
            string command   = "SELECT distinct(date(opentime)) as 日期 FROM " + tablename;

            gridControl_search.DataSource = Sqlite3Helper.GetDs(dbfilePath, command, tablename).Tables[tablename];
        }
예제 #3
0
        /// <summary>
        /// 根据 开始日期 和 结束日期 获取数据
        /// </summary>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <returns></returns>
        public static DataTable GetDataFromDb(DateTime startDate, DateTime endDate)
        {
            string sqlString = $"select pc28,opentime as 日期,expect as 期号 from {TableName} where opentime between '" + startDate.ToString("yyyy-MM-dd") + "' and '" + endDate.AddDays(1).ToString("yyyy-MM-dd") + "'" + "order by  expect desc";
            // 获取数据库pc28数据
            DataTable dbDataTable = Sqlite3Helper.GetDs(Properties.Settings.Default.dbName, sqlString, TableName).Tables[TableName];

            // 更新字段 并且 返回
            return(dbDataTable);
        }
예제 #4
0
        /// <summary>
        /// 根据最近期号获取数据
        /// </summary>
        /// <param name="lastNumOfExpect"></param>
        /// <returns></returns>
        public static DataTable GetDataFromDb(int lastNumOfExpect)
        {
            string sqlString = $"select pc28,opentime as 日期,expect as 期号 from {TableName} order by  expect desc" + $" limit {lastNumOfExpect}";
            // 获取数据库pc28数据
            DataTable dbDataTable = Sqlite3Helper.GetDs(Properties.Settings.Default.dbName, sqlString, TableName).Tables[TableName];

            // 更新字段 并且 返回
            return(dbDataTable);
        }
예제 #5
0
        /// <summary>
        /// 根据开始期号 和 结束期号 获取数据
        /// </summary>
        /// <param name="startExpect">开始期号</param>
        /// <param name="endExpect">结束期号</param>
        /// <returns></returns>
        public static DataTable GetDataFromDb(int startExpect, int endExpect)
        {
            string sqlString;

            if (endExpect <= 0 || endExpect <= startExpect)
            {
                sqlString = $"select pc28,opentime as 日期,expect as 期号 from {TableName} where expect >= {startExpect} " + "order by  expect desc";
            }
            else
            {
                sqlString = $"select pc28,opentime as 日期,expect as 期号 from {TableName} where expect >= {startExpect} and expect <= {endExpect} " + "order by  expect desc";
            }

            // 获取数据库pc28数据
            DataTable dbDataTable = Sqlite3Helper.GetDs(Properties.Settings.Default.dbName, sqlString, TableName).Tables[TableName];

            // 更新字段 并且 返回
            return(dbDataTable);
        }
예제 #6
0
        /// <summary>
        /// 更新任务
        /// </summary>
        public void UpdateTask()
        {
            // 查询数据的最新日期
            string tablename = currentUpdate;
            string command   = "select max(opentime) from " + tablename;

            DataTable dt = Sqlite3Helper.GetDs(dbfilePath, command, tablename).Tables[tablename];
            string    lastDateTimeString = dt.Rows[0][0].ToString() == "" ? "2011-01-01" : dt.Rows[0][0].ToString();

            Bjkl8Util bjkl8OrPk10 = new Bjkl8Util();

            // 利用反射 获取 Bjkl8 或 Pk10 对象
            //Type type = Type.GetType("DXAppXingyun28.util." + currentUpdate.Substring(0, 1).ToUpper() + currentUpdate.Substring(1));
            //dynamic bjkl8OrPk10 = type.Assembly.CreateInstance(type.ToString());

            // 根据最新日期 保存
            bjkl8OrPk10.SaveData(dbfilePath, bjkl8OrPk10.Download(Convert.ToDateTime(lastDateTimeString), DateTime.Now, progress), progress);

            // 等待5秒
        }