public void AddGroupOrSets(AreaGroup groupSets, ObjectList<Area> area) { foreach (Area area2 in area) { Area area3 = new Area(); AreaGroup group = groupSets; area3.Name = area2.Name; if ((groupSets != null) && (groupSets.Id != -1L)) { area3.AreaGroupId = group.Id; } try { area3.SaveChanges(); area3.SaveAddresses(area2.GetAddresses()); } catch (System.Exception exception) { Messages.ShowException(this, exception); break; } if ((area2 != null) && (area2.Id != -1L)) { this.SetAreas(group.GetAreas()); } } }
private void SetGroups(ObjectList<AreaGroup> groups) { this.bsGroups.set_DataSource(new ObjectList<AreaGroup>()); AreaGroup group = new AreaGroup { Id = -1L, Name = "<не выбрано>" }; ((ObjectList<AreaGroup>) this.bsGroups.get_DataSource()).Add(group); ((ObjectList<AreaGroup>) this.bsGroups.get_DataSource()).AddRange(groups); this.lblGroupCounter.set_Text("Всего групп: " + ((int) groups.get_Count())); }
private void copyGroup() { if (((AreaGroup) this.listGroups.get_SelectedItem()).Name != "<не выбрано>") { this.areaGroup = (AreaGroup) this.listGroups.get_SelectedItem(); } }
private void insertGroup() { AreaGroup groupSets = new AreaGroup { Name = this.areaGroup.Name }; try { groupSets.SaveChanges(); this.AddGroupOrSets(groupSets, this.areaGroup.GetAreas()); } catch (System.Exception exception) { Messages.ShowException(this, exception); return; } this.SetGroups(AreaGroup.FindAll()); }
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(); } }