private void ButtonSpremiUlov_Click(object sender, EventArgs e) { if (comboBoxBrod.Text == "--odaberi brod--") { MetroFramework.MetroMessageBox.Show(this, "Niste odabraili brod za ulov", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var result = MetroFramework.MetroMessageBox.Show(this, "Jeste li sigurni da želite dodait novi ulov", "Upit", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { long id_brod = Convert.ToInt64((comboBoxBrod.SelectedItem as ComboboxItem).Value.ToString()); long idKBroda = WindowPrijavaRibara.IdKBroda; Ulov noviulov = new Ulov(Datumulova.Value.Date, PocetakUlova.Value.ToString("HH:mm"), krajUlova.Value.ToString("HH:mm"), id_brod, idKBroda); long id_ulova = DBUlov.DodajUlov(noviulov); foreach (var a in ulovList) { DBStavkaUlov.DodajStavku(a, id_ulova); } MetroFramework.MetroMessageBox.Show(this, "Uspješno ste dodali novi ulov", "Informacija", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } }
private void metroButton1_Click(object sender, EventArgs e) { foreach (var series in chart1.Series) { series.Points.Clear(); } long id_KapBrod = Convert.ToInt64((ComboBoxKapBroda.SelectedItem as ComboboxItem).Value.ToString()); if (id_KapBrod == -1) { ulovPrikaz = DBUlov.DohvatiOdDoSvi(DateTimePocDatum.Value, DateTimeKrajDatum.Value); ulovstavkaSviUkupanStavke = DBStavkaUlov.DohvatiOdDoSveUlovStave(DateTimePocDatum.Value, DateTimeKrajDatum.Value); int i = 0; foreach (var a in ulovstavkaSviUkupanStavke) { chart1.Series["Kilaža"].Points.AddXY(a.Riba.Naziv, a.Kolicina); chart1.Series["Kilaža"].Points[i].Label = a.Kolicina.ToString() + " kg"; i++; } chart1.Series["Kilaža"].LegendText = "#VALX (#PERCENT)"; chart1.Series["Kilaža"].IsValueShownAsLabel = true; chart1.Titles["Title1"].Text = "Ulov ribe od " + DateTimePocDatum.Value.ToShortDateString() + " do " + DateTimeKrajDatum.Value.ToShortDateString(); } else { ulovPrikaz = DBUlov.DohvatiOdDo(DateTimePocDatum.Value, DateTimeKrajDatum.Value, id_KapBrod); ulovstavkaSVIKbrod = DBStavkaUlov.DohvatiOdDoKBrod(DateTimePocDatum.Value, DateTimeKrajDatum.Value, id_KapBrod); var sortiranUlovList = ulovstavkaSVIKbrod.OrderByDescending(stavka => stavka.Kolicina).ToList(); for (int i = 0; i < sortiranUlovList.Count; i++) { var stavka = sortiranUlovList[i]; chart1.Series["Kilaža"].Points.AddXY(stavka.Riba.Naziv, stavka.Kolicina); chart1.Series["Kilaža"].Points[i].Label = stavka.Kolicina.ToString() + " kg"; } chart1.Series["Kilaža"].IsValueShownAsLabel = true; chart1.Series["Kilaža"].LegendText = "#VALX (#PERCENT)"; chart1.Titles["Title1"].Text = "Ulov ribe od " + DateTimePocDatum.Value.ToShortDateString() + " do " + DateTimeKrajDatum.Value.ToShortDateString(); } var ulovPresenter = new ObservableCollection <Ulov>(ulovPrikaz); dgUlov.DataSource = ulovPresenter; List <UlovStavka> ulovStavka = new List <UlovStavka>(); ulovStavka = DBStavkaUlov.DohvatiSveUlovStavkeIRibe(); foreach (var b in ulovPrikaz) { b.UlovList = this.dohvatiStavkeUlova(b.id, ulovStavka); } }
private void ComboBoxKBroda_SelectedIndexChanged(object sender, EventArgs e) { foreach (var series in chart1.Series) { series.Points.Clear(); } if (ComboBoxKapBroda.SelectedIndex == 0) { ulovPrikaz = DBUlov.DohvatiSveUlov(); var ulovPresenter = new ObservableCollection <Ulov>(ulovPrikaz); dgUlov.DataSource = ulovPresenter; List <UlovStavka> ulovStavka = new List <UlovStavka>(); ulovStavka = DBStavkaUlov.DohvatiSveUlovStavkeIRibe(); foreach (var b in ulovPrikaz) { b.UlovList = this.dohvatiStavkeUlova(b.id, ulovStavka); } List <UlovStavka> ukupanUlovstavke = new List <UlovStavka>(); ukupanUlovstavke = DBStavkaUlov.DohvatiSveUlovStavkeIRibeUkupno(); var sortiranUlovList = ukupanUlovstavke.OrderByDescending(stavka => stavka.Kolicina).ToList(); for (int i = 0; i < sortiranUlovList.Count; i++) { var stavka = sortiranUlovList[i]; chart1.Series["Kilaža"].Points.AddXY(stavka.Riba.Naziv, stavka.Kolicina); chart1.Series["Kilaža"].Points[i].Label = stavka.Kolicina.ToString() + " kg"; } chart1.Series["Kilaža"].IsValueShownAsLabel = true; chart1.Series["Kilaža"].LegendText = "#VALX (#PERCENT)"; chart1.Titles["Title1"].Text = "Sve ukupan ulov ribe"; } else { long id_KapBrod = Convert.ToInt64((ComboBoxKapBroda.SelectedItem as ComboboxItem).Value.ToString()); ulovPrikaz = DBUlov.DohvatiUlovKapID(id_KapBrod); var ulovPresenter = new ObservableCollection <Ulov>(ulovPrikaz); dgUlov.DataSource = ulovPresenter; List <UlovStavka> ulovStavka = new List <UlovStavka>(); ulovStavka = DBStavkaUlov.DohvatiSveUlovStavkeIRibe(); foreach (var b in ulovPrikaz) { b.UlovList = this.dohvatiStavkeUlova(b.id, ulovStavka); } } }
private void metroButton2_Click(object sender, EventArgs e) { foreach (var series in chart1.Series) { series.Points.Clear(); } long idKBroda = WindowPrijavaRibara.IdKBroda; ulovstavkaSVIKbrod = DBStavkaUlov.DohvatiOdDoKBrod(DateTimePocDatum.Value, DateTimeKrajDatum.Value, idKBroda); var sortiranUlovList = ulovstavkaSVIKbrod.OrderByDescending(stavka => stavka.Kolicina).ToList(); for (int i = 0; i < sortiranUlovList.Count; i++) { var stavka = sortiranUlovList[i]; chart1.Series["Kilaža"].Points.AddXY(stavka.Riba.Naziv, stavka.Kolicina); chart1.Series["Kilaža"].Points[i].Label = stavka.Kolicina.ToString() + " kg"; } chart1.Series["Kilaža"].IsValueShownAsLabel = true; chart1.Series["Kilaža"].LegendText = "#VALX (#PERCENT)"; chart1.Titles["Title1"].Text = "Ulov ribe od " + DateTimePocDatum.Value.ToShortDateString() + " do " + DateTimeKrajDatum.Value.ToShortDateString(); ulovPrikaz = DBUlov.DohvatiOdDo(DateTimePocDatum.Value, DateTimeKrajDatum.Value, idKBroda); var ulovPresenter = new ObservableCollection <Ulov>(ulovPrikaz); dgUlov.DataSource = ulovPresenter; List <UlovStavka> ulovStavka = new List <UlovStavka>(); ulovStavka = DBStavkaUlov.DohvatiSveUlovStavkeIRibe(); foreach (var b in ulovPrikaz) { b.UlovList = this.dohvatiStavkeUlova(b.id, ulovStavka); } }
private void WindowPovijestUlovaRadnika_Load(object sender, EventArgs e) { var deleteButton = new DataGridViewButtonColumn(); deleteButton.Name = "dataGridViewDeleteButton"; deleteButton.HeaderText = "Obriši"; deleteButton.Text = "Delete"; deleteButton.Width = 70; deleteButton.UseColumnTextForButtonValue = true; this.dgUlov.Columns.Add(deleteButton); metroTabControl1.SelectedTab = metroTabPage1; chartRibe.Series["Kilaža"]["PieLabelStyle"] = "Outside"; chartRibe.Series["Kilaža"].BorderWidth = 1; chartRibe.Series["Kilaža"].BorderColor = System.Drawing.Color.FromArgb(26, 59, 105); chart1.Series["Kilaža"]["PieLabelStyle"] = "Outside"; chart1.Series["Kilaža"].BorderWidth = 1; chart1.Series["Kilaža"].BorderColor = System.Drawing.Color.FromArgb(26, 59, 105); long idKBroda = WindowPrijavaRibara.IdKBroda; ulovPrikaz = DBUlov.DohvatiUlovKapID(idKBroda); List <UlovStavka> ulovStavka = new List <UlovStavka>(); ulovStavka = DBStavkaUlov.DohvatiSveUlovStavkeIRibe(); foreach (var b in ulovPrikaz) { b.UlovList = this.dohvatiStavkeUlova(b.id, ulovStavka); } var ulovPresenter = new ObservableCollection <Ulov>(ulovPrikaz); dgUlov.DataSource = ulovPresenter; }
private void dgUlov_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == dgUlov.NewRowIndex || e.RowIndex < 0) { return; } if (e.ColumnIndex == dgUlov.Columns["dataGridViewDeleteButton"].Index) { var result = MetroFramework.MetroMessageBox.Show(this, "Jeste li sigurni da želite Izbrisati ulov i sve stavke tog ulova", "Upozorenje", MessageBoxButtons.YesNo, MessageBoxIcon.Stop); if (result == DialogResult.Yes) { this.ulovPrikaz.RemoveAt(e.RowIndex); int id_ulov = Convert.ToInt32(dgUlov.Rows[e.RowIndex].Cells[0].Value); DBUlov.IzbrisiUloviStavke(id_ulov); long idKBroda = WindowPrijavaRibara.IdKBroda; dgUlov.DataSource = null; ulovPrikaz = DBUlov.DohvatiUlovKapID(idKBroda); var ulovPresenter = new ObservableCollection <Ulov>(ulovPrikaz); dgUlov.DataSource = ulovPresenter; MetroFramework.MetroMessageBox.Show(this, "Uspješno ste izrisali ulov i stavke ulova", "Informacija", MessageBoxButtons.YesNo, MessageBoxIcon.Information); List <UlovStavka> ulovStavka = new List <UlovStavka>(); ulovStavka = DBStavkaUlov.DohvatiSveUlovStavkeIRibe(); foreach (var b in ulovPrikaz) { b.UlovList = this.dohvatiStavkeUlova(b.id, ulovStavka); } } } }