void UpdateHoliday() { int month = monthCalendar1.SelectionStart.Month; int year = monthCalendar1.SelectionStart.Year; if (bsHolidays.DataSource != null) { DatabaseSet.安らViewDataTable table = bsHolidays.DataSource as DatabaseSet.安らViewDataTable; List <DateTime> holidays = new List <DateTime>(); foreach (DatabaseSet.安らViewRow row in table) { if (row.RowState != DataRowState.Deleted) { holidays.Add(row.ら戳); } } _curMonthHolidays = holidays.ToArray(); UpdateWorkingHours(); } monthCalendar1.BoldedDates = _curMonthHolidays; }
public int GetWorkingDays(int year, int month, DatabaseSet.安らViewDataTable table) { //int holidays = table.Rows.Count; DataRow[] rows = table.Select(null, null, DataViewRowState.CurrentRows); int holidays = rows.Length; int days = DateTime.DaysInMonth(year, month); return(days - holidays); }
private void btnAddHoliday_Click(object sender, EventArgs e) { try { if (bsHolidays.DataSource != null) { DatabaseSet.安らViewDataTable table = bsHolidays.DataSource as DatabaseSet.安らViewDataTable; DatabaseSet.安らViewRow newRow = table.New安らViewRow(); newRow.FillRow(monthCalendar1.SelectionStart); table.Rows.Add(newRow); UpdateHoliday(); NeedSave = true; } } catch (ConstraintException) { MessageBox.Show(monthCalendar1.SelectionStart.ToString("yyyy/MM/dd") + " "); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }