Пример #1
0
        public static CoffeeTable Read(long _id)
        {
            IDbConnection db   = new SqlConnection("Server=GWJSN13\\SQLEXPRESS; Database=Coffee2; user id=admin; password=pass1;");
            CoffeeTable   prod = db.Get <CoffeeTable>(_id);

            return(prod);
        }
Пример #2
0
        public static void Delete(long _productID)
        {
            CoffeeTable prod = new CoffeeTable()
            {
                ProductID = _productID
            };
            IDbConnection db = new SqlConnection("Server=GWJSN13\\SQLEXPRESS; Database=Coffee2; user id=admin; password=pass1;");

            db.Delete(prod);
        }
Пример #3
0
        public static void Update(long _productID, string _productName, string _description, decimal _price, string _category)
        {
            CoffeeTable prod = new CoffeeTable()
            {
                ProductID = _productID, ProductName = _productName, Description = _description, Price = _price, Category = _category
            };
            IDbConnection db = new SqlConnection("Server=GWJSN13\\SQLEXPRESS; Database=Coffee2; user id=admin; password=pass1;");

            db.Update(prod);
        }
Пример #4
0
        public static void Create(string _productName, string _description, decimal _price, string _category) // Creates a product
        {
            // Create the new Product instance
            CoffeeTable prod = new CoffeeTable()
            {
                ProductName = _productName, Description = _description, Price = _price, Category = _category
            };

            // Save it to the database
            IDbConnection db = new SqlConnection("Server=GWJSN13\\SQLEXPRESS; Database=Coffee2; user id=admin; password=pass1;");

            db.Insert <CoffeeTable>(prod);

            // Set the id column of the instance
            //prod.ProductID = _id;

            // Return the instance
            //return prod;
        }