private void btnChangeProperty_Click(object sender, EventArgs e) { if (form != null) { InputDialog caid = new InputDialog("Cadastral area id:"); caid.onDispose += (caID) => { if (Int32.TryParse(caID, out int caIDint)) { CadastralArea ca = new CadastralArea(caIDint); ca = this.form.FindCadastralArea(new CadastralAreaByID(ca)); if (ca != null) { InputDialog pid = new InputDialog("Property id:"); pid.onDispose += (pID) => { Property p = ca.FindProperty(pID); if (p != null) { InputDialog ownerId = new InputDialog("New owner (person.id):"); ownerId.onDispose += (newOwnerID) => { Person per = new Person(newOwnerID); per = form.FindPerson(per); if (per != null) { p.ChangeOwner(this.Person, per); } else { MessageBox.Show("Could not find this person/owner"); } }; ownerId.ShowDialog(); } else { MessageBox.Show("Could not find this property"); } }; pid.ShowDialog(); } else { MessageBox.Show("This cadastral area doesn't exist"); } } else { MessageBox.Show("Input value has to be integer"); } }; caid.ShowDialog(); } }
private void btnChangeAddress_Click(object sender, EventArgs e) { if (form != null) { InputDialog caid = new InputDialog("Cadastral area id:"); caid.onDispose += (caID) => { if (Int32.TryParse(caID, out int caIDint)) { CadastralArea ca = new CadastralArea(caIDint); ca = this.form.FindCadastralArea(new CadastralAreaByID(ca)); if (ca != null) { InputDialog pid = new InputDialog("Property id:"); pid.onDispose += (pID) => { Property p = ca.FindProperty(pID); if (p != null) { p.AddOccupant(this.Person); this.inputAddress.Text = p.Address; } else { MessageBox.Show("Could not find this property"); } }; pid.ShowDialog(); } else { MessageBox.Show("This cadastral area doesn't exist"); } } else { MessageBox.Show("Input value has to be integer"); } }; caid.ShowDialog(); } }
private void btnFind_Click(object sender, EventArgs e) { switch (comboTypes.SelectedIndex) { case 0: // Persons Person p = this.Program.Find(new Person(textSearch.Text)); if (p == null) { goto Error; } PersonView pv = new PersonView(p, this); pv.onDispose += (person) => { p = person; }; pv.ShowDialog(); goto Finish; case 1: // Cadastral Area CadastralArea c = null; if (Int32.TryParse(textSearch.Text, out int search)) { c = new CadastralArea(search); c = this.Program.Find(new CadastralAreaByID(new CadastralArea(search))); } else { c = new CadastralArea(0, textSearch.Text); c = this.Program.Find(new CadastralAreaByName(c)); } if (c == null) { goto Error; } CadastralView cv = new CadastralView(c); cv.onDispose += (cArea, oldName) => { if (oldName != c.Name) { this.Program.UpdateCadastralArea(c, oldName); } }; cv.ShowDialog(); goto Finish; case 2: // Property list InputDialog id = new InputDialog("Catastral area:"); id.onDispose += (caId) => { if (caId != "") { CadastralArea ca = null; if (Int32.TryParse(caId, out int s)) { ca = this.Program.Find(new CadastralAreaByID(new CadastralArea(s, ""))); } else { ca = this.Program.Find(new CadastralAreaByName(new CadastralArea(0, caId))); } if (ca != null) { PropertyList pl = ca.FindPropertyList(textSearch.Text); if (pl == null) { MessageBox.Show("Property list with this id does not exist"); } else { PropertyListView plv = new PropertyListView(pl, this); plv.ShowDialog(); } } else { MessageBox.Show("Cadastral area with this id/name does not exist"); } } else { MessageBox.Show("You have to write something"); } }; id.ShowDialog(); goto Finish; case 3: // Property InputDialog id2 = new InputDialog("Catastral area:"); id2.onDispose += (caId) => { if (caId != "") { CadastralArea ca = null; if (Int32.TryParse(caId, out int s)) { ca = this.Program.Find(new CadastralAreaByID(new CadastralArea(s, ""))); } else { ca = this.Program.Find(new CadastralAreaByName(new CadastralArea(0, caId))); } if (ca != null) { Property prop = ca.FindProperty(textSearch.Text); if (prop == null) { MessageBox.Show("Property with this id does not exist"); } else { PropertyView propv = new PropertyView(prop); propv.ShowDialog(); } } else { MessageBox.Show("Cadastral area with this id/name does not exist"); } } else { MessageBox.Show("You have to write something"); } }; id2.ShowDialog(); goto Finish; } Error: MessageBox.Show("Could not find specified item"); Finish :; }