Advertisement
Guest User

Untitled

a guest
Apr 14th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. using Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace Forme
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         int brojPokusaja = 3;
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.             txtPW.PasswordChar = '*';
  22.         }
  23.  
  24.         private void Form1_Load(object sender, EventArgs e)
  25.         {
  26.  
  27.         }
  28.  
  29.         private void btnUlogujSe_Click(object sender, EventArgs e)
  30.         {
  31.             string korIme = txtUsername.Text;
  32.             string korPw = txtPW.Text;
  33.  
  34.             if (string.IsNullOrEmpty(korIme) || string.IsNullOrEmpty(korPw))
  35.             {
  36.                 MessageBox.Show("Sine moras da popunis sva polja, de si poso'");
  37.                 return;
  38.             }
  39.  
  40.             Korisnik korisnik = null;
  41.  
  42.             foreach (Korisnik k in Repozitorijum.VratiInstancu().Korisnici)
  43.             {
  44.                 if (k.Username == korIme && k.Password == korPw)
  45.                 {
  46.                     korisnik = k;
  47.                     break;
  48.                 }
  49.  
  50.                 else
  51.                 {
  52.                    
  53.                 }
  54.             }
  55.  
  56.             if (korisnik != null)
  57.             {
  58.                
  59.                 Forma f = new Forma(korisnik);
  60.                 this.Hide();
  61.                 f.ShowDialog();
  62.             }
  63.             else
  64.             {
  65.                 brojPokusaja--;
  66.                 MessageBox.Show("Ostalo je vam je jos " + brojPokusaja);
  67.                 txtUsername.Clear();
  68.                 txtPW.Clear();
  69.  
  70.                 if(brojPokusaja <= 0)
  71.                 {
  72.                     txtPW.Enabled = false;
  73.                     txtUsername.Enabled = false;
  74.                     btnUlogujSe.Enabled = false;
  75.                 }
  76.             }
  77.  
  78.  
  79.  
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement