示例#1
0
        private void OnMenuClick(object sender, System.EventArgs e)
        {
            //Event handler fo menu item clicked
            try {
                ToolStripDropDownItem menu = (ToolStripDropDownItem)sender;
                switch (menu.Text)
                {
                case MNU_NEW: break;

                case MNU_OPEN:
                    dlgContact dlg = new dlgContact(this.mContact);
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (CustomerProxy.UpdateContact(this.mContact))
                        {
                            this.ctxRefresh.PerformClick();
                        }
                    }
                    break;

                case MNU_REFRESH:
                    this.Cursor = Cursors.WaitCursor;
                    this.mContactDS.Clear();
                    this.mContactDS.Merge(CustomerProxy.GetContacts());
                    break;
                }
            }
            catch (Exception ex) { reportError(ex); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }
示例#2
0
 private void OnNewContact(object sender, EventArgs e)
 {
     //Event handler for new contact button clicked
     try {
         //Create a new (blank) contact and allow client to update it before displaying it
         Contact contact = new Contact();
         if (this.BeforeContactCreated != null)
         {
             this.BeforeContactCreated(this, new ContactEventArgs(contact));
         }
         dlgContact dlg = new dlgContact(contact);
         dlg.Font = this.Font;
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             //Notify client of new contact (client responsible for persistence)
             if (this.AfterContactCreated != null)
             {
                 this.AfterContactCreated(this, new ContactEventArgs(contact));
             }
         }
     }
     catch (Exception ex) { reportError(new ControlException("Unexpected error while creating new contact.", ex)); }
 }