private void dgUlov_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            var ulov = this.ulovPrikaz[e.RowIndex];

            double ukupnoKg = 0;

            foreach (var stavka in ulov.UlovList)
            {
                ukupnoKg += stavka.Kolicina;
            }
            label4.Text = ukupnoKg.ToString() + " kg";

            var stavkePresenter = new ObservableCollection <StavkaPresenter>(StavkaPresenter.ToPresenter(ulov.UlovList));

            dgStavkeUlov.DataSource = stavkePresenter;

            foreach (var series in chartRibe.Series)
            {
                series.Points.Clear();
            }

            var sortiranUlovList = ulov.UlovList.OrderByDescending(stavka => stavka.Kolicina).ToList();

            for (int i = 0; i < sortiranUlovList.Count; i++)
            {
                var stavka = sortiranUlovList[i];
                chartRibe.Series["Kilaža"].Points.AddXY(stavka.Riba.Naziv, stavka.Kolicina);
                chartRibe.Series["Kilaža"].Points[i].Label = stavka.Kolicina.ToString() + " kg";
            }

            chartRibe.Series["Kilaža"].IsValueShownAsLabel = true;
            chartRibe.Series["Kilaža"].LegendText          = "#VALX (#PERCENT)";
        }
        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;
            }
        }
        private void dgRibe_CellClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == dgRibe.NewRowIndex || e.RowIndex < 0)
            {
                return;
            }

            if (e.ColumnIndex == dgRibe.Columns["dataGridViewDeleteButton"].Index)
            {
                this.ulovList.RemoveAt(e.RowIndex);

                dgRibe.DataSource = null;
                var stavkePresenter = new ObservableCollection <StavkaPresenter>(StavkaPresenter.ToPresenter(ulovList));
                dgRibe.DataSource = stavkePresenter;
            }
        }
Ejemplo n.º 4
0
        private void dgUlov_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            var ulov            = this.ulovPrikaz[e.RowIndex];
            var stavkePresenter = new ObservableCollection <StavkaPresenter>(StavkaPresenter.ToPresenter(ulov.UlovList));

            dgStavkaUlov.DataSource = stavkePresenter;

            foreach (var series in chartRibe.Series)
            {
                series.Points.Clear();
            }
            int i = 0;

            foreach (var stavka in ulov.UlovList)
            {
                chartRibe.Series["Kilaža"].Points.AddXY(stavka.Riba.Naziv, stavka.Kolicina);
                chartRibe.Series["Kilaža"].Points[i].Label = stavka.Kolicina.ToString() + " kg";
                i++;
            }

            chartRibe.Series["Kilaža"].IsValueShownAsLabel = true;
            chartRibe.Series["Kilaža"].LegendText          = "#VALX (#PERCENT)";
        }