Пример #1
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                Schedule schedule = new Schedule()
                {
                    RoomID   = Convert.ToInt32(cmbRoom.SelectedValue),
                    HourID   = Convert.ToInt32(cmbHours.SelectedValue),
                    MovieID  = Convert.ToInt32(cmbMovie.SelectedValue),
                    Date     = monthCalendar1.SelectionRange.Start.ToString("yyyy-MM-dd"),
                    LeftSeat = Convert.ToInt32(txtSeat.Text)
                };
                if (Convert.ToInt32(txtSeat.Text) <= 0)
                {
                    DisplayFailNotify("Left seat must be possitive number");

                    return;
                }

                int state = sbus.InsertNewSchedule(schedule);
                if (state == 1)
                {
                    SuccessNotify notify = new SuccessNotify();
                    notify.lblMessage.Text = "Add new schedule successfully!";
                    notify.ShowDialog();
                }
            }
            catch (FormatException)
            {
                DisplayFailNotify("Left seat must be possitive number");
            }
            catch (Exception)
            {
                DisplayFailNotify("This schedule has already been used");
            }
            parent.LoadData();
        }