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(); }