Пример #1
0
        /// <summary>
        /// change receiver info
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            try {
                using (var objProvider = new MailProvider()) {
                    Receiver objReceiver = objProvider.GetReceiver((int)treeView1.SelectedNode.Tag, treeView1.SelectedNode.Name);
                    if (objReceiver != null)
                    {
                        if (textBox1.Text == String.Empty || textBox2.Text == String.Empty)
                        {
                            throw new ArgumentNullException("Receiver.Name or Receiver.Email");
                        }

                        objReceiver.Name  = textBox1.Text;
                        objReceiver.Email = textBox2.Text;
                        objReceiver.Group = objProvider.GetGroupByName(comboBox2.SelectedItem.ToString());
                        //clear fileds
                        textBox1.Clear();
                        textBox2.Clear();
                    }
                }
                UpdateTree();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
 /// <summary>
 /// change group info
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button4_Click(object sender, EventArgs e)
 {
     try {
         using (var objProvider = new MailProvider()) {
             Group objGroup = objProvider.GetGroupByName(comboBox2.SelectedItem.ToString());
             if (objGroup != null)
             {
                 if (textBox3.Text == String.Empty)
                 {
                     throw new ArgumentNullException("Group Name");
                 }
                 objGroup.Name = textBox3.Text;
                 objProvider.SaveChanges();
                 comboBox2.Items.Clear();
                 comboBox2.Items.AddRange(objProvider.GetAllGroups().ToArray());
             }
         }
         UpdateTree();
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }