private void comboBoxNarudžba_SelectedIndexChanged(object sender, EventArgs e) { int ID; SelectKupacByNarudzbaID_Result Kupac = new SelectKupacByNarudzbaID_Result(); if (comboBoxNarudžba.SelectedIndex != 0) { ID = Convert.ToInt32(comboBoxNarudžba.SelectedValue); Kupac = DBKupci.SelectKupacByNarudzbaID(ID); textBoxIme.Text = Kupac.Ime; textBoxPrezime.Text = Kupac.Prezime; dateTimePickerDatum.Visible = true; dateTimePickerDatum.Value = Kupac.Datum; dataGridViewIgre.DataSource = DBProizvodi.SelectByNarudzbaID(ID); racun(ID); } else { textBoxIme.Text = ""; textBoxPrezime.Text = ""; dateTimePickerDatum.Visible = false; } }
private void button1_Click(object sender, EventArgs e) { Izlaz = new Izlazi(); Stavke = new List <IzlazStavke>(); if (this.ValidateChildren(ValidationConstraints.Enabled)) { try { Izlaz.Datum = DateTime.Now; Izlaz.BrojRacuna = textBoxBrojracuna.Text; int ID = Convert.ToInt32(comboBoxNarudžba.SelectedValue); Izlaz.KupacID = DBKupci.SelectKupacByNarudzbaID(ID).KupacID; Izlaz.Zakljucen = true; Izlaz.NarudzbaID = ID; Izlaz.IznosBezPDV = Convert.ToDecimal(textBoxIznos.Text); Izlaz.IznosSaPDV = Convert.ToDecimal(textBoxUkupno.Text); Izlaz.NarudzbaID = ID; List <SelectIgreByNarudzbaID_Result> Igre = DBProizvodi.SelectByNarudzbaID(ID); foreach (SelectIgreByNarudzbaID_Result ig in Igre) { IzlazStavke stavka = new IzlazStavke(); stavka.ProizvodID = ig.IgraID; stavka.Kolicina = ig.Kolicina; stavka.Cijena = ig.Cijena; Stavke.Add(stavka); } DBIzlazi.Insert(Izlaz, Stavke); MessageBox.Show(global.GetString("izlaz_succ"), "Izlaz", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }