Beispiel #1
0
 private void btOcen_Click(object sender, EventArgs e)
 {
     try
     {
         string tytul = tbTytulOcen.Text;
         int    ocena = Int32.Parse(tbOcena.Text);
         if (ocena == 1 || ocena == 2 || ocena == 3 || ocena == 4 || ocena == 5)
         {
             currentUser.OcenFilm(tytul, ocena);
         }
         else
         {
             Form exWindow = new ExceptionWindow("Wystaw ocene z zakresu 1 do 5");
             exWindow.ShowDialog();
         }
         StringBuilder builder = new StringBuilder();
         List <Film>   lista   = biblioteka.Films.ToList();
         lista.Sort();
         lista.ForEach(f => builder.AppendLine(f.ToString()));
         tbLista.Text = builder.ToString();
         biblioteka.Serialize("filmy.bin");
     }
     catch (Exception ex) {
         Form exWindow = new ExceptionWindow(ex.Message);
         exWindow.ShowDialog();
     }
 }
Beispiel #2
0
        private void btZaloguj_Click(object sender, EventArgs e)
        {
            string username = tbUserName.Text;
            string password = tbPassword.Text;

            tbPassword.Text = "";
            tbUserName.Text = "";
            if (admin.UserName == username)
            {
                currentUser = admin;
                if (admin.checkPassword(password))
                {
                    this.Hide();
                    AdminConsole ac = new AdminConsole(this);
                    ac.Show();
                }
                else
                {
                    Form ex = new ExceptionWindow("Incorrect password");
                    ex.ShowDialog();
                }
            }
            else
            {
                try
                {
                    currentUser = baza.ListaUzytkownikow.First(u => u.UserName == username);
                    if (currentUser.checkPassword(password))
                    {
                        this.Hide();
                        UserConsole ac = new UserConsole(this, baza.ListaUzytkownikow.First(u => u.UserName == username) as NormalnyUzywtkownik);
                        ac.Show();
                    }
                    else
                    {
                        Form ex = new ExceptionWindow("Incorrect password");
                        ex.ShowDialog();
                    }
                }
                catch (Exception ex)
                {
                    Form exWindow = new ExceptionWindow("Such user doesn't exist");
                    exWindow.ShowDialog();
                }
            }
        }
Beispiel #3
0
 private void btUsunOcene_Click(object sender, EventArgs e)
 {
     try
     {
         string tytul = tbTytulUsun.Text;
         currentUser.UsunOcene(biblioteka.Films.First(f => f.Tytul == tytul));
         StringBuilder builder = new StringBuilder();
         List <Film>   lista   = biblioteka.Films.ToList();
         lista.Sort();
         lista.ForEach(f => builder.AppendLine(f.ToString()));
         tbLista.Text = builder.ToString();
         biblioteka.Serialize("filmy.bin");
     }
     catch (Exception ex)
     {
         Form exWindow = new ExceptionWindow(ex.Message);
         exWindow.ShowDialog();
     }
 }