private void gridOnSiteAttendance_RowEnter(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { chkbtnAbsent.Checked = false; chkbtnLeave.Checked = false; chkbtnLeave.Checked = false; chkbtnOutdoor.Checked = false; this.selectedOnSiteEmployeeID = (int)gridOnSiteAttendance.Rows[e.RowIndex].Cells["EmployeeID"].Value; this.selectedOnSiteEmployeeName = gridOnSiteAttendance.Rows[e.RowIndex].Cells["EmployeeName"].Value.ToString(); this._selectedAttendanceRecord = listOnSiteATTENDANCE.Where(x => x.EmployeeID == this.selectedOnSiteEmployeeID).FirstOrDefault(); headerGroupOnSiteAttendanceInput.ValuesSecondary.Heading = "Selected: " + selectedOnSiteEmployeeName; this.selectedAttendanceTYPE = (ATTENDANCE_TYPE)gridOnSiteAttendance.Rows[e.RowIndex].Cells["AttendanceType"].Value; PopulateAttendanceEntryForm(); //SelectListItem typeItem = ((List<SelectListItem>)cboAttendanceType.DataSource).Where(x => x.ID == (int)this.selectedAttendanceTYPE).FirstOrDefault(); //if (typeItem != null) //{ // cboAttendanceType.SelectedItem = typeItem; // txtAttendanceRemarks.Text = gridOnSiteAttendance.Rows[e.RowIndex].Cells["Remarks"].Value.ToString(); //} } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageManualAttendance::gridOnSiteAttendance_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SetAttendanceRowColor() { try { this.Cursor = Cursors.WaitCursor; foreach (DataGridViewRow row in gridAttendance.Rows) { headerGridView.Values.Heading = string.Format("Applying Color : {0} ({1}/{2})", ((DateTime)row.Cells["AttendDate"].Value).ToString("dd MMM yyyy"), row.Index, _AttendanceList.Count); ATTENDANCE_TYPE mType = (ATTENDANCE_TYPE)row.Cells["AttendanceType"].Value; switch (mType) { case ATTENDANCE_TYPE.PRESENT: row.DefaultCellStyle.BackColor = btnPresentColor.SelectedColor; break; case ATTENDANCE_TYPE.ABSENT: row.DefaultCellStyle.BackColor = btnAbsentColor.SelectedColor; break; case ATTENDANCE_TYPE.LEAVE: row.DefaultCellStyle.BackColor = btnLeaveColor.SelectedColor; break; case ATTENDANCE_TYPE.OUT_DOOR: row.DefaultCellStyle.BackColor = btnOutdoorColor.SelectedColor; break; case ATTENDANCE_TYPE.COMP_OFF: row.DefaultCellStyle.BackColor = btnCompOffColor.SelectedColor; break; case ATTENDANCE_TYPE.LATE_COMING: row.DefaultCellStyle.BackColor = btnLateComingColor.SelectedColor; break; case ATTENDANCE_TYPE.EARLY_GOING: row.DefaultCellStyle.BackColor = btnEarlyLeavingColor.SelectedColor; break; case ATTENDANCE_TYPE.MULTIPLE: row.DefaultCellStyle.BackColor = btnDuplicatesColor.SelectedColor; break; } Application.DoEvents(); } headerGridView.Values.Heading = string.Format("Identifying Dulicate Attendance Records & highlighting with defined Color"); Application.DoEvents(); //List<DuplicateAttendaceModel> lstDuplicates = (new ServiceAttendance()).GetDuplicateAttendance(dtAttendanceMonth.Value); //foreach (DuplicateAttendaceModel model in lstDuplicates) //{ // foreach (DataGridViewRow row in gridAttendance.Rows) // { // if ((DateTime)row.Cells["AttendDate"].Value == model.AttendanceDate && (int)row.Cells["FK_EmployeeID"].Value == model.EmployeeID) // { // row.DefaultCellStyle.BackColor = btnDuplicatesColor.SelectedColor; // } // } //} } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageMonthlyAttendanceManager::SetAttendanceRowColor", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }
private void OnColorChange(object sender, ColorEventArgs e) { this.Cursor = Cursors.WaitCursor; try { ATTENDANCE_TYPE mType = (ATTENDANCE_TYPE)((KryptonColorButton)sender).Tag; Color strColor = Color.White; switch (mType) { case ATTENDANCE_TYPE.PRESENT: strColor = btnPresentColor.SelectedColor; break; case ATTENDANCE_TYPE.ABSENT: strColor = btnAbsentColor.SelectedColor; break; case ATTENDANCE_TYPE.LEAVE: strColor = btnLeaveColor.SelectedColor; break; case ATTENDANCE_TYPE.OUT_DOOR: strColor = btnOutdoorColor.SelectedColor; break; case ATTENDANCE_TYPE.COMP_OFF: strColor = btnCompOffColor.SelectedColor; break; case ATTENDANCE_TYPE.LATE_COMING: strColor = btnLateComingColor.SelectedColor; break; case ATTENDANCE_TYPE.EARLY_GOING: strColor = btnEarlyLeavingColor.SelectedColor; break; case ATTENDANCE_TYPE.HOLIDAY: strColor = btnHolidayColor.SelectedColor; break; case ATTENDANCE_TYPE.WEEK_OFF: strColor = btnWeekOffColor.SelectedColor; break; case ATTENDANCE_TYPE.MULTIPLE: strColor = btnDuplicatesColor.SelectedColor; break; } (new ServiceEmployee()).SetColorPreference(Program.CURR_USER.EmployeeID, mType, strColor); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmColorPreference::OnColorChange", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }
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 SetAttendanceRowColor() { try { this.Cursor = Cursors.WaitCursor; List <AttendanceColorModel> lstColors = (new ServiceEmployee()).GetAttendanceColorPreferencesOfEmployee(Program.CURR_USER.EmployeeID); foreach (DataGridViewRow row in gridAttendance.Rows) { headerGroupGrid.ValuesSecondary.Heading = string.Format("Applying Color : {0} ({1}/{2})", ((DateTime)row.Cells["AttendDate"].Value).ToString("dd MMM yyyy"), row.Index, _AttendanceList.Count); ATTENDANCE_TYPE mType = (ATTENDANCE_TYPE)row.Cells["AttendanceType"].Value; switch (mType) { case ATTENDANCE_TYPE.PRESENT: row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.PRESENT).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.ABSENT: row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.ABSENT).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.LEAVE: row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.LEAVE).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.OUT_DOOR: row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.OUT_DOOR).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.COMP_OFF: row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.COMP_OFF).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.LATE_COMING: row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.LATE_COMING).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.EARLY_GOING: row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.EARLY_GOING).FirstOrDefault().ColorAttendance; break; case ATTENDANCE_TYPE.MULTIPLE: row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.MULTIPLE).FirstOrDefault().ColorAttendance; break; } Application.DoEvents(); } headerGroupGrid.ValuesSecondary.Heading = string.Format("Identifying Dulicate Attendance Records & highlighting with defined Color"); Application.DoEvents(); List <DuplicateAttendaceModel> lstDuplicates = (new ServiceAttendance()).GetDuplicateAttendanceBetweenDates(dtFromDate.Value, dtToDate.Value); foreach (DuplicateAttendaceModel model in lstDuplicates) { foreach (DataGridViewRow row in gridAttendance.Rows) { if ((DateTime)row.Cells["AttendDate"].Value == model.AttendanceDate && (int)row.Cells["FK_EmployeeID"].Value == model.EmployeeID) { row.DefaultCellStyle.BackColor = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.MULTIPLE).FirstOrDefault().ColorAttendance; } } } headerGroupGrid.ValuesSecondary.Heading = string.Format("Formatting completed for {0} rows", gridAttendance.Rows.Count); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageMonthlyAttendanceManager::SetAttendanceRowColor", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }
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); } }