Exemplo n.º 1
0
    /// <summary>
    /// 分类添加
    /// </summary>
    public static bool AddClassifyInfo(DataCell_classify dataCell_calssify)
    {
        try
        {
            DataCell_classify dataclassify = dataCell_calssify;
            SqliteDbHelper db;
            db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);

            string querySelect = "SELECT * " + " From " + SQLInfo.classify_table;
            querySelect += " WHERE " + "classify_name = '" + dataclassify.Classify_name + "'";
            SqliteDataReader sqlData = db.ExecuteQuery(querySelect);

            if (sqlData.HasRows)
            {
                //**存在名称一样的**//
                if (sqlData != null)
                {
                    sqlData.Dispose();
                }
                sqlData = null;
                db.CloseSqlConnection();
                return false;
            }
            if (sqlData != null)
            {
                sqlData.Dispose();
            }
            sqlData = null;
            db.CloseSqlConnection();

            SqliteDbHelper db1;
            db1 = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            // string[] aa = new string[] { null, dataclassify.Classify_name, dataclassify.Classify_parentID.ToString(), dataclassify.Classify_numpos.ToString() };
            // db.InsertClassifyInto(SQLInfo.classify_table, dataclassify.Classify_name, dataclassify.Classify_parentID, dataclassify.Classify_numpos);
            string query = "INSERT INTO " + SQLInfo.classify_table + " VALUES (" + "null" + "," + "'" + dataclassify.Classify_name + "'" + "," + dataclassify.Classify_parentID + "," + dataclassify.Classify_numpos;
            query += ")";

            db1.ExecuteQuery(query);
            db1.CloseSqlConnection();
            return true;

        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return false;
        }
        finally
        {

        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 分类添加
    /// </summary>
    public static bool AddClassifyInfo(DataCell_classify dataCell_calssify)
    {
        try
        {
            DataCell_classify dataclassify = dataCell_calssify;
            SqliteDbHelper    db;
            db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);

            string querySelect = "SELECT * " + " From " + SQLInfo.classify_table;
            querySelect += " WHERE " + "classify_name = '" + dataclassify.Classify_name + "'";
            SqliteDataReader sqlData = db.ExecuteQuery(querySelect);

            if (sqlData.HasRows)
            {
                //**存在名称一样的**//
                if (sqlData != null)
                {
                    sqlData.Dispose();
                }
                sqlData = null;
                db.CloseSqlConnection();
                return(false);
            }
            if (sqlData != null)
            {
                sqlData.Dispose();
            }
            sqlData = null;
            db.CloseSqlConnection();



            SqliteDbHelper db1;
            db1 = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            // string[] aa = new string[] { null, dataclassify.Classify_name, dataclassify.Classify_parentID.ToString(), dataclassify.Classify_numpos.ToString() };
            // db.InsertClassifyInto(SQLInfo.classify_table, dataclassify.Classify_name, dataclassify.Classify_parentID, dataclassify.Classify_numpos);
            string query = "INSERT INTO " + SQLInfo.classify_table + " VALUES (" + "null" + "," + "'" + dataclassify.Classify_name + "'" + "," + dataclassify.Classify_parentID + "," + dataclassify.Classify_numpos;
            query += ")";

            db1.ExecuteQuery(query);
            db1.CloseSqlConnection();
            return(true);
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }
        finally
        {
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 模糊搜索
    /// </summary>
    /// <param name="strSearch">搜索内容</param>
    /// <returns></returns>
    public static List <DataCell_model> FuzzySelectModelListInfo(string strSearch)
    {
        SqliteDbHelper db;

        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
        List <DataCell_model> datamodelyList = new List <DataCell_model>();
        string query = "SELECT * " + " From " + SQLInfo.model_table;

        query += " WHERE " + "model_name like '%" + strSearch + "%'";
        SqliteDataReader sqlData = db.ExecuteQuery(query);

        while (sqlData.Read())
        {
            DataCell_model datamode = new DataCell_model();
            datamode.Model_id               = sqlData.GetInt32(sqlData.GetOrdinal("model_ID"));
            datamode.Model_num              = sqlData.GetString(sqlData.GetOrdinal("model_num"));
            datamode.Model_name             = sqlData.GetString(sqlData.GetOrdinal("model_name"));
            datamode.Model_address          = sqlData.GetString(sqlData.GetOrdinal("model_address"));
            datamode.Modle_ThumbnailAddress = sqlData.GetString(sqlData.GetOrdinal("modle_ThumbnailAddress"));
            datamode.Model_Introduction     = sqlData.GetString(sqlData.GetOrdinal("model_Introduction"));
            datamode.Model_classify_name    = sqlData.GetString(sqlData.GetOrdinal("model_classify_name"));
            datamode.Model_type             = sqlData.GetString(sqlData.GetOrdinal("model_type"));
            datamodelyList.Add(datamode);
        }
        sqlData.Close();
        db.CloseSqlConnection();
        Debug.Log(datamodelyList.Count);
        return(datamodelyList);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 分类查找
    /// 根据元件编号查找子分类列表
    /// </summary>
    /// <param name="model_num">元件编号</param>
    /// <returns></returns>
    public static DataCell_model SelectModelInfoByNum(string model_num)
    {
        SqliteDbHelper db;

        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
        string query = "SELECT * " + " From " + SQLInfo.model_table;

        query += " WHERE " + "model_num = '" + model_num + "'";
        DataCell_model   datamode = new DataCell_model();
        SqliteDataReader sqlData  = db.ExecuteQuery(query);

        while (sqlData.Read())
        {
            datamode.Model_id               = sqlData.GetInt32(sqlData.GetOrdinal("model_ID"));
            datamode.Model_num              = sqlData.GetString(sqlData.GetOrdinal("model_num"));
            datamode.Model_name             = sqlData.GetString(sqlData.GetOrdinal("model_name"));
            datamode.Model_address          = sqlData.GetString(sqlData.GetOrdinal("model_address"));
            datamode.Modle_ThumbnailAddress = sqlData.GetString(sqlData.GetOrdinal("modle_ThumbnailAddress"));
            datamode.Model_Introduction     = sqlData.GetString(sqlData.GetOrdinal("model_Introduction"));
            datamode.Model_classify_name    = sqlData.GetString(sqlData.GetOrdinal("model_classify_name"));
        }
        sqlData.Close();
        db.CloseSqlConnection();
        return(datamode);
    }
Exemplo n.º 5
0
    /// <summary>
    /// 分类查找
    /// 根据分类父物体查找子分类列表
    /// </summary>
    /// <param name="parentid">分类父分类id</param>
    /// <returns></returns>
    public static List <DataCell_classify> SelectClassifyListInfo(int parentid)
    {
        SqliteDbHelper db;

        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
        List <DataCell_classify> dataclassifyList = new List <DataCell_classify>();
        //  db.UpdateInto(SQLInfo.classify_table, dataclassify.Classify_name, dataclassify.Classify_parentID, dataclassify.Classify_numpos)
        string query = "SELECT classify_id,classify_name,classify_parent,classify_pos " + " From " + SQLInfo.classify_table;

        query += " WHERE " + "classify_parent = " + parentid;
        SqliteDataReader sqlData = db.ExecuteQuery(query);

        while (sqlData.Read())
        {
            DataCell_classify dataclassify = new DataCell_classify();
            dataclassify.Classify_id       = sqlData.GetInt32(sqlData.GetOrdinal("classify_id"));
            dataclassify.Classify_name     = sqlData.GetString(sqlData.GetOrdinal("classify_name"));
            dataclassify.Classify_numpos   = sqlData.GetInt32(sqlData.GetOrdinal("classify_pos"));
            dataclassify.Classify_parentID = sqlData.GetInt32(sqlData.GetOrdinal("classify_parent"));
            dataclassifyList.Add(dataclassify);
            // Debug.Log(" Classify_id:" + dataclassify.Classify_id + " Classify_name:" + dataclassify.Classify_name + " Classify_parentID:" + dataclassify.Classify_parentID + " Classify_numpos:" + dataclassify.Classify_numpos + "\n");
        }
        sqlData.Close();
        db.CloseSqlConnection();
        Debug.Log(dataclassifyList.Count);
        return(dataclassifyList);
    }
Exemplo n.º 6
0
    public void ConfirmButton(Button button)
    {
        //send score to DB

        /* totalScore();
         * Debug.Log("Total score is " + total + " and Button is " + button.name);
         * Debug.Log(button.name + " is pressed.");
         * Debug.Log("total = " + total); */
        addTotalScore();
        string sid        = PlayerPrefs.GetString("sid", "001");
        string totalScore = total.ToString();

        SqliteDbHelper db = new SqliteDbHelper("Data Source=./sqlite.db");

        if (!db.CheckTable("test0"))
        {
            db.CreateTable("test0",
                           new string[] { "recordID", "userId", "totalScore", "date" },
                           new string[] { "integer primary key autoincrement", "int not null", " text not null", " timestamp default (date('now'))" });
        }
        db.InsertIntoSpecific("test0",
                              new string[] { "userId", "totalScore" },
                              new string[] { sid, "'" + totalScore + "'" });
        db.CloseSqlConnection();
        Debug.Log("OK!");

        GameObject.Find("Canvas").transform.Find("ResultPanels").transform.Find("Result").gameObject.SetActive(false);

        //for development's sake, lets user know what the total score is
        //can be deleted when not needed
        GameObject.Find("Canvas").transform.Find("ResultPanels").transform.Find("Result2").gameObject.SetActive(true);
        ResultText2.text = "Your total score is: " + total;
    }
Exemplo n.º 7
0
 /// <summary>
 /// 分类修改
 /// </summary>
 public static bool UpdateClassifyInfo(DataCell_classify dataCell_calssify)
 {
     try
     {
         SqliteDbHelper db;
         db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
         DataCell_classify dataclassify = dataCell_calssify;
         string            querySelect  = "SELECT * " + " From " + SQLInfo.classify_table;
         querySelect += " WHERE " + "classify_name = '" + dataclassify.Classify_name + "'";
         SqliteDataReader sqlData = db.ExecuteQuery(querySelect);
         if (sqlData.HasRows)
         {
             if (sqlData != null)
             {
                 sqlData.Dispose();
             }
             sqlData = null;
             db.CloseSqlConnection();
             return(false);
         }
         if (sqlData != null)
         {
             sqlData.Dispose();
         }
         sqlData = null;
         db.CloseSqlConnection();
         SqliteDbHelper db2;
         db2 = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
         //  db.UpdateInto(SQLInfo.classify_table, dataclassify.Classify_name, dataclassify.Classify_parentID, dataclassify.Classify_numpos)
         string query = "UPDATE " + SQLInfo.classify_table + " SET " + "classify_name = " + "'" + dataclassify.Classify_name + "'" + "," + "classify_parent = " + dataclassify.Classify_parentID + "," + "classify_pos =" + dataclassify.Classify_numpos;
         query += " WHERE " + "classify_id = " + dataclassify.Classify_id;
         db2.ExecuteQuery(query);
         db2.CloseSqlConnection();
         return(true);
     }
     catch (Exception e)
     {
         Debug.Log(e.ToString());
         return(false);
     }
     finally
     {
     }
 }
Exemplo n.º 8
0
    /// <summary>
    ///  <summary>
    /// 修改分类名称
    /// </summary>
    /// <param name="classify_currentname">当前分类名称</param>
    /// <param name="classify_targetname">修改后分类名称</param>
    /// <returns></returns>
    public static bool UpdateClassifyInfo(string classify_currentname, string classify_targetname)
    {
        try
        {
            SqliteDbHelper db;
            db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            string querySelect = "SELECT * " + " From " + SQLInfo.classify_table;
            querySelect += " WHERE " + "classify_name = " + classify_targetname;
            SqliteDataReader sqlData = db.ExecuteQuery(querySelect);
            if (sqlData.HasRows)
            {
                //**该名称已经存在**//
                if (sqlData != null)
                {
                    sqlData.Dispose();
                }
                sqlData = null;
                db.CloseSqlConnection();
                return(false);
            }
            if (sqlData != null)
            {
                sqlData.Dispose();
            }
            sqlData = null;
            db.CloseSqlConnection();
            SqliteDbHelper db2;
            db2 = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);

            string query = "UPDATE " + SQLInfo.classify_table + " SET " + "classify_name = '" + classify_targetname + "'";
            query += " WHERE " + "classify_name = '" + classify_currentname + "'";
            db2.ExecuteQuery(query);
            db2.CloseSqlConnection();
            return(true);
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }
        finally
        {
        }
    }
Exemplo n.º 9
0
    /// <summary>
    /// 元件模型删除
    /// </summary>
    /// <param name="mode_num">元件编号</param>
    /// <returns></returns>
    public static void DeleteModelInfo(string mode_num)
    {
        SqliteDbHelper db;

        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);

        string query = "Delete  From" + SQLInfo.model_table;

        query += " WHERE  " + "model_num = '" + mode_num + "'";
        db.ExecuteQuery(query);
        db.CloseSqlConnection();
    }
Exemplo n.º 10
0
    /// <summary>
    /// 元件模型删除
    /// </summary>
    public static void DeleteModelInfo(DataCell_model dataCell_model)
    {
        SqliteDbHelper db;

        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
        DataCell_model datamodel = dataCell_model;
        string         query     = "Delete  From" + SQLInfo.model_table;

        query += " WHERE  " + "model_id = " + datamodel.Model_id;
        db.ExecuteQuery(query);
        db.CloseSqlConnection();
    }
Exemplo n.º 11
0
 static int CloseSqlConnection(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         SqliteDbHelper obj = (SqliteDbHelper)ToLua.CheckObject(L, 1, typeof(SqliteDbHelper));
         obj.CloseSqlConnection();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 12
0
    public void LoadScene(int level)
    {
        string sid    = PlayerPrefs.GetString("sid", "001");
        string score  = GameObject.Find("Result/Score").GetComponent <Text>().text;
        string result = GameObject.Find("Result/Text").GetComponent <Text>().text;

        SqliteDbHelper db = new SqliteDbHelper("Data Source=./sqlite.db");

        if (!db.CheckTable("test" + currentLevel.ToString()))
        {
            db.CreateTable("test" + currentLevel.ToString(), new string[] { "recordID", "userId", "score", "result", "date" }, new string[] { "integer primary key autoincrement", "int not null", " text not null", "text not null", " timestamp default (date('now'))" });
        }
        db.InsertIntoSpecific("test" + currentLevel.ToString(), new string[] { "userId", "score", "result" }, new string[] { sid, "'" + score + "'", "'" + result + "'" });
        db.CloseSqlConnection();
        Debug.Log("OK!");
        SceneManager.LoadScene(level);
    }
Exemplo n.º 13
0
    public void register()
    {
        string firstname = GameObject.Find("FirstName/InputField/Text").GetComponent <Text>().text;
        string lastname  = GameObject.Find("LastName/InputField/Text").GetComponent <Text>().text;
        string grade     = GameObject.Find("Grade/InputField/Text").GetComponent <Text>().text;
        string sid       = GameObject.Find("SID/InputField/Text").GetComponent <Text>().text;


        SqliteDbHelper db = new SqliteDbHelper("Data Source=./sqlite.db");

        if (!db.CheckTable("user"))
        {
            db.CreateTable("user", new string[] { "userid", "firstname", "lastname", "grade" }, new string[] { "integer primary key", "text not null", "text not null", "int not null" });
        }
        db.InsertInto("user", new string[] { sid, "'" + firstname + "'", "'" + lastname + "'", grade });
        db.CloseSqlConnection();
        Debug.Log("OK!");
        PlayerPrefs.SetString("sid", sid);
    }
Exemplo n.º 14
0
    void Start()
    {
        SqliteDbHelper db = new SqliteDbHelper("data source=scoreDB.db");

        //   db.InsertInto("leaderboard",3,50);



        //然后在删掉两条数据
        //db.Delete("biao", new string[] { "qq", "qq" }, new string[] { "'123456789'", "'223456789'" });
        //动态查询数据信息
        //  SqliteDataReader sqReader = db.SelectWhere("biao", new string[] { "name", "email" }, new string[] { "qq" }, new string[] { "=" }, new string[] { "123456789" });


        //while (sqReader.Read())                 //表名,查询数据集合,字段,操作,值
        //{
        //    Debug.Log(sqReader.GetString(sqReader.GetOrdinal("name")) + sqReader.GetString(sqReader.GetOrdinal("email")));
        //}
        //删除表
        //db.DeleteContents("biao");
        //关闭对象
        db.CloseSqlConnection();
    }
Exemplo n.º 15
0
    /// <summary>
    ///  <summary>
    /// 修改分类名称
    /// </summary>
    /// <param name="classify_currentname">当前分类名称</param>
    /// <param name="classify_targetname">修改后分类名称</param>
    /// <returns></returns>
    public static bool UpdateClassifyInfo(string classify_currentname, string classify_targetname)
    {
        try
        {
            SqliteDbHelper db;
            db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            string querySelect = "SELECT * " + " From " + SQLInfo.classify_table;
            querySelect += " WHERE " + "classify_name = " + classify_targetname;
            SqliteDataReader sqlData = db.ExecuteQuery(querySelect);
            if (sqlData.HasRows)
            {
                //**该名称已经存在**//
                if (sqlData != null)
                {
                    sqlData.Dispose();
                }
                sqlData = null;
                db.CloseSqlConnection();
                return false;
            }
            if (sqlData != null)
            {
                sqlData.Dispose();
            }
            sqlData = null;
            db.CloseSqlConnection();
            SqliteDbHelper db2;
            db2 = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);

            string query = "UPDATE " + SQLInfo.classify_table + " SET " + "classify_name = '" + classify_targetname + "'";
            query += " WHERE " + "classify_name = '" + classify_currentname + "'";
            db2.ExecuteQuery(query);
            db2.CloseSqlConnection();
            return true;

        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return false;
        }
        finally
        {

        }
    }
Exemplo n.º 16
0
    /// <summary>
    /// 分类修改
    /// </summary>
    public static bool UpdateClassifyInfo(DataCell_classify dataCell_calssify)
    {
        try
        {
            SqliteDbHelper db;
            db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            DataCell_classify dataclassify = dataCell_calssify;
            string querySelect = "SELECT * " + " From " + SQLInfo.classify_table;
            querySelect += " WHERE " + "classify_name = '" + dataclassify.Classify_name + "'";
            SqliteDataReader sqlData = db.ExecuteQuery(querySelect);
            if (sqlData.HasRows)
            {
                if (sqlData != null)
                {
                    sqlData.Dispose();
                }
                sqlData = null;
                db.CloseSqlConnection();
                return false;
            }
            if (sqlData != null)
            {
                sqlData.Dispose();
            }
            sqlData = null;
            db.CloseSqlConnection();
            SqliteDbHelper db2;
            db2 = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            //  db.UpdateInto(SQLInfo.classify_table, dataclassify.Classify_name, dataclassify.Classify_parentID, dataclassify.Classify_numpos)
            string query = "UPDATE " + SQLInfo.classify_table + " SET " + "classify_name = " + "'" + dataclassify.Classify_name + "'" + "," + "classify_parent = " + dataclassify.Classify_parentID + "," + "classify_pos =" + dataclassify.Classify_numpos;
            query += " WHERE " + "classify_id = " + dataclassify.Classify_id;
            db2.ExecuteQuery(query);
            db2.CloseSqlConnection();
            return true;

        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return false;
        }
        finally
        {

        }
    }
Exemplo n.º 17
0
    /// <summary>
    /// 模型元件查找
    /// 根据分类父物体查找子分类列表
    /// </summary>
    /// <param name="model_classify_name">分类名称</param>
    /// <returns></returns>
    public static List<DataCell_model> SelectModelListInfo(string model_classify_name)
    {
        SqliteDbHelper db;
        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
        List<DataCell_model> datamodelyList = new List<DataCell_model>();
        string query = "SELECT * " + " From " + SQLInfo.model_table;
        query += " WHERE " + "model_classify_name = '" + model_classify_name + "'";
        SqliteDataReader sqlData = db.ExecuteQuery(query);
        while (sqlData.Read())
        {
            DataCell_model datamode = new DataCell_model();
            datamode.Model_id = sqlData.GetInt32(sqlData.GetOrdinal("model_ID"));
            datamode.Model_num = sqlData.GetString(sqlData.GetOrdinal("model_num"));
            datamode.Model_name = sqlData.GetString(sqlData.GetOrdinal("model_name"));
            datamode.Model_address = sqlData.GetString(sqlData.GetOrdinal("model_address"));
            datamode.Modle_ThumbnailAddress = sqlData.GetString(sqlData.GetOrdinal("modle_ThumbnailAddress"));
            datamode.Model_Introduction = sqlData.GetString(sqlData.GetOrdinal("model_Introduction"));
            datamode.Model_classify_name = sqlData.GetString(sqlData.GetOrdinal("model_classify_name"));
            datamode.Model_type = sqlData.GetString(sqlData.GetOrdinal("model_type"));
            datamodelyList.Add(datamode);

        }
        sqlData.Close();
        db.CloseSqlConnection();
        Debug.Log(datamodelyList.Count);
        return datamodelyList;
    }
Exemplo n.º 18
0
 /// <summary>
 /// 分类查找
 /// 根据元件编号查找子分类列表
 /// </summary>
 /// <param name="model_num">元件编号</param>
 /// <returns></returns>
 public static DataCell_model SelectModelInfoByNum(string model_num)
 {
     SqliteDbHelper db;
     db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
     string query = "SELECT * " + " From " + SQLInfo.model_table;
     query += " WHERE " + "model_num = '" + model_num + "'";
     DataCell_model datamode = new DataCell_model();
     SqliteDataReader sqlData = db.ExecuteQuery(query);
     while (sqlData.Read())
     {
         datamode.Model_id = sqlData.GetInt32(sqlData.GetOrdinal("model_ID"));
         datamode.Model_num = sqlData.GetString(sqlData.GetOrdinal("model_num"));
         datamode.Model_name = sqlData.GetString(sqlData.GetOrdinal("model_name"));
         datamode.Model_address = sqlData.GetString(sqlData.GetOrdinal("model_address"));
         datamode.Modle_ThumbnailAddress = sqlData.GetString(sqlData.GetOrdinal("modle_ThumbnailAddress"));
         datamode.Model_Introduction = sqlData.GetString(sqlData.GetOrdinal("model_Introduction"));
         datamode.Model_classify_name = sqlData.GetString(sqlData.GetOrdinal("model_classify_name"));
     }
     sqlData.Close();
     db.CloseSqlConnection();
     return datamode;
 }
Exemplo n.º 19
0
    /// <summary>
    /// 分类查找
    /// 根据分类父物体查找子分类列表
    /// </summary>
    /// <param name="parentid">分类父分类id</param>
    /// <returns></returns>
    public static List<DataCell_classify> SelectClassifyListInfo(int parentid)
    {
        SqliteDbHelper db;
        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
        List<DataCell_classify> dataclassifyList = new List<DataCell_classify>();
        //  db.UpdateInto(SQLInfo.classify_table, dataclassify.Classify_name, dataclassify.Classify_parentID, dataclassify.Classify_numpos)
        string query = "SELECT classify_id,classify_name,classify_parent,classify_pos " + " From " + SQLInfo.classify_table;
        query += " WHERE " + "classify_parent = " + parentid;
        SqliteDataReader sqlData = db.ExecuteQuery(query);
        while (sqlData.Read())
        {
            DataCell_classify dataclassify = new DataCell_classify();
            dataclassify.Classify_id = sqlData.GetInt32(sqlData.GetOrdinal("classify_id"));
            dataclassify.Classify_name = sqlData.GetString(sqlData.GetOrdinal("classify_name"));
            dataclassify.Classify_numpos = sqlData.GetInt32(sqlData.GetOrdinal("classify_pos"));
            dataclassify.Classify_parentID = sqlData.GetInt32(sqlData.GetOrdinal("classify_parent"));
            dataclassifyList.Add(dataclassify);
            // Debug.Log(" Classify_id:" + dataclassify.Classify_id + " Classify_name:" + dataclassify.Classify_name + " Classify_parentID:" + dataclassify.Classify_parentID + " Classify_numpos:" + dataclassify.Classify_numpos + "\n");

        }
        sqlData.Close();
        db.CloseSqlConnection();
        Debug.Log(dataclassifyList.Count);
        return dataclassifyList;
    }
Exemplo n.º 20
0
    /// <summary>
    /// 分类查找
    /// 根据ID查找子分类列表
    /// </summary>
    public static DataCell_classify SelectClassifyInfo(int classify_id)
    {
        SqliteDbHelper db;
        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
        //  List<DataCell_classify> dataclassifyList = new List<DataCell_classify>();
        //  db.UpdateInto(SQLInfo.classify_table, dataclassify.Classify_name, dataclassify.Classify_parentID, dataclassify.Classify_numpos)
        string query = "SELECT classify_id,classify_name,classify_parent,classify_pos " + " From " + SQLInfo.classify_table;
        query += " WHERE " + "classify_id = " + classify_id;
        DataCell_classify dataclassify = new DataCell_classify();
        SqliteDataReader sqlData = db.ExecuteQuery(query);
        while (sqlData.Read())
        {

            dataclassify.Classify_id = sqlData.GetInt32(sqlData.GetOrdinal("classify_id"));
            dataclassify.Classify_name = sqlData.GetString(sqlData.GetOrdinal("classify_name"));
            dataclassify.Classify_numpos = sqlData.GetInt32(sqlData.GetOrdinal("classify_pos"));
            dataclassify.Classify_parentID = sqlData.GetInt32(sqlData.GetOrdinal("classify_parent"));
        }
        sqlData.Close();
        db.CloseSqlConnection();
        return dataclassify;
    }
Exemplo n.º 21
0
    //  CREATE TABLE "modelcell" (
    //[model_ID] INT,
    //[model_num] VARCHAR(32),
    //[model_name] VARCHAR(100),
    //[model_address] VARCHAR(300),
    //[modle_ThumbnailAddress] VARCHAR(300),
    //[model_Introduction] VARCHAR(3000),
    //[model_classify_name] VARCHAR(300),
    //CONSTRAINT [] PRIMARY KEY ([model_ID]));

    /// <summary>
    /// 元件模型修改
    /// </summary>
    public static bool UpdateModelInfo(DataCell_model dataCell_model)
    {
        try
        {
            SqliteDbHelper db;
            db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            DataCell_model datamodel   = dataCell_model;
            string         querySelect = "SELECT * " + " From " + SQLInfo.model_table;
            querySelect += " WHERE " + "model_num = '" + datamodel.Model_num + "'";
            SqliteDataReader sqlData = db.ExecuteQuery(querySelect);

            if (!sqlData.HasRows)
            {
                //**存在名称一样的**//
                if (sqlData != null)
                {
                    sqlData.Dispose();
                }
                sqlData = null;
                db.CloseSqlConnection();
                return(false);
            }
            if (sqlData != null)
            {
                sqlData.Dispose();
            }
            sqlData = null;
            db.CloseSqlConnection();



            if (datamodel.Model_address != "")
            {
                Debug.Log("dataCell_model.Model_address:" + dataCell_model.Model_address);
                string targetPath = Application.dataPath + SQLInfo.Model_path;

                if (datamodel.Model_address != targetPath)
                {
                    string path = datamodel.Model_address;
                    if (!FileHelper.CopyDir(ref path, targetPath))
                    {
                        return(false);
                    }
                    datamodel.Model_address = path;
                }
            }
            if (datamodel.Modle_ThumbnailAddress != "")
            {
                Debug.Log("dataCell_model.Modle_ThumbnailAddress:" + dataCell_model.Modle_ThumbnailAddress + " Path:" + Path.GetFileName(dataCell_model.Modle_ThumbnailAddress));
                string targetPath = Application.dataPath + SQLInfo.Texture_path;
                if (datamodel.Modle_ThumbnailAddress != targetPath)
                {
                    string path = datamodel.Modle_ThumbnailAddress;
                    if (!FileHelper.CopyDir(ref path, targetPath))
                    {
                        return(false);
                    }
                    datamodel.Modle_ThumbnailAddress = path;
                }
            }

            SqliteDbHelper db1;
            db1 = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            string query = "UPDATE " + SQLInfo.model_table + " SET " + "model_num = '" + datamodel.Model_num + "'," + "model_name = '" + datamodel.Model_name + "'," + "model_address = '" + datamodel.Model_address;
            query += "'," + "modle_ThumbnailAddress = '" + datamodel.Modle_ThumbnailAddress + "'," + "model_Introduction = '" + datamodel.Model_Introduction + "'," + "model_classify_name = '" + datamodel.Model_classify_name + "' + " + " model_type = '" + datamodel.Model_type + "'";
            query += " WHERE " + "model_id = " + datamodel.Model_id;
            db1.ExecuteQuery(query);
            db1.CloseSqlConnection();
            return(true);
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return(false);
        }
        finally
        {
        }
    }
Exemplo n.º 22
0
    /// <summary>
    /// 元件模型删除
    /// </summary>
    /// <param name="mode_num">元件编号</param>
    /// <returns></returns>
    public static void DeleteModelInfo(string mode_num)
    {
        SqliteDbHelper db;
        db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);

        string query = "Delete  From" + SQLInfo.model_table;
        query += " WHERE  " + "model_num = '" + mode_num + "'";
        db.ExecuteQuery(query);
        db.CloseSqlConnection();
    }
Exemplo n.º 23
0
 /// <summary>
 /// 元件模型删除
 /// </summary>
 public static void DeleteModelInfo(DataCell_model dataCell_model)
 {
     SqliteDbHelper db;
     db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
     DataCell_model datamodel = dataCell_model;
     string query = "Delete  From" + SQLInfo.model_table;
     query += " WHERE  " + "model_id = " + datamodel.Model_id;
     db.ExecuteQuery(query);
     db.CloseSqlConnection();
 }
Exemplo n.º 24
0
    /// <summary>
    /// 添加模型元件
    /// </summary>
    /// <param name="dataCell_model"> 模型类对象</param>
    public static bool AddModelInfo(DataCell_model dataCell_model)
    {
        try
        {
            SqliteDbHelper db;
            db = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            DataCell_model datamodel = dataCell_model;
            string querySelect = "SELECT * " + " From " + SQLInfo.model_table;
            querySelect += " WHERE " + "model_num = '" + datamodel.Model_num + "'";
            SqliteDataReader sqlData = db.ExecuteQuery(querySelect);
            // 有 true  没有 false
            if (sqlData.HasRows)
            {
                //**存在名称一样的**//
                Debug.Log("该名称已经存在" + sqlData.HasRows);
                if (sqlData != null)
                {
                    sqlData.Dispose();
                }
                sqlData = null;
                db.CloseSqlConnection();
                return false;
            }
            if (sqlData != null)
            {
                sqlData.Dispose();
            }
            sqlData = null;
            db.CloseSqlConnection();

            if (datamodel.Model_address != "")
            {
                Debug.Log("dataCell_model.Model_address:" + dataCell_model.Model_address);
                string targetPath = Application.dataPath + SQLInfo.Model_path;

                if (datamodel.Model_address != targetPath)
                {
                    string  path = datamodel.Model_address;
                    if (!FileHelper.CopyDir(ref path, targetPath))
                        return false;
                    datamodel.Model_address = path;
                }
            }
            if (datamodel.Modle_ThumbnailAddress != "")
            {
                Debug.Log("dataCell_model.Modle_ThumbnailAddress:" + dataCell_model.Modle_ThumbnailAddress + " Path:" + Path.GetFileName(dataCell_model.Modle_ThumbnailAddress));
                string targetPath = Application.dataPath + SQLInfo.Texture_path;
                if (datamodel.Modle_ThumbnailAddress != targetPath)
                {
                    string path = datamodel.Modle_ThumbnailAddress;
                    if (!FileHelper.CopyDir(ref  path, targetPath))
                        return false;
                    datamodel.Modle_ThumbnailAddress = path;
                }
            }
            SqliteDbHelper db1;
            db1 = new SqliteDbHelper("Data Source=" + Application.dataPath + SQLInfo.SQL_path);
            string query = "INSERT INTO " + SQLInfo.model_table + " VALUES (" + "null" + ",'" + datamodel.Model_num + "','" + datamodel.Model_name + "','" + datamodel.Model_address;
            query += "','" + datamodel.Modle_ThumbnailAddress + "','" + datamodel.Model_Introduction + "','" + datamodel.Model_classify_name + "','" + datamodel.Model_type + "')";
            db1.ExecuteQuery(query);
            db1.CloseSqlConnection();
            return true;

        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
            return false;
        }
        finally
        {

        }
    }
Exemplo n.º 25
0
    void OnGUI()
    {
        if (Time.timeScale == 0)
        {
            if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.4f, 100, 30), "继续游戏"))
            {
                Time.timeScale = 1;
            }
            //退出游戏
            if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.6f, 100, 30), "退出游戏"))
            {
                Application.Quit();
            }
        }

        int life = 0;

        if (m_player != null)
        {
            life = (int)m_player.m_life;
        }
        else
        {
            //放大字体
            GUI.skin.label.fontSize = 50;

            //提示游戏失败
            GUI.skin.label.alignment = TextAnchor.LowerCenter;
            GUI.Label(new Rect(0, Screen.height * 0.2f, Screen.width, 60), "游戏失败");


            GUI.skin.label.fontSize = 20;
            //显示按钮
            if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.5f + 150, 100, 30), "再试一次"))
            {
                Application.LoadLevel(Application.loadedLevelName);
            }


            //获取最小成绩
            int min = IntScore[0];
            for (int i = 0; i < IntScore.Length; i++)
            {
                if (IntScore[i] < min)
                {
                    min = IntScore[i];
                }
            }
            //如果进入前五 提示
            if (m_score >= min)
            {
                //放大字体
                GUI.skin.label.fontSize = 50;
                //提示游戏失败
                GUI.skin.label.alignment = TextAnchor.LowerCenter;
                GUI.Label(new Rect(0, Screen.height * 0.5f - 50, Screen.width, 60), "您破了纪录");
                GUI.skin.label.fontSize = 30;

                //将高分代替低分
                db.UpdateInto("five", m_score, min);
                db.CloseSqlConnection();
                Debug.Log("close table ok");

                //在数组中重新排位
                for (int i = 0; i < IntScore.Length; i++)
                {
                    if (IntScore[i] == min)
                    {
                        IntScore[i] = m_score;
                        break;
                    }
                }
            }
            if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.5f + 50, 100, 30), "查看记录"))
            {
                buttonDown = true;
                //endConnection();
                Debug.Log(score.Count);
            }
        }
        if (buttonDown == true)
        {
            for (int i = 0; i < IntScore.Length; i++)
            {
                GUI.skin.label.fontSize  = 30;
                GUI.skin.label.alignment = TextAnchor.LowerCenter;
                GUI.Label(new Rect(Screen.width * 0.5f + 150, Screen.height * 0.5f + 50, 100, (i + 1) * 40), IntScore[i].ToString());
            }

            //db.CloseSqlConnection();
        }
        GUI.skin.label.fontSize = 15;
        //显示生命值
        GUI.Label(new Rect(5, 5, 100, 30), "装甲  " + life);
        //show the highScore
        GUI.skin.label.alignment = TextAnchor.LowerCenter;
        GUI.Label(new Rect(0, 5, Screen.width, 30), "记录" + m_hiscore);
        //shou the score you get
        GUI.Label(new Rect(0, 25, Screen.width, 30), "得分" + m_score);
    }
