private void btnToDo_Click(object sender, EventArgs e)
        {
            try {
                string[] str = new string[dataGridView1.Rows.Count];
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Selected == true)
                    {
                        TryGameToDo tryGameToDoObject = new TryGameToDo();
                        tryGameToDoObject.Id        = Convert.ToInt64(dataGridView1.Rows[i].Cells[0].Value);
                        tryGameToDoObject.Url       = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value);
                        tryGameToDoObject.UserName  = Convert.ToString(dataGridView1.Rows[i].Cells[2].Value);
                        tryGameToDoObject.PassWord  = Convert.ToString(dataGridView1.Rows[i].Cells[3].Value);
                        tryGameToDoObject.ReMark    = Convert.ToString(dataGridView1.Rows[i].Cells[4].Value);
                        tryGameToDoObject.DeadLine  = Convert.ToDateTime(dataGridView1.Rows[i].Cells[6].Value);
                        tryGameToDoObject.IsDeleted = false;

                        //sql = new SqLiteHelper("data source=mydb.db");
                        sql = new SqLiteHelper();

                        //创建名为TryGameToDo的数据表
                        sql.CreateTable("TryGameToDo", new string[] { "Id", "Url", "UserName", "PassWord", "ReMark", "DeadLine", "IsDeleted" }, new string[] { "INTEGER", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" });
                        //插入数据
                        sql.InsertValues("TryGameToDo", new string[] { tryGameToDoObject.Id.ToString(), tryGameToDoObject.Url, tryGameToDoObject.UserName, tryGameToDoObject.PassWord, tryGameToDoObject.ReMark, tryGameToDoObject.DeadLine.ToString(), tryGameToDoObject.IsDeleted.ToString() });
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("系统发生异常,请联系管理员!", "错误");
                LogHelper.WriteLog("窗体异常", ex);
            }
        }
Exemplo n.º 2
0
        private void Init()
        {
            //ConsoleManager.Show();//打开信息打印窗口
            LoginCommand        = new DelegateCommand <Login>(runLoginCommand);
            LoginKeyDownCommand = new DelegateCommand <Login>(runLoginKeyDownCommand);
            sql = SqLiteHelper.getInstance;
            sql.ConnectionString = "data source=mydb.db";
            sql.CreateTable("userTB", new string[] { "id", "username", "passwd", "userpower", "itemlist", "times" }, new string[] { "integer primary key AUTOINCREMENT", "varchar2(100) not null", "varchar2(100) not null", "int not null", "varchar2(100) not null", "int not null" });
            //创建名为table1的数据表
            DataTable dt    = sql.ExecuteQuery("select count(*) from userTB");
            int       count = Convert.ToInt32(dt.Rows[0][0].ToString());

            if (count == 0)
            {
                //是新表,需要创建管理员账户
                sql.InsertValues("userTB", new string[] { null, "admin", "123456", "2", "1,1,1,1", "0" });
            }
        }