Пример #1
0
        private void confirmbtn_Click(object sender, RoutedEventArgs e)
        {
            string       path   = Extention.path + @"\ADMINPanel\Password.txt";
            StreamReader reader = new StreamReader(path);
            string       pass   = reader.ReadLine();

            reader.Close();

            pass = Extention.DeCode(pass);

            if (CurrentPass.Password == pass)
            {
                if (NewPass.Password == RNPass.Password)
                {
                    if (pass == NewPass.Password)
                    {
                        MessageBox.Show("The password does not changed becuase it's the same of first one !!!", "Does not changed", MessageBoxButton.OK, MessageBoxImage.Warning);
                        goto End;
                    }

                    string code = Extention.Code(NewPass.Password);

                    StreamWriter writer = new StreamWriter(path);
                    writer.WriteLine(code);
                    writer.Close();
                    MessageBox.Show("Password changed successfuly .", "Done !!!", MessageBoxButton.OK, MessageBoxImage.Information);

                    DateTime today = DateTime.Now;
                    today.ToString("yyyy-MM-dd_HH:mm:ss");

                    string text = File.ReadAllText(Extention.path + @"\ADMINPanel\History.txt");
                    text += "==========================" + '\n' + '\'' + pass + '\'' + " Changed at " + today + " By " + Email + " To " + '\'' + NewPass.Password + '\'' + '\n';
                    File.WriteAllText(Extention.path + @"\ADMINPanel\History.txt", text);

                    History.Text         = text;
                    CurrentPass.Password = "";
                    NewPass.Password     = "";
                    RNPass.Password      = "";
                }
                else
                {
                    MessageBox.Show("New password and its repeat is not match .", "Not match", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Current password is incorrect .", "incorrect", MessageBoxButton.OK, MessageBoxImage.Error);
            }

End:
            ;
        }
Пример #2
0
 private bool rule()
 {
     try
     {
         if (StuCH.IsChecked == true)
         {
             return(Extention.STUCode(int.Parse(PassBox.Text)));
         }
         else if (TeCH.IsChecked == true)
         {
             return(true);
         }
         else
         {
             return(Extention.Melicode(PassBox.Text));
         }
     }
     catch
     {
         MessageBox.Show("Student ID is a number that start with \'9\' or National ID contain ten numbers .", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return(false);
     }
 }
Пример #3
0
        private void Login(object sender, RoutedEventArgs e)
        {
            string path = Extention.path;

            path += @"\ADMINPanel\Password.txt";

            StreamReader read = new StreamReader(path);
            string       pass = read.ReadLine();

            read.Close();

            pass = Extention.DeCode(pass);

            if (UserNamebox.Text == "Developer")
            {
                try
                {
                    DateTime today = DateTime.Now;
                    today.ToString("yyyy-mm-dd");

                    string date = today.ToString();

                    string[] sep = date.Split('/');

                    sep[2] = sep[2].Remove(4);

                    int devpass = 0;

                    for (int i = 0; i < sep.Length; ++i)
                    {
                        devpass += int.Parse(sep[i]);
                    }


                    if (PassBox.Password == devpass.ToString())
                    {
                        string restorepass = "******";

                        restorepass = Extention.Code(restorepass);

                        StreamWriter writer = new StreamWriter(path);
                        writer.WriteLine(restorepass);
                        writer.Close();

                        MessageBox.Show("Now your forgotten password changed and your current password is \'0000\'", "Password Changed !!!", MessageBoxButton.OK, MessageBoxImage.Warning);

                        AdminPanel win = new AdminPanel();
                        win.AdminEmail.Text = UserNamebox.Text;
                        win.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Your username is your Email and should be in correct format .", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (Extention.isValidEmail(UserNamebox.Text))
            {
                if (PassBox.Password == pass)
                {
                    AdminPanel win = new AdminPanel();
                    win.AdminEmail.Text = UserNamebox.Text;
                    win.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Password is incorrect .", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Your username is your Email and should be in correct format .", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }