Example #1
0
        public OrderDetail SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.ORDERDETAIL, 1)), QueryTypes.DATAROW);

            return(new OrderDetail(row));
        }
        public Product SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.PRODUCT, 1)), QueryTypes.DATAROW);

            return(new Product(row));
        }
Example #3
0
        public IList <Order> SelectByCustomer(long customerId)
        {
            String statement = QualifyTableName(DbDefault.GetSelectStatement(
                                                    TableName.ORDERS, String.Format("customer_id = {0}", customerId)));

            DataTable table = null;

            if (Connection != null)
            {
                table = (DataTable)GFXDDbi.Select(Connection, statement, QueryTypes.DATATABLE);
            }
            else
            {
                table = (DataTable)GFXDDbi.Select(statement, QueryTypes.DATATABLE);
            }

            IList <Order> orders = new List <Order>();

            foreach (DataRow row in table.Rows)
            {
                orders.Add(new Order(row));
            }

            return(orders);
        }
Example #4
0
        public Customer SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.CUSTOMER, 1)), QueryTypes.DATAROW);

            return(new Customer(row));
        }
Example #5
0
        public IList <OrderDetail> Select(long orderId)
        {
            String statement = QualifyTableName(DbDefault.GetSelectStatement(
                                                    TableName.ORDERDETAIL, new long[] { orderId }));

            DataTable table = null;

            if (Connection != null)
            {
                table = (DataTable)GFXDDbi.Select(Connection, statement, QueryTypes.DATATABLE);
            }
            else
            {
                table = (DataTable)GFXDDbi.Select(statement, QueryTypes.DATATABLE);
            }

            IList <OrderDetail> orderdetails = new List <OrderDetail>();

            foreach (DataRow row in table.Rows)
            {
                orderdetails.Add(new OrderDetail(row));
            }

            return(orderdetails);
        }
Example #6
0
        public Address SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.ADDRESS, 1)), QueryTypes.DATAROW);

            return(new Address(row));
        }
Example #7
0
        public Supplier SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.SUPPLIER, 1)), QueryTypes.DATAROW);

            return(new Supplier(row));
        }
Example #8
0
        public Category SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.CATEGORY, 1)), QueryTypes.DATAROW);

            return(new Category(row));
        }
Example #9
0
 private String BuildQuery(String statement, Supplier supplier)
 {
     return(String.Format(statement,
                          GFXDDbi.Escape(supplier.Name),
                          supplier.Address.AddressId,
                          GFXDDbi.Escape(supplier.Phone),
                          GFXDDbi.Escape(supplier.Email)));
 }
Example #10
0
 private String BuildQuery(String statement, Order order)
 {
     return(String.Format(statement,
                          GFXDDbi.Escape(order.OrderDate.ToShortDateString()),
                          GFXDDbi.Escape(order.ShipDate.ToShortDateString()),
                          order.Customer.CustomerId,
                          order.SubTotal));
 }
Example #11
0
 private String BuildQuery(String statement, Customer customer)
 {
     return(String.Format(statement,
                          GFXDDbi.Escape(customer.FirstName),
                          GFXDDbi.Escape(customer.LastName),
                          customer.Address.AddressId,
                          GFXDDbi.Escape(customer.Phone),
                          GFXDDbi.Escape(customer.Email),
                          GFXDDbi.Escape(customer.LastOrderDate.ToShortDateString())));
 }
Example #12
0
 private String BuildQuery(String statement, Address address)
 {
     return(String.Format(statement,
                          GFXDDbi.Escape(address.Address1),
                          GFXDDbi.Escape(address.Address2),
                          GFXDDbi.Escape(address.Address3),
                          GFXDDbi.Escape(address.City),
                          GFXDDbi.Escape(address.State.ToString()),
                          GFXDDbi.Escape(address.ZipCode.ToString()),
                          GFXDDbi.Escape(address.Province.ToString()),
                          (int)address.CountryCode));
 }
Example #13
0
        public int Delete(long categoryId)
        {
            String statement = QualifyTableName(DbDefault.GetDeleteStatement(
                                                    TableName.CATEGORY, new long[] { categoryId }));

            if (Connection != null)
            {
                return(GFXDDbi.Delete(Connection, statement));
            }
            else
            {
                return(GFXDDbi.Delete(statement));
            }
        }
Example #14
0
        public int Update(Category category)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.CATEGORY, new long[] { category.CategoryId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, category)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, category)));
            }
        }
