Пример #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Product product = new Product();
                product.ProdName        = txtName.Text.ToString();
                product.ProdPrice       = Convert.ToDecimal(txtPrice.Text);
                product.ProdDescription = txtPDescription.Text.ToString();
                product.CategoryId      = Convert.ToInt32(ddlCategory.SelectedItem.Value);
                product.ProductTypeId   = Convert.ToInt32(ddlProdType.SelectedItem.Value);
                if (imgUploader.HasFile)
                {
                    int            length  = imgUploader.PostedFile.ContentLength;
                    byte[]         imgbyte = new byte[length];
                    HttpPostedFile img     = imgUploader.PostedFile;
                    //set the binary data
                    img.InputStream.Read(imgbyte, 0, length);
                    string filename = Path.GetFileName(imgUploader.PostedFile.FileName);

                    //be.Eimage=txtimage.
                    product.PhotoName = filename;
                    product.Photo     = imgbyte;
                }
                clsProduct _product = new clsProduct();
                _product.AddProduct(product);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //create a new instance of clsProduct
        clsProduct AProduct = new clsProduct();
        //capture the name
        string Name = txtName.Text;
        //capture the price
        string Price = txtName.Text;
        //capture the description
        string Description = txtDescription.Text;
        //variable to the store any error messages
        string Error = "";

        //validate the data
        Error = AProduct.Valid(Name, Price, Description);
        if (Error == "")
        {
            //capture the Name
            AProduct.Name = Name;
            //capture the price
            AProduct.Price = Price;
            //capture the description
            AProduct.Description = Description;
            //store the product name in the session object
            Session["AProduct"] = AProduct;
            //redirect to the viewer page
            Response.Redirect("ProductViewer.aspx");
        }
        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        clsProduct AProduct = new clsProduct();

        AProduct = (clsProduct)Session["AProduct"];
        Response.Write(AProduct.Product_ID);
    }
Пример #4
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 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 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()
        {
            //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);
        }
Пример #8
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);
        }
Пример #9
0
        public static List <clsProduct> ProductEdit(string ProductCode)
        {
            string            con     = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            List <clsProduct> details = new List <clsProduct>();
            SqlDataAdapter    da      = new SqlDataAdapter(@"SELECT        SNO, ProductCode, ProductName, ProductDescription, ProductBarCode, ProductCategoryID, ProductBrandID, ProductOriginID, UnitID, PackingID, ColorID, SizeID, ProductImagePath, 
                         UserID, SizeName, CategoryName, GroupName, BrandName, ProductOriginName, UnitName, PackingName, ColorName,GroupID,ProductUsageTypeID
FROM            IMIS_VWProducts
WHERE        ProductCode='" + ProductCode + "'", con);
            DataTable         dt      = new DataTable();

            da.Fill(dt);
            foreach (DataRow dtrow in dt.Rows)
            {
                clsProduct obj = new clsProduct();
                obj.ProductCode        = dtrow["ProductCode"].ToString();
                obj.ProductName        = dtrow["ProductName"].ToString();
                obj.ProductDescription = dtrow["ProductDescription"].ToString();
                obj.ProductUsageTypeID = int.Parse(dtrow["ProductUsageTypeID"].ToString());
                obj.ProductBarCode     = dtrow["ProductBarCode"].ToString();
                obj.GroupID            = int.Parse(dtrow["GroupID"].ToString());
                obj.ProductCategoryID  = int.Parse(dtrow["ProductCategoryID"].ToString());
                obj.ProductBrandID     = int.Parse(dtrow["ProductBrandID"].ToString());
                obj.ProductOriginID    = int.Parse(dtrow["ProductOriginID"].ToString());
                obj.UnitID             = int.Parse(dtrow["UnitID"].ToString());
                obj.PackingID          = int.Parse(dtrow["PackingID"].ToString());
                obj.UnitID             = int.Parse(dtrow["UnitID"].ToString());
                obj.ColorID            = int.Parse(dtrow["ColorID"].ToString());
                obj.SizeID             = int.Parse(dtrow["SizeID"].ToString());
                obj.ProductImagePath   = dtrow["ProductImagePath"].ToString().Replace("~/", "../");
                details.Add(obj);
            }
            // Newtonsoft.Json.js
            return(details);
        }
Пример #10
0
        public static List <clsProduct> ProductEdit2(clsProduct Obj)
        {
            List <clsProduct> details = new List <clsProduct>();
            DataTable         dt      = new DataTable();

            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter("@SNO", Obj.SNO);
            dt   = clsCURD.GetData("IMIS_ProSelectProductBySNO", p);
            foreach (DataRow dtrow in dt.Rows)
            {
                clsProduct obj = new clsProduct();
                obj.SNO                  = int.Parse(dtrow["SNO"].ToString());
                obj.ProductName          = dtrow["ProductName"].ToString();
                obj.ProductDescription   = dtrow["ProductDescription"].ToString();
                obj.ProductUsageTypeName = dtrow["ProductUsageTypeName"].ToString();
                obj.ProductBarCode       = dtrow["ProductBarCode"].ToString();
                obj.GroupID              = int.Parse(dtrow["GroupID"].ToString());
                obj.ProductCategoryID    = int.Parse(dtrow["ProductCategoryID"].ToString());
                obj.ProductBrandID       = int.Parse(dtrow["ProductBrandID"].ToString());
                obj.ProductOriginID      = int.Parse(dtrow["ProductOriginID"].ToString());
                obj.UnitID               = int.Parse(dtrow["UnitID"].ToString());
                obj.PackingID            = int.Parse(dtrow["PackingID"].ToString());
                obj.UnitID               = int.Parse(dtrow["UnitID"].ToString());
                obj.ColorID              = int.Parse(dtrow["ColorID"].ToString());
                obj.SizeID               = int.Parse(dtrow["SizeID"].ToString());
                obj.SalePrice            = float.Parse(dtrow["SalePrice"].ToString());
                obj.SizeID               = int.Parse(dtrow["SizeID"].ToString());
                obj.ProductImagePath     = dtrow["ProductImagePath"].ToString().Replace("~/", "../");
                details.Add(obj);
            }
            return(details);
        }
 public void InstanceOK()
 {
     //create an instance for the class we want to create
     clsProduct AProduct = new clsProduct();
     //test to see if it exists
     Assert.IsNotNull(AProduct);
 }
Пример #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);
        }
Пример #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;
        }
    }
Пример #14
0
        public void ActiveProductOK()
        {
            clsProduct AProduct   = new clsProduct();
            Boolean    SomeActive = true;

            AProduct.Active = SomeActive;
            Assert.AreEqual(AProduct.Active, SomeActive);
        }
Пример #15
0
        public void ValidMethodOk2()
        {
            clsProduct AProduct = new clsProduct();
            String     Error    = "";

            Error = AProduct.Valid(ProductName, Description, Price);
            Assert.AreEqual(Error, "");
        }
Пример #16
0
        public void DescriptionOK()
        {
            clsProduct AProduct        = new clsProduct();
            string     SomeDescription = "Red";

            AProduct.Description = SomeDescription;
            Assert.AreEqual(AProduct.Description, SomeDescription);
        }
Пример #17
0
        public void PriceOK()
        {
            clsProduct AProduct  = new clsProduct();
            decimal    SomePrice = 1;

            AProduct.Price = SomePrice;
            Assert.AreEqual(AProduct.Price, SomePrice);
        }
Пример #18
0
        public void ProductNoOK()
        {
            clsProduct AProduct      = new clsProduct();
            int        SomeProductNo = 123;

            AProduct.ProductNo = SomeProductNo;
            Assert.AreEqual(AProduct.ProductNo, SomeProductNo);
        }
Пример #19
0
        public void ProductNameOK()
        {
            clsProduct AProduct        = new clsProduct();
            string     SomeProductName = "Samsung";

            AProduct.ProductName = SomeProductName;
            Assert.AreEqual(AProduct.ProductName, SomeProductName);
        }
        public void DiscountPercentagePropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            int        TestData = 20;

            AProduct.DiscountPercentage = TestData;
            Assert.AreEqual(AProduct.DiscountPercentage, TestData);
        }
        public void ProductNoPropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            Int32      TestData = 5;

            AProduct.ProductNo = TestData;
            Assert.AreEqual(AProduct.ProductNo, TestData);
        }
        public void InStockPropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            Boolean    TestData = false;

            AProduct.InStock = TestData;
            Assert.AreEqual(AProduct.InStock, TestData);
        }
        public void StockAmountPropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            Int32      TestData = 3;

            AProduct.StockAmount = TestData;
            Assert.AreEqual(AProduct.StockAmount, TestData);
        }
        public void UnitPricePropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            Double     TestData = 5.50;

            AProduct.UnitPrice = TestData;
            Assert.AreEqual(AProduct.UnitPrice, TestData);
        }
        public void ProductDescriptionPropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            String     TestData = "Wooden art utensil";

            AProduct.ProductDescription = TestData;
            Assert.AreEqual(AProduct.ProductDescription, TestData);
        }
        public void DiscountActivePropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            Boolean    TestData = false;

            AProduct.DiscountActive = TestData;
            Assert.AreEqual(AProduct.InStock, TestData);
        }
Пример #27
0
        public void GenreOK()
        {
            clsProduct ATestProduct = new clsProduct();
            string     TestData     = "Genre of product";

            ATestProduct.Genre = TestData;
            Assert.AreEqual(ATestProduct.Genre, TestData);
        }
Пример #28
0
        private void LoadGrid()
        {
            clsProduct Dal      = new clsProduct();
            DataSet    Products = Dal.LoadProduct();

            GridView1.DataSource = Products.Tables[0];
            GridView1.DataBind();
        }
        public void ProductNamePropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            String     TestData = "Antique Paint Brush";

            AProduct.ProductName = TestData;
            Assert.AreEqual(AProduct.ProductName, TestData);
        }
        public void PropertyOK()
        {
            clsProduct AProduct = new clsProduct();
            Boolean    TestData = true;

            AProduct.Active = TestData;
            Assert.AreEqual(AProduct.Active, TestData);
        }