Ejemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ProductSet productSet = new ProductSet();

            productSet.NameProduct = textBoxNameProduct.Text;
            productSet.Quantity    = textBoxQuantity.Text;
            productSet.Price       = Convert.ToInt32(textBoxPrice.Text);

            Program.master.ProductSet.Add(productSet);
            Program.master.SaveChanges();
            ShowProduct();
        }
Ejemplo n.º 2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     if (listViewProducts.SelectedItems.Count == 1)
     {
         ProductSet productSet = listViewProducts.SelectedItems[0].Tag as ProductSet;
         Program.master.ProductSet.Remove(productSet);
         Program.master.SaveChanges();
         ShowProduct();
     }
     textBoxNameProduct.Text = "";
     textBoxQuantity.Text    = "";
     textBoxPrice.Text       = "";
 }
Ejemplo n.º 3
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewProducts.SelectedItems.Count == 1)
            {
                ProductSet productSet = listViewProducts.SelectedItems[0].Tag as ProductSet;

                productSet.NameProduct = textBoxNameProduct.Text;
                productSet.Quantity    = textBoxQuantity.Text;
                productSet.Price       = Convert.ToInt32(textBoxPrice.Text);

                Program.master.SaveChanges();
                ShowProduct();
            }
        }
Ejemplo n.º 4
0
        private void listViewProducts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewProducts.SelectedItems.Count == 1)
            {
                ProductSet productSet = listViewProducts.SelectedItems[0].Tag as ProductSet;

                textBoxNameProduct.Text = productSet.NameProduct;
                textBoxQuantity.Text    = productSet.Quantity;
                textBoxPrice.Text       = Convert.ToString(productSet.Price);
            }
            else
            {
                textBoxNameProduct.Text = "";
                textBoxQuantity.Text    = "";
                textBoxPrice.Text       = "";
            }
        }