public void PopulateHolidayAndWeekOffViews()
{
btnDeleteHoliday.Visible = true;
ServiceHolidayAndWeekOffs _service = new ServiceHolidayAndWeekOffs();
try
{
tbl_Acct_Financial_Year model = (new ServiceMASTERS()).GetFinancialYearDbRecordByID(this.SelectedFYID);
if (model != null)
{
this.SuspendLayout();
monthViewControl = new ComponentFactory.Krypton.Toolkit.KryptonMonthCalendar();
//monthViewControl.MaxDate = DateTime.Now;
//monthViewControl.MinDate = DateTime.Now;
monthViewControl.MinDate = (DateTime)model.FromDate;
monthViewControl.MaxDate = (DateTime)model.ToDate;
monthViewControl.DateChanged += _Calender_DateChanged;
//_Calender.DayStyle = ButtonStyle.Standalone;
//_Calender.OverrideBolded.Day.Back.Color1 = System.Drawing.Color.Red;
//_Calender.HeaderStyle = HeaderStyle.Primary;
monthViewControl.SelectionStart = (DateTime)model.FromDate;
monthViewControl.SelectionEnd = (DateTime)model.FromDate;
monthViewControl.MaxSelectionCount = 1;
monthViewControl.ShowToday = false;
monthViewControl.ShowTodayCircle = false;
List <TBL_MP_HR_HolidaysAndWeekOff> lstHolidays = _service.GetAllHolidaysForTheFinYear(this.SelectedFYID);
_HolidayAndWeekOffList = new BindingList <SelectListItem>();
foreach (TBL_MP_HR_HolidaysAndWeekOff item in lstHolidays)
{
monthViewControl.AddBoldedDate(item.HolidayDate);
_HolidayAndWeekOffList.Add(new SelectListItem()
{
ID = item.PK_HolidayID, Code = item.HolidayDate.ToString("dd MMM yyyy"), Description = item.Remarks
});
}
gridHolidaysAndWeekOffs.DataSource = _HolidayAndWeekOffList;
//make these columns hidden PK_HolidayID, FK_YearID, HolidayType
gridHolidaysAndWeekOffs.Columns["ID"].Visible =
gridHolidaysAndWeekOffs.Columns["DescriptionToUpper"].Visible =
gridHolidaysAndWeekOffs.Columns["IsActive"].Visible = false;
this.monthViewControl.CalendarDimensions = new System.Drawing.Size(4, 3);
this.monthViewControl.DayOfWeekStyle = ComponentFactory.Krypton.Toolkit.ButtonStyle.Alternate;
this.monthViewControl.DayStyle = ComponentFactory.Krypton.Toolkit.ButtonStyle.Standalone;
this.monthViewControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.monthViewControl.Location = new System.Drawing.Point(0, 0);
this.monthViewControl.OverrideBolded.Day.Back.Color1 = System.Drawing.Color.Yellow;
this.monthViewControl.OverrideBolded.Day.Back.Color2 = System.Drawing.Color.Red;
this.monthViewControl.OverrideBolded.Day.Back.ColorStyle = ComponentFactory.Krypton.Toolkit.PaletteColorStyle.Solid;
//this._Calender.OverrideBolded.Day.Border.Color1 = System.Drawing.Color.Lime;
//this._Calender.OverrideBolded.Day.Border.ColorStyle = ComponentFactory.Krypton.Toolkit.PaletteColorStyle.Solid;
//this._Calender.OverrideBolded.Day.Border.DrawBorders = ((ComponentFactory.Krypton.Toolkit.PaletteDrawBorders)((((ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Top | ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Bottom)
//| ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Left)
//| ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Right)));
//this._Calender.OverrideBolded.Day.Border.Width = 1;
this.monthViewControl.OverrideBolded.Day.Content.ShortText.Color1 = System.Drawing.Color.Red;
this.monthViewControl.OverrideBolded.Day.Content.LongText.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
this.monthViewControl.OverrideBolded.Day.Content.ShortText.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.monthViewControl.OverrideBolded.Day.Content.ShortText.TextH = ComponentFactory.Krypton.Toolkit.PaletteRelativeAlign.Center;
this.monthViewControl.OverrideBolded.Day.Content.ShortText.TextV = ComponentFactory.Krypton.Toolkit.PaletteRelativeAlign.Center;
headerGroupCalendarView.Panel.Controls.Clear();
headerGroupCalendarView.Panel.Controls.Add(monthViewControl);
monthViewControl.Show();
this.ResumeLayout(false);
//monthViewControl.Dock = DockStyle.Fill;
headerGroupRight.ValuesPrimary.Heading = string.Format("FA: {0} till {1}", model.FromDate.ToString("dd MMMM yyyy"), model.ToDate.ToString("dd MMMM yyyy "));
headerGroupRight.ValuesPrimary.Description = string.Format("Holidays: {0} Week-offs: {1}", _service.GetHolidayCountForYear(this.SelectedFYID), _service.GetWeekOffCountForYear(this.SelectedFYID));
}
}
catch (Exception ex)
{
string errMessage = ex.Message;
if (ex.InnerException != null)
{
errMessage += string.Format("\n{0}", ex.InnerException.Message);
}
MessageBox.Show(errMessage, "PageHolidayAndWeekOffs::PopulateHolidayAndWeekOffViews", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}