private void BtnSaveAccountClicked(object sender, EventArgs e) { string name = textBoxName.Text; string address = textBoxAddress.Text; //Accès à la table eatfast_person dans la bdd DataSetEatFast personDataSet = new DataSetEatFast(); DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter personTableAdapter = new DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter(); if (name != "") { //Update name personTableAdapter.UpdateName(name, personRow.PER_ID); } if (address != "") { //Update address personTableAdapter.UpdateAddress(address, personRow.PER_ID); } textBoxName.Text = ""; textBoxAddress.Text = ""; MessageBox.Show("Your account information has been saved!", "Information"); }
private void BtnSaveClicked(object sender, EventArgs e) { //Accès à la table eatfast_person dans la bdd DataSetEatFast personDataSet = new DataSetEatFast(); DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter personTableAdapter = new DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter(); if (!textBoxPassword.Text.Equals(textBoxPasswordConfirm.Text)) { MessageBox.Show("Passwords do not match", "Information"); } else { if (textBoxPassword.Text.Length < 8) { MessageBox.Show("Your password needs to be at least 8 characters long", "Information"); } else { //Update password personTableAdapter.UpdatePassword(HashCode(textBoxPassword.Text), userId); this.Close(); MessageBox.Show("Your password has been updated!", "Information"); } } }
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); } } }
private void UpdateUserAddress() { //Accès à la table eatfast_person dans la bdd DataSetEatFast personDataSet = new DataSetEatFast(); DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter listePerson = new DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter(); try { //Mise à jour de l'adresse de livraison listePerson.UpdateAddress(textBoxAddress.Text, id); Homepage.getInstance().UpdateAddress(textBoxAddress.Text); this.Close(); } catch (Exception o) { MessageBox.Show("Something went wrong"); Console.Write(o); } }
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); } }
private void RegisterUser() { //Accès à la table eatfast_person dans la bdd DataSetEatFast personDataSet = new DataSetEatFast(); DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter listePerson = new DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter(); String name = textBoxSignupName.Text; String email = textBoxSignupEmail.Text; String password = HashCode(textBoxSignupPassword.Text); if (listePerson.FillByEmail(email) == null) { //Si le compte n'existe pas encore listePerson.AddAccount(name, email, password, "", "Client"); this.Hide(); Homepage homepage = Homepage.getInstance(); homepage.Show(); //Pour que le nouvel utilisateur indique son adresse de livraison homepage.InitializeNewUser(email); } else { //Sinon informer que l'utilisateur existe déjà MessageBox.Show("A user with this email already exists"); } }
private void BtnAddAccountClicked(object sender, EventArgs e) { if (textBoxPassword.Text.Equals(textBoxPasswordConfirm.Text)) { if (textBoxPassword.Text.Length < 8) { MessageBox.Show("Your password needs to be at least 8 characters long", "Information"); } else { //Accès à la table eatfast_person dans la bdd DataSetEatFast personDataSet = new DataSetEatFast(); DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter listePerson = new DataSetEatFastTableAdapters.EATFAST_PERSONTableAdapter(); //Information du nouveau compte String type = comboBoxType.GetItemText(comboBoxType.SelectedItem); String name = textBoxName.Text; String email = textBoxEmail.Text; String password = HashCode(textBoxPassword.Text); try{ if (listePerson.FillByEmail(email) == null) { //Si le compte n'existe pas encore //Insertion du nouveau compte if (type == "Client") { //Si le compte est de type client this.clientTableAdapter.AddAccount(name, email, password, "", type); this.clientTableAdapter.FillByAccountTypeClient(this.clientDataSetEatFast.EATFAST_PERSON); } else { //Si le compte est de type administrator this.adminTableAdapter.AddAccount(name, email, password, "", type); this.adminTableAdapter.FillByAccountTypeAdmin(this.adminDataSetEatFast.EATFAST_PERSON); } MessageBox.Show("New account added!", "Information"); } else { //Sinon informer que l'utilisateur existe déjà MessageBox.Show("A user with this email already exists"); } //Réinitialisation des champs comboBoxType.SelectedIndex = 0; textBoxName.Text = ""; textBoxEmail.Text = ""; textBoxPassword.Text = ""; textBoxPasswordConfirm.Text = ""; } catch (OverflowException o) { MessageBox.Show("Something went wrong, please try again"); Console.Write("Exception thrown : "); Console.Write("{0}", o.GetType(), o.Message); } } } else { MessageBox.Show("The passwords do not match", "Information"); } }