Пример #1
0
        /***************************************************************
         * Author: Anthony Simmons                                      *
         * Assignment: Homework #4 WSU Apparel      	 				*
         * Course: CptS 422 - Software Testing							*
         * Date: October 7, 2013								        *
         * Function Name: loadInventory()   		    			    *
         * Description: loads inventory list from saved XML file        *
         * Preconditions: None											*
         * Postconditions: None			        						*
         ****************************************************************/
        public void loadInventory(string fileName)
        {
            apparel.clothesList.Clear();
            using (DataSet data = new DataSet())
            {
                //if(Environment.CurrentDirectory.Contains(fileName))
                {
                    data.ReadXml(fileName);
                    Clothes list = new Clothes();
                    foreach (DataRow dataRow in data.Tables["Clothing"].Rows)
                    {
                        ClothingType type = new ClothingType();
                        type.subcategory = dataRow["Subcategory"].ToString();
                        type.Title = dataRow["Title"].ToString();
                        type.category = dataRow["Category"].ToString();
                        type.Description = dataRow["Description"].ToString();
                        type.price = Convert.ToDouble(dataRow["Price"]);
                        type.quantity = Convert.ToInt32(dataRow["Quantity"]);
                        type.size = dataRow["Size"].ToString();
                        type.Gender = dataRow["Gender"].ToString();
                        type.productID = type.buildProductID();
                        list.categoryName = type.category;

                        if (type.Description == "")
                        {
                            type.Description = type.buildDescription();
                        }

                        list.clothesList.Add(type);

                    }
                    apparel = list;
                }
            }
        }
Пример #2
0
        /***************************************************************
         * Author: Anthony Simmons                                      *
         * Assignment: Homework #4 WSU Apparel      	 				*
         * Course: CptS 422 - Software Testing							*
         * Date: October 7, 2013								        *
         * Function Name: FindClothingInInventory()	    			    *
         * Description: Find the given clothingtype in inventory list   *
         * Preconditions: None											*
         * Postconditions: None			        						*
         ****************************************************************/
        public ClothingType FindClothingInInventory(ClothingType clothe)
        {
            ClothingType found = new ClothingType();

            foreach (ClothingType type in apparel.clothesList)
            {
                if (clothe.Title == type.Title && clothe.size == type.size
                    && clothe.price == type.price && clothe.Gender == type.Gender)
                {
                    found = type;
                    break;
                }
            }

            return found;
        }
Пример #3
0
 /***************************************************************
      * Author: Anthony Simmons                                      *
      * Assignment: Homework #4 WSU Apparel      	 				*
      * Course: CptS 422 - Software Testing							*
      * Date: October 7, 2013								        *
      * Function Name: compareClothes()  		    			    *
      * Description: Compare cloth properties                        *
      * Preconditions: None											*
      * Postconditions: None			        						*
      ****************************************************************/
 public bool compareClothes(ClothingType source)
 {
     return (this.price == source.price && this.Gender.Contains(source.Gender) && this.size.Contains(source.size)
             && this.category.Contains(source.category) && this.Title.Contains(source.Title));
 }
Пример #4
0
        /***************************************************************
         * Author: Anthony Simmons                                      *
         * Assignment: Homework #4 WSU Apparel      	 				*
         * Course: CptS 422 - Software Testing							*
         * Date: October 7, 2013								        *
         * Function Name: btnAddItems_Click()		    			    *
         * Description: Event handler, adds each selected item from     *
         *  tree view to shopping cart list
         * Preconditions: None											*
         * Postconditions: None			        						*
         ****************************************************************/
        private void btnAddItems_Click(object sender, EventArgs e)
        {
            foreach (TreeNode tn in treeViewInventory.Nodes)
            {
                foreach (TreeNode cl in tn.Nodes)
                {
                    if (cl.Checked)
                    {
                        ClothingType clothe = new ClothingType();
                        string []strArr = cl.Text.Split('-', '$');
                        clothe.Title = strArr[0];
                        clothe.category = tn.Text;
                        if (cboBoxSize.SelectedItem.ToString().Contains("Select"))
                        {
                            MessageBox.Show("Please Select a Size");
                            return;
                        }
                        if (cboBoxGender.SelectedItem.ToString().Contains("Select"))
                        {
                            MessageBox.Show("Please Select a Gender");
                            return;
                        }
                        clothe.size = cboBoxSize.SelectedItem.ToString();
                        clothe.Gender = cboBoxGender.SelectedItem.ToString();
                        clothe.Title = strArr[0];
                        clothe.category = tn.Text;
                        clothe.subcategory = clothe.Title.Substring(4);
                        clothe.numSelected++;
                        clothe.Description = clothe.buildDescription();
                        //clothe.productID = "N" + + "-S" + j.ToString() + "-G" + k.ToString();

                        clothe.price = Convert.ToDouble(strArr[2]);

                        bool add = true;
                        for (int i = 0; i < shoppingCart.clothesList.Count; i++)
                        {
                            if (shoppingCart.clothesList[i].compareClothes(clothe))
                            {
                                shoppingCart.clothesList[i].numSelected++;
                                add = false;
                            }
                        }
                        if (add)
                        {
                            shoppingCart.clothesList.Add(clothe);
                        }

                    }
                }
            }
            loadDGVfromClothesList(shoppingCart, dgvShoppingCart, true);
        }
Пример #5
0
        /***************************************************************
         * Author: Anthony Simmons                                      *
         * Assignment: Homework #4 WSU Apparel      	 				*
         * Course: CptS 422 - Software Testing							*
         * Date: October 7, 2013								        *
         * Function Name: loadClothingType()		    			    *
         * Description: Helper Function to loadCothes() creates inventory from scratch      *
         * Preconditions: None											*
         * Postconditions: None			        						*
         ****************************************************************/
        private void loadClothingType(string category, string[] names, double price)
        {
            Clothes clothes = new Clothes();
            clothes.categoryName = category;
            for (int i = 0; i < names.Length; i++)
            {
                for (int j = 1; j < 5; j++)
                {
                    for (int k = 1; k < 3; k++)
                    {
                        ClothingType clothingType = new ClothingType();
                        clothingType.productID = "N" + i.ToString() + "-S" + j.ToString() + "-G" + k.ToString();
                        clothingType.Description = names[i] + " " + category;
                        clothingType.category = category;
                        clothingType.Gender = cboBoxGender.Items[k].ToString();
                        clothingType.quantity = 20;
                        clothingType.size = cboBoxSize.Items[j].ToString();
                        clothingType.Title = names[i];
                        clothingType.price = price;
                        clothes.clothesList.Add(clothingType);
                    }
                }
            }

            inventory.apparel = clothes;
        }
Пример #6
0
        /***************************************************************
         * Author: Anthony Simmons                                      *
         * Assignment: Homework #4 WSU Apparel      	 				*
         * Course: CptS 422 - Software Testing							*
         * Date: October 7, 2013								        *
         * Function Name: btnUpdateInventory_Click()    			    *
         * Description: Updates inventory based on manager's changes    *
         * Preconditions: None											*
         * Postconditions: None			        						*
         ****************************************************************/
        private void btnUpdateInventory_Click(object sender, EventArgs e)
        {
            Clothes list = new Clothes();
            for (int i = 0; i < dgvInventory.Rows.Count - 1; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    if (dgvInventory.Rows[i].Cells[j].Value == null)
                    {
                        MessageBox.Show("Invalid Input!");
                        return;
                    }
                }

                ClothingType cloth = new ClothingType();
                cloth.Title = dgvInventory.Rows[i].Cells[0].Value.ToString();
                cloth.subcategory = dgvInventory.Rows[i].Cells[1].Value.ToString();
                cloth.category = dgvInventory.Rows[i].Cells[2].Value.ToString();
                cloth.Gender = dgvInventory.Rows[i].Cells[3].Value.ToString();
                cloth.size = dgvInventory.Rows[i].Cells[4].Value.ToString();
                cloth.productID = dgvInventory.Rows[i].Cells[5].Value.ToString();

                if (!dgvInventory.Rows[i].Cells[7].Value.ToString().All(Char.IsDigit)
                 || !dgvInventory.Rows[i].Cells[6].Value.ToString().All(isDigitOrPeriod))
                {
                    MessageBox.Show("Invalid Input!");
                    return;
                }
                cloth.price = Convert.ToDouble(dgvInventory.Rows[i].Cells[6].Value);
                cloth.quantity = Convert.ToInt32(dgvInventory.Rows[i].Cells[7].Value);
                cloth.Description = dgvInventory.Rows[i].Cells[8].Value.ToString();

                cloth.price = Math.Abs(cloth.price);
                cloth.quantity = (int)Math.Abs(cloth.quantity);

                list.clothesList.Add(cloth);

            }
            inventory.apparel.clothesList.Clear();
            inventory.apparel = list;
            loadDGVInventory();
            inventory.saveInventory("../../Inventory.xml");
            loadTreeInventory();
        }