Exemple #1
0
        private void closeBtn_Click(object sender, EventArgs e)
        {
            _helper.CloseForm(this, 15);
            AppointmentsForm form = new AppointmentsForm(_scheduleForm, _schedule, _menuForm, _airingDayId, _date, _day, _cinemaDayMovieId, _movieId, _cinemaDayMovieForm);

            _helper.ShowForm(form, 15);
        }
Exemple #2
0
        private async void dgvScheduledMovies_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                var cinemaDayMovieId = dgvScheduledMovies.Rows[e.RowIndex].Cells["CinemaDayMovieId"].Value;
                var movieId          = dgvScheduledMovies.Rows[e.RowIndex].Cells["MovieId"].Value;
                var action           = dgvScheduledMovies.Columns[e.ColumnIndex].Name;
                var cdmApi           = new APIService("cinemaDayMovie");
                var movieApi         = new APIService("movies");
                var cdm = await cdmApi.GetById <Model.CinemaDayMovie>(cinemaDayMovieId);

                var movie = await movieApi.GetById <Model.Movie>(cdm.MovieId);

                CustomMessageBox messageBox = new CustomMessageBox();

                if (action == "Delete")
                {
                    DialogResult dialogResult = MessageBox.Show($"Are you sure you want to permanently delete '{movie.Title}' on the {DateTime.Parse(_date.ToString()).ToShortDateString()}, {_day}?", "Delete movie?", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        await cdmApi.Delete <Model.CinemaDayMovie>(cinemaDayMovieId);

                        this.Close();
                        _scheduleForm.Close();
                        ScheduleForm sch = new ScheduleForm(_schedule.Cinema.CinemaId, _menuForm)
                        {
                            MdiParent = _menuForm,
                            Dock      = DockStyle.Fill
                        };

                        var schedule = await _apiService.CustomGet <Model.Requests.CinemasScheduleRequest>("GetCinemasSchedule", _schedule.Cinema.CinemaId);

                        CinemaDayMovieForm form = new CinemaDayMovieForm(sch, schedule, _menuForm, _airingDayId, _date, _day);
                        sch.Show();
                        _helper.ShowForm(form, 15);

                        messageBox.Show("Movie deleted successfully", "success");
                    }
                }
                else if (action == "Apps")
                {
                    AppointmentsForm form = new AppointmentsForm(_scheduleForm, _schedule, _menuForm, _airingDayId, _date, _day, int.Parse(cinemaDayMovieId.ToString()), int.Parse(movieId.ToString()), this);
                    _helper.CloseForm(this, 15);
                    _helper.ShowForm(form, 15);
                }
            }
        }
Exemple #3
0
        public AddEditAppointmentForm(AppointmentsForm appointmentsForm, ScheduleForm scheduleForm, Model.Requests.CinemasScheduleRequest schedule, MenuForm menuForm, int airingDayId, DateTime date, string day, int cinemaDayMovieId, int movieId, CinemaDayMovieForm cinemaDayMovieForm, int?appointmentId = null)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.Manual;
            this.Location      = new Point(Screen.PrimaryScreen.Bounds.Width - 20 - this.Width, Screen.PrimaryScreen.Bounds.Height - this.Height - saveBtn.Height - 20);
            _scheduleForm      = scheduleForm;
            _schedule          = schedule;
            _airingDayId       = airingDayId;
            _menuForm          = menuForm;
            _date               = date;
            _day                = day;
            _cinemaDayMovieId   = cinemaDayMovieId;
            _movieId            = movieId;
            _appointmentId      = appointmentId;
            _cinemaDayMovieForm = cinemaDayMovieForm;
            _appointmentsForm   = appointmentsForm;

            StartsAt.Format       = DateTimePickerFormat.Custom;
            StartsAt.CustomFormat = "HH:mm";
            StartsAt.ShowUpDown   = true;
        }
