Пример #1
0
 /// <summary>
 /// This function delete book button click operation.
 /// This function is used to remove product list and delete for util function.
 /// </summary>
 /// <returns> This function does not return a value  </returns>
 private void btnDelete_Click(object sender, EventArgs e)
 {
     Logger.GetLogger().WriteLog(LoginedCustomer.getInstance().User.Username, btnDelete.Text, DateTime.Now);
     if (selectedIndex == -1)
     {
         MessageBox.Show("Please select a book from list!");
         return;
     }
     selectedID = listViewBooks.Items[selectedIndex].SubItems[0].Text;
     for (int i = 0; i < listViewBooks.Items.Count; i++)
     {
         if (listViewBooks.Items[i].SubItems[0].Text == selectedID)
         {
             listViewBooks.Items.RemoveAt(i);
             break;
         }
     }
     for (int i = 0; i < StoreMainScreen.productList.Count; i++)
     {
         if (StoreMainScreen.productList[i].ID1 == selectedID)
         {
             UtilUpdate.Delete(StoreMainScreen.productList[i]);
             StoreMainScreen.productList.RemoveAt(i);
             break;
         }
     }
     MessageBox.Show("Deleted Succesfully!");
     selectedIndex = -1;
 }
        /// <summary>
        /// This function includes cancel button click operation.
        /// This function used to called delete for util and cancel order for shopping shoppingCards function.
        /// </summary>
        /// <returns> This function does not return a value </returns>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            Logger.GetLogger().WriteLog(LoginedCustomer.getInstance().User.Username, btnCancel.Text, DateTime.Now);
            DialogResult dr = MessageBox.Show("Your order will be canceled. Do you want to proceed?", "Info",
                                              MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (dr == DialogResult.OK)
            {
                UtilUpdate.Delete(StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex]);
                StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].CancelOrder();
                flpShoppingList.Controls.Clear();
            }
        }
Пример #3
0
 /// <summary>
 /// This function includes remove button click operation.
 /// This function used to deleted this product and updated shopping card.
 /// </summary>
 /// <returns> This function does not return a value  </returns>
 private void btnRemove_Click(object sender, EventArgs e)
 {
     Logger.GetLogger().WriteLog(LoginedCustomer.getInstance().User.Username, btnRemove.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)
         {
             int index = i;
             UtilUpdate.Delete(StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex], index);
             StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].RemoveProduct(StoreMainScreen.shoppingCards[LoginScreen.shoppingCardIndex].itemsToPurchase[i]);
         }
     }
 }