Exemplo n.º 1
0
        // must pass car model. check username
        private void loadInventory(clsCar car)
        {
            lvInventory.Items.Clear();
            lvInventory.SuspendLayout();
            List <clsInventory> list = new List <clsInventory>();

            clsInventory clsinventory = new clsInventory();

            list = clsinventory.getList(car);

            foreach (clsInventory inventory in list)
            {
                ListViewItem oItem = new ListViewItem();

                oItem.Text = inventory.TrackingCode;
                oItem.SubItems.Add(inventory.Details);
                oItem.SubItems.Add(inventory.Supplier);
                oItem.Tag = inventory;

                lvInventory.Items.Add(oItem);
            }

            tsslInventoryAvailableStocks.Text = "Available Stocks: " + lvInventory.Items.Count;
            lvInventory.ResumeLayout();
        }
Exemplo n.º 2
0
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsInventoryCollection AllInventories = new clsInventoryCollection();
            //create the item of test data
            clsInventory TestItem = new clsInventory();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set it's properties
            TestItem.InventoryId = 3;
            TestItem.Active      = true;
            TestItem.Name        = "Samsung OLED TV";
            TestItem.Price       = 2999.99m;
            TestItem.Quantity    = 100;
            TestItem.Category    = "Electronics";
            TestItem.DateAdded   = DateTime.Now.Date;
            TestItem.ImagePath   = "computer6.png";
            //set ThisAddress to the test data
            AllInventories.ThisInventory = TestItem;
            //add the record
            PrimaryKey = AllInventories.Add();
            //set the primary key of the test data
            TestItem.InventoryId = PrimaryKey;
            //find the record
            AllInventories.ThisInventory.Find(PrimaryKey);
            //delete the record
            AllInventories.Delete();
            //now find the record
            Boolean Found = AllInventories.ThisInventory.Find(PrimaryKey);

            //test to see that the two values are the same
            Assert.IsFalse(Found);
        }
        public void InstanceOK()
        {
            //create an instance of the class
            clsInventory AnInventory = new clsInventory();

            Assert.IsNotNull(AnInventory);
        }
        public void NamePropertyOK()
        {
            clsInventory AnInventory = new clsInventory();
            string       Name        = "Cadbury";

            AnInventory.Name = Name;
            Assert.AreEqual(Name, AnInventory.Name);
        }
        public void PricePropertyOK()
        {
            clsInventory AnInventory = new clsInventory();
            decimal      Price       = 5.99m;

            AnInventory.Price = Price;
            Assert.AreEqual(Price, AnInventory.Price);
        }
        public void CategoryPropertyOK()
        {
            clsInventory AnInventory = new clsInventory();
            string       Category    = "Electronics";

            AnInventory.Category = Category;
            Assert.AreEqual(Category, AnInventory.Category);
        }
        public void DateAddedPropertyOK()
        {
            clsInventory AnInventory = new clsInventory();
            DateTime     DateAdded   = DateTime.Now.Date;

            AnInventory.DateAdded = DateAdded;
            Assert.AreEqual(DateAdded, AnInventory.DateAdded);
        }
        public void ValidMethodOK()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreEqual(Error, "");
        }
        public void QuantityPropertyOK()
        {
            clsInventory AnInventory = new clsInventory();
            Int32        Quantity    = 100;

            AnInventory.Quantity = Quantity;
            Assert.AreEqual(Quantity, AnInventory.Quantity);
        }
