示例#1
0
 public MyAccountForm(client loggedClient)
 {
     thisClient = loggedClient;
     connString = "Server=localhost;Port=3306;Database=sncf;uid=root;password=root";
     conn = new MySqlConnection(connString);
     command = conn.CreateCommand();
     if (thisClient.age != null) { modificateurPrix = 1f - Math.Abs((float)thisClient.age / 100 - 0.5f); }
     else { modificateurPrix = 1f; }
     InitializeComponent();
 }
示例#2
0
        private void createNewAccountButton_Click(object sender, EventArgs e)
        {
            client thisClient = new client();
            thisClient.login = this.loginTextBox.Text.ToString();
            thisClient.password = this.passwordTextBox.Text.ToString();
            thisClient.nom = this.nameTextBox.Text.ToString();
            int ageValue;
            if (int.TryParse(this.ageTextBox.Text.ToString(), out ageValue) && ageValue > 0 && ageValue < 150)
            {
                thisClient.age = ageValue;
                thisClient.reduction = Math.Abs(ageValue / 100 - 0.5f);

                client logged = loginFunction(thisClient.login, thisClient.password);

                if (logged == null)
                {
                    try
                    {
                        conn.Open();
                        command.CommandText = "Insert into client (login, password, nom, age, reduction) values('" + thisClient.login + "','" + thisClient.password + "','" + thisClient.nom + "','" + thisClient.age + "','" + thisClient.reduction.ToString().Replace(",", ".") + "')";
                        command.ExecuteNonQuery();
                        command.CommandText = "Select * from client where (login='******')";
                        MySqlDataReader reader = command.ExecuteReader();
                        if (reader.Read())
                        {
                            thisClient.idclient = reader.GetInt32("idclient");
                        }
                    }
                    catch(Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        conn.Close();
                        redirection(thisClient);
                    }       
                }
                else
                {
                    MessageBox.Show("Ce nom d'utilisateur existe déjà, veuillez en choisir un autre.");
                }
            }
            else
            {
                MessageBox.Show("Veuillez entrer votre âge réel.");
            }    
        }
示例#3
0
 private client loginFunction(string login, string password)
 {
     client thisClient = new client();
     command.CommandText = "Select * from client where (login='******') AND (password='******')";
     try
     {
         conn.Open();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     MySqlDataReader reader = command.ExecuteReader(); 
     if (!reader.Read())
     {
         conn.Close();
         return null;
     }
     else
     {
         thisClient.idclient = reader.GetInt32("idclient");
         thisClient.nom = reader.GetString("nom");
         thisClient.age = reader.GetInt32("age");
         thisClient.reduction = reader.GetFloat("reduction");
         thisClient.login = reader.GetString("login");
         thisClient.password = reader.GetString("password");                
         conn.Close();
         return thisClient;
     }
     
 }
示例#4
0
 private void redirection(client thisClient)
 {
     MyAccountForm myAccountForm = new MyAccountForm(thisClient);
     myAccountForm.Show();
 }
示例#5
0
        private void redirection(client thisClient)
        {
            MyAccountForm myAccountForm = new MyAccountForm(thisClient);

            myAccountForm.Show();
        }