Beispiel #1
0
        private void Save(object window)
        {
            var validationResult = Validator.ValidateAll();

            if (validationResult.IsValid)
            {
                document.Name      = Name;
                document.Tag       = Tag;
                document.IssueDate = IssueDate;
                if (document.RelativePath == null)
                {
                    document.RelativePath = FileAccess.Add(RelativePath, FileType.Document);
                }
                else if (document.RelativePath != RelativePath)
                {
                    FileAccess.Delete(document.RelativePath);
                    document.RelativePath = FileAccess.Add(RelativePath, FileType.Document);
                }

                if (document.Id == 0)
                {
                    document = UnitOfWork.Documents.Add(document);
                }

                if (UnitOfWork.Complete() > 0)
                {
                    ((Window)window).DialogResult = true;
                }

                ((Window)window).Close();
            }
        }
Beispiel #2
0
        private void UploadTemplate(object templateType)
        {
            try
            {
                switch ((TemplateType)templateType)
                {
                case TemplateType.Offer:
                    Properties.Settings.Default.OfferTemplatePath =
                        FileAccess.Add(Offer, FileType.Template);
                    break;

                case TemplateType.Confirmation:
                    Properties.Settings.Default.ConfirmationTemplatePath =
                        FileAccess.Add(Confirmation, FileType.Template);
                    break;

                case TemplateType.Invoice:
                    Properties.Settings.Default.InvoiceTemplatePath =
                        FileAccess.Add(Invoice, FileType.Template);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(templateType), templateType, null);
                }
                Properties.Settings.Default.Save();
                MessageBox.Show("Vorlage erfolgreich hochgeladen.");
            }
            catch (IOException)
            {
                MessageBox.Show(
                    "Ein Fehler ist aufgetreten. Bitte vergewissern Sie sich, dass das Dokument " +
                    "nicht von einem anderen Programm geöffnet ist und Sie die Leserechte dafür besitzen.");
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Bitte wählen Sie eine Word-Datei aus.");
            }
            catch (ArgumentException e)
            {
                MessageBox.Show(e.Message);
            }
        }