Exemplo n.º 10
0
        private void btnRemoveInventory_Click(object sender, EventArgs e)
        {
            if (txtBarcode.Text.Trim() != "")
            {
                string   OrigQtValue = txtTotalQty.Text;
                frmInput input       = new frmInput();
                input.Title         = "Remove Inventory";
                input.Caption       = "Quantity";
                input.IsNumericOnly = true;

                if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    clsProductItem fi = clsProductItem.SearchProduct(txtBarcode.Text);

                    if (Convert.ToDouble(input.Value) <= 0)
                    {
                        MessageBox.Show("Quantity must be more than 0", "Remove Item", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (fi != null && fi.StocksRemainingQty - Convert.ToDouble(input.Value) >= 0)
                    {
                        frmInput inputReason = new frmInput();
                        inputReason.Title   = "Remove Inventory";
                        inputReason.Caption = "Reason for Removing";
                        inputReason.Value   = "Transfer Inventory";
                        if (inputReason.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            if (input.Value.Trim() == "")
                            {
                                MessageBox.Show("Must enter reason for removal of inventory", "Remove Items", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            clsInventory itemIventory = new clsInventory();
                            itemIventory.BarCode    = txtBarcode.Text;
                            itemIventory.Capital    = Convert.ToDouble(txtCapital.Text);
                            itemIventory.Quantity   = -(Convert.ToDouble(input.Value));
                            itemIventory.Remarks    = inputReason.Value;
                            itemIventory.ExpiryDate = dtInventory.Value;
                            itemIventory.DateAdded  = dtInventory.Value;
                            itemIventory.Save();

                            fi.TotalInventoryQty = clsInventory.GetTotalInventoryQty(fi.BarCode);
                            fi.Save();
                            UpdateList(txtSearchString.Text);
                            UpdateItemDisplay(fi.BarCode);
                        }
                    }
                    else if (fi == null)
                    {
                        MessageBox.Show(string.Format("Product not found"), "Remove Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(string.Format("Removing quantity greater than available quantity not allowed"), "Remove Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
        public void CategoryMinPlusOne()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       Category    = "aa";

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreEqual(Error, "");
        }
        public void DateAddedInvalidDataType()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       DateAdded   = "a";

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreNotEqual(Error, "");
        }
        public void DateAddedMinBoundary()
        {
            clsInventory AnInventory = new clsInventory();
            string       DateAdded   = DateTime.Now.Date.ToString();
            string       Error       = "";

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreEqual(Error, "");
        }
        public void QuantityMaxPlusOne()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       Quantity    = "10001";

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreNotEqual(Error, "");
        }
        public void QuantityMinBoundary()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       Quantity    = "0";

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreEqual(Error, "");
        }
        public void PriceMaxMinusOne()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       Price       = "9999";

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreEqual(Error, "");
        }
        public void QuantityExtremeMax()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       Quantity    = "99999999";

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreNotEqual(Error, "");
        }
        public void CategoryExtremeMax()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       Category    = "";

            Category = Category.PadRight(500, 'a');
            Error    = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreNotEqual(Error, "");
        }
        public void NameMid()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       Name        = "";

            Name  = Name.PadRight(20, 'a');
            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreEqual(Error, "");
        }
        public void CategoryMaxMinusOne()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            string       Category    = "";

            Category = Category.PadRight(19, 'a');
            Error    = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreEqual(Error, "");
        }
Exemplo n.º 21
0
        private void AddIventoryToGrid(clsInventory inventory)
        {
            int rowidx = dgvInventoryHistory.Rows.Add();

            dgvInventoryHistory.Rows[rowidx].Cells[0].Value = inventory.BarCode;
            dgvInventoryHistory.Rows[rowidx].Cells[1].Value = inventory.Description;
            dgvInventoryHistory.Rows[rowidx].Cells[2].Value = inventory.DateAdded;
            dgvInventoryHistory.Rows[rowidx].Cells[3].Value = inventory.Quantity;
            dgvInventoryHistory.Rows[rowidx].Cells[4].Value = inventory.ExpiryDate.ToString("yyyy-MM-dd");
        }
Exemplo n.º 22
0
        private void cmbInventory_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbInventory.SelectedIndex == -1)
            {
                return;
            }

            clsInventory currentInventory = (clsInventory)(cmbInventory.SelectedItem as clsComboboxItem).Value;

            this.loadSales(currentInventory);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            clsInventory AnInventory = new clsInventory();

            AnInventory.InventoryId = -1;
            InventoryAddForm IF = new InventoryAddForm();

            this.Hide();
            IF.ShowDialog();
            this.Close();
        }
Exemplo n.º 24
0
        private void AddIventoryToGrid(clsInventory inventory)
        {
            int rowidx = dgvInventoryHistory.Rows.Add();

            dgvInventoryHistory.Rows[rowidx].Cells[0].Value = inventory.DateAdded;
            dgvInventoryHistory.Rows[rowidx].Cells[1].Value = inventory.Quantity;
            dgvInventoryHistory.Rows[rowidx].Cells[2].Value = inventory.Capital;
            dgvInventoryHistory.Rows[rowidx].Cells[3].Value = inventory.Quantity * inventory.Capital;
            dgvInventoryHistory.Rows[rowidx].Cells[4].Value = inventory.ExpiryDate.ToString("yyyy-MM-dd");
            dgvInventoryHistory.Rows[rowidx].Cells[5].Value = inventory.Remarks;
        }
Exemplo n.º 25
0
        private void AddItemToGrid(clsInventory fitem)
        {
            int rowidx = dgvPurchase.Rows.Add();

            dgvPurchase.Rows[rowidx].Cells[0].Value = fitem.DateAdded;
            dgvPurchase.Rows[rowidx].Cells[1].Value = fitem.BarCode;
            dgvPurchase.Rows[rowidx].Cells[2].Value = fitem.Description;
            dgvPurchase.Rows[rowidx].Cells[3].Value = fitem.Capital;
            dgvPurchase.Rows[rowidx].Cells[4].Value = fitem.Quantity;
            dgvPurchase.Rows[rowidx].Cells[5].Value = Math.Round(fitem.Quantity * fitem.Capital, 2);
            dgvPurchase.Rows[rowidx].Cells[6].Value = fitem.Remarks;
        }
        public void ActivePropertyOK()
        {
            //create an instance of the class we want to create
            clsInventory AnInventory = new clsInventory();
            //create some test data to assign to the property
            Boolean TestData = true;

            //assign the data to the property
            AnInventory.Active = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(AnInventory.Active, TestData);
        }
        public void DateAddedMinMinusOne()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            DateTime     TestDate;

            TestDate = DateTime.Now.Date;
            TestDate = DateTime.Now.AddDays(-1);
            string DateAdded = TestDate.ToString();

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreNotEqual(Error, "");
        }
        public void DateAddedExtremeMax()
        {
            clsInventory AnInventory = new clsInventory();
            string       Error       = "";
            DateTime     TestDate;

            TestDate = DateTime.Now.Date;
            TestDate = DateTime.Now.AddYears(100);
            string DateAdded = TestDate.ToString();

            Error = AnInventory.Valid(Name, Price, Quantity, Category, DateAdded);
            Assert.AreNotEqual(Error, "");
        }
        public void FindMethodOK()
        {
            //create an instance of the class we want to create
            clsInventory AnInventory = new clsInventory();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //create some test data to use with the method
            int InventoryId = 1;

            //invoke the method
            Found = AnInventory.Find(InventoryId);
            //test to see that the result is correct
            Assert.IsTrue(Found);
        }
Exemplo n.º 30
0
        private void btnAddInventory_Click(object sender, EventArgs e)
        {
            if (txtBarcode.Text.Trim() != "")
            {
                try
                {
                    string         barcode = txtBarcode.Text.Trim();
                    clsProductItem prod    = clsProductItem.SearchProduct(barcode);
                    if (prod == null)
                    {
                        MessageBox.Show("Save the item first.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    frmAddInventory addinventory = new frmAddInventory();
                    addinventory.Quantity = 0;
                    addinventory.Capital  = prod.Capital;
                    addinventory.Retail   = prod.Amount;
                    if (addinventory.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (addinventory.Capital <= 0 || addinventory.Quantity <= 0 || addinventory.Retail <= 0)
                        {
                            MessageBox.Show("Capital/Quantity/Retail must be greater than 0", "Add Item", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        clsInventory itemIventory = new clsInventory();
                        itemIventory.BarCode    = barcode;
                        itemIventory.Capital    = addinventory.Capital;
                        itemIventory.Quantity   = addinventory.Quantity;
                        itemIventory.ExpiryDate = dtInventory.Value;
                        itemIventory.DateAdded  = dtInventory.Value;
                        itemIventory.Save();

                        prod.Capital           = addinventory.Capital;
                        prod.TotalInventoryQty = clsInventory.GetTotalInventoryQty(prod.BarCode);
                        prod.Amount            = addinventory.Retail;
                        prod.Save();

                        //SelectItemFromGrid(itemIventory.BarCode);
                        UpdateItemDisplay(barcode);
                        UpdateList(txtSearchString.Text);
                        //SaveProductItem(); // Update Quantity after saving inventory
                    }
                }
                catch
                {
                }
            }
        }