public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsProductCollection AllProducts = new clsProductCollection();
            //create the item of test data
            clsProduct TestItem   = new clsProduct();
            Int32      PrimaryKey = 0;

            //set its properties
            TestItem.ProductNo   = 1;
            TestItem.ProductName = "Samsung";
            TestItem.Description = "Black";
            TestItem.Price       = 1299;
            TestItem.Active      = true;
            //set ThisProduct to test the data
            AllProducts.ThisProduct = TestItem;
            //add the record
            PrimaryKey         = AllProducts.Add();
            TestItem.ProductNo = PrimaryKey;
            //find the record
            AllProducts.ThisProduct.Find(PrimaryKey);
            //delete the record
            AllProducts.Delete();
            //now find the record
            Boolean Found = AllProducts.ThisProduct.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
        public void UpdateMethodOK()
        {
            clsProductCollection Products    = new clsProductCollection();
            clsProduct           TestProduct = new clsProduct();
            Int32 PrimaryKey = 0;

            TestProduct.ProductName        = "Metal Gear Ray Figure";
            TestProduct.ProductDescription = "A die-cast figurine of Metal Gear Ray from Metal Gear Solid 2.";
            TestProduct.UnitPrice          = 90.00;
            TestProduct.InStock            = true;
            TestProduct.StockAmount        = 1;
            TestProduct.DiscountPercentage = 0;
            TestProduct.DiscountActive     = false;

            Products.ThisProduct  = TestProduct;
            PrimaryKey            = Products.Add();
            TestProduct.ProductNo = PrimaryKey;

            TestProduct.ProductName        = "Metal Gear Solid Snake Figure";
            TestProduct.ProductDescription = "A die-cast figurine of Solid Snake from Metal Gear Solid.";
            TestProduct.UnitPrice          = 60.00;
            TestProduct.InStock            = false;
            TestProduct.StockAmount        = 0;
            TestProduct.DiscountPercentage = 20;
            TestProduct.DiscountActive     = true;

            Products.ThisProduct = TestProduct;
            Products.Update();
            Products.ThisProduct.Find(PrimaryKey);
            Assert.AreEqual(Products.ThisProduct, TestProduct);
        }
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsProductCollection AllProducts = new clsProductCollection();
            //create the item of test data
            clsProduct TestItem   = new clsProduct();
            Int32      PrimaryKey = 0;

            //set its properties
            TestItem.ProductName = "Samsung S9";
            TestItem.Description = "Black";
            TestItem.Price       = 1234;
            TestItem.Active      = true;
            //set ThisProduct to test the data
            AllProducts.ThisProduct = TestItem;
            //add the record
            PrimaryKey = AllProducts.Add();
            //set primary key of
            TestItem.ProductNo = PrimaryKey;
            //modify the test data
            TestItem.ProductName = "IPhone";
            TestItem.Description = "Gold";
            TestItem.Price       = 124;
            TestItem.Active      = false;
            //set the record based on the new test data
            AllProducts.ThisProduct = TestItem;
            //update the record
            AllProducts.Update();
            //find the record
            AllProducts.ThisProduct.Find(PrimaryKey);
            //test to see ThisStaff matches the test data
            Assert.AreEqual(AllProducts.ThisProduct, TestItem);
        }
Ejemplo n.º 4
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsProductCollection AllProducts = new clsProductCollection();
            //creat the item of test data
            clsProduct TestProduct = new clsProduct();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            //TestProduct.Out_Of_Stock = true;
            TestProduct.Product_ID   = 000007;
            TestProduct.Title        = "Test";
            TestProduct.Description  = "Testing";
            TestProduct.Unit_Price   = Convert.ToDouble("50.00");
            TestProduct.Release_Date = Convert.ToDateTime("12/08/1991");
            TestProduct.Genre        = "Horror";
            TestProduct.Platform     = "Sega Megadrive";
            //set thisproduct to the test data
            AllProducts.ThisProduct = TestProduct;
            //add the record
            PrimaryKey = AllProducts.Add();
            //Set the primary key of the test data
            TestProduct.Product_ID = PrimaryKey;
            //find the record
            AllProducts.ThisProduct.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.ThisProduct, TestProduct);
        }
