Example #1
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);
                }
            }
        }
Example #2
0
        public void InitializeNewUser(string email)
        {
            //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 du nouvel utilisateur
                int id = (int)listePerson.FillByEmail(email);
                DataSetEatFast.EATFAST_PERSONRow personRow = personDataSet.EATFAST_PERSON.FindByPER_ID(id);
                this.personRow = personRow;
                NewUser newUser = new NewUser(id);
                newUser.ShowDialog();
            }
            catch (Exception o)
            {
                MessageBox.Show("Something went wrong");
                Console.Write(o);
            }
        }