Ejemplo n.º 1
0
        private void Next(object sender, RoutedEventArgs e)
        {
            _nId = TextBox.Text;
            String   s1       = path + "\\" + _nId + ".bin";
            Checking checking = new Checking("ID", TextBox.Text);

            if (checking.EmptyCheck() && checking.IdLength() && checking.IdCheck())
            {
                if (_mode == 1)
                {
                    if (!File.Exists(@s1))
                    {
                        AdditionForm additionForm = new AdditionForm(_nId, s1);
                        additionForm.Show();
                        this.Close();
                    }
                    else
                    {
                        Errors errors = new Errors("file already exists !");
                        errors.Show();
                    }
                }
                else
                {
                    if (File.Exists(@s1))
                    {
                        Patient patient2 = BinarySerialization.ReadFromBinaryFile <Patient>(@s1);
                        if (_mode == 2)
                        {
                            Editting editting = new Editting(patient2, s1);
                            editting.Show();
                            this.Close();
                        }
                        if (_mode == 3)
                        {
                            Removing removing = new Removing(_nId, patient2, s1);
                            removing.Show();
                            this.Close();
                        }

                        if (_mode == 4)
                        {
                            Show show = new Show(patient2);
                            show.Show();
                            this.Close();
                        }
                    }
                    else
                    {
                        Errors errors = new Errors("file dose not exist!");
                        errors.Show();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void Next(object sender, RoutedEventArgs e)
 {
     if (!File.Exists(@s1))
     {
         Checking c1 = new Checking("name", Name1.Text);
         Checking c2 = new Checking("last name ", LastName.Text);
         Checking c3 = new Checking("doctors name", DoctorsName.Text);
         Checking c4 = new Checking("disease", Disease.Text);
         Checking c5 = new Checking("age", Age.Text);
         Checking c6 = new Checking("", Age.Text);
         Checking c7 = new Checking("medication field", Medications.Text);
         bool     b1, b2, b3, b4, b5, b6, b7;
         b1 = c1.EmptyCheck();
         b2 = c2.EmptyCheck();
         b3 = c3.EmptyCheck();
         b4 = c4.EmptyCheck();
         b5 = c5.EmptyCheck();
         b6 = c6.AgeCheck();
         b7 = c7.EmptyCheck();
         if (b1 && b2 && b3 && b4 && b5 && b6 && b7)
         {
             Patient patient = new Patient();
             patient.nId               = Id.Text;
             patient.name              = Name1.Text;
             patient.lastName          = LastName.Text;
             patient.doctorsName       = DoctorsName.Text;
             patient.disease           = Disease.Text;
             patient.medications       = Medications.Text;
             patient.age               = Int32.Parse(Age.Text);
             patient.receptionDateTime = DateTime.Now;
             BinarySerialization.WriteToBinaryFile(@s1, patient);
             Errors errors = new Errors("successfully saved !");
             this.Close();
             MainWindow mainWindow = new MainWindow();
             mainWindow.Show();
             errors.Show();
         }
     }
     else
     {
         Errors errors = new Errors("already exists !!!!");
         errors.Show();
     }
 }