Example #15
0
        public IList <Supplier> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.SUPPLIER, numRecords)), QueryTypes.DATATABLE);

            IList <Supplier> suppliers = new List <Supplier>();

            foreach (DataRow row in table.Rows)
            {
                suppliers.Add(new Supplier(row));
            }

            return(suppliers);
        }
Example #16
0
        public int Delete(long orderId, long productId)
        {
            String statement = QualifyTableName(DbDefault.GetDeleteStatement(
                                                    TableName.ORDERDETAIL, new long[] { orderId, productId }));

            if (Connection != null)
            {
                return(GFXDDbi.Delete(Connection, statement));
            }
            else
            {
                return(GFXDDbi.Delete(statement));
            }
        }
Example #17
0
        public IList <Customer> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.CUSTOMER, numRecords)), QueryTypes.DATATABLE);

            IList <Customer> customers = new List <Customer>();

            foreach (DataRow row in table.Rows)
            {
                customers.Add(new Customer(row));
            }

            return(customers);
        }
Example #18
0
        public IList <OrderDetail> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.ORDERDETAIL, numRecords)), QueryTypes.DATATABLE);

            IList <OrderDetail> orderdetails = new List <OrderDetail>();

            foreach (DataRow row in table.Rows)
            {
                orderdetails.Add(new OrderDetail(row));
            }

            return(orderdetails);
        }
        public IList <Product> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.PRODUCT, numRecords)), QueryTypes.DATATABLE);

            IList <Product> products = new List <Product>();

            foreach (DataRow row in table.Rows)
            {
                products.Add(new Product(row));
            }

            return(products);
        }
Example #20
0
        public int Update(Customer customer)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.CUSTOMER, new long[] { customer.CustomerId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, customer)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, customer)));
            }
        }
        public int Update(Product product)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.PRODUCT, new long[] { product.ProductId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, product)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, product)));
            }
        }
Example #22
0
        public IList <Category> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.CATEGORY, numRecords)), QueryTypes.DATATABLE);

            IList <Category> categories = new List <Category>();

            foreach (DataRow row in table.Rows)
            {
                categories.Add(new Category(row));
            }

            return(categories);
        }
Example #23
0
        public int Update(Supplier supplier)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.SUPPLIER, new long[] { supplier.SupplierId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, supplier)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, supplier)));
            }
        }
Example #24
0
        public IList <Address> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.ADDRESS, numRecords)), QueryTypes.DATATABLE);

            IList <Address> addresses = new List <Address>();

            foreach (DataRow row in table.Rows)
            {
                addresses.Add(new Address(row));
            }

            return(addresses);
        }
Example #25
0
        public int Update(OrderDetail ordDetail)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.ORDERDETAIL, new long[] { ordDetail.OrderId, ordDetail.ProductId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, ordDetail)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, ordDetail)));
            }
        }
Example #26
0
        public int Delete(long supplierId)
        {
            String statement = QualifyTableName(DbDefault.GetDeleteStatement(
                                                    TableName.SUPPLIER, new long[] { supplierId }));

            if (Connection != null)
            {
                return(GFXDDbi.Delete(Connection, statement));
            }
            else
            {
                return(GFXDDbi.Delete(statement));
            }
        }
 private String BuildQuery(String statement, Product product)
 {
     return(String.Format(statement,
                          GFXDDbi.Escape(product.Name),
                          GFXDDbi.Escape(product.Description),
                          product.Category.CategoryId,
                          product.Supplier.SupplierId,
                          product.UnitCost,
                          product.RetailPrice,
                          product.UnitsInStock,
                          product.ReorderQuantity,
                          GFXDDbi.Escape(product.LastOrderDate.ToShortDateString()),
                          GFXDDbi.Escape(product.NextOrderDate.ToShortDateString())));
 }
Example #28
0
        public int Update(Address address)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.ADDRESS, new long[] { address.AddressId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, address)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, address)));
            }
        }
Example #29
0
        public int Delete(long addressId)
        {
            String statement = DbDefault.GetDeleteStatement(
                TableName.ADDRESS, new long[] { addressId });

            if (Connection != null)
            {
                return(GFXDDbi.Delete(Connection, statement));
            }
            else
            {
                return(GFXDDbi.Delete(statement));
            }
        }
Example #30
0
        public long Insert(Address address)
        {
            String statement = QualifyTableName(DbDefault.GetInsertStatement(
                                                    TableName.ADDRESS, new long[] { address.AddressId }));

            statement = BuildQuery(statement, address);

            if (Connection != null)
            {
                return(GFXDDbi.Insert(Connection, statement));
            }
            else
            {
                return(GFXDDbi.Insert(statement));
            }
        }