Esempio n. 1
0
        private void ChangeUser_B_Click(object sender, EventArgs e)
        {
            SystemArgs.PrintLog($"Инциализация процедуры смены пользователя");

            MessegeTwoButtons Dialog = new MessegeTwoButtons();

            Dialog.Message_L.Text = "Вы действиельно хотеите сменить пользователя?";

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                Confirm = true;

                SystemArgs.MainForm.Login_TB.Text = "";
                SystemArgs.MainForm.Pass_TB.Text  = "";

                this.Close();

                SystemArgs.MainForm.Show();

                SystemArgs.PrintLog($"Процедура смены пользователя успешно завершена");
            }
            else
            {
                SystemArgs.PrintLog($"Процедура смены пользователя отменена");
            }
        }
Esempio n. 2
0
        private void Delete_B_Click(object sender, EventArgs e)
        {
            SystemArgs.PrintLog($"Инициализация процедуры удаления позиции");

            MessegeTwoButtons Dialog = new MessegeTwoButtons();

            Dialog.Message_L.Text = "Вы действиельно хотите удалить эту позицию?";

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                DataFile.RemovePosition(SystemArgs.Positions[Positions_DGV.CurrentCell.RowIndex]);

                SystemArgs.Positions.RemoveAt(Positions_DGV.CurrentCell.RowIndex);

                ShowCurrentPositions(SystemArgs.Positions);

                if (SystemArgs.Positions.Count <= 0)
                {
                    Change_B.Enabled = false;
                    Delete_B.Enabled = false;
                }

                SystemArgs.PrintLog($"Удаление позициии успешно завершено");
            }
            else
            {
                SystemArgs.PrintLog($"Процедура удаления позиции отменена");
            }
        }
Esempio n. 3
0
        public static void SaveUser(String NameUser, String Password)
        {
            if (NameUser.Trim() == "")
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Поле логина должно содержать значение";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Получена пустое значение логина");

                return;
            }

            if (Password.Trim() == "")
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Поле пароля должно содержать значение";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Получена пустое значение пароля");

                return;
            }

            if (!Directory.Exists($@"{SystemPath.DataReg}\{NameUser}"))
            {
                Directory.CreateDirectory($@"{SystemPath.DataReg}\{NameUser}");
                Directory.CreateDirectory($@"{SystemPath.DataUSers}\{NameUser}");

                using (StreamWriter sw = new StreamWriter(File.Create($@"{SystemPath.DataReg}\{NameUser}\{NameUser}.hba")))
                {
                    sw.WriteLine(NameUser);
                    sw.WriteLine(Password);
                }

                SystemArgs.PrintLog($"Директория пользователя {SystemArgs.CurrentUser} создана");
            }
            else
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Пользователь с таким именем уже существует. Вы вернетесь к форме авторизации";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Пользователь существует");

                return;
            }
        }
Esempio n. 4
0
        private void User_B_Click(object sender, EventArgs e)
        {
            SystemArgs.PrintLog($"Просмотр информации о пользователе");

            AboutUser Dialog = new AboutUser();

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
            }
        }
Esempio n. 5
0
        private void Program_B_Click(object sender, EventArgs e)
        {
            SystemArgs.PrintLog($"Просмотр информации о программе");

            AboutProg Dialog = new AboutProg();

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
            }
        }
Esempio n. 6
0
        public static String GetSHA256(String Password)
        {
            UTF8Encoding  Encoder = new UTF8Encoding();
            SHA256Managed SHA256  = new SHA256Managed();

            byte[] Hash = SHA256.ComputeHash(Encoder.GetBytes(Password));

            SystemArgs.PrintLog($"Хеш-последовательность успешно получена");

            return(Convert.ToBase64String(Hash));
        }
