Пример #1
0
 private void btnEditGroup_Click(object sender, System.EventArgs e)
 {
     if (!this.bwLoadAddresses.get_IsBusy())
     {
         AreaGroup group = (AreaGroup) this.listGroups.get_SelectedItem();
         if ((group == null) || (group.Id == -1L))
         {
             Messages.ShowMessage("Выберите группу для редактирования!");
         }
         else
         {
             EnterNameForm form = new EnterNameForm(group.Name);
             if ((form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) && (form.EnteredName != group.Name))
             {
                 group.Name = form.EnteredName;
                 try
                 {
                     group.SaveChanges();
                 }
                 catch (System.Exception exception)
                 {
                     Messages.ShowException(this, exception);
                     return;
                 }
                 this.SetGroups(AreaGroup.FindAll());
                 Messages.ShowMessage("Изменения в группе сохранены.");
             }
             form.Dispose();
         }
     }
 }
Пример #2
0
 private void btnAddGroup_Click(object sender, System.EventArgs e)
 {
     if (!this.bwLoadAddresses.get_IsBusy())
     {
         EnterNameForm form = new EnterNameForm();
         if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
         {
             AreaGroup group = new AreaGroup {
                 Name = form.EnteredName
             };
             try
             {
                 group.SaveChanges();
             }
             catch (System.Exception exception)
             {
                 Messages.ShowException(this, exception);
                 return;
             }
             this.SetGroups(AreaGroup.FindAll());
             Messages.ShowMessage("Создана группа \"" + group.Name + "\".");
         }
         form.Dispose();
     }
 }
Пример #3
0
 private void btnEditArea_Click(object sender, System.EventArgs e)
 {
     if (!this.bwLoadAddresses.get_IsBusy())
     {
         Area area = (Area) this.listAreas.get_SelectedItem();
         if ((area == null) || (area.Id == -1L))
         {
             Messages.ShowMessage("Выберите набор адресов для редактирования!");
         }
         else
         {
             EnterNameForm form = new EnterNameForm(area.Name, area.Id);
             if ((form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) && (form.EnteredName != area.Name))
             {
                 area.Name = form.EnteredName;
                 try
                 {
                     area.SaveChanges();
                 }
                 catch (System.Exception exception)
                 {
                     Messages.ShowException(this, exception);
                     return;
                 }
                 AreaGroup group = (AreaGroup) this.listGroups.get_SelectedItem();
                 if ((group != null) && (group.Id != -1L))
                 {
                     this.SetAreas(group.GetAreas());
                 }
                 else
                 {
                     this.SetAreas(Area.FindAllUserAndNotEmptyName());
                 }
                 Messages.ShowMessage("Изменения в группе сохранены.");
             }
             form.Dispose();
         }
     }
 }
Пример #4
0
 private void btnAddArea_Click(object sender, System.EventArgs e)
 {
     if (!this.bwLoadAddresses.get_IsBusy())
     {
         EnterNameForm form = new EnterNameForm();
         if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
         {
             Area area = new Area();
             AreaGroup group = (AreaGroup) this.listGroups.get_SelectedItem();
             area.Name = form.EnteredName;
             if ((group != null) && (group.Id != -1L))
             {
                 area.AreaGroupId = ((AreaGroup) this.listGroups.get_SelectedItem()).Id;
             }
             try
             {
                 area.SaveChanges();
             }
             catch (System.Exception exception)
             {
                 Messages.ShowException(this, exception);
                 return;
             }
             if ((group != null) && (group.Id != -1L))
             {
                 this.SetAreas(group.GetAreas());
             }
             else
             {
                 this.SetAreas(Area.FindAllUserAndNotEmptyName());
             }
             Messages.ShowMessage("Создан набор адресов \"" + area.Name + "\".");
         }
         form.Dispose();
     }
 }