public frmAddUpdateHoliday(ref Holiday holiday)
        {
            InitializeComponent();

            _holiday = holiday;
            lblDate.Text = holiday.Date.Day + "/" + holiday.Date.Month;
            txtDescription.Text = holiday.Description;
        }
        private void AddHoliday()
        {
            if (mclHoliday.SelectedDates.Count == 0)
            {
                MessageBox.Show("Please select a day.");
                return;
            }
            else
            {
                Holiday holiday = new Holiday();
                holiday.Date = mclHoliday.SelectedDates[0];
                holiday.Description = "";

                if (_holidayList.Find(delegate(Holiday hday)
                {
                    return hday.Date.Day == holiday.Date.Day && hday.Date.Month == holiday.Date.Month;
                }) != null)
                {
                    MessageBox.Show(holiday.Date.Day + @"/" + holiday.Date.Month + " has already been added. Please choose another day.");
                    return;
                }
                else
                {
                    new frmAddUpdateHoliday(ref holiday).ShowDialog(this);
                    if (holiday != null)
                    {
                        _holidayList.Add(holiday);
                        _holidayList.Sort(delegate(Holiday hday1, Holiday hday2)
                        {
                            if (hday1.Date.Month != hday2.Date.Month)
                                return hday1.Date.Month - hday2.Date.Month;
                            else
                                return hday1.Date.Day - hday2.Date.Day;
                        });

                        BindHoliday();
                    }
                }
            }
        }
        public int AddHoliday(Holiday holiday)
        {
            OleDbCommand odCom1 = BuildInsertCmd("Holiday",
                new string[] { "Date"
                ,"Description"
                ,"WorkingCalendarID"
                },
                new object[] { holiday.Date
                ,holiday.Description
                ,holiday.WorkingCalendarID
                }
            );

            if (odCom1.ExecuteNonQuery() == 1)
            {
                odCom1.CommandText = "SELECT @@IDENTITY";
                return Convert.ToInt16(odCom1.ExecuteScalar().ToString());
            }
            return -1;
        }
        public List<Holiday> GetHolidayListByWorkingCalendar(int workingCalendarID)
        {
            OleDbCommand odCom = BuildSelectCmd("Holiday", "*", "WorkingCalendarID=@WorkingCalendarID", new object[] { "@WorkingCalendarID", workingCalendarID });

            OleDbDataReader odRdr = odCom.ExecuteReader();
            List<Holiday> holidayList = new List<Holiday>();
            Holiday holiday = null;
            while (odRdr.Read())
            {
                holiday = new Holiday();

                holiday.ID = Convert.ToInt16(odRdr["ID"]);
                holiday.Date = Convert.ToDateTime(odRdr["Date"]);
                holiday.Description = odRdr["Description"].ToString();
                holiday.WorkingCalendarID = Convert.ToInt16(odRdr["WorkingCalendarID"]);

                holidayList.Add(holiday);
            }

            odRdr.Close();
            return holidayList;
        }
 private void btnCancel_Click(object sender, EventArgs e)
 {
     _holiday = null;
     this.Close();
 }