Exemplo n.º 1
0
 public static AdminHomepage getInstance()
 {
     if (instance == null || instance.IsDisposed)
     {
         instance = new AdminHomepage();
     }
     return(instance);
 }
Exemplo n.º 2
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            if (textBoxLoginEmail.Text == "" || textBoxLoginPassword.Text == "")
            {
                MessageBox.Show("The username or password is incorrect", "Information");
            }
            else
            {
                //Accès à la table eatfast_person dans la bdd
                DataSetEatFast personDataSet = new DataSetEatFast();
                DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter listePerson = new DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter();
                listePerson.Fill(personDataSet.EATFAST_PERSON);

                try
                {
                    //Récupération de l'utilisateur
                    int id = (int)listePerson.FillByEmail(textBoxLoginEmail.Text);
                    DataSetEatFast.EATFAST_PERSONRow personRow = personDataSet.EATFAST_PERSON.FindByPER_ID(id);

                    if (personRow.PER_PASSWORD.Equals(HashCode(textBoxLoginPassword.Text)))
                    {
                        if (personRow.PER_ACCOUNTTYPE == "Client")
                        { //Si compte client
                            this.Hide();
                            Homepage homePage = Homepage.getInstance();
                            homePage.Show();
                            homePage.initializeUser(personRow);
                        }
                        else
                        { //Si compte administrateur
                            this.Hide();
                            AdminHomepage adminHomepage = AdminHomepage.getInstance();
                            adminHomepage.Show();
                            adminHomepage.initializeUser(personRow);
                        }
                    }
                    else
                    {
                        MessageBox.Show("The username or password is incorrect", "Information");
                    }
                }
                catch (Exception o)
                {
                    MessageBox.Show("The username or password is incorrect", "Information");
                    Console.Write(o);
                }
            }
        }