public void ReportByProductNameNoneFound()
        {
            clsProductCollection FilteredProducts = new clsProductCollection();

            FilteredProducts.ReportByProductName("abcdefg");
            Assert.AreEqual(0, FilteredProducts.Count);
        }
        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);
        }
        //function for updating records
        void Update()
        {
            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 == "")
            {
                //find the record to update
                ProductCollect.ThisProduct.Find(ProductNo);
                //get data entered by the user
                ProductCollect.ThisProduct.ProductName = txtProductName.Text;
                ProductCollect.ThisProduct.Description = txtDescription.Text;
                ProductCollect.ThisProduct.Price       = Convert.ToDecimal(txtPrice.Text);
                ProductCollect.ThisProduct.Active      = chkActive.Checked;

                //update the record
                ProductCollect.Update();
                //all done so redirect to the main page
                Response.Redirect("ProductDefault.aspx");
            }
            else
            {
                //report an error
                lblError.Text = "There were problems with the data entered " + Error;
            }
        }
Exemplo n.º 5
0
        public void ProductListOK()
        {
            //create an instance for the class we want to create
            clsProductCollection AllProducts = new clsProductCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsProduct> TestList = new List <clsProduct>();
            //add an item to the list
            //create the item of the test data
            clsProduct TestItem = new clsProduct();

            //set its properties
            TestItem.CategoryID    = 2;
            TestItem.NoAvailable   = 10;
            TestItem.ProductDetail = "used";
            TestItem.ProductID     = 3;
            TestItem.ProductName   = "laptop";
            TestItem.ProductPrice  = 650.00m;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllProducts.ProductList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.ProductList, TestList);
        }
        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);
        }
Exemplo n.º 7
0
        public void ReportByGenreTestDataFound()
        {
            clsProductCollection FilteredProducts = new clsProductCollection();
            Boolean OK = true;

            FilteredProducts.ReportByGenre("Role-playing");
            //check that the correct number of records are found
            if (FilteredProducts.Count == 2)
            {
                //check that the first record product_id is 000003
                if (FilteredProducts.ProductList[0].Product_ID != 000003)
                {
                    OK = true;
                }
                //check that the first record product_id is 000004
                if (FilteredProducts.ProductList[0].Product_ID != 000004)
                {
                    OK = false;
                }
                else
                {
                    OK = false;
                }
                //test to see that there are no records
                Assert.IsTrue(OK);
            }
        }
        Int32 DisplayProductName(string ProductNameFilter)
        {
            Int32  ProductNo;   // var to store the primary key
            string ProductName; // var to store the surname

            //create an instance of the address collection class
            clsProductCollection Product = new clsProductCollection();

            Product.ReportByProductName(ProductNameFilter);
            Int32 RecordCount;                                        // var to store the count of records
            Int32 Index = 0;                                          // var to store the index for the loop

            RecordCount = Product.Count;                              //get the count of records
            lstProduct.Items.Clear();
            while (Index < RecordCount)                               // while there are records to process
            {
                ProductNo   = Product.ProductList[Index].ProductNo;   //get the primary key
                ProductName = Product.ProductList[Index].ProductName; //get the Surnanme

                //create a new entry for the listbox
                ListItem NewEntry = new ListItem(ProductName, ProductNo.ToString());
                lstProduct.Items.Add(NewEntry);
                Index++;
            }
            return(RecordCount);//return the count of records found
        }
Exemplo n.º 9
0
        public void ReportByGenreNoneFound()
        {
            clsProductCollection FilteredProducts = new clsProductCollection();

            FilteredProducts.ReportByGenre("HotDog Sales");
            Assert.AreEqual(0, FilteredProducts.Count);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        public void ReportByTypeDataFound()
        {
            clsProductCollection FilteredProducts = new clsProductCollection();

            Boolean OK = true;

            FilteredProducts.ReportByType("Cape");
            if (FilteredProducts.Count == 2)
            {
                if (FilteredProducts.ProductsList[0].Product_ID != 1)
                {
                    OK = false;
                }
                if (FilteredProducts.ProductsList[1].Product_ID != 9)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }

            Assert.IsTrue(OK);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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;
        }
    }
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        clsProductCollection ProductBook = new clsProductCollection();

        ProductBook.ThisProduct.Find(ProductNo);
        ProductBook.Delete();
        Response.Redirect("ProductList.aspx");
    }
Exemplo n.º 15
0
        public void ReportByTypeNoneFound()
        {
            clsProductCollection FilteredProducts = new clsProductCollection();

            FilteredProducts.ReportByType("Jeff");

            Assert.AreEqual(0, FilteredProducts.Count);
        }
        public void ReportByProductNameMethodOK()
        {
            clsProductCollection Products         = new clsProductCollection();
            clsProductCollection FilteredProducts = new clsProductCollection();

            FilteredProducts.ReportByProductName("");
            Assert.AreEqual(Products.Count, FilteredProducts.Count);
        }