Esempio n. 7
0
        public static String DecryptRSA(String OutputPassword, String Password)
        {
            if (String.IsNullOrEmpty(OutputPassword))
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Входная строка имела пустое значение";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Получено пустое значение пароля");

                return(null);
            }
            ;

            byte[] VectorB         = Encoding.ASCII.GetBytes(Vector);
            byte[] SaltB           = Encoding.ASCII.GetBytes(Salt);
            byte[] OutputPasswordB = Convert.FromBase64String(OutputPassword);

            PasswordDeriveBytes DerivePassword = new PasswordDeriveBytes(Password, SaltB, "SHA1", PasswordIter);

            byte[] KeyBytes = DerivePassword.GetBytes(KeySize / 8);

            RijndaelManaged SymmKey = new RijndaelManaged();

            SymmKey.Mode = CipherMode.CBC;

            byte[] InitialTextBytes = new byte[OutputPasswordB.Length];

            Int32 ByteCount = 0;

            using (ICryptoTransform Decryptor = SymmKey.CreateDecryptor(KeyBytes, VectorB))
            {
                using (MemoryStream MemoryStream = new MemoryStream(OutputPasswordB))
                {
                    using (CryptoStream CryptoStream = new CryptoStream(MemoryStream, Decryptor, CryptoStreamMode.Read))
                    {
                        ByteCount = CryptoStream.Read(InitialTextBytes, 0, InitialTextBytes.Length);
                        MemoryStream.Close();
                        CryptoStream.Close();
                    }
                }
            }

            SymmKey.Clear();

            SystemArgs.PrintLog($"Дешифрование пароля завершено успешно");

            return(Encoding.UTF8.GetString(InitialTextBytes, 0, ByteCount));
        }
Esempio n. 8
0
        public static String EncryptRSA(String InputPassword, String Password)
        {
            if (String.IsNullOrEmpty(InputPassword))
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Входная строка имела пустое значение";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Получено пустое значение пароля");

                return(null);
            }

            byte[] VectorB        = Encoding.ASCII.GetBytes(Vector);
            byte[] SaltB          = Encoding.ASCII.GetBytes(Salt);
            byte[] InputPasswordB = Encoding.UTF8.GetBytes(InputPassword);

            PasswordDeriveBytes DerivePassword = new PasswordDeriveBytes(Password, SaltB, "SHA1", PasswordIter);

            byte[] KeyBytes = DerivePassword.GetBytes(KeySize / 8);

            RijndaelManaged SymmKey = new RijndaelManaged();

            SymmKey.Mode = CipherMode.CBC;

            byte[] EncryptrTextBytes = null;

            using (ICryptoTransform Encryptor = SymmKey.CreateEncryptor(KeyBytes, VectorB))
            {
                using (MemoryStream MemoryStream = new MemoryStream())
                {
                    using (CryptoStream CryptoStream = new CryptoStream(MemoryStream, Encryptor, CryptoStreamMode.Write))
                    {
                        CryptoStream.Write(InputPasswordB, 0, InputPasswordB.Length);
                        CryptoStream.FlushFinalBlock();
                        EncryptrTextBytes = MemoryStream.ToArray();
                        MemoryStream.Close();
                        CryptoStream.Close();
                    }
                }
            }

            SymmKey.Clear();

            SystemArgs.PrintLog($"Шифрование пароля завершено успешно");

            return(Convert.ToBase64String(EncryptrTextBytes));
        }
Esempio n. 9
0
        private void Reg_Form_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                String error = "";

                try
                {
                    if (Login_TB.Text.Trim() == "")
                    {
                        Login_TB.Focus();
                        error = "Необходимо ввести логин пользователя";
                        throw new Exception(error);
                    }

                    if (Pass_TB.Text.Trim() == "")
                    {
                        Pass_TB.Focus();
                        error = "Необходимо ввеситм пароль пользователя";
                        throw new Exception(error);
                    }

                    if (Directory.Exists($@"{SystemPath.DataReg}\{Login_TB.Text.Trim()}"))
                    {
                        error = "Пользовтель с таким именем уже существует";
                        throw new Exception(error);
                    }

                    MessageOneButton Dialog2 = new MessageOneButton();

                    Dialog2.Message_L.Text = "Пользователь успешно зарегистрирован";

                    if (Dialog2.ShowDialog() == DialogResult.OK)
                    {
                    }

                    SystemArgs.PrintLog($"Пользователь успешно зарегистрирован");
                }
                catch
                {
                    MessageOneButton Dialog = new MessageOneButton();

                    Dialog.Message_L.Text = error;

                    if (Dialog.ShowDialog() == DialogResult.OK)
                    {
                    }

                    e.Cancel = true;
                }
            }
        }
