public void azuriraj(string ime, string prezime, string jmbg, string datum_rodjenja, string telefon) { string pogresanUnos = ""; int flag = 0; if (ime.Trim() == "") { pogresanUnos += "Morate uneti ime!" + Environment.NewLine; flag = 1; } if (prezime.Trim() == "") { pogresanUnos += "Morate uneti prezime!" + Environment.NewLine; flag = 1; } if (!jmbg.All(char.IsDigit) || jmbg.Trim() == "") { pogresanUnos += "Morate uneti ispravan JMBG!" + Environment.NewLine; flag = 1; } if (!telefon.All(char.IsDigit) || telefon.Trim() == "") { pogresanUnos += "Morate uneti ispravan telefon!" + Environment.NewLine; flag = 1; } List <Kupac> kupci = new List <Kupac>(); kupci = Globalne.procitajKupce(Globalne.DatKupac); foreach (Kupac k in kupci) { if (k.Telefon == telefon && this.telefon != telefon) { pogresanUnos += "Uneti telefon vec postoji!" + Environment.NewLine; flag = 1; } } if (!DateTime.TryParse(datum_rodjenja, out DateTime datum)) { pogresanUnos += "Netacan unos datuma!" + Environment.NewLine; flag = 1; } if (password.Trim() == "") { pogresanUnos += "Morate uneti lozinku!" + Environment.NewLine; flag = 1; } if (flag == 1) { MessageBox.Show(pogresanUnos, "Pogresan unos podataka!"); } else { Ime = ime; Prezime = prezime; Jmbg = jmbg; Datum_rodjenja = datum; Telefon = telefon; } }
private void brnLoginKupac_Click(object sender, EventArgs e) { if (!File.Exists(Globalne.DatKupac)) { MessageBox.Show("Ne postoji fajl sa kupcima!"); } else { List <Kupac> kupci = new List <Kupac>(); kupci = Globalne.procitajKupce(Globalne.DatKupac); int flag = 0; foreach (Kupac k in kupci) { if (k.Telefon == txtLoginTelefon.Text && k.Password == txtLoginPassword.Text) { Globalne.TrenutniKupac = k; flag = 1; FormKupac frm = new FormKupac(); frm.MdiParent = this.ParentForm; frm.Show(); frm.Dock = DockStyle.Fill; Close(); } } if (flag == 0 && File.Exists(Globalne.DatAdmin)) { txtLoginTelefon.Text = ""; txtLoginPassword.Text = ""; txtLoginTelefon.Focus(); MessageBox.Show("Telefon i lozinka se ne poklapaju", "Login greska!"); } } }
private void btnAzuriraj_Click(object sender, EventArgs e) { foreach (Rezervacija r in rezervacije) { if (r.Equals((Rezervacija)listBox1.SelectedItem)) { if (!txtCena.Text.All(char.IsDigit)) { MessageBox.Show("Cena mora biti broj!", "Greska"); } else if (dateOd.Value < DateTime.Today) { MessageBox.Show("Datum mora biti veci ili jednak od danasnjeg datuma", "Greska"); } else if (dateDo.Value < dateOd.Value) { MessageBox.Show("Datm do mora biti veci ili jednak datumu od!", "Greska"); } else { r.Cena = int.Parse(txtCena.Text); r.DatumOd = dateOd.Value; r.DatumDo = dateDo.Value; Globalne.upisiRezervacije(rezervacije, Globalne.DatRezervacije); listBox1.Items[listBox1.SelectedIndex] = r; MessageBox.Show("Uspesno azuriranje rezervacije!"); } } } }
private void btnPonude_Click(object sender, EventArgs e) { if (cbMarka.Text == "" || cbModel.Text == "" || cbGodiste.Text == "" || cbKubikaza.Text == "" || cbKaroserija.Text == "" || cbBrojVrata.Text == "" || cbGorivo.Text == "" || cbPogon.Text == "" || cbMenjac.Text == "") MessageBox.Show("Nisu izabrani svi podaci za automobil"); else { foreach(Automobil a in automobili) { if (cbMarka.Text == a.Marka && cbModel.Text == a.Model && int.Parse(cbGodiste.Text) == a.Godiste && int.Parse(cbKubikaza.Text) == a.Kubikaza && cbKaroserija.Text == a.Karoserija && int.Parse(cbBrojVrata.Text) == a.BrojVrata && cbGorivo.Text == a.Gorivo && cbPogon.Text == a.Pogon && cbMenjac.Text == a.Menjac) auto = a; } listBox1.Items.Clear(); List<Ponuda> ponude; ponude = Globalne.procitajPonude(Globalne.DatPonude); foreach(Ponuda p in ponude) { if (p.IdAuto == auto.Id) { listBox1.Items.Add(p); //potrebna provera u slucaju da kupac samo klikne rezervisi za trenutni dan if (dateOd.Value >= p.DatumOd && dateOd.Value <= p.DatumDo && dateDo.Value >= dateOd.Value && dateDo.Value <= p.DatumDo) { txtCena.Text = ((dateDo.Value - dateOd.Value).TotalDays * p.Cena + p.Cena).ToString(); uspesno = true; listBox1.SelectedItem = p; } } } } }
private void FormStatistika_Load(object sender, EventArgs e) { lblPrijavljen.Text += Globalne.TrenutniAdmin.Ime + " " + Globalne.TrenutniAdmin.Prezime; dateMesec.Format = DateTimePickerFormat.Custom; dateMesec.CustomFormat = "MMMM yyyy"; dateMesec.ShowUpDown = true; rezervacije = Globalne.procitajRezervacije(Globalne.DatRezervacije); ponude = Globalne.procitajPonude(Globalne.DatPonude); }
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"); } } }
private void FormAzuriraj_Load(object sender, EventArgs e) { lblPrijavljen.Text += Globalne.TrenutniAdmin.Ime + " " + Globalne.TrenutniAdmin.Prezime; if (Globalne.AzurirajKupca) { panelAuto.Visible = false; panelAuto1.Visible = false; lblIzbor.Text += " kupca:"; kupci = Globalne.procitajKupce(Globalne.DatKupac); rezervacije = Globalne.procitajRezervacije(Globalne.DatRezervacije); foreach (Kupac k in kupci) { listBox1.Items.Add(k); } } else if (Globalne.AzurirajAuto) { lbl1.Text = "Marka:"; lbl2.Text = "Model:"; lbl3.Text = "Godiste:"; lbl4.Text = "Kubikaza:"; lbl5.Text = "Pogon:"; lblIzbor.Text += " automobil:"; automobili = Globalne.procitajAutomobile(Globalne.DatAutomobili); ponude = Globalne.procitajPonude(Globalne.DatPonude); rezervacije = Globalne.procitajRezervacije(Globalne.DatRezervacije); foreach (Automobil a in automobili) { listBox1.Items.Add(a); } dateOd.Value = DateTime.Today; dateOd.MinDate = DateTime.Today; dateDo.Value = DateTime.Today; dateDo.MinDate = DateTime.Today; } else if (Globalne.AzurirajPonudu) { comboBox1.Visible = true; lblIzbor.Text += " automobil:"; automobili = Globalne.procitajAutomobile(Globalne.DatAutomobili); foreach (Automobil a in automobili) { comboBox1.Items.Add(a); } ponude = Globalne.procitajPonude(Globalne.DatPonude); panelAuto.Visible = false; panelAuto1.Visible = false; lbl1.Text = "Cena po danu:"; panelPonuda.Visible = false; } }
private void btnUkini_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex == -1) { MessageBox.Show("Nista nije selektovano za brisanje!", "Greska"); } else { rezervacije.Remove((Rezervacija)listBox1.SelectedItem); Globalne.upisiRezervacije(rezervacije, Globalne.DatRezervacije); listBox1.Items.Remove(listBox1.SelectedItem); } }
private void FormAzurirajRezervacije_Load(object sender, EventArgs e) { rezervacije = Globalne.procitajRezervacije(Globalne.DatRezervacije); lblPrijavljen.Text += Globalne.TrenutniAdmin.Ime + " " + Globalne.TrenutniAdmin.Prezime; List <Kupac> kupci = Globalne.procitajKupce(Globalne.DatKupac); foreach (Kupac k in kupci) { cbKupac.Items.Add(k); } dateOd.Value = DateTime.Today; dateDo.Value = DateTime.Today; }
private void FormRezervisi_Load(object sender, EventArgs e) { dateOd.Value = DateTime.Today; dateOd.MinDate = DateTime.Today; dateDo.Value = DateTime.Today; dateDo.MinDate = DateTime.Today; lblPrijavljen.Text += Globalne.TrenutniKupac.Ime + " " + Globalne.TrenutniKupac.Prezime; svePonude = Globalne.procitajPonude(Globalne.DatPonude); automobili = Globalne.procitajAutomobile(Globalne.DatAutomobili); foreach(Automobil a in automobili) //pri pokretanju forme se popunjava combobox za marku if(!cbMarka.Items.Contains(a.Marka)) cbMarka.Items.Add(a.Marka); }
private void FormKupac_Load(object sender, EventArgs e) { lblPrijavljen.Text += Globalne.TrenutniKupac.Ime + " " + Globalne.TrenutniKupac.Prezime; if (File.Exists(Globalne.DatRezervacije)) { rezervacije = Globalne.procitajRezervacije(Globalne.DatRezervacije); foreach (Rezervacija r in rezervacije) { if (r.IdKupac == Globalne.TrenutniKupac.Id) { listBox1.Items.Add(r); } } } }
private void btnObrisi_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { rezervacije.Remove((Rezervacija)listBox1.SelectedItem); Globalne.upisiRezervacije(rezervacije, Globalne.DatRezervacije); dateOd.Value = DateTime.Today; dateDo.Value = DateTime.Today; txtCena.Text = ""; listBox1.Items.Remove(listBox1.SelectedItem); MessageBox.Show("Uspesno obrisana rezervacija"); } else { MessageBox.Show("Rezervacija nije selektovana!", "Greska"); } }
private void btnLoginAdmin_Click(object sender, EventArgs e) { int flag = 0; if (Globalne.GlavniAdmin.Telefon == txtLoginTelefon.Text && Globalne.GlavniAdmin.Password == txtLoginPassword.Text) { Globalne.TrenutniAdmin = Globalne.GlavniAdmin; flag = 1; FormAdmin frm = new FormAdmin(); frm.MdiParent = this.ParentForm; frm.Show(); frm.Dock = DockStyle.Fill; Close(); } if (flag == 0) { List <Administrator> listaAdmina = new List <Administrator>(); listaAdmina = Globalne.procitajAdmine(Globalne.DatAdmin); if (!File.Exists(Globalne.DatAdmin)) { MessageBox.Show("Ne postoji fajl sa adminima!"); } foreach (Administrator a in listaAdmina) { if (a.Telefon == txtLoginTelefon.Text && a.Password == txtLoginPassword.Text) { Globalne.TrenutniAdmin = a; flag = 1; FormAdmin frm = new FormAdmin(); frm.MdiParent = this.ParentForm; frm.Show(); frm.Dock = DockStyle.Fill; Close(); } } } if (flag == 0 && File.Exists(Globalne.DatAdmin)) { txtLoginTelefon.Text = ""; txtLoginPassword.Text = ""; txtLoginTelefon.Focus(); MessageBox.Show("Telefon i lozinka se ne poklapaju", "Login greska!"); } }
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"); }
private void FormDodajRezervaciju_Load(object sender, EventArgs e) { lblPrijavljen.Text += Globalne.TrenutniAdmin.Ime + " " + Globalne.TrenutniAdmin.Prezime; dateOd.Value = DateTime.Today; dateOd.MinDate = DateTime.Today; dateDo.Value = DateTime.Today; dateDo.MinDate = DateTime.Today; kupci = Globalne.procitajKupce(Globalne.DatKupac); foreach (Kupac k in kupci) { cbKupac.Items.Add(k); } automobili = Globalne.procitajAutomobile(Globalne.DatAutomobili); foreach (Automobil a in automobili) { cbAuto.Items.Add(a); } }
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); } } }
private void btnKreiraj_Click(object sender, EventArgs e) { string pogresanUnos = ""; int flag = 0; if (txtIme.Text.Trim() == "") { pogresanUnos += "Morate uneti ime!" + Environment.NewLine; flag = 1; } if (txtPrezime.Text.Trim() == "") { pogresanUnos += "Morate uneti prezime!" + Environment.NewLine; flag = 1; } if (!txtJmbg.Text.All(char.IsDigit) || txtJmbg.Text.Trim() == "") { pogresanUnos += "Morate uneti ispravan JMBG!" + Environment.NewLine; flag = 1; } if (!txtTelefon.Text.All(char.IsDigit) || txtTelefon.Text.Trim() == "") { pogresanUnos += "Morate uneti ispravan telefon!" + Environment.NewLine; flag = 1; } if (Globalne.PraviAdmina) { List <Administrator> administrators = new List <Administrator>(); administrators = Globalne.procitajAdmine(Globalne.DatAdmin); foreach (Administrator a in administrators) { if (a.Telefon == txtTelefon.Text) { pogresanUnos += "Uneti telefon vec postoji!" + Environment.NewLine; flag = 1; } } } else { List <Kupac> kupci = new List <Kupac>(); kupci = Globalne.procitajKupce(Globalne.DatKupac); foreach (Kupac k in kupci) { if (k.Telefon == txtTelefon.Text) { pogresanUnos += "Uneti telefon vec postoji!" + Environment.NewLine; flag = 1; } } } if (txtLozinka.Text.Trim() == "") { pogresanUnos += "Morate uneti lozinku!" + Environment.NewLine; flag = 1; } if (flag == 1) { MessageBox.Show(pogresanUnos, "Pogresan unos podataka!"); } else { if (Globalne.PraviAdmina) { Administrator noviAdmin = new Administrator(txtIme.Text, txtPrezime.Text, txtJmbg.Text, dateDatumRodjenja.Value, txtTelefon.Text, txtLozinka.Text); noviAdmin.upisiAdmina(Globalne.DatAdmin); MessageBox.Show(txtIme.Text + " " + txtPrezime.Text + " je uspesno dodat kao administrator!", "Uspesno dodat novi administrator"); Globalne.PraviAdmina = false; FormAdmin frm = new FormAdmin(); frm.MdiParent = this.ParentForm; frm.Show(); frm.Dock = DockStyle.Fill; Close(); } else { Kupac noviKupac = new Kupac(txtIme.Text, txtPrezime.Text, txtJmbg.Text, dateDatumRodjenja.Value, txtTelefon.Text, txtLozinka.Text); noviKupac.upisiKupca(Globalne.DatKupac); MessageBox.Show("Nalog kupca " + txtIme.Text + " " + txtPrezime.Text + " je uspesno kreiran!", "Uspesno kreiran nalog"); if (Globalne.AdminPraviKupca) { Globalne.AdminPraviKupca = false; FormAdmin frm = new FormAdmin(); frm.MdiParent = this.ParentForm; frm.Show(); frm.Dock = DockStyle.Fill; Close(); } else { FormIzbor frm = new FormIzbor(); frm.MdiParent = this.ParentForm; frm.Show(); frm.Dock = DockStyle.Fill; Close(); } } } }
public static Globalne CreateGlobalne(int id_uzytkownika) { Globalne globalne = new Globalne(); globalne.Id_uzytkownika = id_uzytkownika; return globalne; }
public void AddToGlobalne(Globalne globalne) { base.AddObject("Globalne", globalne); }