示例#1
0
        private void addAttachmentMenuItem_Click(object sender, EventArgs e)
        {
            using (var dialog = new OpenFileDialog())
            {
                dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                dialog.RestoreDirectory = true;
                dialog.Multiselect      = true;

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    StatusObject addAttachmentStatus;
                    using (var oH = new ObjectHelper(_dbSettings, _user))
                    {
                        addAttachmentStatus = oH.AddAttachmentsToRecord(_record, dialog.FileNames);
                    }

                    if (addAttachmentStatus != null)
                    {
                        RefreshRecord();
                        if (!addAttachmentStatus.Success)
                        {
                            NotificationHelper.ShowNotification(this, NotificationHelper.NotificationType.Warning,
                                                                "Failed to add attachment to this record.");
                        }
                    }
                }
                BringToFront();
            }
        }