Esempio n. 10
0
        public static DateTime CurrentDateFile; //Текущая дата

        public static void SetPosition(DateTime CurrentDate, String Name, String Password, String Descrition, String KeyEncryption)
        {
            String PasswordRSA = Encryption.EncryptRSA(Password, KeyEncryption);                         //Шифруем

            String Temp = $"{CurrentDate.ToString()}_{Name}_{PasswordRSA}_{Descrition}_{KeyEncryption}"; //Строка для записи

            String NameFile = CurrentDate.GetHashCode().ToString();                                      //Имя будет уникальное в текущей сборке программы

            using (StreamWriter sw = new StreamWriter(File.Create($@"{SystemPath.DataUSers}\{SystemArgs.CurrentUser.Name}\{NameFile}.df")))
            {
                sw.WriteLine(Temp);
            }

            SystemArgs.PrintLog($"Позиция пользователя успешно сохранена");
        }
Esempio n. 11
0
        public static bool GetUserExists(String Login)
        {
            if (Directory.Exists($@"{SystemPath.DataReg}\{Login}"))
            {
                SystemArgs.PrintLog($"Логин {Login} успешно найден");

                return(true);
            }
            else
            {
                SystemArgs.PrintLog($"Логин {Login} не существует");

                return(false);
            }
        }
Esempio n. 12
0
        public static String GetKeyEncryption()
        {
            Random Random = new Random();

            string Key = String.Empty;

            for (Int32 i = 0; i < 8; i++)
            {
                Int32 Temp = Random.Next(0, Alphabet.Length);

                Key += Alphabet[Temp];
            }

            SystemArgs.PrintLog($"Ключ успешно получен");

            return(Key);
        }
Esempio n. 13
0
        private void ChangeData()
        {
            SystemArgs.PrintLog($"Инициализация процедуры изменения позиции");

            PositionForm Dialog = new PositionForm
            {
                BackgroundImage = Properties.Resources.PositionChange
            };

            DataFile.CurrentDateFile = DateTime.Now;

            Position LastPosition = SystemArgs.Positions[Positions_DGV.CurrentCell.RowIndex];

            Dialog.CurrentDate_TB.Text = LastPosition.DateCreate.ToString();
            Dialog.Name_TB.Text        = LastPosition.Name;
            Dialog.Pass_TB.Text        = LastPosition.Password;
            Dialog.Description_TB.Text = LastPosition.Description;

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                Position Temp = new Position(DataFile.CurrentDateFile, Dialog.Name_TB.Text.Trim(), Dialog.Pass_TB.Text.Trim(), Dialog.Description_TB.Text.Trim());

                DataFile.ChangePosition(Temp.DateCreate, Temp.Name, Temp.Password, Temp.Description, LastPosition.DateCreate, LastPosition.Name, Encryption.GetKeyEncryption());

                SystemArgs.Positions.Remove(LastPosition);

                SystemArgs.Positions.Add(Temp);

                MessageOneButton Dialog2 = new MessageOneButton();

                Dialog2.Message_L.Text = "Позиция успешно изменена. Дата создания обновлена";

                if (Dialog2.ShowDialog() == DialogResult.OK)
                {
                }

                ShowCurrentPositions(SystemArgs.Positions);

                SystemArgs.PrintLog($"Изменение позиции успешно завершено");
            }
            else
            {
                SystemArgs.PrintLog($"Процедура изменении позиции отменена");
            }
        }