Exemple #4
0
        private async void saveBtn_Click(object sender, EventArgs e)
        {
            var messageBox = new CustomMessageBox();

            if (!_helper.ValidateDecimalString(Price.Text, 1, 100))
            {
                messageBox.Show("Enter a valid price (1-100)!", "error");
                return;
            }
            if (HallsBox.SelectedIndex == -1)
            {
                messageBox.Show("Select a hall!", "error");
                return;
            }

            var appApi  = new APIService("Appointments");
            var allApps = await appApi.Get <List <Model.Appointments> >(null);

            allApps.RemoveAll(a => a.HallId != (HallsBox.SelectedItem as dynamic).Value);

            var cdmApi  = new APIService("CinemaDayMovie");
            var allCdms = await cdmApi.Get <List <Model.CinemaDayMovie> >(null);

            var finalApps = new List <Model.Appointments>();

            foreach (var app in allApps)
            {
                foreach (var cdm in allCdms)
                {
                    if (app.CinemaDayMovieId == cdm.CinemaDayMovieId && cdm.AiringDaysOfCinemaId == _airingDayId)
                    {
                        finalApps.Add(app);
                        break;
                    }
                }
            }

            var moviesApi = new APIService("movies");
            var movie     = await moviesApi.GetById <Model.Movie>(_movieId);



            if (_appointmentId.HasValue)
            {
                var app = await appApi.GetById <Model.Appointments>(_appointmentId);

                finalApps.RemoveAll(a => a.AppointmentId == app.AppointmentId);
            }

            bool valid = true;

            foreach (var app in finalApps)
            {
                DateTime newBegins = new DateTime();
                DateTime newEnds   = new DateTime();
                newBegins = DateTime.Parse(StartsAt.Text);
                newEnds   = DateTime.Parse(StartsAt.Text).AddMinutes(TimeSpan.Parse(movie.Duration).TotalMinutes);


                var cdm = await cdmApi.GetById <Model.CinemaDayMovie>(app.CinemaDayMovieId);

                var thisMovie = await moviesApi.GetById <Model.Movie>(cdm.MovieId);

                DateTime begins = new DateTime();
                DateTime ends   = new DateTime();
                begins = DateTime.Parse(app.StartsAt);
                ends   = DateTime.Parse(app.StartsAt).AddMinutes(TimeSpan.Parse(thisMovie.Duration).TotalMinutes);

                bool overlap = begins < newEnds && newBegins < ends;
                if (overlap)
                {
                    valid = false;
                    break;
                }
            }
            if (!valid)
            {
                messageBox.Show("The appointment is overlaping!", "error");
                return;
            }

            Model.Requests.InsertAppointmentRequest Object = new Model.Requests.InsertAppointmentRequest()
            {
                Price            = decimal.Parse(Price.Text),
                CinemaDayMovieId = _cinemaDayMovieId,
                HallId           = (HallsBox.SelectedItem as dynamic).Value,
                SoldSeats        = 0,
                StartsAt         = StartsAt.Value.ToString("HH:mm")
            };

            if (_appointmentId.HasValue)
            {
                await appApi.Update <Model.Appointments>(_appointmentId, Object);

                messageBox.Show("Appointment updated succesfully", "Success");
            }
            else
            {
                await appApi.Insert <Model.Appointments>(Object);

                messageBox.Show("Appointment added succesfully", "Success");
            }

            this.Close();
            _appointmentsForm.Close();
            _cinemaDayMovieForm.Close();
            _scheduleForm.Close();
            ScheduleForm sch = new ScheduleForm(_schedule.Cinema.CinemaId, _menuForm)
            {
                MdiParent = _menuForm,
                Dock      = DockStyle.Fill
            };
            var schedule = await _apiService.CustomGet <Model.Requests.CinemasScheduleRequest>("GetCinemasSchedule", _schedule.Cinema.CinemaId);

            AppointmentsForm form = new AppointmentsForm(sch, schedule, _menuForm, _airingDayId, _date, _day, _cinemaDayMovieId, _movieId, _cinemaDayMovieForm);

            sch.Show();
            _helper.ShowForm(form, 15);
        }