Exemplo n.º 1
0
    private static void AddToPatientList()
    {
        Patient patient = new Patient();
        Console.WriteLine("Enter patient name only capital letters");
        string name = Console.ReadLine();
        patient.FullName = name;
        Console.WriteLine("Enter patient egn ");
        long egn = long.Parse(Console.ReadLine());
        patient.EGN = egn;
        Console.WriteLine("Enter patient age");
        byte age = byte.Parse(Console.ReadLine());
        patient.Age = age;
        Console.WriteLine("Enter doctor name only capital letters");
        string dname = Console.ReadLine();
        patient.DoctorName = dname;
        Console.WriteLine("Enter diagnoses name only capital letters");
        string diagnoses = Console.ReadLine();
        patient.Diagnosis = diagnoses;

        string binFileToStr = BinaryFile.ReadOnBinaryFile("listOFPatient");
        DynamicList dinamicList = new DataArranger(binFileToStr).ListOfPatients;
        IsEGNCorrect(dinamicList, patient);
        dinamicList.Add(patient);
        BinaryFile.WriteOnBinaryFile("listOFPatient", dinamicList);
    }
Exemplo n.º 2
0
    private static void ChangeProperty()
    {
        Console.WriteLine("Write the egn of the patient you want to change.");
        long egn = long.Parse(Console.ReadLine());
        Patient userChoisePatient = new Patient();
        string binFileToStr = BinaryFile.ReadOnBinaryFile("listOFPatient");

        DynamicList dinamicList = new DataArranger(binFileToStr).ListOfPatients;

        for (int i = 0; i < dinamicList.Count; i++)
        {
            Patient patient = dinamicList[i] as Patient;
            if (patient.EGN == egn)
            {
                userChoisePatient = patient;
                dinamicList.Remove(i);
                break;
            }
        }

        Console.WriteLine("Properties that you can change are :");
        Console.WriteLine("-name");
        Console.WriteLine("-age");
        Console.WriteLine("-egn");
        Console.WriteLine("-doctor");
        Console.WriteLine("-diagnosis");
        Console.WriteLine("If you want to change name write name ...");

        string choise = Console.ReadLine();
        if (choise == "name")
        {
            Console.WriteLine("Write the new name");
            userChoisePatient.FullName = Console.ReadLine();
        }
        else if (choise == "age")
        {
            Console.WriteLine("Write the new age");
            userChoisePatient.FullName = Console.ReadLine();
        }
        else if (choise == "egn")
        {
            Console.WriteLine("Write the new egn");
            userChoisePatient.EGN = int.Parse(Console.ReadLine());
        }
        else if (choise == "doctor")
        {
            Console.WriteLine("Write the new doctor");
            userChoisePatient.DoctorName = Console.ReadLine();
        }
        else if (choise == "diagnosis")
        {
            Console.WriteLine("Write the new diagnosis");
            userChoisePatient.Diagnosis = Console.ReadLine();
        }
        else
        {
            throw new ArgumentOutOfRangeException("There is no such property");
        }

        dinamicList.Add(userChoisePatient);
        BinaryFile.WriteOnBinaryFile("listOFPatient", dinamicList);
    }