public void CreatePerson(Packet templatePacket = null) { FormMode = Mode.Create; saveDialogResult = DialogResult.None; btnClose.Visible = true; _templatePacket = templatePacket; }
internal void EditPacket(BL.Packet packet) { passedPacket = packet; linkedPacket = new Packet(); linkedPacket.Merge(passedPacket); _linker.LinkObjectToControl(this, linkedPacket); }
public void EditPerson(Person person, Packet templatePacket = null) { _person = person; if (templatePacket != null) if (templatePacket.TemplatePerson != null) _person.MergeBlanks(templatePacket.TemplatePerson); FormMode = Mode.Edit; btnClose.Visible = false; saveDialogResult = DialogResult.OK; }
internal void Merge(Packet otherPacket) { var tempId = Id; var fieldInfos = GetType().GetFields(); foreach (var info in fieldInfos) { var val = info.GetValue(otherPacket); if (val == null) continue; if (info.FieldType == typeof(Person)) { var otherPerson = (Person) val; var newPerson = new Person(); newPerson.Merge(otherPerson, true); info.SetValue(this, newPerson); continue; } if (string.IsNullOrEmpty(val.ToString())) continue; info.SetValue(this, val); } Id = tempId; }
private void CreateNewPacket() { var newPacketNameTemplate = "Пакет №"; var n = 1; string newPacketName; do { newPacketName = newPacketNameTemplate + n; n++; } while (PacketStorage.Instance.PacketExists(newPacketName)); var packet = new Packet(newPacketName); if (!EditPacket(packet)) return; PacketStorage.Instance.Save(packet); packetsList.Items.Add(packet); packetsList.SelectedItem = packet; }
private void packetsList_SelectedIndexChanged(object sender, EventArgs e) { _currentPacket = packetsList.SelectedItem as Packet; currentPacketList.Items.Clear(); if (_currentPacket == null) { CreateNewPacket(); return; } var range = _currentPacket.EnumPersons(personsList.Items).ToArray(); if (range.Any()) currentPacketList.Items.AddRange(range); }
private bool EditPacket(Packet packet) { if (packet == null) throw new ArgumentNullException("packet"); var form = new PacketForm(); form.EditPacket(packet); if (form.ShowDialog() != DialogResult.OK) return false; PacketStorage.Instance.Save(packet); return true; }