public void Update(RosterTableEvent e) { if (e.Id != null) { e.Update(dbConn); } }
//protected void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e) //{ // if (!RadCalendar1.SelectedDate.Equals(DateTime.MinValue)) // RadScheduler1.SelectedDate = RadCalendar1.SelectedDate; //} //protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e) //{ // RadCalendar1.SelectedDate = RadScheduler1.SelectedDate; // RadCalendar1.FocusedDate = RadCalendar1.SelectedDate; //} protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e) { //e.Appointment.ContextMenuID= e.Appointment.AllowDelete = false; if (e.Appointment.ID.ToString().StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.LEAVEAPP_ID_PREFIX)) { e.Appointment.AllowEdit = false; } else { e.Appointment.AllowEdit = m_IsAllowWrite; } HROne.Lib.Attendance.DataSource.RosterTableEvent rosterTableEvent = (HROne.Lib.Attendance.DataSource.RosterTableEvent)e.Appointment.DataItem; e.Appointment.ToolTip = rosterTableEvent.ToolTip; if (rosterTableEvent.Id.StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.PUBLICHOLIDAY_PREFIX) || rosterTableEvent.Id.StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.STATUTORYHOLIDAY_PREFIX)) { e.Appointment.AllowEdit = false; e.Appointment.ForeColor = System.Drawing.Color.Red; } object dbObjectItem = HROne.Lib.Attendance.DataSource.RosterTableEvent.IDToDBObject(dbConn, e.Appointment.ID); if (dbObjectItem is ERosterTable) { ERosterTable rosterTable = (ERosterTable)dbObjectItem; ERosterCode rosterCode = new ERosterCode(); rosterCode.RosterCodeID = rosterTable.RosterCodeID; if (ERosterCode.db.select(dbConn, rosterCode)) { if (!string.IsNullOrEmpty(rosterCode.RosterCodeColorCode)) { try { e.Appointment.BackColor = System.Drawing.ColorTranslator.FromHtml(rosterCode.RosterCodeColorCode); e.Appointment.ForeColor = AppUtils.ComputeTextColor(e.Appointment.BackColor); } catch { } } } } if (RadScheduler1.SelectedView == SchedulerViewType.TimelineView) { if (RadScheduler1.Appointments.Count > 10) { RadScheduler1.Height = Unit.Parse(""); } } }
public static void Delete(RosterTableEvent e) { }
public static void Insert(RosterTableEvent e) { if (e.Id != null) { } }
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 PopulateEditForm(Appointment editedAppointment) //{ // WebFormUtils.loadValues(RosterClientID, ERosterClient.VLRosterClient, new DBFilter()); // if (editedAppointment.ID != null) // { // string[] id_Array = editedAppointment.ID.ToString().Split(new char[] { '_' }); // if (id_Array.GetLength(0) == 2) // { // if (id_Array[0].Equals("RosterTable")) // { // ERosterTable rosterTable = new ERosterTable(); // rosterTable.RosterTableID = int.Parse(id_Array[1]); // if (ERosterTable.db.select(rosterTable)) // { // Binding ebinding = new Binding(ERosterTable.db); // ebinding.add(RosterTableID); // ebinding.add(EmpID); // ebinding.add(RosterTableDate); // ebinding.add(new DropDownVLBinder(ERosterTable.db, RosterCodeID, ERosterCode.VLRosterCode)); // ebinding.init(Request, Session); // Hashtable values = new Hashtable(); // ERosterTable.db.populate(rosterTable, values); // ebinding.toControl(values); // EEmpPersonalInfo empInfo = new EEmpPersonalInfo(); // empInfo.EmpID = rosterTable.EmpID; // if (EEmpPersonalInfo.db.select(empInfo)) // EmpName.Text = empInfo.EmpEngFullNameWithAlias; // else // EmpName.Text = string.Empty; // } // ERosterCode rosterCode = new ERosterCode(); // rosterCode.RosterCodeID = rosterTable.RosterCodeID; // ERosterCode.db.select(rosterCode); // if (rosterCode.RosterClientID > 0) // RosterClientID.SelectedValue = rosterCode.RosterClientID.ToString(); // RefreshClientSite(rosterCode.RosterClientID); // if (rosterCode.RosterClientSiteID > 0) // RosterClientSiteID.SelectedValue = rosterCode.RosterClientSiteID.ToString(); // RefreshRosterCode(rosterCode.RosterClientSiteID); // } // } // } //} //protected void RefreshClientSite(int RosterClientID) //{ // string selected = RosterClientSiteID.SelectedValue; // DBFilter rosterClientSiteFilter = new DBFilter(); // rosterClientSiteFilter.add(new Match("RosterClientID", RosterClientID)); // WebFormUtils.loadValues(RosterClientSiteID, ERosterClientSite.VLRosterClientSite, rosterClientSiteFilter, null, (string)selected, (string)"combobox.notselected"); //} //protected void RefreshRosterCode(int RosterClientSiteID) //{ // string selected = RosterCodeID.SelectedValue; // DBFilter rosterCodeFilter = new DBFilter(); // rosterCodeFilter.add(new Match("RosterClientSiteID", RosterClientSiteID)); // WebFormUtils.loadValues(RosterCodeID, ERosterCode.VLRosterCode, rosterCodeFilter, null, (string)selected, (string)"combobox.notselected"); //} //protected void SubmitButton_Click(object sender, EventArgs e) //{ // ERosterTable rosterTable = new ERosterTable(); // Binding ebinding = new Binding(ERosterTable.db); // ebinding.add(RosterTableID); // ebinding.add(RosterTableDate); // ebinding.add(EmpID); // ebinding.add(new DropDownVLBinder(ERosterTable.db, RosterCodeID, ERosterCode.VLRosterCode)); // Hashtable values = new Hashtable(); // ebinding.toValues(values); // ERosterTable.db.parse(values, rosterTable); // ERosterTable.db.update(rosterTable); // //// Create resource based on the selected user // ////Resource user = new Resource("User", int.Parse(UserDropDown.SelectedValue), UserDropDown.SelectedItem.Text); // //DateTime start = RadScheduler1.DisplayToUtc(StartTime.SelectedDate.Value); // //DateTime end = RadScheduler1.DisplayToUtc(EndTime.SelectedDate.Value); // //if (EditedAppointmentID == null) // //{ // // // Insert // // Appointment appointment = new Appointment(null, start, end, DescriptionText.Text); // // //appointment.Resources.Add(user); // // RadScheduler1.InsertAppointment(appointment); // //} // //else // //{ // // Appointment appointment = RadScheduler1.Appointments.FindByID(EditedAppointmentID); // // Appointment appointmentToUpdate = RadScheduler1.PrepareToEdit(appointment, RadScheduler1.EditingRecurringSeries); // // appointmentToUpdate.Subject = DescriptionText.Text; // // appointmentToUpdate.Start = start; // // appointmentToUpdate.End = end; // // // Remove the existing user resource, if any // // Resource existingUser = appointmentToUpdate.Resources.GetResourceByType("User"); // // if (existingUser != null) // // { // // appointmentToUpdate.Resources.Remove(existingUser); // // } // // //appointmentToUpdate.Resources.Add(user); // // RadScheduler1.UpdateAppointment(appointmentToUpdate); // //} // RadScheduler1.Rebind(); // RadDock1.Closed = true; //} //protected void RosterClientID_SelectedIndexChanged(object sender, EventArgs e) //{ // string selected = RosterClientID.SelectedValue; // int intRosterClientID; // if (int.TryParse(selected, out intRosterClientID)) // RefreshClientSite(intRosterClientID); // else // RefreshClientSite(0); // selected = RosterClientSiteID.SelectedValue; // int intRosterClientSiteID; // if (int.TryParse(selected, out intRosterClientSiteID)) // RefreshRosterCode(intRosterClientSiteID); // else // RefreshRosterCode(0); //} //protected void RosterClientSiteID_SelectedIndexChanged(object sender, EventArgs e) //{ // string selected = RosterClientSiteID.SelectedValue; // int intRosterClientSiteID; // if (int.TryParse(selected, out intRosterClientSiteID)) // RefreshRosterCode(intRosterClientSiteID); // else // RefreshRosterCode(0); //} //protected void RadDock1_DockPositionChanged(object sender, DockPositionChangedEventArgs e) //{ // Console.Write(e.ToString()); //} //protected void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e) //{ // if (!RadCalendar1.SelectedDate.Equals(DateTime.MinValue)) // RadScheduler1.SelectedDate = RadCalendar1.SelectedDate; //} //protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e) //{ // RadCalendar1.SelectedDate = RadScheduler1.SelectedDate; // RadCalendar1.FocusedDate = RadCalendar1.SelectedDate; //} protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e) { //e.Appointment.ContextMenuID= e.Appointment.AllowDelete = false; if (e.Appointment != null) { HROne.Lib.Attendance.DataSource.RosterTableEvent rosterTableEvent = (HROne.Lib.Attendance.DataSource.RosterTableEvent)e.Appointment.DataItem; e.Appointment.ToolTip = rosterTableEvent.ToolTip; e.Appointment.AllowEdit = false; if (rosterTableEvent.Id.StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.PUBLICHOLIDAY_PREFIX) || rosterTableEvent.Id.StartsWith(HROne.Lib.Attendance.DataSource.RosterTableEvent.STATUTORYHOLIDAY_PREFIX)) { e.Appointment.ForeColor = System.Drawing.Color.Red; } if (rosterTableEvent.IsCancel) { e.Appointment.ForeColor = System.Drawing.Color.Green; } //EEmpPositionInfo userEmpPos = AppUtils.GetLastPositionInfo(dbConn, e.Appointment.Start.Date, m_ESSUserID); object dbObjectItem = HROne.Lib.Attendance.DataSource.RosterTableEvent.IDToDBObject(dbConn, e.Appointment.ID); if (dbObjectItem is ERosterTable) { ERosterTable rosterTable = (ERosterTable)dbObjectItem; ERosterCode rosterCode = new ERosterCode(); rosterCode.RosterCodeID = rosterTable.RosterCodeID; if (ERosterCode.db.select(dbConn, rosterCode)) { if (!string.IsNullOrEmpty(rosterCode.RosterCodeColorCode)) { try { e.Appointment.BackColor = System.Drawing.ColorTranslator.FromHtml(rosterCode.RosterCodeColorCode); e.Appointment.ForeColor = AppUtils.ComputeTextColor(e.Appointment.BackColor); } catch { } } } DBFilter userRosterTableGroupListFilter = new DBFilter(); userRosterTableGroupListFilter.add(new Match("EmpID", m_ESSUserID)); userRosterTableGroupListFilter.add(new Match("EmpRosterTableGroupIsSupervisor", true)); userRosterTableGroupListFilter.add(new Match("empRosterTableGroupEffFr", "<=", e.Appointment.Start.Date)); OR orEmpPosEffToTerms = new OR(); orEmpPosEffToTerms.add(new Match("empRosterTableGroupEffTo", ">=", e.Appointment.Start.Date)); orEmpPosEffToTerms.add(new NullTerm("empRosterTableGroupEffTo")); userRosterTableGroupListFilter.add(orEmpPosEffToTerms); ArrayList empRosterTableGroupList = EEmpRosterTableGroup.db.select(dbConn, userRosterTableGroupListFilter); foreach (EEmpRosterTableGroup empRosterTableGroup in empRosterTableGroupList) { DBFilter subordinateRosterTableGroupListFilter = new DBFilter(); subordinateRosterTableGroupListFilter.add(new Match("EmpID", rosterTable.EmpID)); subordinateRosterTableGroupListFilter.add(new Match("RosterTableGroupID", empRosterTableGroup.RosterTableGroupID)); subordinateRosterTableGroupListFilter.add(new Match("empRosterTableGroupEffFr", "<=", e.Appointment.Start.Date)); OR orSubOrdinateEmpPosEffToTerms = new OR(); orSubOrdinateEmpPosEffToTerms.add(new Match("empRosterTableGroupEffTo", ">=", e.Appointment.Start.Date)); orSubOrdinateEmpPosEffToTerms.add(new NullTerm("empRosterTableGroupEffTo")); subordinateRosterTableGroupListFilter.add(orSubOrdinateEmpPosEffToTerms); if (EEmpRosterTableGroup.db.count(dbConn, subordinateRosterTableGroupListFilter) > 0) { e.Appointment.AllowEdit = true; } //EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, e.Appointment.Start.Date, rosterTable.EmpID); //if (empPos != null) // if (empPos.RosterTableGroupID.Equals(userEmpPos.RosterTableGroupID)) // e.Appointment.AllowEdit = true; // else // e.Appointment.AllowEdit = false; } } } if (RadScheduler1.SelectedView == SchedulerViewType.TimelineView) { if (RadScheduler1.Appointments.Count > 10) { RadScheduler1.Height = Unit.Parse(""); } } }