コード例 #1
0
 private void EditProduct(clsProducts prProduct)
 {
     if (prProduct != null)
     {
         Frame.Navigate(typeof(pgProductDetails), prProduct);
     }
 }
コード例 #2
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            objProd            = new clsProducts();
            objProd.ProductId  = Convert.ToInt32(ddlProdMaster.SelectedValue);
            objProd.strProName = Convert.ToString(ddlProdMaster.SelectedItem.Text);
            objProd.strProAbbr = Convert.ToString(txtAbbr.Text);
            objProd.strDesc    = Convert.ToString(txtDesc.Text);
            if (Session["FileName"] != null && Session["Photo"] != null)
            {
                objProd.strFileName = Convert.ToString(Session["FileName"]);
                objProd.imgFileData = (byte[])Session["Photo"];
            }
            else
            {
                objProd.strFileName = Convert.ToString("No File");
                objProd.imgFileData = null;
            }

            int i = objProd.UpdateProductMasterData();
            if (i == 1)
            {
                lblMsg.Text = "Record has been Modified";
            }
            else
            {
                lblMsg.Text = "Error in process";
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            objPro            = new clsProducts();
            objPro.strProName = Convert.ToString(txtProName.Text);
            objPro.strProAbbr = Convert.ToString(txtAbbr.Text);
            objPro.strDesc    = Convert.ToString(txtDesc.Text);
            if (Session["FileName"] != null && Session["Photo"] != null)
            {
                objPro.strFileName = Convert.ToString(Session["FileName"]);
                objPro.imgFileData = (byte[])Session["Photo"];
            }
            else
            {
                objPro.strFileName = Convert.ToString("No File");
                objPro.imgFileData = null;
            }

            int i = objPro.InsertProductMasterData();
            if (i == 1)
            {
                lblMsg.Text = "Recird inserted";
            }
            else
            {
                lblMsg.Text = "Record not inserted";
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }
コード例 #4
0
        public void DeleteMethodOK()
        {
            //create an instance of the class
            clsProductsCollection AllProducts = new clsProductsCollection();
            //create the item of test data
            clsProducts TestItem = new clsProducts();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.ProductID   = 1;
            TestItem.ProductName = "Pokemon";
            TestItem.Price       = 15.00;
            TestItem.Quantity    = 14;
            //set ThisProduct to test data
            AllProducts.ThisProduct = TestItem;
            //add the record
            PrimaryKey = AllProducts.Add();
            //set the primary key of the test data
            TestItem.ProductID = PrimaryKey;
            //find the record
            AllProducts.ThisProduct.Find(PrimaryKey);
            //delete the record
            AllProducts.Delete();
            //noe find the record
            Boolean Found = AllProducts.ThisProduct.Find(PrimaryKey);

            //test to see that the value was not found
            Assert.IsFalse(Found);
        }
コード例 #5
0
        public void AddMethodOK()
        {
            //create an instance of the class
            clsProductsCollection AllProducts = new clsProductsCollection();
            //create the item of test data
            clsProducts TestItem = new clsProducts();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.ProductID   = 11;
            TestItem.ProductName = "Batman";
            TestItem.Price       = 15.00;
            TestItem.Quantity    = 13;
            //set ThisProduct to test data
            AllProducts.ThisProduct = TestItem;
            //add the record
            PrimaryKey = AllProducts.Add();
            //set the primary key of the test data
            TestItem.ProductID = PrimaryKey;
            //find the record
            AllProducts.ThisProduct.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.ThisProduct, TestItem);
        }
 private void GetAllProductIds()
 {
     try
     {
         clsProducts objProd    = new clsProducts();
         DataSet     dsProdData = objProd.GetAllProductsData();
         if (dsProdData.Tables[0].Rows.Count != 0)
         {
             ddlProducts.DataSource     = dsProdData.Tables[0];
             ddlProducts.DataTextField  = "ProductName";
             ddlProducts.DataValueField = "ProductId";
             ddlProducts.DataBind();
             ddlProducts.Items.Insert(0, "--Select One--");
         }
         else
         {
             ddlProducts.Items.Insert(0, "--Select One--");
             ddlProducts.Items.Insert(1, "No Products");
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
 protected void btnShowAll_Click(object sender, EventArgs e)
 {
     try
     {
         divProducts.Visible = false;
         if (btnShowAll.Text == "Show All")
         {
             objPro = new clsProducts();
             DataSet ds = objPro.GetAllProductsData();
             if (ds.Tables[0].Rows.Count != 0)
             {
                 grdProducts.DataSource = ds.Tables[0];
                 grdProducts.DataBind();
             }
             else
             {
                 grdProducts.EmptyDataText = "Record not found.";
                 grdProducts.DataBind();
             }
             btnShowAll.Text     = "Close Grid";
             divProducts.Visible = true;
         }
         else if (btnShowAll.Text == "Close Grid")
         {
             btnShowAll.Text     = "Show All";
             divProducts.Visible = false;
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
コード例 #8
0
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            clsProducts AProduct = new clsProducts();

            //test to see that it exists
            Assert.IsNotNull(AProduct);
        }
コード例 #9
0
 private void pushData(clsProducts prProducts)
 {
     prProducts                 = _Products;
     _Products.Name             = tbName.Text;
     _Products.Origin           = tbOrigin.Text;
     _Products.ProductCondition = tbProductCondition.Text;
     _Products.Brand            = tbBrand.Text;
     _Products.Quantity         = Convert.ToUInt16(tbQuantity.Text);
     (ctcWorkSpecs.Content as IProductDetailsControl).UpdateControl(prProducts);
 }
コード例 #10
0
 private void updatePage(clsProducts prProducts)
 {
     _Products               = prProducts;
     tbName.Text             = _Products.Name;
     tbName.IsEnabled        = string.IsNullOrEmpty(_Products.Name);
     tbOrigin.Text           = _Products.Origin.ToString();
     tbProductCondition.Text = _Products.ProductCondition.ToString();
     tbBrand.Text            = _Products.Brand.ToString();
     tbQuantity.Text         = _Products.Quantity.ToString();
 }
コード例 #11
0
        public void ValidMethodOK()
        {
            //create an instace of the class
            clsProducts AProduct = new clsProducts();
            //string variable to store error message
            String Error = "";

            //invoke the method
            Error = AProduct.Valid(ProductID, ProductName, Price, Quantity);
            //test if result is correct
            Assert.AreEqual(Error, "");
        }
コード例 #12
0
        public void ProductNameOK()
        {
            //create an instance of the class we want to create
            clsProducts AProduct = new clsProducts();
            //create some test data at assign to the property
            string TestData = "Xbox ONE";

            //assign the data to the property
            AProduct.ProductName = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(AProduct.ProductName, TestData);
        }
コード例 #13
0
        public void PriceOK()
        {
            //create an instance of the class we want to create
            clsProducts AProduct = new clsProducts();
            //create some test data at assign to the property
            double TestData = 99.99;

            //assign the data to the property
            AProduct.Price = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(AProduct.Price, TestData);
        }
コード例 #14
0
        public void QuantityOK()
        {
            //create an instance of the class we want to create
            clsProducts AProduct = new clsProducts();
            //create some test data at assign to the property
            Int32 TestData = 10;

            //assign the data to the property
            AProduct.Quantity = Convert.ToInt32(TestData);
            //test to see that the two values are the same
            Assert.AreEqual(AProduct.Quantity, TestData);
        }
コード例 #15
0
 protected async override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (e.Parameter != null)
     {
         string lcProductName = e.Parameter.ToString();
         //_Products = await pgMain.ServiceClient.GetArtistAsync(lcProductName);
     }
     else
     {
         _Products = new clsProducts();
     }
 }
コード例 #16
0
        public void FindMethodOK()
        {
            //create an instance of the class we want to create
            clsProducts AProduct = new clsProducts();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //create some test data to use woth the method
            Int32 ProductID = 10;

            //invoke the method
            Found = AProduct.Find(ProductID);
            //test to see that the result is correct
            Assert.IsTrue(Found);
        }
コード例 #17
0
        public void QuantityMid()
        {
            //create an instace of the class
            clsProducts AProduct = new clsProducts();
            //string variable to store error
            string Error = "";
            //create test data to pass to the method
            string Quantity = "111"; //this will pass

            //invoke the method
            Error = AProduct.Valid(ProductID, ProductName, Price, Quantity);
            //test if result is correct
            Assert.AreEqual(Error, "");
        }
コード例 #18
0
        public void ProductIDMinMinusOne()
        {
            //create an instace of the class
            clsProducts AProduct = new clsProducts();
            //string variable to store error message
            String Error = "";
            //create test data to pass to method
            string ProductID = ""; //this will trigger error

            //invoke the method
            Error = AProduct.Valid(ProductID, ProductName, Price, Quantity);
            //test if result is correct
            Assert.AreNotEqual(Error, "");
        }
コード例 #19
0
    private void BindData()
    {
        clsProducts objProd = new clsProducts();
        DataSet     ds      = objProd.GetProductStorageMasterData();

        if (ds.Tables[0].Rows.Count != 0)
        {
            ddlTransactionId.DataSource     = ds.Tables[0];
            ddlTransactionId.DataTextField  = "StorageTransactionId";
            ddlTransactionId.DataValueField = "StorageTransactionId";
            ddlTransactionId.DataBind();
        }
        ddlTransactionId.Items.Insert(0, "--Select One--");
    }
コード例 #20
0
        public void QuantityExtremeMax()
        {
            //create an instace of the class
            clsProducts AProduct = new clsProducts();
            //string variable to store error
            string Error = "";
            //create test data to pass to the method
            string Quantity = ""; //this will fail

            Quantity = Quantity.PadRight(500, '1');
            //invoke the method
            Error = AProduct.Valid(ProductID, ProductName, Price, Quantity);
            //test if result is correct
            Assert.AreNotEqual(Error, "");
        }
コード例 #21
0
        private async void btnDelete_ClickAsync(object sender, RoutedEventArgs e)
        {
            if (listProductList.SelectedIndex >= 0)
            {
                MessageDialog lcMessageBox = new MessageDialog("Are you sure?");
                //lcMessageBox.Commands.Add(new UICommand("Yes", async x =>
                //{
                //tbMessages.Text += await ServiceClient.DeleteProductAsync(listProductList.SelectedItem as clsProducts) +'\n';
                //}));
                lcMessageBox.Commands.Add(new UICommand("No"));
                await lcMessageBox.ShowAsync();

                _Products = await ServiceClient.GetCategoryAsync(_Products.Name);
            }
        }
コード例 #22
0
        public void ProductNameMaxMinusOne()
        {
            //create an instace of the class
            clsProducts AProduct = new clsProducts();
            //string variable to store error
            string Error = "";
            //create test data to pass to the method
            string ProductName = ""; //this will pass

            ProductName = ProductName.PadRight(19, 'a');
            //invoke the method
            Error = AProduct.Valid(ProductID, ProductName, Price, Quantity);
            //test if result is correct
            Assert.AreEqual(Error, "");
        }
コード例 #23
0
 private void GetAllProdId()
 {
     try
     {
         objProd = new clsProducts();
         DataSet ds = objProd.GetAllProductsData();
         ddlProdMaster.DataSource     = ds;
         ddlProdMaster.DataValueField = "ProductId";
         ddlProdMaster.DataTextField  = "ProductName";
         ddlProdMaster.Items.Insert(0, "--Select One--");
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
コード例 #24
0
        public void ThisProductOK()
        {
            //create an insta ce of the class
            clsProductsCollection AllProducts = new clsProductsCollection();
            //create the item of test data
            clsProducts TestProduct = new clsProducts();

            //set its properties
            TestProduct.ProductID   = 1;
            TestProduct.ProductName = "Pokemon";
            TestProduct.Price       = 15.00;
            TestProduct.Quantity    = 14;
            //assign the data to tje property
            AllProducts.ThisProduct = TestProduct;
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.ThisProduct, TestProduct);
        }
コード例 #25
0
        public void TestProductIDFound()
        {
            //create an instance of the class we want to create
            clsProducts AProduct = new clsProducts();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is ok (assume it is)
            Boolean OK = true;
            //create some test data to use with the method
            Int32 ProductID = 10;

            //invoke the method
            Found = AProduct.Find(ProductID);
            //check the productID
            if (AProduct.ProductID != 10)
            {
                OK = false;
            }
            //test to seee that the result is correct
            Assert.IsTrue(OK);
        }
コード例 #26
0
        public void ListAndCountOK()
        {
            //create an insta ce of the class
            clsProductsCollection AllProducts = new clsProductsCollection();
            //create some test data to assign to the property
            List <clsProducts> TestList = new List <clsProducts>();
            //create the item of test data
            clsProducts TestItem = new clsProducts();

            //set its properties
            TestItem.ProductID   = 1;
            TestItem.ProductName = "Pokemon";
            TestItem.Price       = 15.00;
            TestItem.Quantity    = 14;
            //add item to the test list
            TestList.Add(TestItem);
            //assign the data to tje property
            AllProducts.ProductsList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.Count, TestList.Count);
        }