Ejemplo n.º 5
0
        public void DeleteMethodOK()
        {
            clsProductCollection AllProducts = new clsProductCollection();
            clsProduct           TestItem    = new clsProduct();

            Int32 PrimaryKey = 0;

            TestItem.Product_ID    = 1;
            TestItem.Name          = "Dave";
            TestItem.Type          = "Dave";
            TestItem.Colour        = "Dave";
            TestItem.Cost          = 1;
            TestItem.Stock_Count   = 1;
            TestItem.Is_Available  = true;
            TestItem.Next_Delivery = DateTime.Now.Date;

            AllProducts.ThisProduct = TestItem;
            PrimaryKey = AllProducts.Add();

            TestItem.Product_ID = PrimaryKey;
            AllProducts.ThisProduct.Find(PrimaryKey);

            AllProducts.Delete();

            Boolean Found = AllProducts.ThisProduct.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Ejemplo n.º 6
0
    protected void OK_Click(object sender, EventArgs e)
    {
        clsProduct AProduct           = new clsProduct();
        String     ProductName        = txtProductName.Text;
        String     ProductDescription = txtProductDescription.Text;
        String     UnitPrice          = txtUnitPrice.Text;
        String     StockAmount        = txtStockAmount.Text;
        String     DiscountPercentage = txtDiscountPercentage.Text;
        String     Error = "";

        Error = AProduct.Valid(ProductName, ProductDescription, UnitPrice, StockAmount, DiscountPercentage);

        if (Error == "")
        {
            if (Convert.ToInt32(StockAmount) == 0)
            {
                AProduct.InStock = false;
            }
            else
            {
                AProduct.InStock = true;
            }

            if (Convert.ToInt32(DiscountPercentage) == 0)
            {
                AProduct.DiscountActive = false;
            }
            else
            {
                AProduct.DiscountActive = true;
            }

            AProduct.ProductNo          = ProductNo;
            AProduct.ProductName        = ProductName;
            AProduct.ProductDescription = ProductDescription;
            AProduct.UnitPrice          = Convert.ToDouble(UnitPrice);
            AProduct.StockAmount        = Convert.ToInt32(StockAmount);
            AProduct.DiscountPercentage = Convert.ToInt32(DiscountPercentage);
            AProduct.Active             = Active.Checked;
            clsProductCollection Products = new clsProductCollection();

            if (ProductNo == -1)
            {
                Products.ThisProduct = AProduct;
                Products.Add();
            }
            else
            {
                Products.ThisProduct.Find(ProductNo);
                Products.ThisProduct = AProduct;
                Products.Update();
            }
            Response.Redirect("ProductList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
Ejemplo n.º 7
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        clsProduct AProduct = new clsProduct();

        int    Product_ID    = Convert.ToInt32(TxtID.Text);
        string Name          = TxtName.Text;
        string Type          = TxtType.Text;
        string Colour        = TxtColour.Text;
        int    Cost          = Convert.ToInt32(TxtCost.Text);
        int    Stock_Count   = Convert.ToInt32(TxtStock_Count.Text);
        string Next_Delivery = TxtNext_Delivery.Text;

        string Error = "";

        Error = AProduct.Valid(Product_ID, Name, Type, Colour, Cost, Stock_Count, Next_Delivery);
        if (Error == "")
        {
            AProduct.Product_ID = ProductId;

            AProduct.Name          = TxtName.Text;
            AProduct.Type          = TxtType.Text;
            AProduct.Colour        = TxtColour.Text;
            AProduct.Cost          = Convert.ToInt32(TxtCost.Text);
            AProduct.Stock_Count   = Convert.ToInt32(TxtStock_Count.Text);
            AProduct.Is_Available  = Convert.ToBoolean(ChkAvailable.Checked);
            AProduct.Next_Delivery = Convert.ToDateTime(TxtNext_Delivery.Text);

            clsProductCollection ProductList = new clsProductCollection();

            if (ProductId == -1)
            {
                ProductList.ThisProduct = AProduct;
                ProductList.Add();
            }
            else
            {
                ProductList.ThisProduct.Find(ProductId);
                ProductList.ThisProduct = AProduct;

                Response.Redirect("ProductList.aspx");
            }



            Response.Redirect("ProductViewer.aspx");
        }
        else
        {
            LblError.Text = Error;
        }
    }
        public void DeleteMethodOK()
        {
            clsProductCollection Products    = new clsProductCollection();
            clsProduct           TestProduct = new clsProduct();
            Int32 PrimaryKey = 0;

            TestProduct.ProductName        = "Metal Gear Ray Figure";
            TestProduct.ProductDescription = "A die-cast figurine of Metal Gear Ray from Metal Gear Solid 2.";
            TestProduct.UnitPrice          = 90.00;
            TestProduct.InStock            = true;
            TestProduct.StockAmount        = 1;
            TestProduct.DiscountPercentage = 0;
            TestProduct.DiscountActive     = false;

            Products.ThisProduct  = TestProduct;
            PrimaryKey            = Products.Add();
            TestProduct.ProductNo = PrimaryKey;
            Products.ThisProduct.Find(PrimaryKey);
            Products.Delete();
            Boolean Found = Products.ThisProduct.Find(PrimaryKey);
        }
Ejemplo n.º 9
0
        //function for creating new records
        void Add()
        {
            clsProductCollection ProductCollect = new clsProductCollection();
            String Error = ProductCollect.ThisProduct.Valid(txtProductName.Text, txtDescription.Text, txtPrice.Text);

            //if the data is OK then add it to the objct
            if (Error == "")
            {
                ProductCollect.ThisProduct.ProductName = txtProductName.Text;
                ProductCollect.ThisProduct.Description = txtDescription.Text;
                ProductCollect.ThisProduct.Price       = Convert.ToDecimal(txtPrice.Text);
                ProductCollect.ThisProduct.Active      = chkActive.Checked;
                //add the record
                ProductCollect.Add();
                //all done so redirect back to the main page
                Response.Redirect("ProductDefault.aspx");
            }
            else
            {
                lblError.Text = "There were problems with the data entered" + Error;
            }
        }
Ejemplo n.º 10
0
        public void DeleteMethodOK()
        {
            clsProductCollection AllProducts = new clsProductCollection();
            clsProduct           TestProduct = new clsProduct();
            Int32 PrimaryKey = 0;

            TestProduct.Product_ID   = 000007;
            TestProduct.Title        = "Test";
            TestProduct.Description  = "Testing";
            TestProduct.Unit_Price   = Convert.ToDouble("50.00");
            TestProduct.Release_Date = Convert.ToDateTime("12/08/1991");
            TestProduct.Genre        = "Horror";
            TestProduct.Platform     = "Sega Megadrive";
            AllProducts.ThisProduct  = TestProduct;
            PrimaryKey             = AllProducts.Add();
            TestProduct.Product_ID = PrimaryKey;
            AllProducts.ThisProduct.Find(PrimaryKey);
            AllProducts.Delete();
            Boolean Found = AllProducts.ThisProduct.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Ejemplo n.º 11
0
        public void UpdateMethodOK()
        {
            clsProductCollection AllProducts = new clsProductCollection();
            clsProduct           TestProduct = new clsProduct();
            Int32 PrimaryKey = 0;

            //set its propertieis
            TestProduct.Product_ID   = 000022;
            TestProduct.Title        = "Test";
            TestProduct.Description  = "Testing";
            TestProduct.Unit_Price   = Convert.ToDouble("50.00");
            TestProduct.Release_Date = Convert.ToDateTime("12/08/1991");
            TestProduct.Out_Of_Stock = "0";
            TestProduct.Genre        = "Horror";
            TestProduct.Platform     = "Sega Megadrive";
            AllProducts.ThisProduct  = TestProduct;
            //add test data
            PrimaryKey = AllProducts.Add();
            //set primary key of test data
            TestProduct.Product_ID = PrimaryKey;
            //modify the test data
            TestProduct.Product_ID   = 000007;
            TestProduct.Title        = "Test2";
            TestProduct.Description  = "2Testing";
            TestProduct.Unit_Price   = Convert.ToDouble("60.00");
            TestProduct.Release_Date = Convert.ToDateTime("12/08/1998");
            TestProduct.Genre        = "Rythem";
            TestProduct.Platform     = "Sega Saturn";
            AllProducts.ThisProduct  = TestProduct;
            //set the record based on the new test data
            AllProducts.ThisProduct = TestProduct;
            //update the record
            AllProducts.Update();
            //find the record
            AllProducts.ThisProduct.Find(PrimaryKey);
            //test to see thisproduct matches the test data
            Assert.AreEqual(AllProducts.ThisProduct, TestProduct);
        }
Ejemplo n.º 12
0
        public void UpdateMethodOK()
        {
            clsProductCollection AllProducts = new clsProductCollection();
            clsProduct           TestItem    = new clsProduct();

            Int32 PrimaryKey = 0;

            TestItem.Name          = "Dave";
            TestItem.Type          = "Dave";
            TestItem.Colour        = "Dave";
            TestItem.Cost          = 1;
            TestItem.Stock_Count   = 1;
            TestItem.Is_Available  = true;
            TestItem.Next_Delivery = DateTime.Now.Date;

            AllProducts.ThisProduct = TestItem;
            PrimaryKey = AllProducts.Add();

            TestItem.Product_ID = PrimaryKey;


            TestItem.Name          = "Joe";
            TestItem.Type          = "Joe";
            TestItem.Colour        = "Joe";
            TestItem.Cost          = 21;
            TestItem.Stock_Count   = 12;
            TestItem.Is_Available  = false;
            TestItem.Next_Delivery = DateTime.Now.Date;

            AllProducts.ThisProduct = TestItem;
            AllProducts.Update();


            AllProducts.ThisProduct.Find(PrimaryKey);

            Assert.AreEqual(AllProducts.ThisProduct, TestItem);
        }
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsProductCollection AllProducts = new clsProductCollection();
            //create the item of test data
            clsProduct TestItem   = new clsProduct();
            Int32      PrimaryKey = 0;

            //set its properties
            TestItem.ProductNo   = 1;
            TestItem.ProductName = "Samsung";
            TestItem.Description = "Black";
            TestItem.Price       = 1299;
            TestItem.Active      = true;
            //set ThisProduct to test the data
            AllProducts.ThisProduct = TestItem;
            //add the record
            PrimaryKey         = AllProducts.Add();
            TestItem.ProductNo = PrimaryKey;
            //find the record
            AllProducts.ThisProduct.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.ThisProduct, TestItem);
        }
Ejemplo n.º 14
0
    //event handler for the ok button
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //creates a new instance of clsProduct
        clsProduct AProduct = new clsProduct();
        //capture product_id
        string ProductID = Convert.ToString(txtProductID);
        //capture title
        string Title = txtTitle.Text;
        //Capture Description
        string Description = txtDescription.Text;
        //Capture unit price
        string Unit_Price = txtUnitPrice.Text;
        //Capture Platform
        string Platform = txtPlatform.Text;
        //Capture Release_Date
        string Release_Date = txtReleaseDate.Text;
        //Capture Genre
        string Genre = txtGenre.Text;
        //Capture Out of stock
        string Out_Of_Stock = txtOut_Of_Stock.Text;
        //variable to store any error messages
        string Error = "";

        //validate the data
        Error = AProduct.Valid(Title, Description, Unit_Price, Release_Date, Platform, Genre);
        if (Error == "")
        {
            //capture the product id
            AProduct.Product_ID = Product_ID;

            //capture the title
            AProduct.Title = Title;
            //capture the Description
            AProduct.Description = Description;
            //capture the Unit price
            AProduct.Unit_Price = Convert.ToDouble(Unit_Price);
            //capture the genre
            AProduct.Genre = Genre;
            //Capture the platform
            AProduct.Platform = Platform;
            //Capture the release date
            AProduct.Release_Date = Convert.ToDateTime(Release_Date);
            //capture the out of stock status
            AProduct.Out_Of_Stock = Out_Of_Stock;


            //Create a new instance of the address collection
            clsProductCollection ProductList = new clsProductCollection();
            //if this is a new record then add the data
            if (Product_ID == -1)
            {
                //set the ThisProduct property
                ProductList.ThisProduct = AProduct;
                //Add the new record
                ProductList.Add();
            }
            else//otherwise must be an update
            {
                //find the record to update
                ProductList.ThisProduct.Find(Product_ID);
                //set the thisproduct property
                ProductList.ThisProduct = AProduct;
                //update the record
                ProductList.Update();
            }

            //Redirect back to the listpage
            Response.Redirect("ProductList.aspx");
        }
        else
        {
            //display the error message
            lblError.Text = Error;
        }

        //store the product id in the session object
        Session["AProduct"] = AProduct;
        //Redirect to the viewer page
        Response.Redirect("ProductViewer.aspx");
    }