예제 #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Automobil auto = (Automobil)comboBox1.SelectedItem;

            listBox1.Items.Clear();
            foreach (Ponuda p in ponude)
            {
                if (p.IdAuto == auto.Id)
                {
                    listBox1.Items.Add(p);
                }
            }
        }
예제 #2
0
 private void cbPogon_SelectedIndexChanged(object sender, EventArgs e)
 {
     cbMenjac.Items.Clear();
     cbMenjac.ResetText();
     cbMenjac.SelectedIndex = -1;
     int br = 0;
     foreach (Automobil a in automobili)
         if (a.Marka == cbMarka.SelectedItem.ToString() && a.Model == cbModel.SelectedItem.ToString() && a.Godiste == int.Parse(cbGodiste.SelectedItem.ToString())
             && a.Kubikaza == int.Parse(cbKubikaza.SelectedItem.ToString()) && a.Karoserija == cbKaroserija.SelectedItem.ToString() &&
             a.BrojVrata == int.Parse(cbBrojVrata.SelectedItem.ToString()) && a.Gorivo == cbGorivo.SelectedItem.ToString() && a.Pogon == cbPogon.SelectedItem.ToString())
         {
             if (!cbMenjac.Items.Contains(a.Menjac))
                 cbMenjac.Items.Add(a.Menjac);
             auto = a;
             br++;
         }
     if (br == 1)
         cbMenjac.SelectedItem = cbMenjac.Items[0];
 }
예제 #3
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (Globalne.AzurirajKupca)
     {
         Kupac k = (Kupac)listBox1.SelectedItem;
         if (k != null)
         {
             txt1.Text = k.Ime;
             txt2.Text = k.Prezime;
             txt3.Text = k.Jmbg;
             txt4.Text = k.Datum_rodjenja.ToShortDateString();
             txt5.Text = k.Telefon;
         }
     }
     else if (Globalne.AzurirajAuto)
     {
         Automobil a = (Automobil)listBox1.SelectedItem;
         if (a != null)
         {
             txt1.Text = a.Marka;
             txt2.Text = a.Model;
             txt3.Text = a.Godiste.ToString();
             txt4.Text = a.Kubikaza.ToString();
             txt5.Text = a.Pogon;
             txt6.Text = a.Menjac;
             txt7.Text = a.Karoserija;
             txt8.Text = a.Gorivo;
             txt9.Text = a.BrojVrata.ToString();
         }
     }
     else if (Globalne.AzurirajPonudu)
     {
         Ponuda p = (Ponuda)listBox1.SelectedItem;
         if (p != null)
         {
             txt1.Text = p.Cena.ToString();
         }
     }
 }
예제 #4
0
 private void cbMarka_SelectedIndexChanged(object sender, EventArgs e)
 {
     cbModel.Items.Clear();           //brisanje svega iz combo boxova i reset selektovanih itema
     cbModel.ResetText();
     cbModel.SelectedIndex = -1;
     cbGodiste.ResetText();
     cbGodiste.Items.Clear();
     cbGodiste.SelectedIndex = -1;
     cbKubikaza.Items.Clear();
     cbKubikaza.ResetText();
     cbKubikaza.SelectedIndex = -1;
     cbKaroserija.Items.Clear();
     cbKaroserija.ResetText();
     cbKaroserija.SelectedIndex = -1;
     cbBrojVrata.Items.Clear();
     cbBrojVrata.ResetText();
     cbBrojVrata.SelectedIndex = -1;
     cbGorivo.Items.Clear();
     cbGorivo.ResetText();
     cbGorivo.SelectedIndex = -1;
     cbPogon.Items.Clear();
     cbPogon.ResetText();
     cbPogon.SelectedIndex = -1;
     cbMenjac.Items.Clear();
     cbMenjac.ResetText();
     cbMenjac.SelectedIndex = -1;
     int br = 0;
     foreach (Automobil a in automobili)
         if (a.Marka == cbMarka.SelectedItem.ToString())      //na odabir marke popunjava se model
         {
             if (!cbModel.Items.Contains(a.Model))   
                 cbModel.Items.Add(a.Model);
             auto = a;
             br++;
         }
     if (br == 1)                  //ukoliko postoji samo jedan model automatski se selektuje
         cbModel.SelectedItem = cbModel.Items[0];
     
 }
예제 #5
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);
                }
            }
        }
예제 #6
0
        private void btnDodajAuto_Click(object sender, EventArgs e)
        {
            string pogresanUnos = "";
            int    flag         = 0;

            if (txtMarka.Text.Trim() == "")
            {
                pogresanUnos += "Morate uneti marku automobila!" + Environment.NewLine;
                flag          = 1;
            }
            if (txtModel.Text.Trim() == "")
            {
                pogresanUnos += "Morate uneti model automobila!" + Environment.NewLine;
                flag          = 1;
            }
            if (txtGodiste.Text.Trim() == "" || !txtGodiste.Text.All(char.IsDigit) || int.Parse(txtGodiste.Text) > DateTime.Today.Year)
            {
                pogresanUnos += "Morate uneti korektno godiste automobila!" + Environment.NewLine;
                flag          = 1;
            }
            if (txtKubikaza.Text.Trim() == "" || !txtKubikaza.Text.All(char.IsDigit))
            {
                pogresanUnos += "Morate uneti ispravno kubikazu!" + Environment.NewLine;
                flag          = 1;
            }
            if (txtPogon.Text.Trim() == "")
            {
                pogresanUnos += "Morate uneti pogon!" + Environment.NewLine;
                flag          = 1;
            }
            if (txtMenjac.Text.Trim() == "")
            {
                pogresanUnos += "Morate uneti vrstu menjaca!" + Environment.NewLine;
                flag          = 1;
            }
            if (txtKaroserija.Text.Trim() == "")
            {
                pogresanUnos += "Morate uneti karoseriju!" + Environment.NewLine;
                flag          = 1;
            }
            if (txtGorivo.Text.Trim() == "")
            {
                pogresanUnos += "Morate uneti vrstu goriva!" + Environment.NewLine;
                flag          = 1;
            }
            if (txtBrojVrata.Text.Trim() == "" || !txtBrojVrata.Text.All(char.IsDigit))
            {
                pogresanUnos += "Morate uneti ispravno broj vrata!" + Environment.NewLine;
                flag          = 1;
            }
            if (flag == 1)
            {
                MessageBox.Show(pogresanUnos, "Pogresan unos podataka!");
            }
            else
            {
                Automobil noviAuto = new Automobil(txtMarka.Text, txtModel.Text, int.Parse(txtGodiste.Text), int.Parse(txtKubikaza.Text), txtPogon.Text, txtMenjac.Text, txtKaroserija.Text, txtGorivo.Text, int.Parse(txtBrojVrata.Text));
                noviAuto.upisiAutomobil(Globalne.DatAutomobili);
                MessageBox.Show("Novi automobil uspesno dodat!", "Uspesno dodavanje");
                FormAdmin frm = new FormAdmin();
                frm.MdiParent = this.ParentForm;
                frm.Show();
                frm.Dock = DockStyle.Fill;
                Close();
            }
        }