Exemplo n.º 1
0
        public Boolean dodajNoviAutomobil()
        {
            Boolean          flag            = false;
            List <Automobil> ListaAutomobila = new List <Automobil>();

            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            foreach (Automobil a in ListaAutomobila)
            {
                if (this.idbr == a.idbr)
                {
                    flag = true;
                    break;
                }
            }
            if (flag == false)
            {
                ListaAutomobila.Add(this);
                RadSaDatotekama.upisAutomobilDatoteke(ref ListaAutomobila);
                MessageBox.Show("Uspešno ste dodali novi Automobil u sistem!");
            }
            else
            {
                MessageBox.Show("Uneti IDBR vec postoji u sistemu!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            ListaAutomobila.Clear();
            return(flag);
        }
        public void prikazSvihMarki(object sender, EventArgs e)
        {
            Boolean          flagNadjen      = false;
            List <Automobil> ListaAutomobila = new List <Automobil>();

            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            for (int i = 0; i < ListaAutomobila.Count; i++)
            {
                for (int j = i + 1; j < ListaAutomobila.Count; j++)
                {
                    if (ListaAutomobila[i].Marka == ListaAutomobila[j].Marka)
                    {
                        flagNadjen = true;
                    }
                }
                if (flagNadjen == false)
                {
                    cbMarka.Items.Add(ListaAutomobila[i].Marka);
                }
                else
                {
                    flagNadjen = false;
                }
            }
            ListaAutomobila.Clear();
        }
        public void prikazTrenutnihAutomobila(object sender, EventArgs e)
        {
            Automobil        pom             = null;
            List <Automobil> ListaAutomobila = new List <Automobil>();

            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            cbSviAutomobili.Items.Clear();
            for (int i = 0; i < ListaAutomobila.Count - 1; i++)
            {
                for (int j = i + 1; j < ListaAutomobila.Count; j++)
                {
                    if (ListaAutomobila[i].Idbr > ListaAutomobila[j].Idbr)
                    {
                        pom = ListaAutomobila[i];
                        ListaAutomobila[i] = ListaAutomobila[j];
                        ListaAutomobila[j] = pom;
                    }
                }
            }
            foreach (Automobil a in ListaAutomobila)
            {
                cbSviAutomobili.Items.Add(a);
            }
            ListaAutomobila.Clear();
        }
Exemplo n.º 4
0
        public Boolean dodajNovuPonudu()
        {
            Boolean          flagAutomobil   = false;
            Boolean          flagPonuda      = true;
            List <Automobil> ListaAutomobila = new List <Automobil>();
            List <Ponuda>    ListaPonuda     = new List <Ponuda>();

            RadSaDatotekama.citanjePonudeDatoteke(ref ListaPonuda);
            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            foreach (Automobil a in ListaAutomobila)
            {
                if (a.Idbr == idbrAutomobila)
                {
                    flagAutomobil = true;
                }
            }
            foreach (Ponuda p in ListaPonuda)
            {
                if (((this.datumOd.Date >= p.datumOd.Date && this.datumOd.Date <= p.datumDo.Date) ||
                     (this.datumDo.Date >= p.datumOd.Date && this.datumDo.Date <= p.datumDo.Date)) &&
                    flagAutomobil == true && this.idbrAutomobila == p.idbrAutomobila)
                {
                    flagPonuda = false;
                }
            }
            if (flagAutomobil == true)
            {
                if (flagPonuda == true)
                {
                    ListaPonuda.Add(this);
                    RadSaDatotekama.upisPonudeDatoteke(ref ListaPonuda);
                }
                else
                {
                    MessageBox.Show("Ne možete preklapati datume Ponude za jedan isti automobil!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Traženi IDBR nije dodeljen ni jednom Automobilu!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (flagAutomobil == true && flagPonuda == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        public void ukloniAuto()
        {
            Boolean          flag            = false;
            List <Ponuda>    ListaPonuda     = new List <Ponuda>();
            List <Automobil> ListaAutomobila = new List <Automobil>();

            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            RadSaDatotekama.citanjePonudeDatoteke(ref ListaPonuda);
            for (int i = 0; i < ListaAutomobila.Count; i++)
            {
                if (this.idbr == ListaAutomobila[i].idbr)
                {
                    ListaAutomobila.RemoveAt(i);
                    --i;
                    flag = true;
                }
            }
            for (int i = 0; i < ListaPonuda.Count; i++)
            {
                if (this.idbr == ListaPonuda[i].IdbrAutomobila)
                {
                    ListaPonuda.RemoveAt(i);
                    --i;
                }
            }
            if (flag == true)
            {
                RadSaDatotekama.upisAutomobilDatoteke(ref ListaAutomobila);
                RadSaDatotekama.upisPonudeDatoteke(ref ListaPonuda);
                MessageBox.Show("Uspešno ste obrisali Automobil iz sistema!");
            }
            else
            {
                MessageBox.Show("Automobil koji ste hteli da obrišete ne postoji u sistemu!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            ListaPonuda.Clear();
            ListaAutomobila.Clear();
        }
        public void prikazOstalih(object sender, EventArgs e)
        {
            object           m               = cbModel.SelectedItem;
            string           model           = m as string;
            Boolean          flagGodiste     = false;
            Boolean          flagKubikaza    = false;
            Boolean          flagKaroserija  = false;
            Boolean          flagBrojVrata   = false;
            Boolean          flagGorivo      = false;
            Boolean          flagPogon       = false;
            Boolean          flagMenjac      = false;
            List <Automobil> ListaAutomobila = new List <Automobil>();

            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            Rezervacija.ocistiPolja(ref cbGodiste, ref cbKubikaza, ref cbKaroserija, ref cbBrojVrata, ref cbGorivo, ref cbPogon, ref cbMenjac);
            for (int i = 0; i < ListaAutomobila.Count; i++)
            {
                if (ListaAutomobila[i].Model == model)
                {
                    for (int j = i + 1; j < ListaAutomobila.Count; j++)
                    {
                        if (ListaAutomobila[i].Model == ListaAutomobila[j].Model)
                        {
                            if (ListaAutomobila[i].Godiste == ListaAutomobila[j].Godiste)
                            {
                                flagGodiste = true;
                            }
                            if (ListaAutomobila[i].Kubikaza == ListaAutomobila[j].Kubikaza)
                            {
                                flagKubikaza = true;
                            }
                            if (ListaAutomobila[i].Karoserija == ListaAutomobila[j].Karoserija)
                            {
                                flagKaroserija = true;
                            }
                            if (ListaAutomobila[i].BrojVrata == ListaAutomobila[j].BrojVrata)
                            {
                                flagBrojVrata = true;
                            }
                            if (ListaAutomobila[i].Gorivo == ListaAutomobila[j].Gorivo)
                            {
                                flagGorivo = true;
                            }
                            if (ListaAutomobila[i].Pogon == ListaAutomobila[j].Pogon)
                            {
                                flagPogon = true;
                            }
                            if (ListaAutomobila[i].VrstaMenjaca == ListaAutomobila[j].VrstaMenjaca)
                            {
                                flagMenjac = true;
                            }
                        }
                    }
                    if (flagGodiste == false)
                    {
                        cbGodiste.Items.Add(ListaAutomobila[i].Godiste);
                    }
                    if (flagKubikaza == false)
                    {
                        cbKubikaza.Items.Add(ListaAutomobila[i].Kubikaza);
                    }
                    if (flagKaroserija == false)
                    {
                        cbKaroserija.Items.Add(ListaAutomobila[i].Karoserija);
                    }
                    if (flagBrojVrata == false)
                    {
                        cbBrojVrata.Items.Add(ListaAutomobila[i].BrojVrata);
                    }
                    if (flagGorivo == false)
                    {
                        cbGorivo.Items.Add(ListaAutomobila[i].Gorivo);
                    }
                    if (flagPogon == false)
                    {
                        cbPogon.Items.Add(ListaAutomobila[i].Pogon);
                    }
                    if (flagMenjac == false)
                    {
                        cbMenjac.Items.Add(ListaAutomobila[i].VrstaMenjaca);
                    }
                    flagGodiste = flagKubikaza = flagKaroserija = flagBrojVrata = flagGorivo = flagPogon = flagMenjac = false;
                }
            }
            ListaAutomobila.Clear();
        }
        public void prikazModela(object sender, EventArgs e)
        {
            Boolean          uslov           = true;
            object           m               = cbMarka.SelectedItem;
            string           marka           = m as string;
            Boolean          flagNadjen      = false;
            List <Automobil> ListaAutomobila = new List <Automobil>();

            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            cbModel.Items.Clear();
            GlavnaLista.Clear();
            for (int i = 0; i < ListaAutomobila.Count; i++)
            {
                if (ListaAutomobila[i].Marka == marka)
                {
                    for (int j = i + 1; j < ListaAutomobila.Count; j++)
                    {
                        if (ListaAutomobila[i].Model == ListaAutomobila[j].Model &&
                            ListaAutomobila[i].Marka == ListaAutomobila[j].Marka)
                        {
                            flagNadjen = true;
                        }
                    }
                    if (flagNadjen == false)
                    {
                        cbModel.Items.Add(ListaAutomobila[i].Model);
                    }
                    else
                    {
                        flagNadjen = false;
                    }
                }
                if (cbMarka.Text != "")
                {
                    if (ListaAutomobila[i].Marka != cbMarka.Text)
                    {
                        uslov = false;
                    }
                }
                if (cbModel.Text != "")
                {
                    if (ListaAutomobila[i].Model != cbModel.Text)
                    {
                        uslov = false;
                    }
                }
                if (cbGodiste.Text != "")
                {
                    if (ListaAutomobila[i].Godiste != int.Parse(cbGodiste.Text))
                    {
                        uslov = false;
                    }
                }
                if (cbKubikaza.Text != "")
                {
                    if (ListaAutomobila[i].Kubikaza != int.Parse(cbKubikaza.Text))
                    {
                        uslov = false;
                    }
                }
                if (cbKaroserija.Text != "")
                {
                    if (ListaAutomobila[i].Karoserija != cbKaroserija.Text)
                    {
                        uslov = false;
                    }
                }
                if (cbBrojVrata.Text != "")
                {
                    if (ListaAutomobila[i].BrojVrata != int.Parse(cbBrojVrata.Text))
                    {
                        uslov = false;
                    }
                }
                if (cbGorivo.Text != "")
                {
                    if (ListaAutomobila[i].Gorivo != cbGorivo.Text)
                    {
                        uslov = false;
                    }
                }
                if (cbPogon.Text != "")
                {
                    if (ListaAutomobila[i].Pogon != cbPogon.Text)
                    {
                        uslov = false;
                    }
                }
                if (cbMenjac.Text != "")
                {
                    if (ListaAutomobila[i].VrstaMenjaca != cbMenjac.Text)
                    {
                        uslov = false;
                    }
                }
                if (uslov == true)
                {
                    GlavnaLista.Add(ListaAutomobila[i]);
                }
                uslov = true;
            }
            ListaAutomobila.Clear();
        }
Exemplo n.º 8
0
        public void azurirajAutomobil(int noviIdbr)
        {
            Boolean            flagIdbr        = true;
            Boolean            flag            = false;
            List <Rezervacija> ListaRez        = new List <Rezervacija>();
            List <Ponuda>      ListaPonuda     = new List <Ponuda>();
            List <Automobil>   ListaAutomobila = new List <Automobil>();

            RadSaDatotekama.citanjeRezDatoteke(ref ListaRez);
            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            RadSaDatotekama.citanjePonudeDatoteke(ref ListaPonuda);
            foreach (Automobil a in ListaAutomobila)
            {
                if (a.idbr == this.idbr)
                {
                    flag = true;
                }
                if (noviIdbr == a.idbr && a.idbr != this.idbr)
                {
                    flagIdbr = false;
                }
            }
            if (flag == true)
            {
                if (flagIdbr == true)
                {
                    for (int i = 0; i < ListaPonuda.Count; i++)
                    {
                        if (ListaPonuda[i].IdbrAutomobila == this.idbr)
                        {
                            ListaPonuda[i].IdbrAutomobila = noviIdbr;
                        }
                    }
                    for (int i = 0; i < ListaRez.Count; i++)
                    {
                        if (ListaRez[i].IdbrAutomobila == this.idbr)
                        {
                            ListaRez[i].IdbrAutomobila = noviIdbr;
                        }
                    }
                    for (int i = 0; i < ListaAutomobila.Count; i++)
                    {
                        if (ListaAutomobila[i].idbr == this.idbr)
                        {
                            this.idbr          = noviIdbr;
                            ListaAutomobila[i] = this;
                        }
                    }
                    RadSaDatotekama.upisRezDatoteke(ref ListaRez);
                    RadSaDatotekama.upisPonudeDatoteke(ref ListaPonuda);
                    RadSaDatotekama.upisAutomobilDatoteke(ref ListaAutomobila);
                    MessageBox.Show("Uspešno ste ažurirali podatke o Automobilu!");
                }
                else
                {
                    MessageBox.Show("Novi IDBR koji ste uneli već postoji u sistemu!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Ne možete da ažurirate Automobil koji ne postoji u sistemu!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            ListaPonuda.Clear();
            ListaAutomobila.Clear();
        }
        public void crtanjeGrafika(object sender, PaintEventArgs e)
        {
            Boolean            flagNadjen      = false;
            int                redniBrojMeseca = cbMeseci.SelectedIndex + 1;
            int                godina          = 2010 + cbGodina.SelectedIndex;
            List <Rezervacija> ListaRez        = new List <Rezervacija>();
            List <Automobil>   ListaAutomobila = new List <Automobil>();
            List <Statistika>  ListaStat       = new List <Statistika>();

            RadSaDatotekama.citanjeRezDatoteke(ref ListaRez);
            RadSaDatotekama.citanjeAutomobilDatoteke(ref ListaAutomobila);
            int ukupanBrojDanaUMesecu    = 0;
            int ukupanBrojDanaAutomobila = 0;

            //Racunanje ukupnog broja dana u mesecu koji su rezervisani
            for (int i = 0; i < ListaRez.Count; i++)
            {
                if (ListaRez[i].DatumOd.Month == redniBrojMeseca && ListaRez[i].DatumDo.Month == redniBrojMeseca &&
                    ListaRez[i].DatumOd.Year == godina && ListaRez[i].DatumDo.Year == godina)
                {
                    ukupanBrojDanaUMesecu += (int)(ListaRez[i].DatumDo.Date - ListaRez[i].DatumOd.Date).TotalDays + 1;
                }
                else if (ListaRez[i].DatumOd.Month == redniBrojMeseca && ListaRez[i].DatumDo.Month != redniBrojMeseca &&
                         ListaRez[i].DatumOd.Year == godina && ListaRez[i].DatumDo.Year == godina)
                {
                    int      brojDana     = DateTime.DaysInMonth(ListaRez[i].DatumOd.Year, ListaRez[i].DatumOd.Month);
                    DateTime poslednjiDan = new DateTime(ListaRez[i].DatumOd.Year, ListaRez[i].DatumOd.Month, brojDana);
                    ukupanBrojDanaUMesecu += (int)(poslednjiDan.Date - ListaRez[i].DatumOd.Date).TotalDays + 1;
                }
                else if (ListaRez[i].DatumOd.Month != redniBrojMeseca && ListaRez[i].DatumDo.Month == redniBrojMeseca &&
                         ListaRez[i].DatumOd.Year == godina && ListaRez[i].DatumDo.Year == godina)
                {
                    DateTime prviDan = new DateTime(ListaRez[i].DatumDo.Year, ListaRez[i].DatumDo.Month, 1);
                    ukupanBrojDanaUMesecu += (int)(ListaRez[i].DatumDo.Date - prviDan.Date).TotalDays + 1;
                }
                else if (ListaRez[i].DatumOd.Month <redniBrojMeseca && ListaRez[i].DatumDo.Month> redniBrojMeseca &&
                         ListaRez[i].DatumOd.Year == godina && ListaRez[i].DatumDo.Year == godina)
                {
                    DateTime prviDan   = new DateTime(godina, redniBrojMeseca, 1);
                    DateTime zadnjiDan = prviDan.AddMonths(1).AddDays(-1);
                    ukupanBrojDanaUMesecu += (int)(zadnjiDan.Date - prviDan.Date).TotalDays + 1;
                }
            }
            //Racunanje broja dana u mesecu za pojedinacne Automobile
            for (int i = 0; i < ListaAutomobila.Count; i++)
            {
                for (int j = 0; j < ListaRez.Count; j++)
                {
                    if (ListaAutomobila[i].Idbr == ListaRez[j].IdbrAutomobila)
                    {
                        if (ListaRez[j].DatumOd.Month == redniBrojMeseca && ListaRez[j].DatumDo.Month == redniBrojMeseca &&
                            ListaRez[j].DatumOd.Year == godina && ListaRez[j].DatumDo.Year == godina)
                        {
                            ukupanBrojDanaAutomobila += (int)(ListaRez[j].DatumDo.Date - ListaRez[j].DatumOd.Date).TotalDays + 1;
                            flagNadjen = true;
                        }
                        else if (ListaRez[j].DatumOd.Month == redniBrojMeseca && ListaRez[j].DatumDo.Month != redniBrojMeseca &&
                                 ListaRez[j].DatumOd.Year == godina && ListaRez[j].DatumDo.Year == godina)
                        {
                            int      brojDana     = DateTime.DaysInMonth(ListaRez[j].DatumOd.Year, ListaRez[j].DatumOd.Month);
                            DateTime poslednjiDan = new DateTime(ListaRez[j].DatumOd.Year, ListaRez[j].DatumOd.Month, brojDana);
                            ukupanBrojDanaAutomobila += (int)(poslednjiDan.Date - ListaRez[j].DatumOd.Date).TotalDays + 1;
                            flagNadjen = true;
                        }
                        else if (ListaRez[j].DatumOd.Month != redniBrojMeseca && ListaRez[j].DatumDo.Month == redniBrojMeseca &&
                                 ListaRez[j].DatumOd.Year == godina && ListaRez[j].DatumDo.Year == godina)
                        {
                            DateTime prviDan = new DateTime(ListaRez[j].DatumDo.Year, ListaRez[j].DatumDo.Month, 1);
                            ukupanBrojDanaAutomobila += (int)(ListaRez[j].DatumDo.Date - prviDan.Date).TotalDays + 1;
                            flagNadjen = true;
                        }
                        else if (ListaRez[j].DatumOd.Month <redniBrojMeseca && ListaRez[j].DatumDo.Month> redniBrojMeseca &&
                                 ListaRez[j].DatumOd.Year == godina && ListaRez[j].DatumDo.Year == godina)
                        {
                            DateTime prviDan   = new DateTime(godina, redniBrojMeseca, 1);
                            DateTime zadnjiDan = prviDan.AddMonths(1).AddDays(-1);
                            ukupanBrojDanaAutomobila += (int)(zadnjiDan.Date - prviDan.Date).TotalDays + 1;
                            flagNadjen = true;
                        }
                    }
                }
                if (flagNadjen == true)
                {
                    double racun    = 100.0 / ((double)ukupanBrojDanaUMesecu / (double)ukupanBrojDanaAutomobila);
                    double procenat = Math.Round(racun, 2);
                    ListaStat.Add(new Statistika(ListaAutomobila[i].Idbr, ukupanBrojDanaAutomobila, procenat,
                                                 ListaAutomobila[i].Marka, ListaAutomobila[i].Model));
                }
                flagNadjen = false;
                ukupanBrojDanaAutomobila = 0;
            }
            //Crtanje
            Rectangle r           = new Rectangle(20, 30, 170, 170);
            float     ukupniUgao  = 0;
            float     pocetniUgao = -90f;
            int       pomeraj     = 0;
            Random    rnd         = new Random();

            lbPrikazStatistike.Items.Clear();
            for (int i = 0; i < ListaStat.Count; i++)
            {
                int        red   = rnd.Next(0, 256);
                int        green = rnd.Next(0, 256);
                int        blue  = rnd.Next(0, 256);
                SolidBrush boja  = new SolidBrush(Color.FromArgb(red, green, blue));
                ukupniUgao = 360 / (float)ukupanBrojDanaUMesecu * (float)ListaStat[i].UkupanBrojRezMesec;
                e.Graphics.FillPie(boja, r, pocetniUgao, ukupniUgao);
                pocetniUgao += ukupniUgao;
                e.Graphics.FillRectangle(boja, new Rectangle(250, 5 + pomeraj, 10, 10));
                lbPrikazStatistike.Items.Add(ListaStat[i]);
                pomeraj += 15;
            }
            ListaRez.Clear();
            ListaStat.Clear();
            ListaAutomobila.Clear();
        }