示例#1
0
        private void exit_btn_Click(object sender, RoutedEventArgs e)
        {
            user_desktop w = new user_desktop();

            w.Show();
            this.Close();
        }
示例#2
0
        private void exit_btn_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection sqlConnection = new SqlConnection(connection_string);

            sqlConnection.Open();
            SqlCommand sqlCommand = new SqlCommand("update Users set FullName=@FullName,E_mail=@E_mail,_Password=@_Password,PhoneNumber=@PhoneNumber where FullName=@F and E_mail=@E and _Password=@_P", sqlConnection);

            sqlCommand.Parameters.AddWithValue("@FullName", FullName_txt.Text);
            sqlCommand.Parameters.AddWithValue("@E_mail", E_mail_txt.Text);
            sqlCommand.Parameters.AddWithValue("@_Password", Password_txt.Text);
            sqlCommand.Parameters.AddWithValue("@PhoneNumber", PhoneNumber_txt.Text);
            sqlCommand.Parameters.AddWithValue("@F", Current_user.FullName);
            sqlCommand.Parameters.AddWithValue("@E", Current_user.E_mail);
            sqlCommand.Parameters.AddWithValue("@_P", Current_user.Password);
            sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
            sqlCommand.Dispose();
            user_desktop w = new user_desktop();

            w.Show();
            this.Close();
        }
        private void sign_in_Click(object sender, RoutedEventArgs e)
        {
            string password = null;

            for (int i = 0; i < Current_user.admin_login_counter % 10; i++)
            {
                password += "1";
            }
            for (int i = 0; i < sign_in_email.Text.Length; i++)
            {
                if (sign_in_email.Text[i] == 'a' || sign_in_email.Text[i] == 'e' || sign_in_email.Text[i] == 'i' || sign_in_email.Text[i] == 'o' || sign_in_email.Text[i] == 'u' || sign_in_email.Text[i] == 'A' || sign_in_email.Text[i] == 'E' || sign_in_email.Text[i] == 'I' || sign_in_email.Text[i] == 'O' || sign_in_email.Text[i] == 'U')
                {
                    password += "0";
                }
            }
            if (Regex.IsMatch(sign_in_email.Text, ".?admin.?"))
            {
                if (sign_in_password.Password == password)
                {
                    MessageBox.Show("You Signed In Successfully As Admin");
                    Current_user.admin_login_counter++;
                    admin_desktop w = new admin_desktop();
                    w.Show();
                    this.Close();
                    return;
                }
            }
            SqlConnection sqlConnection = new SqlConnection(connection_string);
            SqlDataReader sqlDataReader;
            SqlCommand    sqlCommand;

            sqlConnection.Open();
            if (check_conditions.email_check(sign_in_email.Text))
            {
                sqlCommand = new SqlCommand("select * from Users where E_mail=@E_mail and _Password=@_Password", sqlConnection);
                sqlCommand.Parameters.AddWithValue("@E_mail", sign_in_email.Text);
                sqlCommand.Parameters.AddWithValue("@_Password", sign_in_password.Password);
                sqlDataReader = sqlCommand.ExecuteReader();
            }
            else
            {
                sqlCommand = new SqlCommand("select * from Users where PhoneNUmber=@Phone_Number and _Password=@_Password", sqlConnection);
                sqlCommand.Parameters.AddWithValue("@Phone_Number", sign_in_email.Text);
                sqlCommand.Parameters.AddWithValue("@_Password", sign_in_password.Password);
                sqlDataReader = sqlCommand.ExecuteReader();
            }


            while (sqlDataReader.Read())
            {
                MessageBox.Show("You Signed In Successfully As User");
                Current_user.FullName      = sqlDataReader.GetValue(0).ToString();
                Current_user.E_mail        = sqlDataReader.GetValue(1).ToString();
                Current_user.NationalCode  = sqlDataReader.GetValue(2).ToString();
                Current_user.PhoneNumber   = sqlDataReader.GetValue(3).ToString();
                Current_user.Password      = sqlDataReader.GetValue(4).ToString();
                Current_user.image_uri     = sqlDataReader.GetValue(5).ToString();
                Current_user.shopping_list = sqlDataReader.GetValue(6).ToString();
                Current_user.cart          = sqlDataReader.GetValue(7).ToString();

                sqlDataReader.Close();
                sqlCommand.Dispose();
                sqlConnection.Close();
                user_desktop w = new user_desktop();
                w.Show();
                this.Close();
                return;
            }
            MessageBox.Show("Wrong Email or Password!");
            sqlDataReader.Close();
            sqlCommand.Dispose();
            sqlConnection.Close();
        }