Exemplo n.º 26
0
    void OnGUI()
    {
        if (GUILayout.Button("create table"))
        {
            db.CreateTable("mytable", new string[] { "id", "name", "email" }, new string[] { "int", "varchar(20)", "varchar(50)" });
            Debug.Log("create table ok");
        }

        if (GUILayout.Button("insert data"))
        {
            db.InsertInto("mytable",
                          new string[] { "" + (++id), "'随风去旅行" + id + "'", "'zhangj_live" + id + "@163.com'" });

            Debug.Log("insert table ok");
        }
        if (GUILayout.Button("insert data specific"))
        {
            db.InsertIntoSpecific("mytable",
                                  new string[] { "name", "id" }, new string[] { "'随风去旅行6'", "99" });

            Debug.Log("insert data specific ok");
        }
        if (GUILayout.Button("Delete data"))
        {
            db.Delete("mytable",
                      new string[] { "name" }, new string[] { "'随风去旅行6'" });

            Debug.Log("Delete data ok");
        }
        if (GUILayout.Button("Read Full Table"))
        {
            IDataReader sqReader = db.ReadFullTable("mytable");
            while (sqReader.Read())
            {
                string id = "id=" + sqReader.GetInt32(sqReader.GetOrdinal("id"));
                name = "name=" + sqReader.GetString(sqReader.GetOrdinal("name"));
                emls = "email=" + sqReader.GetString(sqReader.GetOrdinal("email"));
                Debug.LogError(id + "/" + name + "/" + emls);
            }

            Debug.Log("Read Full Table ok");
        }

        if (GUILayout.Button("search database"))
        {
            IDataReader sqReader = db.SelectWhere("mytable", new string[] { "name", "email" }, new string[] { "id" }, new string[] { "=" }, new string[] { "2" });
            while (sqReader.Read())
            {
                name = "name=" + sqReader.GetString(sqReader.GetOrdinal("name"));
                emls = "email=" + sqReader.GetString(sqReader.GetOrdinal("email"));
            }
        }

        if (GUILayout.Button("Update data"))
        {
            db.UpdateInto("mytable",
                          new string[] { "name", "email" }, new string[] { "'吴小雄'", "'吴小雄21a'" },
                          "id", "5");

            Debug.Log("Update data ok");
        }

        if (name != "")
        {
            GUI.Label(new Rect(100, 100, 100, 100), name);
            GUI.Label(new Rect(100, 200, 100, 100), emls);
            //  GUILayout.Label(emls);
        }
        if (GUILayout.Button("close database"))
        {
            db.CloseSqlConnection();
            Debug.Log("close table ok");
        }
    }