public Trening_kreiranje() { InitializeComponent(); ek = new List <Ekipa>(); vj = new List <Vjezbe>(); try { DB_connection.OpenConn(); ek = DB_GET.Ekipa_Get_All(); vj = DB_GET.Vjezbe_Get_All(); DB_connection.CloseConn(); } catch (ArgumentException err) { lblTreningKreirajResult.ForeColor = Color.Red; Change_label("Greška kod učitavanja podataka: " + err.ToString()); } cmbTreningKreiraj01.Items.Clear(); cmbTreningKreiraj01.DisplayMember = "Naziv"; foreach (var i in ek) { cmbTreningKreiraj01.Items.Add(i); } var collection = new ObservableCollection <Vjezbe>(vj); collection.CollectionChanged += Collection_CollectionChanged; BindingSource datasource = new BindingSource(collection, null); dgvTreningKreiraj01.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvTreningKreiraj01.AutoResizeColumns(); dgvTreningKreiraj01.AllowUserToAddRows = false; dgvTreningKreiraj01.DataSource = datasource; dgvTreningKreiraj01.Columns["Id"].Visible = false; DataGridViewCheckBoxColumn chbCell = new DataGridViewCheckBoxColumn(); chbCell.ValueType = typeof(bool); chbCell.Name = "Koristi"; chbCell.HeaderText = "Koristi"; dgvTreningKreiraj01.Columns.Add(chbCell); }
private void cmbBrisanjeOdabir_SelectedIndexChanged(object sender, EventArgs e) { int selected_idex = cmbBrisanjeOdabir.SelectedIndex; selected_item = cmbBrisanjeOdabir.SelectedItem.ToString(); try { DB_connection.OpenConn(); switch (selected_idex) { case 0: { ekipe = DB_GET.Ekipa_Get_All(); var collection = new ObservableCollection <Ekipa>(ekipe); datasource = new BindingSource(collection, null); selected_item = "EKIPA"; break; } case 1: { igrac = DB_GET.Igraci_Get_All(); var collection = new ObservableCollection <Igraci>(igrac); datasource = new BindingSource(collection, null); selected_item = "IGRAC"; break; } case 2: { prisutan = DB_GET.Prisutnost_Get_All(); var collection = new ObservableCollection <Prisutnost>(prisutan); datasource = new BindingSource(collection, null); selected_item = "PRISUTNOST"; break; } case 3: { trening = DB_GET.Trening_Get_All(); var collection = new ObservableCollection <Trening>(trening); datasource = new BindingSource(collection, null); selected_item = "TRENING"; break; } case 4: { statistike = DB_GET.Statistika_Get_All(); var collection = new ObservableCollection <Statistika>(statistike); datasource = new BindingSource(collection, null); selected_item = "STATISTIKA"; break; } case 5: { zapisnik = DB_GET.Zapisnik_Get_All(); var collection = new ObservableCollection <Zapisnik>(zapisnik); datasource = new BindingSource(collection, null); selected_item = "ZAPISNIK"; break; } case 6: { vjezba = DB_GET.Vjezbe_Get_All(); var collection = new ObservableCollection <Vjezbe>(vjezba); datasource = new BindingSource(collection, null); selected_item = "VJEZBE"; break; } case 7: { kosevi = DB_GET.Kosevi_Get_All(); var collection = new ObservableCollection <Kosevi>(kosevi); datasource = new BindingSource(collection, null); selected_item = "KOSEVI"; break; } } DB_connection.CloseConn(); } catch (ArgumentException err) { lblBrisanjeResult.ForeColor = Color.Red; Change_label("Greška kod brisanja: " + err.ToString()); } dgvBrisanje.DataSource = datasource; dgvBrisanje.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvBrisanje.AutoResizeColumns(); }