protected void Delete_Click(object sender, EventArgs e) { ArrayList list = new ArrayList(); foreach (DataListItem item in Repeater.Items) { CheckBox c = (CheckBox)item.FindControl("DeleteItem"); HtmlInputHidden h = (HtmlInputHidden)item.FindControl("StatutoryHolidayID"); if (c.Checked) { EStatutoryHoliday obj = new EStatutoryHoliday(); obj.StatutoryHolidayID = Int32.Parse(h.Value); list.Add(obj); } } foreach (EStatutoryHoliday obj in list) { if (EStatutoryHoliday.db.select(dbConn, obj)) { WebUtils.StartFunction(Session, FUNCTION_CODE); db.delete(dbConn, obj); WebUtils.EndFunction(dbConn); } } view = loadData(info, db, Repeater); //Response.Redirect(Request.Url.LocalPath); }
protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e) { HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls); e.Item.FindControl("DeleteItem").Visible = IsAllowEdit; if (e.Item.ItemIndex == Repeater.EditItemIndex) { ebinding = new Binding(dbConn, db); ebinding.add((HtmlInputHidden)e.Item.FindControl("StatutoryHolidayID")); ebinding.add(new TextBoxBinder(db, ((WebDatePicker)e.Item.FindControl("StatutoryHolidayDate")).TextBox, "StatutoryHolidayDate")); ebinding.add((TextBox)e.Item.FindControl("StatutoryHolidayDesc")); ebinding.init(Request, Session); EStatutoryHoliday obj = new EStatutoryHoliday(); db.toObject(((DataRowView)e.Item.DataItem).Row, obj); Hashtable values = new Hashtable(); db.populate(obj, values); ebinding.toControl(values); } else { e.Item.FindControl("Edit").Visible = IsAllowEdit; HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("StatutoryHolidayID"); h.Value = ((DataRowView)e.Item.DataItem)["StatutoryHolidayID"].ToString(); } }
protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e) { string holidayDescription = string.Empty; if (DateTime.Compare(e.TimeSlot.Start.Date, DateTime.Now.Date) == 0) { e.TimeSlot.CssClass = "RadSchedulerToday"; } else if (e.TimeSlot.Start.Date.DayOfWeek == DayOfWeek.Sunday) { e.TimeSlot.CssClass = "RadSchedulerHoliday"; } else if (EPublicHoliday.IsHoliday(dbConn, e.TimeSlot.Start.Date)) { e.TimeSlot.CssClass = "RadSchedulerHoliday"; //Label holidayLabel = new Label(); //holidayLabel.Text = holidayDescription; //holidayLabel.ForeColor = System.Drawing.Color.Red; ////holidayLabel.CssClass = "FloatRight"; ////e.TimeSlot.Control.Controls.AddAt(1, holidayLabel); //e.TimeSlot.Control.Controls[0].Controls.AddAt(1, holidayLabel); } else if (EStatutoryHoliday.IsHoliday(dbConn, e.TimeSlot.Start.Date)) { e.TimeSlot.CssClass = "RadSchedulerHoliday"; //Label holidayLabel = new Label(); //holidayLabel.Text = holidayDescription; //holidayLabel.ForeColor = System.Drawing.Color.Red; ////holidayLabel.CssClass = "FloatRight"; ////e.TimeSlot.Control.Controls.AddAt(1, holidayLabel); //e.TimeSlot.Control.Controls[0].Controls.AddAt(1, holidayLabel); } }
protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e) { Button b = (Button)e.CommandSource; if (b.ID.Equals("Edit")) { Repeater.EditItemIndex = e.Item.ItemIndex; view = loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(AddPanel, false); } else if (b.ID.Equals("Cancel")) { Repeater.EditItemIndex = -1; view = loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(AddPanel, true); } else if (b.ID.Equals("Save")) { ebinding = new Binding(dbConn, db); ebinding.add((HtmlInputHidden)e.Item.FindControl("StatutoryHolidayID")); ebinding.add(new TextBoxBinder(db, ((WebDatePicker)e.Item.FindControl("StatutoryHolidayDate")).TextBox, "StatutoryHolidayDate")); ebinding.add((TextBox)e.Item.FindControl("StatutoryHolidayDesc")); ebinding.init(Request, Session); EStatutoryHoliday obj = new EStatutoryHoliday(); Hashtable values = new Hashtable(); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); ebinding.toValues(values); db.validate(errors, values); if (!errors.isEmpty()) { return; } db.parse(values, obj); if (!AppUtils.checkDuplicate(dbConn, db, obj, errors, "StatutoryHolidayDate")) { return; } WebUtils.StartFunction(Session, FUNCTION_CODE); db.update(dbConn, obj); WebUtils.EndFunction(dbConn); Repeater.EditItemIndex = -1; view = loadData(info, db, Repeater); WebUtils.SetEnabledControlSection(AddPanel, true); } }
protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e) { if (DateTime.Compare(e.TimeSlot.Start.Date, DateTime.Now.Date) == 0) { e.TimeSlot.CssClass = "RadSchedulerToday"; } else if (e.TimeSlot.Start.Date.DayOfWeek == DayOfWeek.Sunday) { e.TimeSlot.CssClass = "RadSchedulerHoliday"; } else if (EPublicHoliday.IsHoliday(dbConn, e.TimeSlot.Start.Date)) { e.TimeSlot.CssClass = "RadSchedulerHoliday"; } else if (EStatutoryHoliday.IsHoliday(dbConn, e.TimeSlot.Start.Date)) { e.TimeSlot.CssClass = "RadSchedulerHoliday"; } }
protected void Add_Click(object sender, EventArgs e) { Repeater.EditItemIndex = -1; EStatutoryHoliday c = new EStatutoryHoliday(); Hashtable values = new Hashtable(); binding.toValues(values); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); db.validate(errors, values); if (!errors.isEmpty()) { return; } db.parse(values, c); if (!AppUtils.checkDuplicate(dbConn, db, c, errors, "StatutoryHolidayDate")) { return; } WebUtils.StartFunction(Session, FUNCTION_CODE); db.insert(dbConn, c); WebUtils.EndFunction(dbConn); StatutoryHolidayDate.Value = string.Empty; StatutoryHolidayDesc.Text = string.Empty; view = loadData(info, db, Repeater); }
private static DataRow CreateWorkingSummaryTemplateRow(DatabaseConnection dbConn, DataTable dataTable, Hashtable hierarchyLevelHashTable, EEmpPersonalInfo empInfo, DateTime PeriodFrom, DateTime PeriodTo, EWorkHourPattern currentWorkHourPattern) { double restDayCount = 0; double statutoryHolidayCount = 0; double restDayTaken = 0; double statutoryHolidayTaken = 0; double workHourPatternWorkingDaysCount = 0; double workHourPatternLunchTimeCount = 0; double workHourPatternWorkingHourCount = 0; double totalWorkingDays = 0; double totalWorkingHours = 0; double totalLunchMins = 0; double totalWorkingHoursExpected = 0; double totalLateMins = 0; double totalEarlyLeaveMins = 0; double totalOvertimeMins = 0; double totalLeaveApplicationDayTaken = 0; EEmpTermination empTermination = EEmpTermination.GetObjectByEmpID(dbConn, empInfo.EmpID); bool hasStatutoryHolidayRosterCode = false; // Check if Roster Code List contains Statutory Holiday Roster Code ArrayList rosterCodeList = ERosterCode.db.select(dbConn, new DBFilter()); foreach (ERosterCode rosterCode in rosterCodeList) { if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_STATUTORYHOLIDAY)) { hasStatutoryHolidayRosterCode = true; break; } } if (currentWorkHourPattern != null) { for (DateTime asOfDate = PeriodFrom; asOfDate <= PeriodTo; asOfDate = asOfDate.AddDays(1)) { if (EStatutoryHoliday.IsHoliday(dbConn, asOfDate))// && currentWorkHourPattern.WorkHourPatternUseStatutoryHolidayTable) { statutoryHolidayCount++; } //rest day must be integer and rest within 24 hour restDayCount += (1 - currentWorkHourPattern.GetDefaultDayUnit(dbConn, asOfDate, false, false)); double workDayUnit = 0; double workHourUnit = 0; double LunchTimeUnit = 0; if (empInfo.EmpDateOfJoin <= asOfDate) { workDayUnit = currentWorkHourPattern.GetDefaultDayUnit(dbConn, asOfDate, false, false); LunchTimeUnit = currentWorkHourPattern.GetDefaultLunch(dbConn, asOfDate); workHourUnit = currentWorkHourPattern.GetDefaultWorkHour(dbConn, asOfDate); DBFilter leaveAppFilter = new DBFilter(); leaveAppFilter.add(new Match("EmpID", empInfo.EmpID)); leaveAppFilter.add(new Match("LeaveAppDateFrom", "<=", asOfDate)); leaveAppFilter.add(new Match("LeaveAppDateTo", ">=", asOfDate)); leaveAppFilter.add(new Match("LeaveAppNoPayProcess", false)); ArrayList leaveAppList = ELeaveApplication.db.select(dbConn, leaveAppFilter); foreach (ELeaveApplication leaveApp in leaveAppList) { if (leaveApp.LeaveAppDateFrom.Equals(leaveApp.LeaveAppDateTo)) { workDayUnit -= leaveApp.LeaveAppDays; double currentDayDefaultDayUnit = currentWorkHourPattern.GetDefaultDayUnit(dbConn, asOfDate, false, false); if (currentDayDefaultDayUnit * leaveApp.LeaveAppDays > 0) { workHourUnit -= currentWorkHourPattern.GetDefaultWorkHour(dbConn, asOfDate) / currentDayDefaultDayUnit * leaveApp.LeaveAppDays; } } else { workDayUnit = 0; workHourUnit = 0; LunchTimeUnit = 0; } } if (workDayUnit < 0) { workDayUnit = 0; } if (workHourUnit < 0) { workHourUnit = 0; } if (workDayUnit < 1) { LunchTimeUnit = 0; } if (empTermination != null) { if (empTermination.EmpTermLastDate < asOfDate) { workDayUnit = 0; workHourUnit = 0; LunchTimeUnit = 0; } } } workHourPatternWorkingDaysCount += workDayUnit; workHourPatternWorkingHourCount += workHourUnit; workHourPatternLunchTimeCount += LunchTimeUnit; } DBFilter leaveAppTakenFilter = new DBFilter(); leaveAppTakenFilter.add(new Match("EmpID", empInfo.EmpID)); leaveAppTakenFilter.add(new Match("LeaveAppDateFrom", "<=", PeriodTo)); leaveAppTakenFilter.add(new Match("LeaveAppDateTo", ">=", PeriodFrom)); leaveAppTakenFilter.add(new Match("LeaveAppNoPayProcess", false)); ArrayList leaveAppTakenList = ELeaveApplication.db.select(dbConn, leaveAppTakenFilter); foreach (ELeaveApplication leaveApp in leaveAppTakenList) { totalLeaveApplicationDayTaken += leaveApp.LeaveAppDays; } } DBFilter attendanceRecordFilter = new DBFilter(); attendanceRecordFilter.add(new Match("EmpID", empInfo.EmpID)); attendanceRecordFilter.add(new Match("AttendanceRecordDate", ">=", PeriodFrom)); attendanceRecordFilter.add(new Match("AttendanceRecordDate", "<=", PeriodTo)); attendanceRecordFilter.add("AttendanceRecordDate", true); ArrayList attendanceRecordList = EAttendanceRecord.db.select(dbConn, attendanceRecordFilter); foreach (EAttendanceRecord attendanceRecord in attendanceRecordList) { ERosterCode rosterCode = new ERosterCode(); rosterCode.RosterCodeID = attendanceRecord.RosterCodeID; if (ERosterCode.db.select(dbConn, rosterCode)) { if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_RESTDAY)) { restDayTaken++; } if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_STATUTORYHOLIDAY)) { statutoryHolidayTaken++; } } double workingHours = attendanceRecord.TotalWorkingHourTimeSpan(dbConn).TotalHours; if (workingHours <= 0) { workingHours = attendanceRecord.AttendanceRecordActualWorkingHour + Convert.ToDouble(attendanceRecord.AttendanceRecordActualEarlyLeaveMins - attendanceRecord.AttendanceRecordActualLateMins + attendanceRecord.AttendanceRecordActualOvertimeMins) / 60.0; } totalWorkingDays += attendanceRecord.AttendanceRecordActualWorkingDay; totalWorkingHours += workingHours; totalWorkingHoursExpected += attendanceRecord.AttendanceRecordActualWorkingHour; totalLateMins += attendanceRecord.AttendanceRecordActualLateMins; totalEarlyLeaveMins += attendanceRecord.AttendanceRecordActualEarlyLeaveMins; totalOvertimeMins += attendanceRecord.AttendanceRecordActualOvertimeMins; totalLunchMins += attendanceRecord.AttendanceRecordActualLunchTimeMins; } if (totalWorkingDays <= 0 && totalWorkingHours <= 0 && totalLunchMins <= 0 && empInfo.EmpDateOfJoin <= PeriodFrom) { totalWorkingDays = workHourPatternWorkingDaysCount; totalWorkingHours = workHourPatternWorkingHourCount; totalLunchMins = workHourPatternLunchTimeCount * 60; } DataRow row = dataTable.NewRow(); row[FIELD_EMP_NO] = empInfo.EmpNo; row["EnglishName"] = empInfo.EmpEngFullName; row["ChineseName"] = empInfo.EmpChiFullName; DBFilter empPosFilter = new DBFilter(); EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, PeriodTo, empInfo.EmpID); if (empPos != null) { ECompany company = new ECompany(); company.CompanyID = empPos.CompanyID; if (ECompany.db.select(dbConn, company)) { row["Company"] = company.CompanyCode; } DBFilter empHierarchyFilter = new DBFilter(); empHierarchyFilter.add(new Match("EmpPosID", empPos.EmpPosID)); ArrayList empHierarchyList = EEmpHierarchy.db.select(dbConn, empHierarchyFilter); foreach (EEmpHierarchy empHierarchy in empHierarchyList) { EHierarchyLevel hierarchyLevel = (EHierarchyLevel)hierarchyLevelHashTable[empHierarchy.HLevelID]; if (hierarchyLevel != null) { EHierarchyElement hierarchyElement = new EHierarchyElement(); hierarchyElement.HElementID = empHierarchy.HElementID; if (EHierarchyElement.db.select(dbConn, hierarchyElement)) { row[hierarchyLevel.HLevelDesc] = hierarchyElement.HElementCode; } } } } row[FIELD_AS_OF_DATE] = PeriodTo; row[FIELD_REST_DAY_ENTITLED] = restDayCount - statutoryHolidayCount; if (hasStatutoryHolidayRosterCode) { row[FIELD_REST_DAY_TAKEN] = restDayTaken; } else { row[FIELD_REST_DAY_TAKEN] = restDayTaken > statutoryHolidayCount ? restDayTaken - statutoryHolidayCount : 0; } row[FIELD_TOTAL_WORKING_DAYS] = totalWorkingDays; row[FIELD_TOTAL_WORKING_HOURS] = totalWorkingHours; row[FIELD_TOTAL_LUNCH_HOURS] = totalLunchMins / 60.0; row[FIELD_EXTRA_TOTAL_STATUTORY_HOLIDAY] = statutoryHolidayCount; row[FIELD_EXTRA_TOTAL_LEAVE_APPLICATION_TAKEN] = totalLeaveApplicationDayTaken; row[FIELD_EXTRA_TOTAL_WORKING_HOURS_EXPECTED] = totalWorkingHoursExpected; row[FIELD_EXTRA_TOTAL_LATE_MINS] = totalLateMins; row[FIELD_EXTRA_TOTAL_EARLYLEAVE_MINS] = totalEarlyLeaveMins; row[FIELD_EXTRA_TOTAL_OVERTIME_MINS] = totalOvertimeMins; dataTable.Rows.Add(row); return(row); }
protected RosterTableEventList GenerateEventList(ICollection DBObjectList) { RosterTableEventList tmpEventList = new RosterTableEventList(); if (DBObjectList != null) { foreach (DBObject dbObject in DBObjectList) { if (dbObject is ERosterTable) { ERosterTable rosterTable = (ERosterTable)dbObject; ERosterCode rosterCode = new ERosterCode(); rosterCode.RosterCodeID = rosterTable.RosterCodeID; bool hasRecord = ERosterCode.db.select(dbConn, rosterCode); if (hasRecord || rosterCode.RosterCodeID == 0) { RosterTableEvent eventDetail = new RosterTableEvent(); eventDetail.Id = RosterTableEvent.ROSTER_TABLE_ID_PREFIX + "_" + rosterTable.RosterTableID; // Override Start/End time only when the roster code exists if (rosterTable.RosterTableOverrideInTime.Ticks.Equals(0) || !hasRecord) { eventDetail.StartTime = rosterTable.RosterTableDate.Add(rosterCode.RosterCodeInTime.TimeOfDay); } else { eventDetail.StartTime = rosterTable.RosterTableDate.Add(rosterTable.RosterTableOverrideInTime.TimeOfDay); } if (rosterTable.RosterTableOverrideOutTime.Ticks.Equals(0) || !hasRecord) { eventDetail.EndTime = rosterTable.RosterTableDate.Add(rosterCode.RosterCodeOutTime.TimeOfDay); } else { eventDetail.EndTime = rosterTable.RosterTableDate.Add(rosterTable.RosterTableOverrideOutTime.TimeOfDay); } if (eventDetail.StartTime >= eventDetail.EndTime) { eventDetail.EndTime = eventDetail.EndTime.AddDays(1); if (!DisplayOvernightToNextDay) { eventDetail.EndTime = eventDetail.EndTime.Date; } } EEmpPersonalInfo empInfo = new EEmpPersonalInfo(); empInfo.EmpID = rosterTable.EmpID; EEmpPersonalInfo.db.select(dbConn, empInfo); eventDetail.Subject = (hasRecord ? rosterCode.RosterCode : "(unspecified)") + " - " + empInfo.EmpEngDisplayName; eventDetail.ToolTip = eventDetail.Subject; eventDetail.Label = rosterCode.RosterClientSiteID; eventDetail.RecurrenceInfo = string.Empty; eventDetail.OwnerId = rosterCode.RosterClientSiteID; tmpEventList.Add(eventDetail); } } else if (dbObject is ELeaveApplication) { ELeaveApplication leaveApplication = (ELeaveApplication)dbObject; ELeaveCode leaveCode = new ELeaveCode(); leaveCode.LeaveCodeID = leaveApplication.LeaveCodeID; bool hasRecord = ELeaveCode.db.select(dbConn, leaveCode); if (hasRecord) { RosterTableEvent eventDetail = new RosterTableEvent(); eventDetail.Id = RosterTableEvent.LEAVEAPP_ID_PREFIX + "_" + leaveApplication.LeaveAppID; if (leaveApplication.LeaveAppUnit.Equals(ELeaveApplication.LEAVEUNIT_DAYS)) { eventDetail.StartTime = leaveApplication.LeaveAppDateFrom; eventDetail.EndTime = leaveApplication.LeaveAppDateTo.AddDays(1); } else { eventDetail.StartTime = leaveApplication.LeaveAppDateFrom; eventDetail.EndTime = leaveApplication.LeaveAppDateFrom; if (!leaveApplication.LeaveAppTimeFrom.Ticks.Equals(0)) { eventDetail.StartTime = eventDetail.StartTime.Add(leaveApplication.LeaveAppTimeFrom.TimeOfDay); } if (!leaveApplication.LeaveAppTimeTo.Ticks.Equals(0)) { eventDetail.EndTime = eventDetail.EndTime.Add(leaveApplication.LeaveAppTimeTo.TimeOfDay); } if (leaveApplication.LeaveAppUnit.Equals(ELeaveApplication.LEAVEUNIT_AM)) { if (eventDetail.StartTime.Equals(leaveApplication.LeaveAppDateFrom)) { eventDetail.StartTime = eventDetail.StartTime.Add(new TimeSpan(0, 0, 0)); } if (eventDetail.EndTime.Equals(leaveApplication.LeaveAppDateFrom)) { eventDetail.EndTime = eventDetail.EndTime.Add(new TimeSpan(13, 0, 0)); } } if (leaveApplication.LeaveAppUnit.Equals(ELeaveApplication.LEAVEUNIT_PM)) { if (eventDetail.StartTime.Equals(leaveApplication.LeaveAppDateFrom)) { eventDetail.StartTime = eventDetail.StartTime.Add(new TimeSpan(13, 0, 0)); } if (eventDetail.EndTime.Equals(leaveApplication.LeaveAppDateFrom)) { eventDetail.EndTime = eventDetail.EndTime.AddDays(1); } } else { if (eventDetail.StartTime.Equals(leaveApplication.LeaveAppDateFrom)) { eventDetail.StartTime = eventDetail.StartTime.Add(new TimeSpan(0, 0, 0)); } if (eventDetail.EndTime.Equals(leaveApplication.LeaveAppDateFrom)) { eventDetail.EndTime = eventDetail.EndTime.AddDays(1); } } } EEmpPersonalInfo empInfo = new EEmpPersonalInfo(); empInfo.EmpID = leaveApplication.EmpID; EEmpPersonalInfo.db.select(dbConn, empInfo); //eventDetail.Subject = (hasRecord ? leaveCode.LeaveCode : "(unspecified)") + " - " + empInfo.EmpEngDisplayName; if (leaveApplication.LeaveAppDays < 0 || leaveApplication.LeaveAppHours < 0) { eventDetail.IsCancel = true; } string LeaveUnitDetail = string.Empty; if (leaveApplication.LeaveAppUnit.Equals("D")) { LeaveUnitDetail = leaveApplication.LeaveAppDays + " " + "Day" + (leaveApplication.LeaveAppDays > 1 ? "s" : string.Empty); } else if (leaveApplication.LeaveAppUnit.Equals("H")) { if (leaveApplication.LeaveAppTimeFrom.Ticks.Equals(0) || leaveApplication.LeaveAppTimeTo.Ticks.Equals(0)) { LeaveUnitDetail = leaveApplication.LeaveAppHours + " " + "Hour" + (leaveApplication.LeaveAppHours > 1 ? "s" : string.Empty); } else { LeaveUnitDetail = leaveApplication.LeaveAppTimeFrom.ToString("HH:mm") + "-" + leaveApplication.LeaveAppTimeTo.ToString("HH:mm"); } } else if (leaveApplication.LeaveAppUnit.Equals("A")) { if (leaveApplication.LeaveAppDays > 0) { LeaveUnitDetail = "A.M."; } else { LeaveUnitDetail = "-A.M."; } } else if (leaveApplication.LeaveAppUnit.Equals("P")) { if (leaveApplication.LeaveAppDays > 0) { LeaveUnitDetail = "P.M."; } else { LeaveUnitDetail = "-P.M."; } } eventDetail.Subject = (hasRecord ? leaveCode.LeaveCode : "(unspecified)") + (string.IsNullOrEmpty(LeaveUnitDetail) ? string.Empty : ("(" + LeaveUnitDetail + ")")) + " - " + empInfo.EmpEngDisplayName; eventDetail.ToolTip = eventDetail.Subject; //eventDetail.Label = rosterCode.RosterClientSiteID; eventDetail.RecurrenceInfo = string.Empty; //eventDetail.OwnerId = rosterCode.RosterClientSiteID; tmpEventList.Add(eventDetail); } } else if (dbObject is EPublicHoliday) { EPublicHoliday holiday = (EPublicHoliday)dbObject; RosterTableEvent eventDetail = new RosterTableEvent(); eventDetail.Id = RosterTableEvent.PUBLICHOLIDAY_PREFIX + "_" + holiday.PublicHolidayID; eventDetail.StartTime = holiday.PublicHolidayDate; eventDetail.EndTime = holiday.PublicHolidayDate.AddDays(1); eventDetail.Subject = holiday.PublicHolidayDesc; eventDetail.ToolTip = eventDetail.Subject; //eventDetail.Label = rosterCode.RosterClientSiteID; eventDetail.RecurrenceInfo = string.Empty; //eventDetail.OwnerId = rosterCode.RosterClientSiteID; tmpEventList.Add(eventDetail); } else if (dbObject is EStatutoryHoliday) { EStatutoryHoliday holiday = (EStatutoryHoliday)dbObject; RosterTableEvent eventDetail = new RosterTableEvent(); eventDetail.Id = RosterTableEvent.STATUTORYHOLIDAY_PREFIX + "_" + holiday.StatutoryHolidayID; eventDetail.StartTime = holiday.StatutoryHolidayDate; eventDetail.EndTime = holiday.StatutoryHolidayDate.AddDays(1); eventDetail.Subject = holiday.StatutoryHolidayDesc; eventDetail.ToolTip = eventDetail.Subject; //eventDetail.Label = rosterCode.RosterClientSiteID; eventDetail.RecurrenceInfo = string.Empty; //eventDetail.OwnerId = rosterCode.RosterClientSiteID; tmpEventList.Add(eventDetail); } } } return(tmpEventList); }
protected void btnUpdate_Click(object sender, EventArgs e) { PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); if (HolidayTableFile.HasFile) { string strTmpFolder = HROne.Common.Folder.GetOrCreateSessionTempFolder(Session.SessionID).FullName;; //Environment.GetFolderPath(Environment.SpecialFolder.InternetCache); string strTmpFile = System.IO.Path.Combine(strTmpFolder, AppUtils.ServerDateTime().ToString("~yyyyMMddHHmmss_") + HolidayTableFile.FileName); HolidayTableFile.SaveAs(strTmpFile); try { ArrayList pendingStatHolList = new ArrayList(); DataTable rawDataTable = HROne.Import.ExcelImport.parse(strTmpFile, string.Empty).Tables[TABLE_NAME]; if (rawDataTable.Columns.Contains("Date") && rawDataTable.Columns.Contains("Description")) { foreach (DataRow row in rawDataTable.Rows) { EStatutoryHoliday statHol = new EStatutoryHoliday(); statHol.StatutoryHolidayDate = HROne.Import.Parse.toDateTimeObject(row["Date"]); if (statHol.StatutoryHolidayDate.Year.ToString().Trim().Equals(YearSelect.SelectedValue.Trim())) { if (!row.IsNull("Description")) { statHol.StatutoryHolidayDesc = (string)row["Description"]; } pendingStatHolList.Add(statHol); } } } else { errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_FILE); } if (pendingStatHolList.Count > 0) { WebUtils.StartFunction(Session, FUNCTION_CODE); DBFilter filter = sbinding.createFilter(); filter.add("StatutoryHolidayDate", true); ArrayList holidayList = EStatutoryHoliday.db.select(dbConn, filter); foreach (EStatutoryHoliday statHol in holidayList) { EStatutoryHoliday updatedHol = null; foreach (EStatutoryHoliday pendingStatHol in pendingStatHolList) { if (pendingStatHol.StatutoryHolidayDate.Equals(statHol.StatutoryHolidayDate)) { updatedHol = pendingStatHol; if (!statHol.StatutoryHolidayDesc.Equals(pendingStatHol.StatutoryHolidayDesc)) { statHol.StatutoryHolidayDesc = pendingStatHol.StatutoryHolidayDesc; EStatutoryHoliday.db.update(dbConn, statHol); } break; } } if (updatedHol != null) { pendingStatHolList.Remove(updatedHol); } else { EStatutoryHoliday.db.delete(dbConn, statHol); } } foreach (EStatutoryHoliday insertStatHol in pendingStatHolList) { EStatutoryHoliday.db.insert(dbConn, insertStatHol); } WebUtils.EndFunction(dbConn); } else { errors.addError(HROne.Translation.PageErrorMessage.ERROR_NO_RECORD_IMPORT); } } catch (Exception) { errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_FILE); } System.IO.File.Delete(strTmpFile); } else { errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_FILE); } Repeater.EditItemIndex = -1; view = loadData(info, db, Repeater); if (errors.isEmpty()) { errors.addError(HROne.Translation.PageMessage.IMPORT_SUCCESSFUL); } }