コード例 #1
0
 private void AddingButton_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(AddName.Text) && !string.IsNullOrWhiteSpace(AddDescription.Text) && !string.IsNullOrWhiteSpace(AddPrice.Text) && !string.IsNullOrWhiteSpace(AddQuantity.Text))
     {
         try
         {
             string InsertQuery = "insert into items(ITEM_NAME,ITEM_PRICE,ITEM_DESCRIPTION,ITEM_QUANTATY) VALUES('" + AddName.Text + "','" + int.Parse(AddPrice.Text) + "','" + AddDescription.Text + "'," + int.Parse(AddQuantity.Text) + ")";
             connection.Open();
             MySqlCommand cmd = new MySqlCommand(InsertQuery, connection);
             cmd.ExecuteNonQuery();
         }
         catch (MySqlException ex)
         {
             MessageBox.Show(ex.ToString());
         }
         finally
         {
             connection.Close();
             MessageBox.Show("Successfully Added", "Success");
             AddName.Clear();
             AddDescription.Clear();
             AddPrice.Clear();
             AddQuantity.Clear();
         }
     }
     else
     {
         MessageBox.Show("incorrect input", "ERROR");
     }
 }
        public async Task <ActionResult> AddProduct(int productId, [FromBody] AddQuantity itemQuantity)
        {
            var userId = User.Identity.Name;

            var(basket, errors) = await _basketBusinessComponent.AddItemToBasket(userId, productId, itemQuantity.Quantity ?? 0);

            if (errors.IsValid)
            {
                return(Ok(_mapper.Map <Basket>(basket)));
            }

            return(_mapper.Map <ActionResult>(errors));
        }
コード例 #3
0
        //allow admins to add quantity of product when new stock arrives
        private void btnQuantity_Click(object sender, EventArgs e)
        {
            var addProductQuantity = new AddQuantity(this, ProductList);

            addProductQuantity.ShowDialog();
        }