コード例 #1
0
 private void ButtonClick(object sender, RoutedEventArgs e)
 {
     if (Name.Text == "")
     {
         Error.Content = "Заполните все поля";
     }
     else
     {
         if (ListOfAccount.Search(Name.Text))
         {
             Error.Content = "Имя уже используется";
         }
         else
         {
             Account newAccount = new Account();
             newAccount.bName = Name.Text;
             newAccount.bPassword = "";
             newAccount.bLock = false;
             newAccount.bRestrictionPassword = true;
             ListOfAccount.account.Add(newAccount);
             ListOfAccount.writeFromListToFile();
             Error.Content = "Логин создан";
         }
     }
 }
コード例 #2
0
        public WorkingWithList()
        {
            InitializeComponent();
            ListOfAccount.writeFromFileToList();
            Account firstAccount = new Account();
            firstAccount = ListOfAccount.account[j];

            personalName.Content = firstAccount.bName;

            if (firstAccount.bLock == true)
            {
                lockPerson.IsChecked = true;
            }
            else
            {
                lockPerson.IsChecked = false;
            }

            if (firstAccount.bRestrictionPassword == true)
            {
                restrictionPassword.IsChecked = true;
            }
            else
            {
                restrictionPassword.IsChecked = false;
            }
        }
コード例 #3
0
        private void ButtonClick2(object sender, RoutedEventArgs e)
        {
            ListOfAccount.strLogin = "";
            Account newAccount = new Account();
            newAccount = ListOfAccount.account[0];

            if (Name.Text == "")
            {
                Message.Content = "Введите имя";
            }
            else
            {
                if (Password.Password == newAccount.bPassword && Name.Text == "ADMIN")
                {
                    ListOfAccount.strLogin = Name.Text;
                    ChangePassoword chWindow = new ChangePassoword();
                    chWindow.Show();
                    Close();
                }
                else
                {
                    int iCheck = ListOfAccount.Authorization(Name.Text, Password.Password);

                    if (iCheck == 1)
                    {
                        if (ListOfAccount.strLogin == "ADMIN")
                        {
                                AdministratorMode amWindow = new AdministratorMode();
                                amWindow.Show();
                                Close();
                        }
                        else
                        {
                            ChangePassoword chWindow = new ChangePassoword();
                            chWindow.Show();
                            Close();
                        }
                    }

                    if (iCheck == 2)
                    {
                        Message.Content = "Логин заблокирован";
                    }

                    if (iCheck == 0)
                    {
                        if (j < 2)
                        {
                            Message.Content = "Не существует имени c таким паролем";
                            j++;
                        }
                        else
                        {
                            Close();
                        }
                    }
                }
            }
        }
コード例 #4
0
        public static int Authorization(string strName, string strPassword)
        {
            for (int i = 0; i < account.Count; i++)
            {
                Account newAccount = new Account();
                newAccount = account[i];
                if (newAccount.bName == strName && newAccount.bPassword == strPassword)
                {
                    strLogin = strName;
                    if (newAccount.bLock == true)
                    {
                        return 2;
                    }
                    else
                    {
                        return 1;
                    }
                }

            }
            return 0;
        }
コード例 #5
0
 public static bool Search(string strName)
 {
     for (int i = 0; i < account.Count; i++)
     {
         Account newAccount = new Account();
         newAccount = account[i];
         if (newAccount.bName == strName)
         {
             return true;
         }
     }
     return false;
 }
コード例 #6
0
        public static void writeFromListToFile()
        {
            string strDataFile = AppDomain.CurrentDomain.BaseDirectory + "DataAccount.dat";
            BinaryWriter bw = new BinaryWriter(File.Open(strDataFile, FileMode.Create));

            Account newAccount = new Account();
            for (int i = 0; i < account.Count; i++)
            {
                newAccount = account[i];
                bw.Write(newAccount.bName);
                bw.Write(newAccount.bPassword);
                bw.Write(newAccount.bLock);
                bw.Write(newAccount.bRestrictionPassword);
            }
            bw.Close();
        }
コード例 #7
0
        //ListOfAccount() { }
        public static void writeFromFileToList()
        {
            string strDataFile = AppDomain.CurrentDomain.BaseDirectory + "DataAccount.dat";
            BinaryReader br = new BinaryReader(File.Open(strDataFile, FileMode.Open));
            account.Clear();

            while (br.PeekChar() >= 0)
            {
                Account newAccount = new Account();
                newAccount.bName = br.ReadString();
                newAccount.bPassword = br.ReadString();
                newAccount.bLock = br.ReadBoolean();
                newAccount.bRestrictionPassword = br.ReadBoolean();
                account.Add(newAccount);
            }
            br.Close();
        }
コード例 #8
0
        private void ConfPassword_Click(object sender, RoutedEventArgs e)
        {
            Error.Content = "";
            Error2.Content = "";
            int j = 0;
            bool bCheck = false;
            string strPassword = "";
            ListOfAccount.bCheakAdmin = false;
            for (int i = 0; i < ListOfAccount.account.Count; i++)
            {
                Account checkAccount = new Account();
                checkAccount = ListOfAccount.account[i];
                if (checkAccount.bName == ListOfAccount.strLogin)
                {
                    j = i;
                    bCheck = checkAccount.bRestrictionPassword;
                    strPassword = checkAccount.bPassword;
                }
            }

            if (NewPassword.Password == "" || ConfNewPassword.Password == "")
                {
                    Error.Content = "Заполните все поля";
                }
                else
                {
                    if (NewPassword.Password == ConfNewPassword.Password
                        && OldPassword.Password == strPassword)
                    {
                        if (bCheck == true)
                        {

                            if (ListOfAccount.Restriction(NewPassword.Password))
                            {
                                Account newAccount = new Account();
                                newAccount.bName = ListOfAccount.strLogin;
                                newAccount.bPassword = NewPassword.Password;
                                newAccount.bLock = false;
                                newAccount.bRestrictionPassword = bCheck;
                                ListOfAccount.account[j] = NewAccount;
                                ListOfAccount.writeFromListToFile();
                                Error.Content = "Пароль успешно заменен";
                                ListOfAccount.bCheakAdmin = true;
                            }
                            else
                            {
                                Error.Content = "Пароль имеет недопустимые";
                                Error2.Content = "символы";
                            }
                        }
                        else
                        {
                            Account newAccount = new Account();
                            newAccount.bName = ListOfAccount.strLogin;
                            newAccount.bPassword = NewPassword.Password;
                            newAccount.bLock = false;
                            newAccount.bRestrictionPassword = bCheck;
                            ListOfAccount.account[j] = NewAccount;
                            ListOfAccount.writeFromListToFile();
                            Error.Content = "Пароль успешно заменен";
                            ListOfAccount.bCheakAdmin = true;
                        }
                    }
                    else Error.Content = "Проверьте правильность старого пароля";
                }
        }
コード例 #9
0
        private void NextPersonClick(object sender, RoutedEventArgs e)
        {
            if (j != ListOfAccount.Count() - 1)
            {
                j++;
            }
            else
            {
                j = 1;
            }

            Account firstAccount = new Account();
            firstAccount = ListOfAccount.account[j];

            personalName.Content = firstAccount.bName;

            if (firstAccount.bLock == true)
            {
                lockPerson.IsChecked = true;
            }
            else
            {
                lockPerson.IsChecked = false;
            }

            if (firstAccount.bRestrictionPassword == true)
            {
                restrictionPassword.IsChecked = true;
            }
            else
            {
                restrictionPassword.IsChecked = false;
            }
        }
コード例 #10
0
        private void SaveInfoPerson_Click(object sender, RoutedEventArgs e)
        {
            Account firstAccount = new Account();
            firstAccount = ListOfAccount.account[j];

            if (lockPerson.IsChecked == true)
            {
                firstAccount.bLock = true;
            }
            else
            {
                firstAccount.bLock = false;
            }

            if (restrictionPassword.IsChecked == true)
            {
                firstAccount.bRestrictionPassword = true;
            }
            else
            {
                firstAccount.bRestrictionPassword = false;
            }

            ListOfAccount.account[j] = firstAccount;
        }