Esempio n. 1
0
        public settings(whatsapp parentForm)
        {
            InitializeComponent();

            this.parentForm             = parentForm;
            pictureBox_photo.Image      = Account.Photo;
            label_username.Text         = Account.Username;
            richTextBox_about.Text      = Account.About;
            label_registrationDate.Text = "Enregistré le " + Account.RegistrationDate.ToShortDateString();
        }
Esempio n. 2
0
        private void settings_FormClosed(object sender, FormClosedEventArgs e)
        {
            whatsapp whattForm = new whatsapp();

            whattForm.Show();
        }
Esempio n. 3
0
        private void button_login_Click(object sender, EventArgs e)
        {
            try
            {
                maskedTextBox_number.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
                string phN = maskedTextBox_number.Text;
                maskedTextBox_number.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
                Regex phoneNum = new Regex(@"^(06)\d{8}$");
                if (!phoneNum.IsMatch(phN))
                {
                    throw new Exception("Le numéro de téléphone entreé est invalid");
                }
                if (textBox_password.Text.Length > 30)
                {
                    throw new Exception("Le mot de passe ne doit pas dépasser 30 caractères");
                }
                if (!Connection.getReader("SELECT AccountID FROM Accounts WHERE Tel = '" + phN + "' AND Password = '******';").HasRows)
                {
                    throw new Exception("Le numéro de téléphone ou le mot de passe est incorrect");
                }

                Connection.closeCon();
                System.Data.SqlClient.SqlDataReader dataR = Connection.getReader("SELECT * FROM Accounts WHERE Tel = '" + phN + "' AND Password = '******';");

                while (dataR.Read())
                {
                    Account.Accid    = int.Parse(dataR.GetValue(0).ToString());
                    Account.Username = dataR.GetString(1);
                    Account.Password = dataR.GetString(2);
                    Account.Tel      = dataR.GetString(3);
                    Account.About    = dataR.GetString(4);
                    System.IO.MemoryStream memStream = new System.IO.MemoryStream((byte[])dataR.GetValue(5));
                    Account.Photo            = Image.FromStream(memStream);
                    Account.SecurityQ        = dataR.GetString(6);
                    Account.SecurityA        = dataR.GetString(7);
                    Account.LastSeen         = (DateTime)dataR.GetValue(8);
                    Account.RegistrationDate = (DateTime)dataR.GetValue(9);
                }

                dataR.Close();
                Connection.closeCon();
                Connection.sendQuery("UPDATE Accounts SET LastSeen = '" + DateTime.Now.ToString() + "' WHERE AccountID = " + Account.Accid + ";");
                dataR = Connection.getReader("SELECT * FROM appSettings WHERE AccountID = " + Account.Accid + ";");
                while (dataR.Read())
                {
                    if (dataR.GetValue(1).GetType() != typeof(System.DBNull))
                    {
                        System.IO.MemoryStream memStream = new System.IO.MemoryStream((byte[])dataR.GetValue(1));
                        AppSettings.BackgroundImage = Image.FromStream(memStream);
                    }
                    else
                    {
                        AppSettings.BackgroundImage = null;
                    }
                    AppSettings.BackgroundColor        = Color.FromArgb(int.Parse(dataR.GetValue(2).ToString()), int.Parse(dataR.GetValue(3).ToString()), int.Parse(dataR.GetValue(4).ToString()));
                    AppSettings.AccountBackgroundColor = Color.FromArgb(int.Parse(dataR.GetValue(5).ToString()), int.Parse(dataR.GetValue(6).ToString()), int.Parse(dataR.GetValue(7).ToString()));
                    AppSettings.ContactBackgroundColor = Color.FromArgb(int.Parse(dataR.GetValue(8).ToString()), int.Parse(dataR.GetValue(9).ToString()), int.Parse(dataR.GetValue(10).ToString()));
                    AppSettings.AccountTextColor       = Color.FromArgb(int.Parse(dataR.GetValue(11).ToString()), int.Parse(dataR.GetValue(12).ToString()), int.Parse(dataR.GetValue(13).ToString()));
                    AppSettings.ContactTextColor       = Color.FromArgb(int.Parse(dataR.GetValue(14).ToString()), int.Parse(dataR.GetValue(15).ToString()), int.Parse(dataR.GetValue(16).ToString()));
                }
                Connection.closeCon();
                whatsapp wtsForm = new whatsapp();
                wtsForm.Show();
                MessageBox.Show("Bienvenue sur votre compte\nvous vous êtes connecté la dernière fois le “ " + Account.LastSeen + " ”", "Bienvenue", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Hide();
            }
            catch (Exception expt)
            {
                MessageBox.Show(expt.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Connection.closeCon();
            }
        }