示例#1
0
        public static List <Customer> read(string customQuery, string limitQuery)
        {
            try
            {
                List <Customer> customers = new List <Customer>();

                DBHandler dbHandler = new DBHandler();

                string query = "SELECT * FROM customer ";

                if (limitQuery != null)
                {
                    query += limitQuery;
                }

                dbHandler.OPEN(query);

                while (dbHandler.reader.Read())
                {
                    Customer customer = new Customer();

                    customer.code     = DBDataHandler.object_to_string(dbHandler.reader["code"]);
                    customer.name     = DBDataHandler.object_to_string(dbHandler.reader["name"]);
                    customer.address1 = DBDataHandler.object_to_string(dbHandler.reader["address1"]);
                    customer.email    = DBDataHandler.object_to_string(dbHandler.reader["email"]);

                    customers.Add(customer);
                }

                dbHandler.CLOSE();


                return(customers);
            }
            catch (Exception)
            {
                return(null);
            }
        }
示例#2
0
        public static List <Inventory> read(string customQuery, string limitQuery)
        {
            try
            {
                DBHandler        dbHandler   = new DBHandler();
                List <Inventory> inventories = new List <Inventory>();

                string query = "SELECT * FROM inventory ";

                if (limitQuery != null)
                {
                    query += limitQuery;
                }

                dbHandler.OPEN(query);

                while (dbHandler.reader.Read())
                {
                    Inventory inventory = new Inventory();

                    inventory.code        = DBDataHandler.object_to_string(dbHandler.reader["code"]);
                    inventory.name        = DBDataHandler.object_to_string(dbHandler.reader["name"]);
                    inventory.description = DBDataHandler.object_to_string(dbHandler.reader["description"]);
                    inventory.price       = DBDataHandler.object_to_decimal(dbHandler.reader["price"]);

                    inventories.Add(inventory);
                }

                dbHandler.CLOSE();

                return(inventories);
            }
            catch (Exception)
            {
                return(null);
            }
        }