private void AddSectionBtn_Click(object sender, EventArgs e)
        {
            AddSectionForm asf = new AddSectionForm();

            asf.ShowDialog();

            if (asf.DialogResult == DialogResult.OK)
            {
                var context = new FiskalnaBlagajnaEntities();
                var section = new SectionTable();

                section.Name = asf.getName();

                context.SectionTable.Add(section);
                context.SaveChanges();

                MessageBox.Show("Odijeljak uspiješno pohranjen!");
            }
        }
        public void displayData(object sender, MouseEventArgs e)
        {
            var context   = new FiskalnaBlagajnaEntities();
            int sectionID = ((SectionTable)(sender as Button).Tag).Id;

            flowLayoutPanel2.Controls.Clear();

            foreach (var c in context.SectionTable.Find(sectionID).ItemTable)
            {
                Button itemBtn = new Button();

                itemBtn.Name        = "ItemBtn";
                itemBtn.Text        = c.Name.Trim();
                itemBtn.Tag         = c;
                itemBtn.Width       = 180;
                itemBtn.Height      = 60;
                itemBtn.Font        = new Font(itemBtn.Font.FontFamily, 14);
                itemBtn.MouseClick += new MouseEventHandler(this.addItem);

                flowLayoutPanel2.Controls.Add(itemBtn);
            }
        }
        private void EditBtn_Click(object sender, EventArgs e)
        {
            var context    = new FiskalnaBlagajnaEntities();
            int selectedID = Int32.Parse(VEDGridView.SelectedRows[0].Cells[0].Value.ToString());

            try
            {
                if (VEDGridView.ColumnCount == 5) //itemTabel
                {
                    var         item = context.ItemTable.Find(selectedID);
                    AddItemForm aif  = new AddItemForm();

                    aif.setItemNames(item.Name);
                    aif.setItemPrice(item.Price.ToString());
                    aif.setItemQuantity(item.Quantity.ToString());
                    aif.setItemTax(item.Tax.ToString());
                    //aif.setComboBoxSelection();

                    aif.ShowDialog();


                    if (aif.DialogResult == DialogResult.OK)
                    {
                        item.Name     = aif.getItemName();
                        item.Price    = Int32.Parse(aif.getItemPrice());
                        item.Quantity = Int32.Parse(aif.getItemQuantity());
                        item.Tax      = Int32.Parse(aif.getItemTax());
                        item.SectionTable.Add(context.SectionTable.Find(aif.getComboBoxSelection()));

                        context.ItemTable.AddOrUpdate(item);
                        context.SaveChanges();

                        MessageBox.Show("Artikal je uspiješno uređen");
                    }
                }
                else if (VEDGridView.ColumnCount == 3)//userTabel
                {
                    var         user = context.UserTable.Find(selectedID);
                    AddUserForm aif  = new AddUserForm();

                    aif.setUserNames(user.Name);
                    aif.setIdTextBox(user.Id);

                    aif.ShowDialog();

                    if (aif.DialogResult == DialogResult.OK)
                    {
                        user.Name = aif.getNameTextBox();

                        context.UserTable.AddOrUpdate(user);
                        context.SaveChanges();

                        MessageBox.Show("Korisnik je uspiješno uređen");
                    }
                }
                else // sectionTable
                {
                    var            section = context.SectionTable.Find(selectedID);
                    AddSectionForm aif     = new AddSectionForm();


                    aif.setSectionName(section.Name);

                    aif.ShowDialog();

                    if (aif.DialogResult == DialogResult.OK)
                    {
                        section.Name = aif.getName();

                        context.SectionTable.AddOrUpdate(section);
                        context.SaveChanges();

                        MessageBox.Show("Odjeljak je uspiješno uređen");
                    }
                }
            }
            catch (Exception n)
            {
                MessageBox.Show(n.ToString());
            }
        }