private void BtnEdit_Click(object sender, EventArgs e) { if ((dayView1.SelectedAppointment != null)) { if (dayView1.SelectedAppointment.Locked == false) { creat_app = false; app_tem = dayView1.SelectedAppointment; Book_room_info dlg_book = new Book_room_info(); dlg_book.ShowDialog(); } } }
private void BtnCreat_Click(object sender, EventArgs e) { DateTime begin = dayView1.SelectionStart; DateTime end = dayView1.SelectionEnd; bool a = false; creat_app = true; if (LbStart.Text == "[...]") { a = true; } if (dayView1.SelectedAppointment != null) { a = true; } else { foreach (Appointment app in m_Appointments) { if (((DateTime.Compare(begin, app.StartDate) > 0) & (DateTime.Compare(begin, app.EndDate) < 0)) | ((DateTime.Compare(end, app.StartDate) > 0) & (DateTime.Compare(end, app.EndDate) < 0)) | ((DateTime.Compare(begin, app.StartDate) < 0) & (DateTime.Compare(end, app.EndDate) > 0))) { a = true; break; } } } if (a == false) { Appointment m_App = new Appointment(); m_App.StartDate = begin; m_App.EndDate = end; m_App.BorderColor = Color.Red; m_Appointments.Add(m_App); dayView1.SelectedAppointment = m_App; dayView1.Invalidate(); string querybook = "SELECT Id from dbo.book_room_schedule "; DataTable tbl_Id_book = DataProvider.Instance.ExecuteQuery(querybook); m_App.Title = "New"; m_App.Id = (int)tbl_Id_book.Rows[tbl_Id_book.Rows.Count - 1].ItemArray[0] + 1; m_App.ID_room = ma_phong; app_tem = m_App; Book_room_info dlg_book = new Book_room_info(); dlg_book.ShowDialog(); } else { MessageBox.Show("Không cho phép chèn lên nhau", "Chú ý ! ", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }