Skip to content

Commit

Permalink
Dodan gumb zaposlenici
Browse files Browse the repository at this point in the history
  • Loading branch information
Juric22 committed Jun 13, 2024
1 parent 2cbef60 commit 9979c61
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
13 changes: 13 additions & 0 deletions Software/SZUUP/SZUUP/FrmPopisJela.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 19 additions & 14 deletions Software/SZUUP/SZUUP/FrmPopisJela.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using SZUUP.Models;
using SZUUP.Repozitoris;
Expand All @@ -8,6 +9,8 @@ namespace SZUUP
{
public partial class FrmPopisJela : Form
{
private List<Jelo> allJela; // To store all meals

public FrmPopisJela()
{
InitializeComponent();
Expand All @@ -18,6 +21,7 @@ public FrmPopisJela()
btnPretraziJelo.Click += new EventHandler(this.btnPretraziJelo_Click);
btnUrediJelo.Click += new EventHandler(this.btnUrediJelo_Click);
btnObrisiJelo.Click += new EventHandler(this.btnObrisiJelo_Click);
btnZaposlenici.Click += new EventHandler(this.btnZaposlenici_Click); // Manually added this line
}

private void FrmPopisJela_Load(object sender, EventArgs e)
Expand All @@ -27,10 +31,10 @@ private void FrmPopisJela_Load(object sender, EventArgs e)

private void ShowJela()
{
List<Jelo> jela = JeloRepozitorij.GetJela();
if (jela != null && jela.Count > 0)
allJela = JeloRepozitorij.GetJela(); // Get all meals and store them
if (allJela != null && allJela.Count > 0)
{
dgvJela.DataSource = jela;
dgvJela.DataSource = allJela;
dgvJela.Columns["Id_jelo"].DisplayIndex = 0;
dgvJela.Columns["Id_Kategorija"].DisplayIndex = 1;
dgvJela.Columns["Naziv"].DisplayIndex = 2;
Expand Down Expand Up @@ -59,19 +63,13 @@ private void btnPretraziJelo_Click(object sender, EventArgs e)
return;
}

bool found = false;
foreach (DataGridViewRow row in dgvJela.Rows)
var filteredJela = allJela.Where(j => j.Naziv.Equals(searchQuery, StringComparison.OrdinalIgnoreCase)).ToList();

if (filteredJela.Count > 0)
{
if (row.Cells["Naziv"].Value != null && row.Cells["Naziv"].Value.ToString().Equals(searchQuery, StringComparison.OrdinalIgnoreCase))
{
row.Selected = true;
dgvJela.FirstDisplayedScrollingRowIndex = row.Index; // Scroll to the selected row
found = true;
break;
}
dgvJela.DataSource = filteredJela;
}

if (!found)
else
{
MessageBox.Show("Jelo nije pronađeno.", "Informacija", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Expand Down Expand Up @@ -127,5 +125,12 @@ private void FrmPopisJela_Load_1(object sender, EventArgs e)
{
// Handle form load event if needed
}

private void btnZaposlenici_Click(object sender, EventArgs e)
{
FrmZaposlenici frmZaposlenici = new FrmZaposlenici();
frmZaposlenici.ShowDialog();
}

}
}

0 comments on commit 9979c61

Please sign in to comment.