Esempio n. 14
0
        public static void ChangePosition(DateTime CurrentDate, String Name, String Password, String Descrition, DateTime LastDate, String LastName, String KeyEncryption)
        {
            String PasswordRSA = Encryption.EncryptRSA(Password, KeyEncryption);                         //Шифруем

            String Temp = $"{CurrentDate.ToString()}_{Name}_{PasswordRSA}_{Descrition}_{KeyEncryption}"; //Строка для записи

            String NameFile = CurrentDate.GetHashCode().ToString();                                      //Имя будет уникальное в текущей сборке программы

            bool Check = false;

            String PathChange = String.Empty;

            if (Directory.Exists($@"{SystemPath.DataUSers}\{SystemArgs.CurrentUser.Name}"))
            {
                String[] Path = Directory.GetFiles($@"{SystemPath.DataUSers}\{SystemArgs.CurrentUser.Name}");

                foreach (String PathFile in Path)
                {
                    using (StreamReader sw = new StreamReader(File.Open(PathFile, FileMode.Open)))
                    {
                        String[] Temp2 = sw.ReadLine().Split('_');

                        if ((Temp2[0] == LastDate.ToString()) & (Temp2[1] == LastName))
                        {
                            Check      = true;
                            PathChange = PathFile;
                            break;
                        }
                    }
                }

                if (Check)
                {
                    using (StreamWriter sw = new StreamWriter(File.Create(PathChange)))
                    {
                        sw.WriteLine(Temp);
                        SystemArgs.PrintLog($"Позиция пользователя успешно изменена");
                    }
                }
            }
            else
            {
                SystemArgs.PrintLog($"Директория позиций пользователя не найдена");
            }
        }
Esempio n. 15
0
        private void Exit_B_Click(object sender, EventArgs e)
        {
            SystemArgs.PrintLog($"Инциализация процедуры выхода из программы");

            MessegeTwoButtons Dialog = new MessegeTwoButtons();

            Dialog.Message_L.Text = "Вы действителньо хотите выйти?";

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                SystemArgs.PrintLog($"Процедура выхода из программы успешно завершена");

                Application.Exit();
            }
            else
            {
                SystemArgs.PrintLog($"Процедура выхода из программы отменена");
            }
        }
Esempio n. 16
0
        private void Main_Form_Load(object sender, EventArgs e)
        {
            Change_B.Enabled = false;
            Delete_B.Enabled = false;

            SystemArgs.Positions = new List <Position>();

            String[] TempPositions = Operations.GetAllPositions();

            FirstRowDGV();

            for (Int32 i = 0; i < TempPositions.Length; i++)
            {
                Position Temp = Operations.ToPosition(TempPositions[i]);

                if (Temp == null)
                {
                    MessageOneButton Dialog = new MessageOneButton();

                    Dialog.Message_L.Text = "Ошибка при получени данных. Выход из приложения";

                    if (Dialog.ShowDialog() == DialogResult.OK)
                    {
                        SystemArgs.PrintLog($"Ошибка при получени данных");
                    }

                    SystemArgs.MainForm.Close();
                    this.WindowState = FormWindowState.Minimized; // - морграние
                }
                else
                {
                    SystemArgs.Positions.Add(Temp);
                }
            }

            SystemArgs.PrintLog($"Конвертация позиций => Успешно ");

            ShowCurrentPositions(SystemArgs.Positions);

            SystemArgs.PrintLog($"Визуализация позиций => Успешно ");

            //Positions_DGV.ClearSelection(); //Убираем выделение первой ячейки при загрузке таблицы
        }
Esempio n. 17
0
        public static String [] GetAllPositions()
        {
            SystemArgs.PrintLog($"Процедура получения позиций пользователя => Старт ");

            String Data = "";

            String[] PathFiles;

            if (Directory.Exists($@"{SystemPath.DataUSers}\{SystemArgs.CurrentUser.Name}"))
            {
                PathFiles = Directory.GetFiles($@"{SystemPath.DataUSers}\{SystemArgs.CurrentUser.Name}");

                for (Int32 i = 0; i < PathFiles.Length; i++)
                {
                    using (StreamReader sr = new StreamReader(File.Open(PathFiles[i], FileMode.Open)))
                    {
                        Data = sr.ReadLine();
                    }

                    PathFiles[i] = Data;
                }
            }
            else
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Директория пользователя не найдена";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Директория пользователя не найдена");

                return(new String[0]);
            }

            return(PathFiles);
        }
