Esempio n. 1
0
        public EditUI(OrderItem oi)
        {
            InitializeComponent();

            //Copied Names of strings from MainUI to EditUI
            txt_ProductNameEdit.Text = oi.ProductName;
            nud_QuantityEdit.Value = oi.Quantity;
            string stringVal = Convert.ToString(oi.LatestPrice);
            txt_LatestPriceEdit.Text = stringVal;
        }
Esempio n. 2
0
        public void AddItemQuantityAddedInvalid()
        {
            // Arrange
            string pName = "Beans";
            decimal lPrice = 1.00M;
            int quant = 4;
            OrderItem beans = new OrderItem(pName, lPrice, quant);

            // Act
            beans.AddItems(1.00M, -1);

            // Assert
        }
Esempio n. 3
0
        public void AddItemQuantityAddedBlank()
        {
            // Arrange
            string pName = "Beans";
            decimal lPrice = 1.00M;
            int quant = 4;
            OrderItem beans = new OrderItem(pName, lPrice, quant);

            // Act
            beans.AddItem();

            // Assert

            Assert.AreEqual(5, beans.Quantity);
        }
Esempio n. 4
0
        public void AddItemsQuantityAdded()
        {
            // Arrange
            string pName = "Beans";
            decimal lPrice = 1.00M;
            int quant = 4;
            OrderItem beans = new OrderItem(pName, lPrice, quant);

            // Act
            beans.AddItems(4);

            // Assert
            Assert.AreEqual("Beans", beans.ProductName);
            Assert.AreEqual(1.00M, beans.LatestPrice);
            Assert.AreEqual(8, beans.Quantity);
        }
Esempio n. 5
0
        public void OrderItemInvalid()
        {
            // Arrange
            string pName = "";
            decimal lPrice = 1.00M;
            int quant = 4;

            // Act
            OrderItem beans = new OrderItem(pName, lPrice, quant);

            // Assert
        }
Esempio n. 6
0
        public void RemoveItemsQuantityValid()
        {
            // Arrange
            string pName = "Beans";
            decimal lPrice = 1.00M;
            int quant = 4;
            OrderItem beans = new OrderItem(pName, lPrice, quant);

            // Act
            beans.RemoveItems(4);

            // Assert
            Assert.AreEqual(0, beans.Quantity);
        }
Esempio n. 7
0
        public void RemoveItemsQuantityNegativeInvalid()
        {
            // Arrange
            string pName = "Beans";
            decimal lPrice = 1.00M;
            int quant = 4;
            OrderItem beans = new OrderItem(pName, lPrice, quant);

            // Act
            beans.RemoveItems(-1);

            // Assert
        }
Esempio n. 8
0
        public void OrderItemValid()
        {
            // Arrange
            string pName = "Beans";
            decimal lPrice = 1.00M;
            int quant = 4;

            // Act
            OrderItem beans = new OrderItem(pName, lPrice, quant);

            // Assert
            Assert.AreEqual("Beans", beans.ProductName);
            Assert.AreEqual(1.00M, beans.LatestPrice);
            Assert.AreEqual(4, beans.Quantity);
        }
Esempio n. 9
0
 //Edit values of selected item of selected row
 private void btn_EditItem_Click(object sender, EventArgs e)
 {
     //Only continues if Row has been selected
     if (this.dgv_Basket.SelectedRows.Count > 0)
     {
         //Makes rows selected select full row.
         this.dgv_Basket.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
         //Rows selected is equal to an item in OrderItems.
         this.dgv_Basket.DataSource = shop.OrderItems;
         //Create new item (oi) using data in selected rows.
         OrderItem oi = new OrderItem((dgv_Basket.CurrentRow.Cells[0].Value.ToString()),
             Convert.ToDecimal(dgv_Basket.CurrentRow.Cells[2].Value),
             Convert.ToInt32(dgv_Basket.CurrentRow.Cells[1].Value));
         //Uses oi so the data can be used in other form (EditUI)
         EditUI edit = new EditUI(oi);
         //Continues only after user clicks OK on EditUI Form.
         if (edit.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             //Convert string to decimal.
             decimal editedLatestPrice;
             if (Decimal.TryParse((edit.SEditedLatestPrice.Remove(0, 1)), out editedLatestPrice))
             {
                 // Use the new inputted data from EditUI to create and add the item to the list.
                 OrderItem ni = new OrderItem(edit.EditedProductName, editedLatestPrice, edit.EditedQuantity);
                 shop.EditProduct(oi.ProductName, edit.EditedProductName, editedLatestPrice, edit.EditedQuantity, ni);
                 dgv_Basket.Update();
                 UpdateReadOnlys();
             }
         }
     }
     else //Will keep showing unless a row is selected.
     {
         MessageBox.Show("Please select one row");
     }
 }