示例#1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Update_Click(object sender, EventArgs e)
        {
            try
            {
                bool b_mustMore      = System.Text.RegularExpressions.Regex.IsMatch(mustMore.Text, @"^\+?[1-9][0-9]*$");
                bool b_OtherMore     = System.Text.RegularExpressions.Regex.IsMatch(OtherMore.Text, @"^\+?[1-9][0-9]*$");
                bool b_minPrice      = System.Text.RegularExpressions.Regex.IsMatch(minPrice.Text, @"^\d+(\.\d+)?$");
                bool b_timerGrade    = System.Text.RegularExpressions.Regex.IsMatch(timerGrade.Text, @"^\+?[1-9][0-9]*$");
                bool b_mustToSell    = System.Text.RegularExpressions.Regex.IsMatch(mustToSell.Text, @"^\+?[1-9][0-9]*$");
                bool b_mustToBuy     = System.Text.RegularExpressions.Regex.IsMatch(mustToBuy.Text, @"^\+?[1-9][0-9]*$");
                bool b_otherToBuy    = System.Text.RegularExpressions.Regex.IsMatch(otherToBuy.Text, @"^\+?[1-9][0-9]*$");
                bool b_otherToSell   = System.Text.RegularExpressions.Regex.IsMatch(otherToSell.Text, @"^\+?[1-9][0-9]*$");
                bool b_maxOrderCount = System.Text.RegularExpressions.Regex.IsMatch(maxOrderCount.Text, @"^\+?[1-9][0-9]*$");

                if (!b_mustMore ||
                    !b_OtherMore ||
                    !b_minPrice ||
                    !b_timerGrade ||
                    !b_mustToSell ||
                    !b_mustToBuy ||
                    !b_otherToBuy ||
                    !b_otherToSell ||
                    !b_maxOrderCount)
                {
                    MessageBox.Show("输入的值不合法");
                }

                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string sql  = "UPDATE attrbute SET " +
                              "mustMore=" + mustMore.Text +
                              ",OtherMore=" + OtherMore.Text +
                              ",minPrice=" + minPrice.Text +
                              ",timerGrade=" + timerGrade.Text +
                              ",mustToSell=" + mustToSell.Text +
                              ",mustToBuy=" + mustToBuy.Text +
                              ",otherToBuy=" + otherToBuy.Text +
                              ",otherToSell=" + otherToSell.Text +
                              ",maxOrderCount=" + maxOrderCount.Text +
                              ",updateDate='" + time + "'" +
                              " WHERE fk_uid=" + uid;

                SqLiteHelper sqlHelper = new SqLiteHelper();
                sqlHelper.SqliteOpen();

                SQLiteDataReader srd = sqlHelper.Execute(sql);
                if (srd != null)
                {
                    MessageBox.Show("修改成功");
                    sqlHelper.SqliteClose();
                    Close();
                    return;
                }
                sqlHelper.SqliteClose();
            }
            catch
            {
                return;
            }
        }
示例#2
0
文件: MainForm.cs 项目: jutao023/Wes
        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();
            }
        }
示例#3
0
文件: MainForm.cs 项目: jutao023/Wes
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            if (strategyList.SelectedItems.Count != 1)
            {
                return;
            }
            DialogResult result = MessageBox.Show("确定删除", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            string strid = strategyList.SelectedItems[0].SubItems[3].Text;

            foreach (var v in baseList)
            {
                if (strid == v.userId + "")
                {
                    if (v.runStatus == EnumRunStatus.运行中)
                    {
                        MessageBox.Show("运行中无法删除");
                        return;
                    }
                }
            }

            try
            {
                int          uid       = int.Parse(strid);
                SqLiteHelper sqlHelper = new SqLiteHelper();
                sqlHelper.SqliteOpen();

                sqlHelper.DeleteValuesAND(
                    "attrbute",
                    new string[] { "fk_uid" },
                    new string[] { strid },
                    new string[] { "=" }
                    );
                sqlHelper.DeleteValuesAND(
                    "user",
                    new string[] { "uid" },
                    new string[] { strid },
                    new string[] { "=" }
                    );
                sqlHelper.SqliteClose();
                strategyList.Items.RemoveAt(strategyList.SelectedItems[0].Index);
            }
            catch
            {
                return;
            }
        }
示例#4
0
文件: MainForm.cs 项目: jutao023/Wes
        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("刷新失败!");
            }
        }
