示例#1
0
 private void mnuRemove_Click(object sender, EventArgs e)
 {
     if (tabControl1.SelectedIndex == 0)//datagridView
     {
         CeUserNotificationsClass.EventEntry cNot = new CeUserNotificationsClass.EventEntry();
         if (dataGrid1.CurrentRowIndex != -1)
         {
             CeUserNotificationsClass.EventEntry[] _entry = (CeUserNotificationsClass.EventEntry[])dataGrid1.DataSource;
             cNot = _entry[dataGrid1.CurrentRowIndex];
             if (MessageBox.Show("Are you sure to delete '" + cNot.sApp + "'?", "Remove Entry", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.No)
             {
                 return;
             }
             int iCnt = clsNoti.deleteEntry(cNot);
             if (iCnt > 0)
             {
                 MessageBox.Show("Number of deleted entries: " + iCnt.ToString());
                 fillList();
                 //dataGrid1.Refresh();
             }
             else
             {
                 MessageBox.Show("Nothing deleted");
             }
         }
     }
     else if (tabControl1.SelectedIndex == 1)//treeView
     {
         TreeNode tn = this.treeView1.SelectedNode;
         if (tn == null)
         {
             return;
         }
         UserNotificationInfoHeader userNotification = getNotiHandleOfTreeView(tn);
         if (userNotification == null)
         {
             return; //not found
         }
         if (MessageBox.Show("Are you sure to delete '" + userNotification.UserNotificationTrigger.Application + "'?", "Remove Entry", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.No)
         {
             return;
         }
         bool bRes = CEGETUSERNOTIFICATION.CeGetUserNotification.ClearUserNotification((IntPtr)userNotification.hNotification);
         if (bRes)
         {
             MessageBox.Show("Deleted entry: " + userNotification.UserNotificationTrigger.Application);
             fillList();
             //dataGrid1.Refresh();
         }
         else
         {
             MessageBox.Show("Nothing deleted");
         }
     }
 }
 private void mnuRemove_Click(object sender, EventArgs e)
 {
     if (tabControl1.SelectedIndex == 0)//datagridView
     {
         CeUserNotificationsClass.EventEntry cNot = new CeUserNotificationsClass.EventEntry();
         if (dataGrid1.CurrentRowIndex != -1)
         {
             CeUserNotificationsClass.EventEntry[] _entry = (CeUserNotificationsClass.EventEntry[])dataGrid1.DataSource;
             cNot = _entry[dataGrid1.CurrentRowIndex];
             if (MessageBox.Show("Are you sure to delete '" + cNot.sApp + "'?", "Remove Entry", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.No)
                 return;
             int iCnt = clsNoti.deleteEntry(cNot);
             if (iCnt > 0)
             {
                 MessageBox.Show("Number of deleted entries: " + iCnt.ToString());
                 fillList();
                 //dataGrid1.Refresh();
             }
             else
                 MessageBox.Show("Nothing deleted");
         }
     }
     else if (tabControl1.SelectedIndex == 1)//treeView
     { 
         TreeNode tn = this.treeView1.SelectedNode;
         if (tn == null)
             return;
         UserNotificationInfoHeader userNotification = getNotiHandleOfTreeView(tn);
         if (userNotification == null)
             return; //not found
         if (MessageBox.Show("Are you sure to delete '" + userNotification.UserNotificationTrigger.Application + "'?", "Remove Entry", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.No)
             return;
         bool bRes = CEGETUSERNOTIFICATION.CeGetUserNotification.ClearUserNotification((IntPtr)userNotification.hNotification);
         if (bRes)
         {
             MessageBox.Show("Deleted entry: " + userNotification.UserNotificationTrigger.Application);
             fillList();
             //dataGrid1.Refresh();
         }
         else
             MessageBox.Show("Nothing deleted");
     }
 }