Exemplo n.º 17
0
    protected void BtnYes_Click(object sender, EventArgs e)
    {
        clsProductCollection ProductList = new clsProductCollection();

        ProductList.ThisProduct.Find(ProductId);
        ProductList.Delete();
        Response.Redirect("ProductList");
    }
Exemplo n.º 18
0
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            clsProductCollection AllProducts = new clsProductCollection();

            //test to see that it exists
            Assert.IsNotNull(AllProducts);
        }
        void DeleteProduct()
        {
            clsProductCollection ProductCollect = new clsProductCollection();

            //find the record to delete
            ProductCollect.ThisProduct.Find(ProductNo);
            //delete the record
            ProductCollect.Delete();
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ProductNo = Convert.ToInt32(Session["ProductNo"]);
        clsProductCollection ProductBook = new clsProductCollection();

        ProductBook.ThisProduct.Find(ProductNo);
        lblName.Text = ProductBook.ThisProduct.ProductName;
        lblDesc.Text = ProductBook.ThisProduct.ProductDescription;
    }
Exemplo n.º 21
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsProductCollection Products = new clsProductCollection();

        Products.ReportByProductName(txtNameSearch.Text);
        ProductListBox.DataSource     = Products.ProductList;
        ProductListBox.DataValueField = "ProductNo";
        ProductListBox.DataTextField  = "ProductName";
        ProductListBox.DataBind();
    }
Exemplo n.º 22
0
    protected void BtnApply_Click(object sender, EventArgs e)
    {
        clsProductCollection Products = new clsProductCollection();

        Products.ReportByType(TxtType.Text);

        LstProductList.DataSource    = Products.ProductsList;
        LstProductList.DataTextField = "Type";
        LstProductList.DataBind();
    }
        public void ReportByProductNameNoneFound()
        {
            //create an instance of the filtered data
            clsProductCollection FilteredProduct = new clsProductCollection();

            //apply a Product name that doesn't exist
            FilteredProduct.ReportByProductName("qqqqq");
            //test to see that there are no records
            Assert.AreEqual(0, FilteredProduct.Count);
        }
        public void ReportByProductNameOK()
        {
            //create an instance of the class containing unfiltered results
            clsProductCollection AllProducts = new clsProductCollection();
            //create an instance of the filtered data
            clsProductCollection FilteredProduct = new clsProductCollection();

            //apply a blank string(Should return all records);
            FilteredProduct.ReportByProductName("");
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.Count, FilteredProduct.Count);
        }
Exemplo n.º 25
0
    protected void btnYes_Click(object sender, EventArgs e)
    {
        //CREATE A NEW INSTANCE OF THE PRODUCT LIST
        clsProductCollection ProductList = new clsProductCollection();

        //find the record to delete
        ProductList.ThisProduct.Find(Product_ID);
        //delete the record
        ProductList.Delete();
        //redirect back to the main page
        Response.Redirect("ProductList.aspx");
    }
Exemplo n.º 26
0
    void DisplayProduct()
    {
        clsProductCollection ProductBook = new clsProductCollection();

        ProductBook.ThisProduct.Find(ProductNo);
        //display data from product object in the form for editing.
        txtProductNo.Text          = ProductBook.ThisProduct.ProductNo.ToString();
        txtProductName.Text        = ProductBook.ThisProduct.ProductName;
        txtProductDescription.Text = ProductBook.ThisProduct.ProductDescription;
        txtUnitPrice.Text          = ProductBook.ThisProduct.UnitPrice.ToString();
        txtStockAmount.Text        = ProductBook.ThisProduct.StockAmount.ToString();
        txtDiscountPercentage.Text = ProductBook.ThisProduct.DiscountPercentage.ToString();
    }
Exemplo n.º 27
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsProductCollection Products = new clsProductCollection();

        //Products.ReportByGenre(txtFilter.Text);
        lstProductList.DataSource = Products.ProductList;
        //set the name of the primary field
        lstProductList.DataValueField = "Product_ID";
        //SET THE NAME OF THE FIELD TO DISPLAY
        lstProductList.DataTextField = "Genre";
        //bind the data to the list
        lstProductList.DataBind();
    }
Exemplo n.º 28
0
        void DisplayProduct()
        {
            //create an instance of Product Collection
            clsProductCollection ProductCollect = new clsProductCollection();

            //find the record to update
            ProductCollect.ThisProduct.Find(ProductNo);
            //display the data for this record
            txtProductName.Text = ProductCollect.ThisProduct.ProductName;
            txtDescription.Text = ProductCollect.ThisProduct.Description;
            txtPrice.Text       = ProductCollect.ThisProduct.Price.ToString();
            chkActive.Checked   = ProductCollect.ThisProduct.Active;
        }
Exemplo n.º 29
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;
        }
    }
        void DisplayProduct()
        {
            //create an instance of the Product collection
            clsProductCollection Product = new clsProductCollection();

            //set the source to the list of Product in the collection
            lstProduct.DataSource = Product.ProductList;
            //get the primary key
            lstProduct.DataValueField = "ProductNo";
            //set the data field to display
            lstProduct.DataTextField = "ProductName";
            //bind data to the list
            lstProduct.DataBind();
        }