コード例 #1
0
ファイル: DBManager.cs プロジェクト: thongvo/myfiles
        //Select statement

        public AccountTypeDB GetAccountTypeByName(string name)
        {
            string query = "SELECT id as Id, name as Name FROM account_type where name = ?";
            AccountTypeDB type = connection.Query<AccountTypeDB>(query, name).First();
            if(type == null)
            {
                type = new AccountTypeDB();
            }
            return type;
        }
コード例 #2
0
ファイル: DBManager.cs プロジェクト: thongvo/myfiles
        public List<AccountTypeDB> GetAllAccountTypeForWindow()
        {
            string query = "SELECT * FROM account_type where name != 'Address Book' and name != 'Self' and name != 'CSV' and name != 'VCF'";

            //Create a list to store the result
            List<AccountTypeDB> list = new List<AccountTypeDB>();

            //Open connection
            if (this.OpenConnection() == true)
            {
                //Create Command
                SQLiteCommand cmd = new SQLiteCommand(query, connection);
                //Create a data reader and Execute the command
                SQLiteDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int id = Int32.Parse(dataReader["id"].ToString());
                    string name = dataReader["name"].ToString();

                    AccountTypeDB type = new AccountTypeDB();
                    type.Id = id;
                    type.Name = name;
                    list.Add(type);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

            }
            return list;
        }
コード例 #3
0
ファイル: DBManager.cs プロジェクト: thongvo/myfiles
        public List<AccountTypeDB> GetAccountType() // ttt
        {
            List<AccountTypeDB> lists = new List<AccountTypeDB>();

            if (this.OpenConnection() == true)
            {
                string query = "SELECT * FROM account_type";
                //Create Command
                SQLiteCommand cmd = new SQLiteCommand(query, connection);
                //Create a data reader and Execute the command
                SQLiteDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    AccountTypeDB type = new AccountTypeDB();
                    int id = Int32.Parse(dataReader["id"].ToString());
                    string name = dataReader["name"].ToString();
                    type.Id = id;
                    type.Name = name;
                    lists.Add(type);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

            }
            return lists;

        }
コード例 #4
0
ファイル: DBManager.cs プロジェクト: thongvo/myfiles
        /////////////////////////////////

        //Select statement

        public AccountTypeDB GetAccountTypeByName(string name)
        {
            AccountTypeDB type = new AccountTypeDB();
            if (this.OpenConnection() == true)
            {
                string query = "SELECT * FROM account_type where name = @name";
                //Create Command
                SQLiteCommand cmd = new SQLiteCommand(query, connection);
                cmd.Parameters.AddWithValue("@name", name);
                //Create a data reader and Execute the command
                SQLiteDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int id = Int32.Parse(dataReader["id"].ToString());

                    type.Id = id;
                    type.Name = name;
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

            }
            return type;
        }