Exemple #1
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);
    }
Exemple #2
0
    private static void RemovePatient()
    {
        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;
            }
        }

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