Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox2.Text))
     {
         MessageBox.Show(
             "Wystąpił błąd. Błędnie wypełniony formularz. Nie dodano kategorii. ",
             "Zamknij",
             MessageBoxButtons.OK,
             MessageBoxIcon.Error);
     }
     else
     {
         string   name        = textBox1.Text;
         string   description = textBox2.Text;
         Category category    = new Category()
         {
             Name        = name,
             Description = description
         };
         prodContext.Categories.Add(category);
         prodContext.SaveChanges();
         MessageBox.Show(
             "Dodano kategorię",
             "Zamknij",
             MessageBoxButtons.OK,
             MessageBoxIcon.Information);
         this.Close();
         CategoryForm categoryForm = new CategoryForm();
         categoryForm.ShowDialog();
     }
 }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            CategoryForm categoryForm = new CategoryForm();

            categoryForm.ShowDialog();
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox2.Text) ||
                String.IsNullOrEmpty(textBox3.Text) || String.IsNullOrEmpty(textBox4.Text))
            {
                MessageBox.Show(
                    "Wystąpił błąd. Błędnie wypełniony formularz. Nie dodano produktu. ",
                    "Zamknij",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            else
            {
                string  name         = textBox1.Text;
                int     number       = int.Parse(textBox2.Text);
                decimal price        = decimal.Parse(textBox3.Text);
                int     id_kategorii = int.Parse(textBox4.Text);
                Product product      = new Product()
                {
                    Name         = name,
                    UnitsInStock = number,
                    CategoryID   = id_kategorii,
                    UnitPrice    = price
                };

                prodContext.Products.Add(product);
                prodContext.SaveChanges();
                MessageBox.Show(
                    "Dodano produkt",
                    "Zamknij",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                this.Close();
                CategoryForm categoryForm = new CategoryForm();
                categoryForm.ShowDialog();
            }
        }