public AddEditHallForm(MenuForm menuForm, CinemasHallsForm cinemasHallsForm, string cinemaName, string cinemaLocation, int cinemaId, int?hallId = null) { InitializeComponent(); _menuForm = menuForm; _cinemaId = cinemaId; _hallId = hallId; _cinemasHallsForm = cinemasHallsForm; _cinemaName = cinemaName; _cinemaLocation = cinemaLocation; this.StartPosition = FormStartPosition.Manual; this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - 20 - this.Width, Screen.PrimaryScreen.Bounds.Height - this.Height - saveBtn.Height - 20); }
private async void dgvHalls_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { var hallId = dgvHalls.Rows[e.RowIndex].Cells["HallId"].Value; var action = dgvHalls.Columns[e.ColumnIndex].Name; var hallApi = new APIService("halls"); var hall = await hallApi.GetById <Model.Hall>(hallId); CustomMessageBox messageBox = new CustomMessageBox(); if (action == "Edit") { AddEditHallForm form = new AddEditHallForm(_menuForm, this, _cinemaName, _cinemaLoactin, _cinemaId, int.Parse(hallId.ToString())) { }; form.Show(); form.Opacity = 0; while (form.Opacity < 1.0) { await Task.Delay(15); form.Opacity += 0.05; } form.Opacity = 1; } else if (action == "Delete") { DialogResult dialogResult = MessageBox.Show($"Are you sure you want to delete the hall '{hall.HallName} {hall.HallNumber}' in '{_cinemaName}'?", "Delete hall", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Helper helper = new Helper(); await hallApi.Delete <Model.Hall>(hallId); helper.CloseForm(this, 15); CinemasHallsForm form = new CinemasHallsForm(_menuForm, _cinemaId, _cinemaName, _cinemaLoactin); helper.ShowForm(form, 15); messageBox.Show("Hall deleted successfully", "success"); } } } }
private async void saveBtn_Click(object sender, EventArgs e) { var messageBox = new CustomMessageBox(); if (string.IsNullOrWhiteSpace(HallName.Text) || HallName.Text.Length < 4) { messageBox.Show("The hall name field requires 4 letters!", "error"); return; } if (HallNumber.Value < 1 || HallNumber.Value > 100) { messageBox.Show("Enter a valid hall number (1-100)!", "error"); return; } if (HallSeats.Value < 1 || HallSeats.Value > 100) { messageBox.Show("Enter valid seats (1-100)!", "error"); return; } Model.Requests.InsertHallRequest hall = new Model.Requests.InsertHallRequest() { HallName = HallName.Text, HallNumber = (int)HallNumber.Value, NumberOfseats = (int)HallSeats.Value, CinemaId = _cinemaId }; if (_hallId.HasValue) { await _apiService.Update <Model.Hall>(_hallId, hall); messageBox.Show("Hall updated succesfully", "Success"); } else { await _apiService.Insert <Model.Hall>(hall); messageBox.Show("Hall added succesfully", "Success"); } CinemasHallsForm form = new CinemasHallsForm(_menuForm, _cinemaId, _cinemaName, _cinemaLocation); _cinemasHallsForm.Close(); while (this.Opacity > 0.0) { await Task.Delay(15); this.Opacity -= 0.05; } this.Opacity = 0; this.Close(); form.Show(); form.Opacity = 0; while (form.Opacity < 1.0) { await Task.Delay(15); form.Opacity += 0.05; } form.Opacity = 1; }