Exemplo 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();
                    }
                }
            }
        }
        private async Task DoWork()
        {
            await Task.Run(() =>
            {
                for (int i = 0; i <= 100; i++)
                {
                    test = i;
                    Thread.Sleep(100);
                }

                messageBox = BinarySerialization.ReadFromBinaryFile <ObservableCollection <BaseMessage> >(@"C:\Users\X\Desktop\Lab\Test.bin");
                OnPropertyChanged("MyList");
            });
        }
 private void LContacts()
 {
     contactBook = BinarySerialization.ReadFromBinaryFile <ObservableCollection <string> >(@"C:\Users\X\Desktop\Lab\contacts.bin");
     OnPropertyChanged("ContactList");
 }