示例#1
0
        private void showEdit_Click(object sender, EventArgs e)
        {
            if (!showNrTicketsText.Text.All(Char.IsDigit))
            {
                StatusLabel.Text = "Invalid number of tickets selected!";
                return;
            }
            if (showIDText.Text == "")
            {
                StatusLabel.Text = "Error! No ID chosen!";
                return;
            }
            if (showTitleText.Text == "")
            {
                StatusLabel.Text = "Error! No title chosen!";
                return;
            }
            if (showDistributionText.Text == "")
            {
                StatusLabel.Text = "Error! No distribution chosen!";
                return;
            }
            if (showNrTicketsText.Text == "")
            {
                StatusLabel.Text = "Error! No number of tickets chosen!";
                return;
            }
            if (!(showGenreSelection.SelectedIndex == 0 || showGenreSelection.SelectedIndex == 1))
            {
                StatusLabel.Text = "Error! No genre chosen!";
                return;
            }
            if (!showServices.isID(Convert.ToInt32(showIDText.Text)))
            {
                StatusLabel.Text = "Error! The show with the given ID does not exist!";
            }
            ShowModel model = new ShowModel();

            model.setID(Convert.ToInt32(showIDText.Text));
            model.setTitle(showTitleText.Text);
            model.setDistribution(showDistributionText.Text);
            model.setNumberOfTickets(Convert.ToInt32(showNrTicketsText.Text));
            if (showGenreSelection.SelectedIndex == 0)
            {
                model.setGenre("Opera");
            }
            else
            {
                model.setGenre("Ballet");
            }
            model.setDate(showDatePicker.Value.Date);
            showServices.update(model);
            StatusLabel.Text = "Show edited!";

            //refresh
            ShowRefresh();
            showGenreSelection.SelectedIndex = -1;
        }
示例#2
0
        private void showAdd_Click(object sender, EventArgs e)
        {
            if (!showNrTicketsText.Text.All(Char.IsDigit))
            {
                StatusLabel.Text = "Invalid number of tickets selected!";
                return;
            }
            if (showTitleText.Text == "")
            {
                StatusLabel.Text = "Error! No title chosen!";
                return;
            }
            if (showDistributionText.Text == "")
            {
                StatusLabel.Text = "Error! No distribution chosen!";
                return;
            }
            if (showNrTicketsText.Text == "")
            {
                StatusLabel.Text = "Error! No number of tickets chosen!";
                return;
            }
            if (!(showGenreSelection.SelectedIndex == 0 || showGenreSelection.SelectedIndex == 1))
            {
                StatusLabel.Text = "Error! No genre chosen!";
                return;
            }
            if (showServices.isShow(showTitleText.Text, showDatePicker.Value.Date))
            {
                StatusLabel.Text = "Error! Show already exists!";
                return;
            }
            ShowModel model = new ShowModel();

            model.setTitle(showTitleText.Text);
            model.setDistribution(showDistributionText.Text);
            model.setNumberOfTickets(Convert.ToInt32(showNrTicketsText.Text));
            if (showGenreSelection.SelectedIndex == 0)
            {
                model.setGenre("Opera");
            }
            else
            {
                model.setGenre("Ballet");
            }
            model.setDate(showDatePicker.Value.Date);
            showServices.add(model);

            //refresh
            ShowRefresh();
            StatusLabel.Text = "Show added!";
        }
示例#3
0
        public ShowModel map(ShowDTO showdto)
        {
            ShowModel model = new ShowModel();

            model.setID(showdto.getID());
            model.setGenre(showdto.getGenre());
            model.setDistribution(showdto.getDistribution());
            model.setDate(showdto.getDate());
            model.setNumberOfTickets(showdto.getNumberOfTickets());
            model.setTitle(showdto.getTitle());

            return(model);
        }