private void btnDodajKupca_Click(object sender, EventArgs e) { foreach (Control c in tabKupac.Controls) { if (c is TextBox && c.Text == "") { MessageBox.Show("Popunite sva polja!"); return; } } Regex regJmbg = new Regex("^[0-9]{13}$"); Regex regBroj = new Regex("^[0-9]{3}-[0-9]{3,4}-[0-9]{3}$"); if (!regJmbg.IsMatch(txtJMBG.Text) || !regBroj.IsMatch(txtTelefon.Text)) { MessageBox.Show("Neispravan jmbg ili telefon!"); return; } foreach (Control c in tabKupac.Controls) { if (c is TextBox && String.IsNullOrEmpty((c as TextBox).Text)) { MessageBox.Show("Popunite sva polja!"); return; } } Kupac k = new Kupac(txtIme.Text, txtPrezime.Text, txtJMBG.Text, txtTelefon.Text, dtDatumRod.Value, txtKorisnickoIme.Text, txtLozinka.Text); if (admin.DodajKupca(k)) { MessageBox.Show("Uspesno dodat kupac!"); lstKupci.Items.Add(k.ToString()); foreach (Control c in tabKupac.Controls) { if (c is TextBox) { c.Text = ""; } else if (c is DateTimePicker) { (c as DateTimePicker).Value = DateTime.Now; } } txtIdKupca.Text = (Kupac.BrojKupaca + 1).ToString(); radioDodaj.Enabled = radioIzmeni.Enabled = true; } else { MessageBox.Show("Greska, vec postoji kupac sa datim korisnickim imenom!"); } }