Exemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Order anOrder = new Order();

            anOrder.OrderId = Convert.ToInt32(textBoxOrderID.Text);

            Ordered ordered = new Ordered();

            ordered.ProductId = Convert.ToInt32(textBoxProductID.Text);
            ordered.Quantity  = Convert.ToInt32(textBoxQuantity.Text);

            anOrder.Ordered      = ordered;
            anOrder.OrderDate    = Convert.ToDateTime(dateTimePickerOrderDate.Text);
            anOrder.ShipDate     = Convert.ToDateTime(dateTimePickerShipDate.Text);
            anOrder.SalesClerkId = LoggedIn.EmpId;

            foreach (Book element in (ProductDA.GetBook()))
            {
                if (element.Isbn == anOrder.Ordered.ProductId)
                {
                    if ((element.Qoh - anOrder.Ordered.Quantity) >= 0)
                    {
                        element.Qoh = element.Qoh - anOrder.Ordered.Quantity;
                        ProductDA.UpdateBook(element);
                        OrderDA.SetOrder(anOrder);
                        RefreshList();
                    }
                    else
                    {
                        MessageBox.Show("Not enough stock to complete order.\nAsk Inventory to add more stock before completing order.", "Error!");
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (comboBoxProduct.Text == "Book")
            {
                Book aBook = new Book();
                aBook.Isbn     = Convert.ToInt32(textBoxISBN.Text);
                aBook.Name     = textBoxName.Text;
                aBook.Price    = Convert.ToDouble(textBoxPrice.Text);
                aBook.Year     = Convert.ToInt32(textBoxYear.Text);
                aBook.Qoh      = Convert.ToInt32(textBoxQOH.Text);
                aBook.Category = textBoxCategoryVersion.Text;

                ProductDA.SetBook(aBook);
            }
            else
            {
                if (comboBoxProduct.Text == "Software")
                {
                    Software aSoftware = new Software();
                    aSoftware.Name    = textBoxName.Text;
                    aSoftware.Price   = Convert.ToDouble(textBoxPrice.Text);
                    aSoftware.Year    = Convert.ToInt32(textBoxYear.Text);
                    aSoftware.Qoh     = Convert.ToInt32(textBoxQOH.Text);
                    aSoftware.Version = textBoxCategoryVersion.Text;

                    ProductDA.SetSoftware(aSoftware);
                }
            }
            RefreshList();
        }
Exemplo n.º 3
0
        private void listViewInventory_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = listViewInventory.FocusedItem.Index;

            if (comboBoxProduct.Text == "Book")
            {
                List <Book> myBookList = ProductDA.GetBook();

                textBoxISBN.Text            = Convert.ToString(myBookList[index].Isbn);
                textBoxName.Text            = myBookList[index].Name;
                textBoxPrice.Text           = Convert.ToString(myBookList[index].Price);
                textBoxYear.Text            = Convert.ToString(myBookList[index].Year);
                textBoxQOH.Text             = Convert.ToString(myBookList[index].Qoh);
                textBoxCategoryVersion.Text = myBookList[index].Category;
            }
            else
            {
                if (comboBoxProduct.Text == "Software")
                {
                    List <Software> mySoftwareList = ProductDA.GetSoftware();

                    textBoxName.Text            = mySoftwareList[index].Name;
                    textBoxPrice.Text           = Convert.ToString(mySoftwareList[index].Price);
                    textBoxYear.Text            = Convert.ToString(mySoftwareList[index].Year);
                    textBoxQOH.Text             = Convert.ToString(mySoftwareList[index].Qoh);
                    textBoxCategoryVersion.Text = mySoftwareList[index].Version;
                }
                RefreshList();
            }
        }
Exemplo n.º 4
0
        public static void DeleteSoftware(Software software)
        {
            List <Software> mySoftwareList = ProductDA.GetSoftware();

            using (StreamWriter sw = new StreamWriter(filePathTemp))
            {
                foreach (Software element in mySoftwareList)
                {
                    if (element.Name != software.Name)
                    {
                        sw.WriteLine(element.GetSoftwareInfo());
                    }
                }
            }
            File.Replace(filePathTemp, filePathSoftware, filePathBackup);
        }
Exemplo n.º 5
0
        public static void DeleteBook(Book book)
        {
            List <Book> myBookList = ProductDA.GetBook();

            using (StreamWriter sw = new StreamWriter(filePathTemp))
            {
                foreach (Book element in myBookList)
                {
                    if (element.Isbn != book.Isbn)
                    {
                        sw.WriteLine(element.GetBookInfo());
                    }
                }
            }
            File.Replace(filePathTemp, filePathBook, filePathBackup);
        }
Exemplo n.º 6
0
 public void RefreshList()
 {
     if (comboBoxProduct.Text == "Book")
     {
         listViewInventory.Items.Clear();
         List <Book> myBookList = ProductDA.GetBook();
         foreach (Book element in myBookList)
         {
             listViewInventory.Items.Add(ProductDA.ConvertToListViewItemBook(element));
         }
     }
     else
     {
         if (comboBoxProduct.Text == "Software")
         {
             listViewInventory.Items.Clear();
             List <Software> mySoftwareList = ProductDA.GetSoftware();
             foreach (Software element in mySoftwareList)
             {
                 listViewInventory.Items.Add(ProductDA.ConvertToListViewItemSoftware(element));
             }
         }
     }
 }