Beispiel #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            SqLiteHelper sqlHelper = new SqLiteHelper();

            sqlHelper.SqliteOpen();
            try
            {
                //查询所有可以交易品种
                symbols = SYRequest.QureyAllSymbol();
                if (symbols == null)
                {
                    MessageBox.Show("查询当前可用交易品种失败!");
                    windowStop = true;
                    Close();
                    return;
                }

                //读取整张表
                SQLiteDataReader reader = sqlHelper.ReadFullTable("user");
                if (reader != null)
                {
                    List <string> item = new List <string>();
                    while (reader.Read())
                    {
                        int    id         = reader.GetInt32(reader.GetOrdinal("id"));
                        string username   = reader.GetString(reader.GetOrdinal("username"));
                        string password   = reader.GetString(reader.GetOrdinal("password"));
                        int    uid        = reader.GetInt32(reader.GetOrdinal("uid"));
                        string coinSymbol = reader.GetString(reader.GetOrdinal("coinSymbol"));
                        string reamrks    = reader.GetString(reader.GetOrdinal("remarks"));

                        ListViewItem lvt = new ListViewItem();
                        lvt.Text = id + "";
                        lvt.SubItems.Add(username);
                        lvt.SubItems.Add("********");
                        lvt.SubItems.Add(uid + "");
                        lvt.SubItems.Add(coinSymbol);
                        lvt.SubItems.Add(getRunStatus(uid).ToString());
                        lvt.SubItems.Add(reamrks);
                        strategyList.Items.Add(lvt);
                    }
                }
                sqlHelper.SqliteClose();

                //设置顶时任务
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Enabled  = true;
                timer.Interval = 10000;//执行间隔时间,单位为毫秒
                timer.Start();
                timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimer);
            }
            catch
            {
                sqlHelper.SqliteClose();
            }
        }
Beispiel #2
0
        private void btn_Flush_Click(object sender, EventArgs e)
        {
            try
            {
                //查询所有可以交易品种
                symbols = SYRequest.QureyAllSymbol();
                if (symbols == null)
                {
                    MessageBox.Show("刷新失败!");
                    return;
                }

                SqLiteHelper sqlHelper = new SqLiteHelper();
                strategyList.Items.Clear();
                sqlHelper.SqliteOpen();
                //读取整张表
                SQLiteDataReader reader = sqlHelper.ReadFullTable("user");
                if (reader != null)
                {
                    List <string> item = new List <string>();
                    while (reader.Read())
                    {
                        int    id         = reader.GetInt32(reader.GetOrdinal("id"));
                        string username   = reader.GetString(reader.GetOrdinal("username"));
                        string password   = reader.GetString(reader.GetOrdinal("password"));
                        int    uid        = reader.GetInt32(reader.GetOrdinal("uid"));
                        string coinSymbol = reader.GetString(reader.GetOrdinal("coinSymbol"));
                        string reamrks    = reader.GetString(reader.GetOrdinal("remarks"));

                        ListViewItem lvt = new ListViewItem();
                        lvt.Text = id + "";
                        lvt.SubItems.Add(username);
                        lvt.SubItems.Add("********");
                        lvt.SubItems.Add(uid + "");
                        lvt.SubItems.Add(coinSymbol);
                        lvt.SubItems.Add(getRunStatus(uid).ToString());
                        lvt.SubItems.Add(reamrks);
                        strategyList.Items.Add(lvt);
                    }
                }
                sqlHelper.SqliteClose();
                MessageBox.Show("刷新成功!");
            }
            catch
            {
                MessageBox.Show("刷新失败!");
            }
        }
Beispiel #3
0
    static void dllMain(string[] args)
    {
        sql = new SqLiteHelper();
        sql.SqliteOpen("");

        //创建名为table1的数据表
        sql.CreateTable("table1", new string[] { "ID", "Name", "Age", "Email" }, new string[] { "INTEGER", "TEXT", "INTEGER", "TEXT" });
        //插入两条数据
        sql.InsertValues("table1", new string[] { "1", "张三", "22", "*****@*****.**" });
        sql.InsertValues("table1", new string[] { "2", "李四", "25", "*****@*****.**" });

        //更新数据,将Name="张三"的记录中的Name改为"Zhang3"
        sql.UpdateValues("table1", new string[] { "Name" }, new string[] { "ZhangSan" }, "Name", "Zhang3");

        //删除Name="张三"且Age=26的记录,DeleteValuesOR方法类似
        sql.DeleteValuesAND("table1", new string[] { "Name", "Age" }, new string[] { "张三", "22" }, new string[] { "=", "=" });


        //读取整张表
        SQLiteDataReader reader = sql.ReadFullTable("table1");

        while (reader.Read())
        {
            //读取ID
            Log("" + reader.GetInt32(reader.GetOrdinal("ID")));
            //读取Name
            Log("" + reader.GetString(reader.GetOrdinal("Name")));
            //读取Age
            Log("" + reader.GetInt32(reader.GetOrdinal("Age")));
            //读取Email
            Log(reader.GetString(reader.GetOrdinal("Email")));
        }

        while (true)
        {
            Console.ReadLine();
        }
    }