Esempio n. 18
0
        private void Search_B_Click(object sender, EventArgs e)
        {
            String Search = Search_TB.Text.Trim();

            if (Search == String.Empty)
            {
                ResetSearch();
                return;
            }

            SystemArgs.Result.Clear();

            foreach (Position Temp in SystemArgs.Positions)
            {
                if (Temp.GetSearchString().IndexOf(Search) != -1)
                {
                    SystemArgs.Result.Add(Temp);
                }
            }

            if (SystemArgs.Result.Count != 0)
            {
                ShowCurrentPositions(SystemArgs.Result);

                SystemArgs.PrintLog($"Удачное завершение поиска поиска. Результатов {SystemArgs.Result.Count}");
            }
            else
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Поиск не дал результатов";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                    SystemArgs.PrintLog($"Поиск не дал результатов");
                    return;
                }
            }
        }
Esempio n. 19
0
        private void Add_B_Click(object sender, EventArgs e)
        {
            SystemArgs.PrintLog($"Инициализация процедуры добавления позиции");

            PositionForm Dialog = new PositionForm
            {
                BackgroundImage = Properties.Resources.Position
            };

            DataFile.CurrentDateFile = DateTime.Now;

            Dialog.CurrentDate_TB.Text = DataFile.CurrentDateFile.ToString();

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                Position Temp = new Position(DataFile.CurrentDateFile, Dialog.Name_TB.Text.Trim(), Dialog.Pass_TB.Text.Trim(), Dialog.Description_TB.Text.Trim());

                SystemArgs.Positions.Add(Temp);

                DataFile.SetPosition(Temp.DateCreate, Temp.Name, Temp.Password, Temp.Description, Encryption.GetKeyEncryption());

                MessageOneButton Dialog2 = new MessageOneButton();

                Dialog2.Message_L.Text = "Позиция успешно добавлена";

                if (Dialog2.ShowDialog() == DialogResult.OK)
                {
                }

                ShowCurrentPositions(SystemArgs.Positions);

                SystemArgs.PrintLog($"Добавление позиции завершено успешно");
            }
            else
            {
                SystemArgs.PrintLog($"Процедура добавления позиции отменена");
            }
        }
Esempio n. 20
0
        public static void RemovePosition(Position Position)
        {
            bool Check = false;

            String PathDelete = String.Empty;

            if (Directory.Exists($@"{SystemPath.DataUSers}\{SystemArgs.CurrentUser.Name}"))
            {
                String[] Path = Directory.GetFiles($@"{SystemPath.DataUSers}\{SystemArgs.CurrentUser.Name}");

                foreach (String PathFile in Path)
                {
                    using (StreamReader sw = new StreamReader(File.Open(PathFile, FileMode.Open)))
                    {
                        String[] Temp = sw.ReadLine().Split('_');

                        if ((Temp[0] == Position.DateCreate.ToString()) & (Temp[1] == Position.Name))
                        {
                            Check      = true;
                            PathDelete = PathFile;
                            break;
                        }
                    }
                }

                if (Check)
                {
                    File.Delete(PathDelete);

                    SystemArgs.PrintLog($"Позиция пользователя успешно удалена");
                }
            }
            else
            {
                SystemArgs.PrintLog($"Директория позиций пользователя {SystemArgs.CurrentUser} не найдена");
            }
        }
Esempio n. 21
0
        public static void GetDataLogPath()
        {
            if (File.Exists(DataLogPath))
            {
                using (StreamReader sr = new StreamReader(File.Open(DataLogPath, FileMode.Open)))
                {
                    DataLog = sr.ReadLine();
                }
            }
            else
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Файл DateLog.conf не обнаружен";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Файл DataLog.conf не найден");

                return;
            }
        }
