Example #1
0
        private void btnNazad_Click(object sender, EventArgs e)
        {
            FormAdmin frm = new FormAdmin();

            frm.MdiParent = this.ParentForm;
            frm.Show();
            frm.Dock = DockStyle.Fill;
            Close();
        }
Example #2
0
        private void btnNazad_Click(object sender, EventArgs e)
        {
            Globalne.AzurirajAuto   = false;
            Globalne.AzurirajKupca  = false;
            Globalne.AzurirajPonudu = false;
            FormAdmin frm = new FormAdmin();

            frm.MdiParent = this.ParentForm;
            frm.Show();
            frm.Dock = DockStyle.Fill;
            Close();
        }
Example #3
0
        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 btnNazad_Click(object sender, EventArgs e)
 {
     if (Globalne.PraviAdmina || Globalne.AdminPraviKupca)
     {
         Globalne.PraviAdmina     = false;
         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();
     }
 }
        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();
                    }
                }
            }
        }
Example #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();
            }
        }