Exemplo n.º 1
0
 private void btn_Xoa_Click(object sender, EventArgs e)
 {
     if (monthCalendar1.SelectedDates.Count > 0 && IsNgayPhep(monthCalendar1.SelectedDates))
     {
         if (MessageBox.Show("Bạn muốn xoá ngày nghỉ phép cho nhân viên " + oThongTinCNVC.txt_MaNV.Text + " ?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             try
             {
                 Pabo.Calendar.SelectedDatesCollection c = new Pabo.Calendar.SelectedDatesCollection(monthCalendar1);
                 c = monthCalendar1.SelectedDates;
                 List <string> delDates = new List <string>();
                 for (int i = 0; i < c.Count; i++)
                 {
                     Pabo.Calendar.DateItem[] dt = monthCalendar1.GetDateInfo(c[i]);
                     if (dt.Count() > 0 && dt[0].BackColor1 == Color.IndianRed)
                     {
                         delDates.Add(dt[0].Date.ToShortDateString());
                     }
                 }
                 oChamCong.Delete(oThongTinCNVC.txt_MaNV.Text, delDates.ToArray());
                 GetAndBindMonthCalendar();
                 MessageBox.Show("Xoá thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             catch (Exception)
             {
                 MessageBox.Show("Xoá không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }