private void btnYes_Click(object sender, EventArgs e)
 {
     try
     {
         int state = sbus.DeleteSchedule(roomID, hourID, date);
         if (state == 1)
         {
             SuccessNotify notify = new SuccessNotify();
             notify.lblMessage.Text = "Delete schedule successfully!";
             notify.ShowDialog();
         }
         else
         {
             SuccessNotify notify = new SuccessNotify();
             notify.lblMessage.Text = "Delete schedule failed!";
             notify.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     parent.LoadData();
     this.Close();
 }
        private void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                int state = -1;
                if (Convert.ToInt32(txtSeat.Text) <= 0)
                {
                    DisplayFailNotify("Left seat must be possitive number");

                    return;
                }

                if (roomDK == roomID && hourDK == hourID && dateDK.Equals(date))
                {
                    int leftSeat = Convert.ToInt32(txtSeat.Text);
                    state = sbus.UpdateSeatAndMovie(leftSeat, movieID, roomDK, hourDK, dateDK);
                }
                else
                {
                    MessageBox.Show("roomDK " + roomDK + "\t" + roomID +
                                    "hourDK " + hourDK + "\t" + hourID +
                                    "dateDK " + dateDK + "\t" + date);
                    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)
                    };
                    state = sbus.UpdateSchedule(schedule, roomDK, hourDK, dateDK);
                }

                if (state == 1)
                {
                    SuccessNotify notify = new SuccessNotify();
                    notify.lblMessage.Text = "Update schedule successfully!";
                    notify.ShowDialog();
                }
            }
            catch (FormatException)
            {
                DisplayFailNotify("Left seat must be possitive number");
            }
            catch (Exception)
            {
                DisplayFailNotify("This schedule has already been used");
            }
            parent.LoadData();
        }
Example #3
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();
        }