예제 #1
0
파일: Form1.cs 프로젝트: Jinkela-N/AcHelper
        /// <summary>
        /// 检查是否为第一次使用和是否有id记录
        /// </summary>
        /// <returns></returns>
        public void checkUserId()
        {
            bool        isUserIdRec = false;
            SqlLiteConn conn        = new SqlLiteConn();
            DataTable   dt          = conn.GetSchema();

            if (dt.Rows.Count > 0)
            {
                //是否有记录
                SQLiteParameter[] pars = new SQLiteParameter[] { new SQLiteParameter("", "") };
                string            sql  = "select count() from user where id >0";
                SQLiteDataReader  r    = conn.ExecuteReader(sql, pars);
                if (r.Read() && (r.GetInt32(0) > 0))
                {
                    r.Close();
                    isUserIdRec = true;
                }
                else
                {
                    isUserIdRec = false;
                }
            }
            else
            {
                //空数据库初始化
                string sql = @"
                    DROP TABLE IF EXISTS 'main'.'user';
                    CREATE TABLE 'user' (
                    'id'  INTEGER NOT NULL,
                    'userid'  INTEGER,
                    'username'  TEXT NOT NULL,
                    'userpassword'  TEXT NOT NULL,
                    'moni'  REAL,
                    PRIMARY KEY ('id')
                    );";
                conn.ExecuteNonQuery(sql);
            }
            if (!isUserIdRec)
            {
                login loginform = new login();
                loginform.Show();
            }
        }
예제 #2
0
 /// <summary>
 /// 检查是否为第一次使用和是否有id记录
 /// </summary>
 /// <returns></returns>
 public void checkUserId()
 {
     bool isUserIdRec = false;
     SqlLiteConn conn = new SqlLiteConn();
     DataTable dt = conn.GetSchema();
     if (dt.Rows.Count > 0)
     {
         //是否有记录
         SQLiteParameter[] pars = new SQLiteParameter[] { new SQLiteParameter("", "") };
         string sql = "select count() from user where id >0";
         SQLiteDataReader r = conn.ExecuteReader(sql, pars);
         if (r.Read() && (r.GetInt32(0) > 0))
         {
             r.Close();
             isUserIdRec = true;
         }
         else
         {
             isUserIdRec = false;
         }
     }
     else
     {
         //空数据库初始化
         string sql = @"
             DROP TABLE IF EXISTS 'main'.'user';
             CREATE TABLE 'user' (
             'id'  INTEGER NOT NULL,
             'userid'  INTEGER,
             'username'  TEXT NOT NULL,
             'userpassword'  TEXT NOT NULL,
             'moni'  REAL,
             PRIMARY KEY ('id')
             );";
         conn.ExecuteNonQuery(sql);
     }
     if (!isUserIdRec)
     {
         login loginform = new login();
         loginform.Show();
     }
 }
예제 #3
0
파일: Form1.cs 프로젝트: Jinkela-N/AcHelper
        private void button_userManage_Click(object sender, EventArgs e)
        {
            login loginform = new login();

            loginform.Show();
        }
예제 #4
0
 private void button_userManage_Click(object sender, EventArgs e)
 {
     login loginform = new login();
     loginform.Show();
 }