Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        /***************************************************************
         * Author: Anthony Simmons                                      *
         * Assignment: Homework #4 WSU Apparel      	 				*
         * Course: CptS 422 - Software Testing							*
         * Date: October 7, 2013								        *
         * Function Name: loadDGVfromClothesList()	    			    *
         * Description: loads a given data grid from the given list     *
         * Preconditions: None											*
         * Postconditions: None			        						*
         ****************************************************************/
        private void loadDGVfromClothesList(Clothes list, DataGridView dgv, bool shopping)
        {
            int i;
            double total = 0.0;
            dgv.Rows.Clear();
            for (i = 0; i < list.clothesList.Count; i++ )
            {
                list.clothesList[i].productID = list.clothesList[i].buildProductID();
                dgv.Rows.Add(list.clothesList[i].Title);
                dgv.Rows[i].Cells[1].Value = list.clothesList[i].subcategory;
                dgv.Rows[i].Cells[2].Value = list.clothesList[i].category;
                dgv.Rows[i].Cells[3].Value = list.clothesList[i].Gender;
                dgv.Rows[i].Cells[4].Value = list.clothesList[i].size;
                dgv.Rows[i].Cells[5].Value = list.clothesList[i].productID;
                dgv.Rows[i].Cells[6].Value = list.clothesList[i].price;

                if (shopping)
                {
                    dgv.Rows[i].Cells[7].Value = list.clothesList[i].numSelected;
                    dgv.Rows[i].Cells[8].Value = (double)(list.clothesList[i].price * list.clothesList[i].numSelected);
                    dgv.Rows[i].Cells[9].Value = list.clothesList[i].Description;
                }
                else
                {
                    dgv.Rows[i].Cells[7].Value = list.clothesList[i].quantity;
                    dgv.Rows[i].Cells[8].Value = list.clothesList[i].Description;
                }

                total += (double)(list.clothesList[i].price * list.clothesList[i].numSelected);
            }

            if (shopping)
            {
                if (total > 200.0 && !discountType.Contains("Bulk"))
                {
                    discount += discountBulk;
                    discountType += " + Bulk " + (discountBulk*100).ToString() + "%";
                }

                dgv.Rows.Add("Discount: ");
                if (discountType.Contains("Select Discount:"))
                {
                    discountType = "None";
                }
                dgv.Rows[i].Cells[5].Value = discountType;
                dgv.Rows[i].Cells[6].Value = (discount * 100).ToString("#.##") + "%";
                dgv.Rows[i].Cells[8].Value = "Savings: $" + ((double)(total - (total * (1 - discount)))).ToString("#.##");

                i++;
                total *= (1 - discount);
                dgv.Rows.Add("Sub Total: ");
                dgv.Rows[i].Cells[8].Value = "$" + total.ToString("#.##");
                i++;

                dgv.Rows.Add("Sales Tax: ");
                dgv.Rows[i].Cells[1].Value = ((int)(tax*100f)).ToString() + "%";
                float salesTax = (float)total * tax;
                dgv.Rows[i].Cells[8].Value = "$" + (salesTax).ToString("#.##");

                i++;
                dgv.Rows.Add("Total: ");
                dgv.Rows[i].Cells[8].Value = "$" + (total + salesTax).ToString("#.##");

            }
        }
Exemplo n.º 4
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();
        }