private void btnconf_Click(object sender, EventArgs e)
        {
            //check for nom textbox if empty or not
            if (NomTxt.Text == "" || NomTxt.Text == "Votre nom")
            {
                wrongnom.Visible = true;
            }
            else
            {
                wrongnom.Visible = false;
            }

            //check for user textbox if empty or not

            if (usertxt.Text == "" || usertxt.Text == "Nom utilisateur")
            {
                wronguser.Visible = true;
            }
            else
            {
                wronguser.Visible = false;
            }

            //check for password textbox if empty or not

            if (PassTxt.Text == "" || PassTxt.Text == "Votre mot clé")
            {
                motclereg.Visible = true;
            }
            else
            {
                motclereg.Visible = false;
            }

            //check for password second time textbox if empty or not

            if (Confpass.Text == "" || Confpass.Text == "Confirmer Votre mot")
            {
                conf.Visible = true;
            }
            else
            {
                conf.Visible = false;
            }

            // check for type de l'utilisateur
            if ((radioBtnEleve.Checked == false) && (radioBtnProf.Checked == false))
            {
                typeq.Visible = true;
            }
            else
            {
                typeq.Visible = false;

                if (radioBtnEleve.Checked == true)
                {
                    Variables.Type = false;
                }
                else
                {
                    Variables.Type = true;
                }
            }

            //check for genre

            if ((male.Checked == false) && (femelle.Checked == false))
            {
                genreq.Visible = true;
            }
            else
            {
                genreq.Visible = false;
            }

            // il faut l'eleve de 5 ans et plus
            if (((2021 - Datepicker.Value.Year) < 5) && radioBtnEleve.Checked == true)
            {
                dateq.Visible = true;
            }

            else
            {
                if ((radioBtnEleve.Checked == false) || (radioBtnProf.Checked == false) || (male.Checked == false) || (femelle.Checked == false))
                {
                    dateq.Visible = false;

                    if ((usertxt.Text.Length > 0) && (PassTxt.Text.Length > 0) && (usertxt.Text != "Nom utilisateur") && (PassTxt.Text != "Votre mot clé"))
                    {
                        DataRow[] dr   = dt.Select("(([user] = '" + usertxt.Text + "') AND ([pass] = '" + PassTxt.Text + "'))");
                        DataRow[] deja = dt.Select("(([user] = '" + CryptageEtHachage.HashPasswordsAndScores(usertxt.Text) + "') AND ([nom] = '" + CryptageEtHachage.HashPasswordsAndScores(NomTxt.Text) + "'))");

                        if (deja.Length == 1)
                        {
                            utilisateurDeja.Visible = true;
                        }
                        else
                        {
                            utilisateurDeja.Visible = false;
                            dateq.Visible           = false;

                            DataRow dr2 = dt.NewRow();
                            dr2[0] = usertxt.Text;
                            dr2[1] = PassTxt.Text;
                            dr2[2] = NomTxt.Text;
                            dr2[3] = 2021 - Datepicker.Value.Year;

                            if (Variables.Type == false)
                            {
                                dr2[5] = "Eleve";
                            }
                            else
                            {
                                dr2[5] = "Prof";
                            }
                            if (male.Checked == true)
                            {
                                dr2[4] = "mâle";
                            }
                            else
                            {
                                dr2[4] = "femelle";
                            }

                            // set les scores = 0
                            for (int i = 6; i < 39; i++)
                            {
                                dr2[i] = 0;
                            }
                            dr2[23] = "1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1";
                            dr2[38] = 60; //metre la meilleur score 60 s dans la jeux de suites de nbss

                            dt.Rows.Add(dr2);
                            ds.WriteXml(Application.StartupPath + "\\users.xml");
                            CryptageEtHachage.HashXmlUsers(usertxt.Text, PassTxt.Text, Application.StartupPath + "\\users.xml");
                            this.ShowInTaskbar = false;


                            Variables.intro = new Introduction();


                            intro_video intro_Video = new intro_video();
                            intro_Video.Show();



                            if ((dr2[4].ToString() == "mâle") && (Variables.Type = false))
                            {
                                Variables.B = new Bitmap(Application.StartupPath + "\\Pics\\boy.png");
                                Variables.intro.userphoto.Image = Variables.B;
                            }
                            else if ((dr2[4].ToString() == "femelle") && (Variables.Type = false))
                            {
                                Variables.B = new Bitmap(Application.StartupPath + "\\Pics\\girl.png");
                                Variables.intro.userphoto.Image = Variables.B;
                            }
                            else if ((dr2[4].ToString() == "mâle") && (Variables.Type = true))
                            {
                                Variables.B = new Bitmap(Application.StartupPath + "\\Pics\\administrator_male.png");
                                Variables.intro.userphoto.Image = Variables.B;
                            }
                            else if ((dr2[4].ToString() == "femelle") && (Variables.Type = true))
                            {
                                Variables.B = new Bitmap(Application.StartupPath + "\\Pics\\woman_profile.png");
                                Variables.intro.userphoto.Image = Variables.B;
                            }

                            Variables.exSup = dr2[23].ToString().Split(',');
                            Variables.intro.userphoto.Image = Variables.B;
                            Variables.UserNom             = usertxt.Text;
                            Variables.UserPass            = PassTxt.Text;
                            Variables.intro.username.Text = Variables.UserNom;
                            this.Hide();
                        }
                    }
                    else if ((usertxt.Text.Length > 0) && (((PassTxt.Text.Length == 0) || (PassTxt.Text == "Votre mot clé")) || ((Confpass.Text.Length == 0) || (Confpass.Text == "Confirmer Votre mot"))))
                    {
                        motclereg.Visible = true;
                        conf.Visible      = true;
                        if ((PassTxt.Text != Confpass.Text))
                        {
                            wrongpass.Visible = true;
                            conf.Visible      = false;
                        }
                        else
                        {
                            wrongpass.Visible = false;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //zmouseClickButton.Play();

            if ((UserTxt.Text.Length > 0) && UserTxt.Text != "Votre nom d'utilisateur")
            {
                if (PassTxt.Text.Length > 0)
                {
                    dr = dt.Select("(([user] = '" + CryptageEtHachage.HashPasswordsAndScores(UserTxt.Text) + "') AND ([pass] = '" + CryptageEtHachage.HashPasswordsAndScores(PassTxt.Text) + "'))");
                }
                if (panel1.Visible == true)
                {
                    dr = dt.Select("(([user] = '" + CryptageEtHachage.HashPasswordsAndScores(UserTxt.Text) + "'))");
                    if (dr.Length == 1)
                    {
                        if (nomText.Text != dr[0]["nom"].ToString())
                        {
                            InfoFlse.Visible = true; return;
                        }
                        else
                        {
                            panel1.Visible = false;
                            PassTxt.Text   = dr[0]["pass"].ToString();
                        }
                    }
                    else
                    {
                        InfoFlse.Visible = true; return;
                    }
                }
                if (PassTxt.Text.Length < 0)
                {
                    motcle.Visible = true; return;
                }

                if (dr.Length == 1)
                {
                    Variables.intro   = new Introduction();
                    Variables.matiere = new MatiereStart();
                    intro_video intro_ = new intro_video();
                    intro_.Show();

                    if ((CryptageEtHachage.Combine(dr[0]["genre"].ToString()) == "mâle") && (CryptageEtHachage.Combine(dr[0]["Type"].ToString()) == "Eleve"))
                    {
                        Variables.B = new Bitmap(Application.StartupPath + "\\Pics\\boy.png");
                        Variables.intro.userphoto.Image = Variables.B;
                    }
                    else if ((CryptageEtHachage.Combine(dr[0]["genre"].ToString()) == "femelle") && (CryptageEtHachage.Combine(dr[0]["Type"].ToString()) == "Eleve"))
                    {
                        Variables.B = new Bitmap(Application.StartupPath + "\\Pics\\girl.png");
                        Variables.intro.userphoto.Image = Variables.B;
                    }
                    else if ((CryptageEtHachage.Combine(dr[0]["genre"].ToString()) == "mâle") && (CryptageEtHachage.Combine(dr[0]["Type"].ToString()) == "Prof"))
                    {
                        Variables.B = new Bitmap(Application.StartupPath + "\\Pics\\administrator_male.png");
                        Variables.intro.userphoto.Image = Variables.B;
                    }
                    else if ((CryptageEtHachage.Combine(dr[0]["genre"].ToString()) == "femelle") && (CryptageEtHachage.Combine(dr[0]["Type"].ToString()) == "Prof"))
                    {
                        Variables.B = new Bitmap(Application.StartupPath + "\\Pics\\woman_profile.png");
                        Variables.intro.userphoto.Image = Variables.B;
                    }



                    this.ShowInTaskbar = false;

                    Variables.exSup = dr[0]["exSupp"].ToString().Split(',');

                    Variables.UserNom             = UserTxt.Text;
                    Variables.UserPass            = PassTxt.Text;
                    Variables.intro.username.Text = Variables.UserNom;
                    this.Hide();
                }
                else
                {
                    wrongData.Visible = true;
                }
            }

            if (PassTxt.Text == "")
            {
                motcle.Visible = true;
            }
        }