Пример #1
0
 public NewNoteType(NotesType Typenoteform)
 {
     InitializeComponent();
     this.Typenoteform = Typenoteform;
     Switcher.pageSwitchweNotetypes = this;
     this.Init();
 }
Пример #2
0
        private void Savenotetipe_Click(object sender, RoutedEventArgs e)
        {
            if (txtNoteType.Text == "" || txtDescription.Text == "")
            {
                MessageBox.Show("please fill in the blank fields", ("Form Validation"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            //display the dialog the first time the Save button is clicked only:
            if (string.IsNullOrEmpty(choosenFileName))
            {
                SaveFileDialog saveFile = new SaveFileDialog();
                saveFile.Filter = "RichText Files (*.rtf)|*.rtf|All Files (*.*)|*.*";
                if (saveFile.ShowDialog() != true)
                {
                    return;
                }
                choosenFileName = saveFile.FileName;
            }

            // Create a TextRange around the entire document.
            TextRange documentTextRange = new TextRange(
                Note.Document.ContentStart, Note.Document.ContentEnd);

            // If this file exists, it's overwritten.
            using (FileStream fs = File.Create(choosenFileName))
            {
                if (System.IO.Path.GetExtension(choosenFileName).ToLower() == ".rtf")
                {
                    documentTextRange.Save(fs, DataFormats.Rtf);
                }
                else
                {
                    documentTextRange.Save(fs, DataFormats.Xaml);
                }
                this.file = choosenFileName;
            }

            NoteTypeBLL NoteTypeBLL = new NoteTypeBLL();

            if (this.Typenoteform.isEdit == false)
            {
                if (NoteTypeBLL.AddNoteType(this.GetData()) > 0)
                {
                    this.ClearForm();
                    MessageBox.Show("Note Type successfully added !");
                    this.Typenoteform.LoadNoteType();
                }
                else
                {
                    MessageBox.Show("Note Type failed to add !");
                }
            }
            else
            {
                if (NoteTypeBLL.EditNoteType(this.GetData()) == true)
                {
                    this.ClearForm();
                    MessageBox.Show("Document changed successfully !");
                    this.Typenoteform.LoadNoteType();
                }
                else
                {
                    MessageBox.Show("Document failed to change !");
                }
            }
            NotesType v = new NotesType();

            Switcher.Switchnotetypes(v);
        }
Пример #3
0
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            NotesType v = new NotesType();

            Switcher.Switchnotetypes(v);
        }