Esempio n. 22
0
        private void Reg_B_Click(object sender, EventArgs e)
        {
            Reg_Form Dialog = new Reg_Form();

            this.Hide();

            SystemArgs.PrintLog($"Инициализаия процедуры регистарции пользователя");

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                Registrations.SaveUser(Dialog.Login_TB.Text.Trim(), Hash.GetSHA256(Dialog.Pass_TB.Text.Trim()));

                SystemArgs.PrintLog($"Пользователь успешно зарегистрирован");
            }
            else
            {
                SystemArgs.PrintLog($"Процедура регистрации пользователя отменена");
            }

            SystemArgs.MainForm.Login_TB.Text = "";
            SystemArgs.MainForm.Pass_TB.Text  = "";

            this.Show();
        }
Esempio n. 23
0
        public static void CheckFiles()
        {
            try
            {
                SystemArgs.PrintLog($"Запуск приложения");

                if (!File.Exists(SystemPath.DataRegPath))
                {
                    throw new Exception();
                }

                if (!File.Exists(SystemPath.DataUSersPath))
                {
                    throw new Exception();
                }

                if (!File.Exists(SystemPath.DataLogPath))
                {
                    throw new Exception();
                }

                SystemPath.GetDataRegPath();
                SystemPath.GetDataLogPath();
                SystemPath.GetDataUsersPath();

                if (!Directory.Exists(SystemPath.DataLog))
                {
                    throw new Exception();
                }

                if (!Directory.Exists(SystemPath.DataReg))
                {
                    throw new Exception();
                }

                if (!Directory.Exists(SystemPath.DataUSers))
                {
                    throw new Exception();
                }
            }
            catch (UnauthorizedAccessException)
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Недостаточно прав для доступа к системным файлам";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Недостаточно прав доступа для запуска ПО");

                Environment.Exit(0); //Завершение процесса
            }
            catch (Exception)
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Ошибка при получении путей конфигурации";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Файл конфигурации не найден");

                Environment.Exit(0); //Завершение процесса
            }
        }
Esempio n. 24
0
        public static bool GetUserStatus(String Login, String Pass)
        {
            if (File.Exists($@"{SystemPath.DataReg}\{Login}\{Login}.hba"))
            {
                using (StreamReader sr = new StreamReader(File.Open($@"{SystemPath.DataReg}\{Login}\{Login}.hba", FileMode.Open)))
                {
                    String TempLogin = sr.ReadLine();
                    String TempPass  = sr.ReadLine();

                    if (TempLogin == Login)
                    {
                        if (TempPass == Pass)
                        {
                            return(true);
                        }
                        else
                        {
                            MessageOneButton Dialog = new MessageOneButton();

                            Dialog.Message_L.Text = $@"Неправильный логин или пароль";

                            if (Dialog.ShowDialog() == DialogResult.OK)
                            {
                            }

                            SystemArgs.PrintLog($"Получен неправильный логин или пароль");

                            return(false);
                        }
                    }
                    else
                    {
                        MessageOneButton Dialog = new MessageOneButton();

                        Dialog.Message_L.Text = $@"Неправильный логин или пароль";

                        if (Dialog.ShowDialog() == DialogResult.OK)
                        {
                        }

                        SystemArgs.PrintLog($"Получен неправильный логин или пароль");

                        return(false);
                    }
                }
            }
            else
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = $@"Файл {Login}.hba не обнаружен";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Конфигурационный файл {Login}.hba не найден");

                return(false);
            }
        }
