Пример #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: 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);
        }