Beispiel #1
0
        private void OnToolbarItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            //Toolbar handler - forward to main menu handler
            long id = 0;

            Issue.Action     action     = null;
            Issue.Attachment attachment = null;
            try {
                //Get the current action
                id     = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name);
                action = this.mIssue.Item(id);
                switch (e.ClickedItem.Name)
                {
                case "btnNew":  this.ctxActionsNew.PerformClick(); break;

                case "btnPrint": this.ctxActionsPrint.PerformClick();  break;

                case "btnRefresh": this.ctxRefresh.PerformClick(); break;

                case "btnOpen":
                    //Open the selected attachment
                    attachment = action.Item(this.lsvAttachments.SelectedItems[0].Text);
                    attachment.Open();
                    break;

                case "btnAttach":
                    //Save an attachment to the selected action
                    OpenFileDialog dlgOpen = new OpenFileDialog();
                    dlgOpen.AddExtension = true;
                    dlgOpen.Filter       = "All Files (*.*) | *.*";
                    dlgOpen.FilterIndex  = 0;
                    dlgOpen.Title        = "Select Attachment to Save...";
                    dlgOpen.FileName     = "";
                    if (dlgOpen.ShowDialog(this) == DialogResult.OK)
                    {
                        attachment          = action.Item(0);
                        attachment.Filename = dlgOpen.FileName;
                        attachment.Save();
                        OnActionSelected(null, EventArgs.Empty);
                    }
                    break;

                case "btnSend":
                    if (this.lsvActions.SelectedItems.Count > 0)
                    {
                        //Create new mail item
                        if (OutlookApp == null)
                        {
                            return;
                        }
                        Outlook.MailItem item = (Outlook.MailItem)OutlookApp.CreateItem(Outlook.OlItemType.olMailItem);
                        item.Subject = this._Issue.Subject;
                        item.Body    = action.Comment;
                        item.To      = EnterpriseFactory.GetContact(this._Issue.ContactID).Email;
                        item.Display(false);
                    }
                    break;
                }
            }
            catch (Exception ex) { reportError(new ControlException("Unexpected error in IssueInspector.", ex)); }
        }