예제 #1
0
파일: TheBook.cs 프로젝트: darkarki83/.NET
        public void AddClient(object sender, ChoiceEventArgs e)
        {
            Client.InputClient(out client);
            one.Add(client);

            Console.WriteLine("New Client Added");
        }
예제 #2
0
        static public void Load(PhoneBook phoneBook)
        {
            BinaryReader dataIn;

            try
            {
                dataIn = new BinaryReader(
                    new FileStream("SaveBook.dat", FileMode.Open));
            }
            catch (IOException exc)
            {
                Console.WriteLine("Cannot Open SaveBook File For Input");
                Console.WriteLine("Reason: " + exc.Message);
                return;
            }
            try
            {
                phoneBook.Count = dataIn.ReadInt32();

                Client client = new Client();

                for (int i = 0; i < phoneBook.Count; i++)
                {
                    client.firstName  = dataIn.ReadString();
                    client.lastName   = dataIn.ReadString();
                    client.foneNumber = dataIn.ReadInt32();
                    client.adress     = dataIn.ReadString();
                    phoneBook.Add(client);
                    phoneBook.Count--;
                }
            }
            catch (IOException exc)
            {
                Console.WriteLine("Error Reading Inventory File");
                Console.WriteLine("Reason: " + exc.Message);
            }
            finally
            {
                dataIn.Close();
            }
        }