private void btnUpdateHoliday_Click(object sender, EventArgs e) { try { frmAddEditHolidayAndWeekOff frm = null; TBL_MP_HR_HolidaysAndWeekOff model = (new ServiceHolidayAndWeekOffs()).GetHolidayDbRecordByDate(this.SelectedDate); if (model != null) { frm = new frmAddEditHolidayAndWeekOff(model.PK_HolidayID); } else { frm = new frmAddEditHolidayAndWeekOff(); frm.SelectedYearID = this.SelectedFYID; frm.HolidayDate = this.SelectedDate; } if (frm.ShowDialog() == DialogResult.OK) { PopulateHolidayAndWeekOffViews(); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageHolidayAndWeekOffs::btnUpdateHoliday_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ScatterData() { try { TBL_MP_HR_HolidaysAndWeekOff model = (new ServiceHolidayAndWeekOffs()).GetHolidayDbRecordByHolidayID(this.HolidayID); if (model != null) { cboFinancialYear.SelectedItem = ((List <SelectListItem>)cboFinancialYear.DataSource).Where(x => x.ID == model.FK_YearID).FirstOrDefault(); dtDate.Value = (DateTime)model.HolidayDate; if ((ATTENDANCE_TYPE)model.HolidayType == ATTENDANCE_TYPE.HOLIDAY) { radioBtnHoliday.Checked = true; } if ((ATTENDANCE_TYPE)model.HolidayType == ATTENDANCE_TYPE.WEEK_OFF) { radioBtnWeekOff.Checked = true; } txtRemark.Text = model.Remarks; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditEmployeeRelation::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool RemoveHolidayAandWeekOffOnDate(DateTime dtDate) { bool result = false; try { TBL_MP_HR_HolidaysAndWeekOff model = _dbContext.TBL_MP_HR_HolidaysAndWeekOff.Where(x => x.HolidayDate == dtDate).FirstOrDefault(); if (model != null) { _dbContext.TBL_MP_HR_HolidaysAndWeekOff.Remove(model); _dbContext.SaveChanges(); result = true; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceHolidayAndWeekOffs::RemoveHolidayAandWeekOffOnDate", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public bool UpdateHolidayAndWeekOffsInfo(TBL_MP_HR_HolidaysAndWeekOff model) { bool result = false; try { TBL_MP_HR_HolidaysAndWeekOff dbModel = _dbContext.TBL_MP_HR_HolidaysAndWeekOff.Where(x => x.PK_HolidayID == model.PK_HolidayID).FirstOrDefault(); dbModel.FK_YearID = model.FK_YearID; dbModel.HolidayDate = model.HolidayDate; dbModel.HolidayType = model.HolidayType; dbModel.Remarks = model.Remarks; _dbContext.SaveChanges(); result = true; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceHolidayAndWeekOffs::UpdateHolidayAndWeekOffsInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private void btnOK_Click(object sender, EventArgs e) { TBL_MP_HR_HolidaysAndWeekOff model = null; ServiceHolidayAndWeekOffs _service = new ServiceHolidayAndWeekOffs(); try { if (!this.ValidateChildren()) { return; } if (this.HolidayID == 0) { model = new TBL_MP_HR_HolidaysAndWeekOff(); } else { model = _service.GetHolidayDbRecordByHolidayID(this.HolidayID); } model.FK_YearID = ((SelectListItem)cboFinancialYear.SelectedItem).ID; if (radioBtnHoliday.Checked) { model.HolidayType = (int)ATTENDANCE_TYPE.HOLIDAY; } if (radioBtnWeekOff.Checked) { model.HolidayType = (int)ATTENDANCE_TYPE.WEEK_OFF; } model.HolidayDate = dtDate.Value; model.Remarks = txtRemark.Text.Trim(); if (this.HolidayID == 0) { this.HolidayID = _service.AddNewHolidayAndWeekOffs(model); } else { _service.UpdateHolidayAndWeekOffsInfo(model); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditHolidayAndWeekOff::btnOK_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public TBL_MP_HR_HolidaysAndWeekOff GetHolidayDbRecordByDate(DateTime dtDate) { TBL_MP_HR_HolidaysAndWeekOff model = null; try { model = _dbContext.TBL_MP_HR_HolidaysAndWeekOff.Where(x => x.HolidayDate == dtDate).FirstOrDefault(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceHolidayAndWeekOffs::GetHolidayDbRecordByDate", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
public int AddNewHolidayAndWeekOffs(TBL_MP_HR_HolidaysAndWeekOff model) { int newID = 0; try { _dbContext.TBL_MP_HR_HolidaysAndWeekOff.Add(model); _dbContext.SaveChanges(); newID = model.PK_HolidayID; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceHolidayAndWeekOffs::AddNewHolidayAndWeekOffs", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(newID); }
public bool IsHolidayOrWeekOff(DateTime currDate) { bool result = false; try { TBL_MP_HR_HolidaysAndWeekOff dbOff = _dbContext.TBL_MP_HR_HolidaysAndWeekOff.Where(x => x.HolidayDate == currDate).FirstOrDefault(); if (dbOff != null) { result = true; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceHolidayAndWeekOffs::IsHolidayOrWeekOff", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private void gridHolidaysAndWeekOffs_RowEnter(object sender, DataGridViewCellEventArgs e) { btnDeleteHoliday.Visible = false; try { this.SelectedDate = DateTime.Parse(gridHolidaysAndWeekOffs.Rows[e.RowIndex].Cells["Code"].Value.ToString()); TBL_MP_HR_HolidaysAndWeekOff model = (new ServiceHolidayAndWeekOffs()).GetHolidayDbRecordByDate(this.SelectedDate); if (model != null) { btnDeleteHoliday.Visible = true; ATTENDANCE_TYPE type = (ATTENDANCE_TYPE)model.HolidayType; headerGroupRight.ValuesSecondary.Heading = string.Format("{0} - {1} ({2})", SelectedDate.ToString("dd MMM yy"), model.Remarks, ((type == ATTENDANCE_TYPE.HOLIDAY) ? "Holiday" : "Week-Off")); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageHolidayAndWeekOffs::gridHolidaysAndWeekOffs_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void _Calender_DateChanged(object sender, DateRangeEventArgs e) { btnDeleteHoliday.Visible = false; try { this.SelectedDate = e.Start; TBL_MP_HR_HolidaysAndWeekOff model = (new ServiceHolidayAndWeekOffs()).GetHolidayDbRecordByDate(this.SelectedDate); if (model != null) { btnDeleteHoliday.Visible = true; ATTENDANCE_TYPE type = (ATTENDANCE_TYPE)model.HolidayType; headerGroupRight.ValuesSecondary.Heading = string.Format("{0} - {1} ({2})", SelectedDate.ToString("dd MMM yy"), model.Remarks, ((type == ATTENDANCE_TYPE.HOLIDAY)?"Holiday":"Week-Off")); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageHolidayAndWeekOffs::_Calender_DateChanged", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void PrepareAttendanceDescription(KryptonHeaderGroup header, DateTime currDate) { string strDescription = string.Empty; int employeeID = 0; List <AttendanceColorModel> lstColors = (new ServiceEmployee()).GetAttendanceColorPreferencesOfEmployee(Program.CURR_USER.EmployeeID); try { header.HeaderStylePrimary = HeaderStyle.DockActive; string description = string.Empty; header.ValuesPrimary.Heading = string.Format("{0} ({1})", currDate.ToString("dd MMM"), currDate.ToString("ddd")); header.ValuesPrimary.Image = null; header.ValuesSecondary.Heading = string.Empty; List <vAttendanceRegister> dbItems = (new ServiceAttendance()).GetAttendanceInfoDbRecordsOfEmplyeeOnDate(this.EmployeeID, currDate); strDescription = string.Empty; foreach (vAttendanceRegister item in dbItems) { strDescription += string.Format("{1}-{2} {0}", item.AttendanceRemarks, item.AttendInTime.ToString("hh:mmtt"), item.AttendOutTime.ToString("hh:mmtt")); strDescription += (item.AtWarehouse) ? "At Warehouse ":""; if (item.AttendanceType == (int)ATTENDANCE_TYPE.LEAVE || item.AttendanceType == (int)ATTENDANCE_TYPE.OUT_DOOR) { strDescription += string.Format("({0})\n\n", (item.IsActive)?"Approved":"Unapproved"); if (item.isLeaveRejected == true) { strDescription = string.Empty; strDescription += string.Format("{1}-{2} {0}", item.AttendanceRemarks, item.AttendInTime.ToString("hh:mmtt"), item.AttendOutTime.ToString("hh:mmtt")); strDescription += (item.AtWarehouse) ? "At Warehouse " : ""; strDescription += string.Format("(Rejected)\n\n"); } } } Label lblDescription = new Label(); lblDescription.BackColor = Color.Transparent; lblDescription.Text = strDescription; header.Panel.Controls.Add(lblDescription); lblDescription.Dock = DockStyle.Fill; if (dbItems.Count > 0) { if (dbItems.Count == 1) { vAttendanceRegister dbItem = dbItems[0]; ATTENDANCE_TYPE attendanceTYPE = (ATTENDANCE_TYPE)dbItem.AttendanceType; switch (attendanceTYPE) { case ATTENDANCE_TYPE.PRESENT: header.ValuesPrimary.Description = "Present"; //header.ValuesSecondary.Heading = string.Format("{0} - {1}", dbItem.AttendInTime.ToString("hh:mm tt"), dbItem.AttendOutTime.ToString("hh:mm tt")); //header.ValuesSecondary.Description = string.Format("{0}", dbItem.AttendanceRemarks); header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.PRESENT).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.ABSENT: header.ValuesPrimary.Description = "Absent"; //header.ValuesSecondary.Heading = string.Format("{0} - {1}", dbItem.AttendInTime.ToString("hh:mm tt"), dbItem.AttendOutTime.ToString("hh:mm tt")); //header.ValuesSecondary.Description = string.Format("{0}", dbItem.AttendanceRemarks); header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.ABSENT).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.LEAVE: header.ValuesPrimary.Description = "Leave"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.LEAVE).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.OUT_DOOR: header.ValuesPrimary.Description = "Outdoor"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.OUT_DOOR).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.COMP_OFF: header.ValuesPrimary.Description = "CompOff"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.COMP_OFF).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.LATE_COMING: header.ValuesPrimary.Description = "Late Coming"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.LATE_COMING).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.EARLY_GOING: header.ValuesPrimary.Description = "Early Leaving"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.EARLY_GOING).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.SANDWICH_LEAVE: header.ValuesPrimary.Description = "Sandwich Leave"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.LEAVE).FirstOrDefault().ColorAttendance; break; } } else { header.ValuesPrimary.Description = "Multiple Entries"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.MULTIPLE).FirstOrDefault().ColorAttendance; } } ServiceHolidayAndWeekOffs serviceOff = new ServiceHolidayAndWeekOffs(); if (serviceOff.IsHolidayOrWeekOff(currDate)) { TBL_MP_HR_HolidaysAndWeekOff dbOff = serviceOff.GetHolidayDbRecordByDate(currDate); if (dbOff != null) { if (dbOff.HolidayType == (int)ATTENDANCE_TYPE.WEEK_OFF) { if (AppCommon.isSecondSaturday(currDate) || AppCommon.isFourthSaturday(currDate)) { if ((new ServiceEmployee()).IsWeekOffDayForEmployee("SATURDAY", this.EmployeeID)) { header.ValuesPrimary.Description = "Week Off"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.WEEK_OFF).FirstOrDefault().ColorAttendance; strDescription += string.Format("Week Off {0}", dbOff.Remarks); lblDescription.Text = strDescription; } } else { header.ValuesPrimary.Description = "Week Off"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.WEEK_OFF).FirstOrDefault().ColorAttendance; strDescription += string.Format("Week Off {0}", dbOff.Remarks); lblDescription.Text = strDescription; } } if (dbOff.HolidayType == (int)ATTENDANCE_TYPE.HOLIDAY) { header.ValuesPrimary.Description = "Holiday"; header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.HOLIDAY).FirstOrDefault().ColorAttendance; strDescription += string.Format("Holiday {0}", dbOff.Remarks); lblDescription.Text = strDescription; } } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ControlEmployeeAttendanceViewer::PrepareAttendanceDescription", MessageBoxButtons.OK, MessageBoxIcon.Error); } }