示例#5
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (nullString(new string[] { txt_coinSymbol.Text, txt_password.Text, txt_uid.Text, txt_username.Text }))
            {
                MessageBox.Show("值不能为空");
                return;
            }
            bool nub = System.Text.RegularExpressions.Regex.IsMatch(txt_uid.Text, "^[0-9]*$");

            if (!nub)
            {
                MessageBox.Show("uid,只能是数字");
                return;
            }

            SqLiteHelper sqlHelp = new SqLiteHelper();

            try
            {
                sqlHelp.SqliteOpen();
                SQLiteDataReader reader = null;

                string sqluid = "SELECT * FROM user WHERE uid=" + txt_uid.Text + " or username='******' or coinSymbol='" + txt_coinSymbol.Text + "'";
                reader = sqlHelp.Execute(sqluid);
                if (reader.Read())
                {
                    MessageBox.Show("uid,账户,产品编码,不能重复插入");
                    sqlHelp.SqliteClose();
                    return;
                }
                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                sqlHelp.InsertValuesNoKey("user", new string[] { txt_uid.Text, txt_username.Text,
                                                                 txt_password.Text, txt_coinSymbol.Text, txtRemarks.Text, time });

                string[] vaes = new string[] { txt_uid.Text, "1", "1", "0.001", "1", "30", "30", "80", "80", "100", time, time };
                sqlHelp.InsertValuesNoKey("attrbute", vaes);
                sqlHelp.SqliteClose();

                Close();
            }
            catch (Exception ex)
            {
                sqlHelp.SqliteClose();
                MessageBox.Show(ex.ToString());
            }
        }
示例#6
0
        private void LoadConfig()
        {
            SqLiteHelper sqlHelper = new SqLiteHelper();

            sqlHelper.SqliteOpen();
            try
            {
                string sql = "SELECT * FROM attrbute WHERE fk_uid=" + userId;
                //读取整张表
                SQLiteDataReader reader = sqlHelper.Execute(sql);
                if (reader != null)
                {
                    reader.Read();
                    mustMore      = reader.GetInt32(reader.GetOrdinal("mustMore"));
                    OtherMore     = reader.GetInt32(reader.GetOrdinal("OtherMore"));
                    minPrice      = reader.GetDouble(reader.GetOrdinal("minPrice"));
                    timerGrade    = reader.GetInt32(reader.GetOrdinal("timerGrade"));
                    mustToSell    = reader.GetInt32(reader.GetOrdinal("mustToSell"));
                    mustToBuy     = reader.GetInt32(reader.GetOrdinal("mustToBuy"));
                    otherToBuy    = reader.GetInt32(reader.GetOrdinal("otherToBuy"));
                    otherToSell   = reader.GetInt32(reader.GetOrdinal("otherToSell"));
                    maxOrderCount = reader.GetInt32(reader.GetOrdinal("maxOrderCount"));
                }
                else
                {
                    Print("加载配置信息异常即将交易停止!");
                    sqlHelper.SqliteClose();
                    closeTrade();
                    return;
                }
                sqlHelper.SqliteClose();
            }
            catch (Exception ex)
            {
                sqlHelper.SqliteClose();
                OnError(EnumExceptionCode.交易异常, "加载配置信息异常即将交易停止!\r\n" + ex.ToString());
                return;
            }
        }
示例#7
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();
        }
    }
示例#8
0
        private void Setting_Load(object sender, EventArgs e)
        {
            this.Location = (Point) new Size(Control.MousePosition.X - 50, Control.MousePosition.Y - 80);

            SqLiteHelper sqlHelper = new SqLiteHelper();

            sqlHelper.SqliteOpen();
            try
            {
                string sql = "SELECT * FROM attrbute WHERE fk_uid=" + uid;
                //读取整张表
                SQLiteDataReader reader = sqlHelper.Execute(sql);
                if (reader != null)
                {
                    reader.Read();

                    reader.GetInt32(reader.GetOrdinal("attrbute_id"));
                    fk_uid.Text        = reader.GetInt32(reader.GetOrdinal("fk_uid")) + "";
                    mustMore.Text      = reader.GetInt32(reader.GetOrdinal("mustMore")) + "";
                    OtherMore.Text     = reader.GetInt32(reader.GetOrdinal("OtherMore")) + "";
                    minPrice.Text      = reader.GetDouble(reader.GetOrdinal("minPrice")) + "";
                    timerGrade.Text    = reader.GetInt32(reader.GetOrdinal("timerGrade")) + "";
                    mustToSell.Text    = reader.GetInt32(reader.GetOrdinal("mustToSell")) + "";
                    mustToBuy.Text     = reader.GetInt32(reader.GetOrdinal("mustToBuy")) + "";
                    otherToBuy.Text    = reader.GetInt32(reader.GetOrdinal("otherToBuy")) + "";
                    otherToSell.Text   = reader.GetInt32(reader.GetOrdinal("otherToSell")) + "";
                    maxOrderCount.Text = reader.GetInt32(reader.GetOrdinal("maxOrderCount")) + "";

                    reader.GetString(reader.GetOrdinal("updateDate"));
                    reader.GetString(reader.GetOrdinal("createDate"));
                }
                sqlHelper.SqliteClose();
            }
            catch
            {
                sqlHelper.SqliteClose();
            }
        }