コード例 #1
0
ファイル: Program.cs プロジェクト: RustamZakAs/ResumeRZ
        private static void RZResetDatabase(ref RZPersonalInfo[] info)
        {
            RZDeleteFile("mydata.bin");

            var temp_info = new RZPersonalInfo[0];

            info = temp_info;

            //BinaryWriter bw;
            ////create the file
            //try
            //{
            //    bw = new BinaryWriter(new FileStream("mydata.bin", FileMode.Create));
            //}
            //catch (IOException e)
            //{
            //    Console.WriteLine(e.Message + "\n Cannot create file.");
            //    return;
            //}
            //writing into the file
            //try
            //{
            //    bw.Write("");
            //}
            //catch (IOException e)
            //{
            //    Console.WriteLine(e.Message + "\n Cannot reset Database.");
            //    return;
            //}
            //bw.Close();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: RustamZakAs/ResumeRZ
        private static void RZReadBin(ref RZPersonalInfo[] oldInfo)
        {
            BinaryReader br;

            int il   = 1;
            var info = new RZPersonalInfo[il];

            //reading from the file
            try
            {
                br = new BinaryReader(new FileStream("mydata.bin", FileMode.Open));
            }
            catch (IOException e)
            {
                Console.WriteLine(e.Message + "\n Cannot open file.");
                return;
            }
            try
            {
                il = br.ReadInt32();
                Console.WriteLine("Integer data: {0}", il);
                if (il > 0)
                {
                    info = new RZPersonalInfo[il];
                }
                for (int i = 0; i < il; i++)
                {
                    info[i].rz_name     = br.ReadString();
                    info[i].rz_surname  = br.ReadString();
                    info[i].rz_age      = br.ReadInt32();
                    info[i].rz_login    = br.ReadString();
                    info[i].rz_password = br.ReadString();
                }
            }
            catch (IOException e)
            {
                Console.WriteLine(e.Message + "\n Cannot read from file.");
                return;
            }
            br.Close();
            oldInfo = info;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: RustamZakAs/ResumeRZ
        private static void RZSignUp(ref RZPersonalInfo[] oldInfo, int userCount)
        {
            Console.SetWindowSize(35, 19);
            Console.SetBufferSize(35, 19);
            var info = new RZPersonalInfo[userCount];

            if (userCount > 1)
            {
                for (int i = 0; i < oldInfo.Length; i++)
                {
                    info[i].rz_name     = oldInfo[i].rz_name;
                    info[i].rz_surname  = oldInfo[i].rz_surname;
                    info[i].rz_age      = oldInfo[i].rz_age;
                    info[i].rz_login    = oldInfo[i].rz_login;
                    info[i].rz_password = oldInfo[i].rz_password;
                }
            }

            userCount -= 1;
            do
            {
                Console.WriteLine(userCount);
                do
                {
                    Console.SetCursorPosition(2, 6);
                    Console.Write("Name:    ");
                    info[userCount].rz_name = Console.ReadLine();
                } while (info[userCount].rz_name.Length == 0);
                do
                {
                    Console.SetCursorPosition(2, 7);
                    Console.Write("Surname: ");
                    info[userCount].rz_surname = Console.ReadLine();
                } while (info[userCount].rz_surname.Length == 0);
                do
                {
                    Console.SetCursorPosition(2, 8);
                    Console.Write("Age:     ");
                    int.TryParse(Console.ReadLine(), out info[userCount].rz_age);
                } while (info[userCount].rz_age == 0);

                Console.WriteLine($"Name:    {info[userCount].rz_name}");
                Console.WriteLine($"Surname: {info[userCount].rz_surname}");
                Console.WriteLine($"Age:     {info[userCount].rz_age}");
                Console.WriteLine();

                if (info[userCount].rz_name.Length > 0)
                {
                    info[userCount].rz_login  = info[userCount].rz_name.ToUpper();
                    info[userCount].rz_login += "_";
                }
                if (info[userCount].rz_surname.Length > 0)
                {
                    string temp_name = info[userCount].rz_surname.ToLower();
                    info[userCount].rz_login += temp_name[0];
                    if (info[userCount].rz_surname.Length > 1)
                    {
                        info[userCount].rz_login += temp_name[1];
                    }
                }
                if (info[userCount].rz_age > 0)
                {
                    if (info[userCount].rz_surname.Length > 0)
                    {
                        info[userCount].rz_login += "_";
                    }
                    info[userCount].rz_login += info[userCount].rz_age.ToString();
                }

                info[userCount].rz_password = RandomString(password_len);

                Console.WriteLine($"User Login:    {info[userCount].rz_login}");
                Console.WriteLine($"User Password: {info[userCount].rz_password}");

                Console.ReadKey();
            } while (info[userCount].rz_login.Length == 0);
            RZWriteBin(ref info);
            oldInfo = info;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: RustamZakAs/ResumeRZ
        public static void Main(string[] args)
        {
            var info = new RZPersonalInfo[userCount];

            RZMenyu(ref info);
        }