예제 #1
0
        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;
        }
예제 #2
0
        /////////////////////////////////

        //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;
        }