Example #1
0
 private void BindGrid()
 {
     korisniciGrid.DataSource = DAKorisnici.SelectByName(imePrezimeInput.Text.Trim());
     korisniciGrid.Columns[0].Visible = false;
     korisniciGrid.ClearSelection();
     korisnik = null;
 }
 public PitanjaOdgovori(eProdaja_Service.Data.Korisnici k)
 {
     InitializeComponent();
     if (k != null)
     {
         korisnik = k;
     }
     BindGridPitanja();
 }
        private void dodajButton_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                eProdaja_Service.Data.Korisnici korisnik = new eProdaja_Service.Data.Korisnici();

                if (korisnikIzmjene != null)
                    korisnik.KorisnikID = korisnikIzmjene.KorisnikID;

                korisnik.Ime = imeInput.Text.Trim();
                korisnik.Prezime = prezimeInput.Text.Trim();
                korisnik.Email = emailInput.Text.Trim();
                korisnik.Telefon = telefonInput.Text.Trim();

                if (korisnik.KorisnikID > 0)
                {
                    DAKorisnici.Update(korisnik);
                    MessageBox.Show(Global.GetString("update_succ"), "Izmjene korisničkih podataka",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                    return;
                }

                korisnik.KorisnickoIme = korisnickoImeInput.Text;
                korisnik.LozinkaSalt = UIHelper.GenerateSalt();
                korisnik.LozinkaHash = UIHelper.GenerateHash(lozinkaInput.Text, korisnik.LozinkaSalt);

                korisnik.Uloge = ulogeList.CheckedItems.Cast<Uloge>().ToList();

                try
                {
                    DAKorisnici.Insert(korisnik);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Global.GetString(ex.Message), "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //Omogućiti dodavanje novog korisnika prije zatvaranja forme
                if (MessageBox.Show(Global.GetString("user_succ") + "\n" + Global.GetString("user_add_q"), "Korisnik",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    clear();
                else
                    this.Close();
            }
        }
Example #4
0
 private void korisniciGrid_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     korisnik = DAKorisnici.SelectById(Convert.ToInt32(korisniciGrid.SelectedRows[0].Cells[0].Value));
 }