public double obracunajPopust(Igrica i) { double x = i.Cijena; if (this.TipRegistracije == 0) { return i.Cijena; } else if (TipRegistracije == 1) { x = x - x * 0.05; return x; } else if (TipRegistracije == 2) { x = x - x * 0.07; return x; } else x = x - x * 0.1; return x; }
private void Dodaj_Click(object sender, EventArgs e) { DAL.DAL f = DAL.DAL.Instanca; try { // f.kreirajKonekciju("localhost", "gamecenter", "root", ""); //InitializeComponent(); Igrica x = new Igrica(0, xNaziv.Text, false, Convert.ToInt32(xDostupnost.Text), Convert.ToDouble(xCijena.Text), Convert.ToInt16(xPlatforma.Text), xKategorija.Text, "default"); DAL.DAL.IgricaDAO aj = f.getDAO.getIgricaDAO(); aj.create(x); MessageBox.Show("Uspjesno je dodan!"); this.Close(); } catch { MessageBox.Show("Nije uspjelo dodavanje!"); } }
private void button7_Click(object sender, EventArgs e) { Igrica x = new Igrica(); for (int i = 0; i < sveIgrice.Count; i++) { if (games.SelectedItem.ToString() == sveIgrice[i].ToString()) { x.Naziv = sveIgrice[i].Naziv; x.Kategorija = sveIgrice[i].Kategorija; x.Platforma = sveIgrice[i].Platforma; x.Sifra = sveIgrice[i].Sifra; x.Trailer = sveIgrice[i].Trailer; x.Dostupnost = sveIgrice[i].Dostupnost; x.Cijena = sveIgrice[i].Cijena; x.slika = sveIgrice[i].slika; x.PostaviSliku(x.slika); } } if(editujIgru.Text == "Potvrdi") { editujIgru.Text = "Edituj igricu"; p_u.Visible = false; k_u.Visible = false; d_u.Visible = false; c_u.Visible = false; platf_din.Text = p_u.Text; kat_din.Text = k_u.Text; dost_din.Text = d_u.Text; cijena_din.Text = c_u.Text; DAL.DAL f = DAL.DAL.Instanca; try { x.Kategorija = k_u.Text; x.Platforma = Convert.ToInt32(1); x.Dostupnost = Convert.ToInt32(d_u.Text); x.Cijena = Convert.ToDouble(c_u.Text); DAL.DAL.IgricaDAO juza = f.getDAO.getIgricaDAO(); juza.update(x); sveIgrice = juza.getAll(); games.DataSource = null; games.DataSource = sveIgrice; } catch { MessageBox.Show("greška"); } } else { editujIgru.Text = "Potvrdi"; p_u.Visible = true; k_u.Visible = true; d_u.Visible = true; c_u.Visible = true; p_u.Text = platf_din.Text; k_u.Text = kat_din.Text; d_u.Text = dost_din.Text; c_u.Text = cijena_din.Text; } }
void DodajUShoppingCart(Igrica i) { i.Cijena = obracunajPopust(i); ShoppingCart.Add(i); }