Exemple #1
0
 private void btnAzuriraj_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex == -1)
     {
         MessageBox.Show("Nista nije selektovano u listi!", "Greska");
     }
     else
     {
         if (Globalne.AzurirajKupca)
         {
             foreach (Kupac k in kupci)
             {
                 if (k.Equals((Kupac)listBox1.SelectedItem))
                 {
                     k.azuriraj(txt1.Text, txt2.Text, txt3.Text, txt4.Text, txt5.Text);
                     listBox1.Items[listBox1.SelectedIndex] = k;
                 }
             }
             Globalne.upisiKupce(kupci, Globalne.DatKupac);
             MessageBox.Show("Uspesno azuriranje kupca");
         }
         else if (Globalne.AzurirajPonudu)
         {
             foreach (Ponuda p in ponude)
             {
                 if (p.Equals((Ponuda)listBox1.SelectedItem))
                 {
                     if (!txt1.Text.All(char.IsDigit))
                     {
                         MessageBox.Show("Cena mora biti broj");
                     }
                     else
                     {
                         p.Cena = int.Parse(txt1.Text);
                         Globalne.upisiPonude(ponude, Globalne.DatPonude);
                         listBox1.Items[listBox1.SelectedIndex] = p;
                         MessageBox.Show("Uspesno azuriranje ponude");
                     }
                 }
             }
         }
         else if (Globalne.AzurirajAuto)
         {
             foreach (Automobil a in automobili)
             {
                 if (a.Equals((Automobil)listBox1.SelectedItem))
                 {
                     a.azuriraj(txt1.Text, txt2.Text, txt3.Text, txt4.Text, txt5.Text, txt6.Text, txt7.Text, txt8.Text, txt9.Text);
                     listBox1.Items[listBox1.SelectedIndex] = a;
                 }
             }
             Globalne.upisiAutomobile(automobili, Globalne.DatAutomobili);
             MessageBox.Show("Uspesno azuriranje automobila");
         }
     }
 }
Exemple #2
0
        private void btnRezervisi_Click(object sender, EventArgs e) 
        {
            if (listBox1.SelectedIndex == -1)
                MessageBox.Show("Morate izabrati neki od datume iz liste ponudjenih datuma!", "Greska");
            else if (uspesno)
            {
                uspesno = false;
                Rezervacija novaRezervacija = new Rezervacija(auto.Id, Globalne.TrenutniKupac.Id, dateOd.Value, dateDo.Value, int.Parse(txtCena.Text));
                novaRezervacija.upisiRezervaciju(Globalne.DatRezervacije);                
                Ponuda p1;
                Ponuda p2;
                Ponuda pom = (Ponuda)listBox1.SelectedItem;
                if (pom.DatumOd != dateOd.Value)
                {
                    p1 = new Ponuda(auto.Id, pom.DatumOd, dateOd.Value.AddDays(-1), pom.Cena);
                    svePonude.Add(p1);
                    listBox1.Items.Add(p1);
                }
                if (pom.DatumDo != dateDo.Value)    
                {
                    p2 = new Ponuda(auto.Id, dateDo.Value.AddDays(1), pom.DatumDo, pom.Cena);
                    svePonude.Add(p2);
                    listBox1.Items.Add(p2);
                }
                for (int i = svePonude.Count - 1; i >= 0; i--)
                {
                    if (svePonude[i].IdAuto == pom.IdAuto && svePonude[i].DatumOd == pom.DatumOd && svePonude[i].DatumDo == pom.DatumDo && svePonude[i].Cena == pom.Cena)
                    {
                        svePonude.RemoveAt(i);
                    }
                }
                Globalne.upisiPonude(svePonude, Globalne.DatPonude);               
                listBox1.Items.Remove(pom);
                MessageBox.Show("Uspesna rezervacija!", "Obavestenje");                
                FormKupac frm = new FormKupac();
                frm.MdiParent = this.ParentForm;
                frm.Show();
                frm.Dock = DockStyle.Fill;
                Close();
            }
            else
                MessageBox.Show("Izabrani datum nije medju ponudjenim!", "Pogresan unos");


        }
Exemple #3
0
        private void btnObrisi_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                MessageBox.Show("Nista nije selektovano u listi!", "Greska");
            }
            else
            {
                if (Globalne.AzurirajKupca)
                {
                    Kupac selektovan = (Kupac)listBox1.SelectedItem;
                    foreach (Rezervacija r in rezervacije.ToList())   //brisanje svih rezervacija gde se obrisani kupac pojavljuje
                    {
                        if (r.IdKupac == selektovan.Id)
                        {
                            rezervacije.Remove(r);
                        }
                    }
                    Globalne.upisiRezervacije(rezervacije, Globalne.DatRezervacije);
                    kupci.Remove(selektovan);
                    Globalne.upisiKupce(kupci, Globalne.DatKupac);
                    txt1.Text = "";
                    txt2.Text = "";
                    txt3.Text = "";
                    txt4.Text = "";
                    txt5.Text = "";
                    listBox1.Items.Remove(listBox1.SelectedItem);

                    MessageBox.Show("Uspesno obrisan kupac");
                }
                else if (Globalne.AzurirajPonudu)
                {
                    ponude.Remove((Ponuda)listBox1.SelectedItem);
                    Globalne.upisiPonude(ponude, Globalne.DatPonude);
                    txt1.Text = "";
                    listBox1.Items.Remove(listBox1.SelectedItem);
                    MessageBox.Show("Uspesno obrisana ponuda");
                }
                else if (Globalne.AzurirajAuto)
                {
                    Automobil selektovan = (Automobil)listBox1.SelectedItem;

                    foreach (Ponuda p in ponude.ToList())      //brisanje svih ponuda/rezervacija gde se taj automobil pojavljuje
                    {
                        if (p.IdAuto == selektovan.Id)
                        {
                            ponude.Remove(p);
                        }
                    }
                    foreach (Rezervacija r in rezervacije.ToList())
                    {
                        if (r.IdAuto == selektovan.Id)
                        {
                            rezervacije.Remove(r);
                        }
                    }

                    automobili.Remove(selektovan);       //brisanje selektovanog automobila



                    MessageBox.Show("Uspesno obrisan automobil");
                    Globalne.upisiAutomobile(automobili, Globalne.DatAutomobili);
                    Globalne.upisiPonude(ponude, Globalne.DatPonude);
                    txt1.Text = "";
                    txt2.Text = "";
                    txt3.Text = "";
                    txt4.Text = "";
                    txt5.Text = "";
                    txt6.Text = "";
                    txt7.Text = "";
                    txt8.Text = "";
                    txt9.Text = "";
                    listBox1.Items.Remove(listBox1.SelectedItem);
                }
            }
        }