Esempio n. 25
0
        private void Headers_DGV_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            CurrentTypeSort = !CurrentTypeSort;

            if (e.ColumnIndex == 0)
            {
                if (CurrentTypeSort)
                {
                    Headers_DGV[e.ColumnIndex, 0].Value = "Дата добавления ↑";
                }
                else
                {
                    Headers_DGV[e.ColumnIndex, 0].Value = "Дата добавления ↓";
                }

                Headers_DGV[1, 0].Value = "Логин";
                Headers_DGV[2, 0].Value = "Пароль";
                Headers_DGV[3, 0].Value = "Наименование | Описание";

                Sort.ByDate(CurrentTypeSort);


                SystemArgs.PrintLog($"Сортировака по дате выполнена");
            }
            else if (e.ColumnIndex == 1)
            {
                if (CurrentTypeSort)
                {
                    Headers_DGV[e.ColumnIndex, 0].Value = "Логин ↑";
                }
                else
                {
                    Headers_DGV[e.ColumnIndex, 0].Value = "Логин ↓";
                }

                Headers_DGV[0, 0].Value = "Дата добавления";
                Headers_DGV[2, 0].Value = "Пароль";
                Headers_DGV[3, 0].Value = "Наименование | Описание";

                Sort.ByName(CurrentTypeSort);


                SystemArgs.PrintLog($"Сортировака по логину выполнена");
            }
            else if (e.ColumnIndex == 2)
            {
                if (CurrentTypeSort)
                {
                    Headers_DGV[e.ColumnIndex, 0].Value = "Пароль ↑";
                }
                else
                {
                    Headers_DGV[e.ColumnIndex, 0].Value = "Пароль ↓";
                }

                Headers_DGV[0, 0].Value = "Дата добавления";
                Headers_DGV[1, 0].Value = "Логин";
                Headers_DGV[3, 0].Value = "Наименование | Описание";

                Sort.ByPassword(CurrentTypeSort);

                SystemArgs.PrintLog($"Сортировака по паролю выполнена");
            }
            else
            {
                if (CurrentTypeSort)
                {
                    Headers_DGV[e.ColumnIndex, 0].Value = "Наименование | Описание ↑";
                }
                else
                {
                    Headers_DGV[e.ColumnIndex, 0].Value = "Наименование | Описание ↓";
                }

                Headers_DGV[0, 0].Value = "Дата добавления";
                Headers_DGV[1, 0].Value = "Логин";
                Headers_DGV[2, 0].Value = "Пароль";

                Sort.ByDescription(CurrentTypeSort);

                SystemArgs.PrintLog($"Сортировака по описанию выполнена");
            }

            ShowCurrentPositions(SystemArgs.Positions);
        }
Esempio n. 26
0
        private void Exit_B_Click(object sender, EventArgs e)
        {
            SystemArgs.PrintLog($"Выход из приложения");

            Application.Exit();
        }
Esempio n. 27
0
        private void Enter_B_Click(object sender, EventArgs e)
        {
            String CurrentLogin = Login_TB.Text.Trim();

            if (CurrentLogin != "")
            {
                if (Autorization.GetUserExists(CurrentLogin))
                {
                    String CurrentPass = Pass_TB.Text.Trim();

                    if (CurrentPass != "")
                    {
                        if (Autorization.GetUserStatus(CurrentLogin, Hash.GetSHA256(CurrentPass)))
                        {
                            SystemArgs.CurrentUser = new User(CurrentLogin);

                            SystemArgs.PrintLog($"Пользователь {SystemArgs.CurrentUser.Name} успешно авторизовался");

                            Main_Form Main = new Main_Form();
                            Main.Show();

                            this.Hide();
                        }
                    }
                    else
                    {
                        MessageOneButton Dialog = new MessageOneButton();

                        Dialog.Message_L.Text = "Поле пароля должно содержать значение";

                        if (Dialog.ShowDialog() == DialogResult.OK)
                        {
                        }

                        SystemArgs.PrintLog($"Получено пустое поле пароля");

                        Pass_TB.Focus();
                        return;
                    }
                }
                else
                {
                    MessageOneButton Dialog = new MessageOneButton();

                    Dialog.Message_L.Text = $@"Неправильный логин или пароль";

                    if (Dialog.ShowDialog() == DialogResult.OK)
                    {
                    }

                    SystemArgs.PrintLog($"Введен енправильный логин или пароль");
                }
            }
            else
            {
                MessageOneButton Dialog = new MessageOneButton();

                Dialog.Message_L.Text = "Поле логина должно содержать значение";

                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                }

                SystemArgs.PrintLog($"Получено пустое поле логина");

                Login_TB.Focus();
                return;
            }
        }