private void ButtonDodajribu_Click(object sender, EventArgs e) { if (ComboBoxRibe.SelectedItem == null || decimal.ToDouble(numericUpDownKilaza.Value) == 0.00) { MetroFramework.MetroMessageBox.Show(this, "Niste odabrali ribu ili niste dodali količinu ribe", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { long id_ribe = Convert.ToInt64((ComboBoxRibe.SelectedItem as ComboboxItem).Value.ToString()); bool vec_postoji = false; Riba riba = new Riba(ComboBoxRibe.Text.ToString(), id_ribe); double doublevalue = decimal.ToDouble(Math.Round(numericUpDownKilaza.Value, 2)); foreach (var a in ulovList) { if (id_ribe == a.Riba.Id_ribe) { a.Kolicina += doublevalue; vec_postoji = true; } } if (vec_postoji == false) { this.ulovList.Add(new UlovStavka(doublevalue, riba)); } else { } var stavkePresenter = new ObservableCollection <StavkaPresenter>(StavkaPresenter.ToPresenter(ulovList)); dgRibe.DataSource = stavkePresenter; } }
public static List <UlovStavka> DohvatiSveUlovStavkeIRibeUkupno() { List <UlovStavka> listaStavki = new List <UlovStavka>(); SQLiteCommand c = Bazapodataka.con.CreateCommand(); c.CommandText = @"SELECT UlovStavka.id_riba, Riba.naziv, SUM(UlovStavka.kolicina) as kolicina FROM UlovStavka LEFT JOIN Riba ON UlovStavka.id_riba = Riba.id GROUP BY UlovStavka.id_riba"; SQLiteDataReader reader = c.ExecuteReader(); while (reader.Read()) { Riba r = new Riba(); UlovStavka k = new UlovStavka(); r.id = (long)reader["id_riba"]; r.Naziv = (string)reader["naziv"]; k.Kolicina = Convert.ToDouble(reader["kolicina"]); k.Riba = r; listaStavki.Add(k); } reader.Dispose(); c.Dispose(); return(listaStavki); }
public static List <UlovStavka> DohvatiOdDoSveUlovStave(DateTime pocetakdatum, DateTime krajdatum) { List <UlovStavka> listaStavki = new List <UlovStavka>(); SQLiteCommand c = Bazapodataka.con.CreateCommand(); c.CommandText = String.Format(@"SELECT UlovStavka.id_riba, Riba.naziv, SUM(UlovStavka.kolicina) as kolicina, Ulov.id_kapetan FROM UlovStavka LEFT JOIN Riba ON UlovStavka.id_riba = Riba.id LEFT JOIN Ulov ON UlovStavka.id_ulov = Ulov.id WHERE Ulov.datum BETWEEN '{0}' and '{1}' GROUP BY UlovStavka.id_riba", pocetakdatum.ToFileTime(), krajdatum.ToFileTime()); SQLiteDataReader reader = c.ExecuteReader(); while (reader.Read()) { Riba r = new Riba(); UlovStavka k = new UlovStavka(); r.id = (long)reader["id_riba"]; r.Naziv = (string)reader["naziv"]; k.Kolicina = Convert.ToDouble(reader["kolicina"]); k.Riba = r; listaStavki.Add(k); } reader.Dispose(); c.Dispose(); return(listaStavki); }
public static void DodajRibu(Riba a) { SQLiteCommand c = Bazapodataka.con.CreateCommand(); c.CommandText = String.Format(@"INSERT INTO Riba (naziv) VALUES ('{0}')", a.Naziv); c.ExecuteNonQuery(); c.Dispose(); }
public static List <Riba> DohvatiSveRibe() { List <Riba> listaRiba = new List <Riba>(); SQLiteCommand c = Bazapodataka.con.CreateCommand(); c.CommandText = "SELECT id,naziv FROM Riba"; SQLiteDataReader reader = c.ExecuteReader(); while (reader.Read()) { Riba k = new Riba(); k.id = (long)reader["id"]; k.Naziv = (string)reader["naziv"]; listaRiba.Add(k); } reader.Dispose(); c.Dispose(); return(listaRiba); }
public UlovStavka(double kolicina, Riba riba) { this.Kolicina = kolicina; this.Riba = riba; }
public UlovStavka(double kolicina, Riba riba, long id_ulova) { this.Kolicina = kolicina; this.Riba = riba; this.Id_ulova = id_ulova; }