public VagAcceptForm(Station station, SendingPoint sentFrom, bool sideActiv) { InitializeComponent(); vagAcceptDialogPresenter = new VagAcceptDialogPresenter(this); this.sentFrom = sentFrom; this.station = station; cbSide.Enabled = sideActiv; vagAcceptDialogPresenter.loadInitValues(); }
private void buttonSave_Click(object sender, EventArgs e) { StorePlace editedStorePlace = null; Address address; try { var apartmentNumber = Int32.Parse(textBoxApartmentNumber.Text); if (apartmentNumber < 0) { throw new FormatException(); } address = new Address { City = textBoxCity.Text, PostCode = textBoxPostCode.Text, Street = textBoxStreet.Text, HomeNumber = textBoxHomeNumber.Text, ApartmentNumber = apartmentNumber }; } catch (FormatException ex) { MessageBox.Show("Numer domu jest nieujemną liczbą typu całkowitego. Wprowadzono nieprawidłową wartość.", "Nieprawidłowa wartość", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } switch (comboBoxStorePlaceType.SelectedIndex) { case 0: editedStorePlace = new Warehouse() { Name = textBoxStorePlaceName.Text, Address = address, ManagerName = textBoxWarehouseManagerName.Text, Type = 0 }; break; case 1: editedStorePlace = new SendingPoint() { Name = textBoxStorePlaceName.Text, Address = address, WorkersCount = (int)counterStorePlaceWorkersCount.Value, Type = 1 }; break; } if (storePlace.Type == -1) { _storePlaceController.AddStoreplace(editedStorePlace); } else { editedStorePlace.Id = storePlace.Id; editedStorePlace.AddressId = storePlace.AddressId; editedStorePlace.Address.Id = storePlace.AddressId; _storePlaceController.UpdateStoreplace(editedStorePlace); } this.Close(); }