/// <summary>
        /// This function update music cd button click operation.
        /// This function is used to update product list and update for util function.
        /// </summary>
        /// <returns> This function does not return a value  </returns>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Logger.GetLogger().WriteLog(LoginedCustomer.getInstance().User.Username, btnUpdate.Text, DateTime.Now);
            if (!isBlank())
            {
                MessageBox.Show("Please fill all blanks!");
                return;
            }
            else if (pboxMusicCD.Image == null)
            {
                MessageBox.Show("Please select an image.");
                return;
            }
            NumberFormatInfo provider = new NumberFormatInfo();

            provider.NumberDecimalSeparator = ".";
            MusicCD_Type type = MusicCD_Type.Romance;

            switch (cBoxType.SelectedIndex)
            {
            case 1:
                type = MusicCD_Type.HardRock;
                break;

            case 2:
                type = MusicCD_Type.Country;
                break;

            default:
                break;
            }
            Creator c = new MusicCdFactory(txtName.Text, txtID.Text, Convert.ToDouble(txtPrice.Text, provider),
                                           txtSinger.Text, type, pboxMusicCD.Image);

            string[]     lvItem = { txtID.Text, txtName.Text, txtPrice.Text, txtSinger.Text, cBoxType.Text };
            ListViewItem item   = new ListViewItem(lvItem);

            for (int i = 0; i < listViewMusicCDs.Items.Count; i++)
            {
                if (listViewMusicCDs.Items[i].SubItems[0].Text == selectedID)
                {
                    listViewMusicCDs.Items[i] = item;
                    break;
                }
            }
            for (int i = 0; i < StoreMainScreen.productList.Count; i++)
            {
                if (StoreMainScreen.productList[i].ID1 == selectedID)
                {
                    StoreMainScreen.productList[i] = c.FactoryMethod();
                    break;
                }
            }
            UtilUpdate.Update(c.FactoryMethod());
            MessageBox.Show("Updated Succesfully!");
            panelAddMusicCD.Visible = false;
            selectedIndex           = -1;
        }
 /// <summary>
 /// This function includes increase button click operation and updated shopping card.
 /// </summary>
 /// <returns> This function does not return a value  </returns>
 private void btnIncrease_Click(object sender, EventArgs e)
 {
     Logger.GetLogger().WriteLog(LoginedCustomer.getInstance().User.Username, btnIncrease.Text, DateTime.Now);
     for (int i = 0; i < StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase.Count; i++)
     {
         if (StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase[i].Product.Name == lblProductName.Text)
         {
             StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase[i].Quantity++;
             double paymentAmount = (StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase[i].Product.Price *
                                     StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase[i].Quantity);
             StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].PaymentAmount +=
                 StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase[i].Product.Price;
             lblNumber.Text = StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase[i].Quantity.ToString();
             lblPrice.Text  = paymentAmount.ToString() + " ₺";
             UtilUpdate.Update(StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex]);
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// This function update book button click operation.
        /// This function is used to update product list and update for util function.
        /// </summary>
        /// <returns> This function does not return a value  </returns>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Logger.GetLogger().WriteLog(LoginedCustomer.getInstance().User.Username, btnUpdate.Text, DateTime.Now);
            if (!isBlank())
            {
                MessageBox.Show("Please fill all blanks!");
                return;
            }
            else if (pboxBook.Image == null)
            {
                MessageBox.Show("Please select an image.");
                return;
            }
            NumberFormatInfo provider = new NumberFormatInfo();

            provider.NumberDecimalSeparator = ".";
            Creator c = new BookFactory(txtName.Text, txtID.Text, Convert.ToDouble(txtPrice.Text, provider), txtISBN.Text, txtAuthor.Text,
                                        txtPublisher.Text, Convert.ToInt32(txtPages.Text), pboxBook.Image);

            string[]     lvItem = { txtID.Text, txtName.Text, txtPrice.Text, txtISBN.Text, txtAuthor.Text, txtPublisher.Text, txtPages.Text };
            ListViewItem item   = new ListViewItem(lvItem);

            for (int i = 0; i < listViewBooks.Items.Count; i++)
            {
                if (listViewBooks.Items[i].SubItems[0].Text == selectedID)
                {
                    listViewBooks.Items[i] = item;
                    break;
                }
            }
            for (int i = 0; i < StoreMainScreen.productList.Count; i++)
            {
                if (StoreMainScreen.productList[i].ID1 == selectedID)
                {
                    StoreMainScreen.productList[i] = c.FactoryMethod();
                    break;
                }
            }
            UtilUpdate.Update(c.FactoryMethod());
            MessageBox.Show("Updated Succesfully!");
            panelAddBook.Visible = false;
            selectedIndex        = -1;
        }