private void BackButton_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show(Constants.WarningMessages.UnsavedChanges, Constants.GoBackPrompt, MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { CinemasForm cinemasForm = new CinemasForm(); cinemasForm.TopLevel = false; cinemasForm.AutoScroll = true; this.Hide(); ((Button)sender).Parent.Parent.Controls.Add(cinemasForm); cinemasForm.Show(); } }
private void ShowCinemasBtn_Click(object sender, EventArgs e) { foreach (Form frm in this.MdiChildren) { frm.Close(); } CinemasForm form = new CinemasForm { MdiParent = this, Dock = DockStyle.Fill }; form.Show(); Slider.Height = ShowCinemasBtn.Height; Slider.Top = ShowCinemasBtn.Top; }
private void DeleteCinemaButton_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show(Constants.DeleteCinemaMessage, Constants.CategoryDeletePrompt, MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { try { cinemaService.RemoveCinema(cinema.Name, cinema.Town.Name); MessageBox.Show(Constants.SuccessMessages.CinemaDeletedSuccessfully); CinemasForm cinemasForm = new CinemasForm(); cinemasForm.TopLevel = false; cinemasForm.AutoScroll = true; this.Hide(); ((Button)sender).Parent.Parent.Controls.Add(cinemasForm); cinemasForm.Show(); } catch (Exception) { MessageBox.Show(Constants.ErrorMessages.CinemaDeleteMessage); } } }
private void EditCinemaButton_Click(object sender, EventArgs e) { string oldCinemaName = cinema.Name; string oldTownName = cinema.Town.Name; string newCinemaName = this.CinemaName.Text; string newTownName = this.TownName.Text; try { cinemaService.UpdateCinema(oldCinemaName, oldTownName, newCinemaName, newTownName); MessageBox.Show(Constants.SuccessMessages.CinemaUpdatedSuccessfully); CinemasForm cinemasForm = new CinemasForm(); cinemasForm.TopLevel = false; cinemasForm.AutoScroll = true; this.Hide(); ((Button)sender).Parent.Parent.Controls.Add(cinemasForm); cinemasForm.Show(); } catch (Exception) { MessageBox.Show(Constants.ErrorMessages.CinemaUpdateErrorMessage); } }
private async void SaveBtn_Click(object sender, EventArgs e) { var messageBox = new CustomMessageBox(); if (string.IsNullOrWhiteSpace(Cinema.Text) || Cinema.Text.Length < 4) { messageBox.Show("The cinema field requires 4 letters!", "error"); return; } if (string.IsNullOrWhiteSpace(Address.Text) || Address.Text.Length < 5) { messageBox.Show("The address field requires 5 letters!", "error"); return; } if (string.IsNullOrWhiteSpace(Location.Text) || Location.Text.Length < 4) { messageBox.Show("The location field requires 4 letters!", "error"); return; } if (StreetNumber.Value <= 0 || StreetNumber.Value > 100) { messageBox.Show("Enter a valid street number (1-100)!", "error"); return; } if (string.IsNullOrWhiteSpace(Description.Text) || Description.Text.Length < 5) { messageBox.Show("The description field requires 5 letters!", "error"); return; } if (string.IsNullOrWhiteSpace(ImageLink.Text) || !ImageLink.Text.Contains(".jpg")) { messageBox.Show("Enter a valid '.jpg' image link!", "error"); return; } if (string.IsNullOrWhiteSpace(Rating.Text) || !decimal.TryParse(Rating.Text, out decimal n)) { messageBox.Show("Enter a valid rating (0-5)!", "error"); return; } decimal rating = decimal.Parse(Rating.Text); if (rating < 0 || rating > 5) { messageBox.Show("Enter a valid rating (0-5)!", "error"); return; } if (string.IsNullOrWhiteSpace(PhoneNumber.Text) || PhoneNumber.Text.Length < 9) { messageBox.Show("Enter a valid phone number", "error"); return; } if (!string.IsNullOrWhiteSpace(PhoneNumber.Text)) { string pattern = @"\(?\d{3}\)?-? ?/*\d{3}-? *-?\d{3}"; Regex reg = new Regex(pattern); if (!reg.IsMatch(PhoneNumber.Text)) { messageBox.Show("Phone number: xxx/xxx-xxx", "error"); return; } } InsertCinemaRequest request = new InsertCinemaRequest() { Name = Cinema.Text, Address = Address.Text, StreetNumber = (int)StreetNumber.Value, Location = Location.Text, PhoneNumber = PhoneNumber.Text, Rating = decimal.Parse(Rating.Text), Description = Description.Text, ImageLink = ImageLink.Text }; if (_cinemaId.HasValue) { await _apiService.Update <Model.Cinema>(_cinemaId, request); } else { await _apiService.Insert <Model.Cinema>(request); } this.Close(); foreach (Form frm in _menuForm.MdiChildren) { frm.Close(); } CinemasForm form = new CinemasForm { MdiParent = _menuForm, Dock = DockStyle.Fill }; form.Show(); if (_cinemaId.HasValue) { messageBox.Show("Cinema updated successfully!", "success"); } else { messageBox.Show("Cinema added successfully!", "success"); } }